Made game harder, beeeeeches.
authorDavid Sharpe <decoydavid@gmail.com>
Sat, 17 May 2014 19:56:07 +0000 (21:56 +0200)
committerDavid Sharpe <decoydavid@gmail.com>
Sat, 17 May 2014 19:56:07 +0000 (21:56 +0200)
data/location_decks/standard.yaml
naja/actions.py
naja/widgets/text.py

index 150a6e118ff7a1a0530079d524b8b7515fc2fbf6..0e95c856afe245f64c8b81390e65ed72f2b816e8 100644 (file)
@@ -13,6 +13,9 @@ _action_definitions:
   - &TOGGLE-BITS-DEFAULT
     action_class: 'ToggleBits'
     required_bits: []
+  - &TOGGLE-BITS-HARM-DEFAULT
+    action_class: 'ToggleBitsAndHarm'
+    required_bits: []
   - &BAD-DEFAULT
     action_class: 'LoseHealthOrMSB'
     required_bits: []
@@ -214,6 +217,31 @@ _card_definitions:
       - *SHIFT-W
       - *HEAL-RB
 
+  - &SHIFT-N-AND-HARM
+    card_name: 'shift-n-harm'
+    actions:
+      - *TOGGLE-BITS-HARM-DEFAULT
+      - *SHIFT-N
+      - *HEAL-RG
+  - &SHIFT-S-AND-HARM
+    card_name: 'shift-s-harm'
+    actions:
+      - *TOGGLE-BITS-HARM-DEFAULT
+      - *SHIFT-S
+      - *HEAL-RG
+  - &SHIFT-E-AND-HARM
+    card_name: 'shift-e-harm'
+    actions:
+      - *TOGGLE-BITS-HARM-DEFAULT
+      - *SHIFT-E
+      - *HEAL-RB
+  - &SHIFT-W-AND-HARM
+    card_name: 'shift-w-harm'
+    actions:
+      - *TOGGLE-BITS-HARM-DEFAULT
+      - *SHIFT-W
+      - *HEAL-RB
+
   - &ROT-CW-AND-SET
     card_name: 'rot-cw-set'
     actions:
@@ -239,6 +267,19 @@ _card_definitions:
       - *SHIFT-W
       - *BITSHIFT-L
 
+  - &MEAN-CARD
+    card_name: 'mean-card'
+    actions:
+      - *BAD-DEFAULT
+
+  - &REALLY-MEAN-CARD
+    card_name: 'mean-card'
+    actions:
+      - action_class: 'ClearBitsAndHealth'
+        required_bits: []
+      - action_class: 'LoseHealthOrMSB'
+        required_bits: [RED]
+
 cards:
   - *WIN-CARD-1
   - *WIN-CARD-2
@@ -255,10 +296,16 @@ cards:
   - *SHIFT-S-AND-HEAL
   - *SHIFT-E-AND-HEAL
   - *SHIFT-W-AND-HEAL
+  - *SHIFT-N-AND-HARM
+  - *SHIFT-S-AND-HARM
+  - *SHIFT-E-AND-HARM
+  - *SHIFT-W-AND-HARM
   - *SHIFT-E-BITSHIFT
   - *SHIFT-W-BITSHIFT
   - *ROT-CW-AND-SET
   - *ROT-CCW-AND-SET
+  - *MEAN-CARD
+  - *REALLY-MEAN-CARD
 
 replacement_params:
   chance: 0.2
index 4064947648abb1bd4205a20fb0ed7b455a36af85..7ae189e0b1c1db50f4ea1c576fbb1b9222fd4f18 100644 (file)
@@ -77,6 +77,10 @@ class LocationAction(object):
                 'data': self.data,
                 'action_class': self.__class__.__name__}
 
+    def take_damage(self, board):
+        sound.play_sound('awwww.ogg')
+        board.lose_health()
+
 
 class DoNothing(LocationAction):
     TEXT = "No effect."
@@ -92,8 +96,7 @@ class LoseHealthOrMSB(LocationAction):
 
     def perform_action(self, board, location):
         if not self.check_and_clear_MSB(board.player):
-            sound.play_sound('awwww.ogg')
-            board.lose_health()
+            self.take_damage(board)
 
 
 class SetBits(LocationAction):
@@ -112,6 +115,15 @@ class ClearBits(LocationAction):
         board.player.bits.clear_bits(location.bitwise_operand)
 
 
+class ClearBitsAndHealth(LocationAction):
+    TEXT = "Clear %(location_bits)s and {HEALTH}."
+    GLYPHS = (ACTION_GLYPHS.CLEAR_BITS, ACTION_GLYPHS.DAMAGE)
+
+    def perform_action(self, board, location):
+        board.player.bits.clear_bits(location.bitwise_operand)
+        self.take_damage(board)
+
+
 class ToggleBits(LocationAction):
     TEXT = "Toggle %(location_bits)s."
     GLYPHS = (ACTION_GLYPHS.TOGGLE_BITS,)
@@ -120,6 +132,15 @@ class ToggleBits(LocationAction):
         board.player.bits.toggle_bits(location.bitwise_operand)
 
 
+class ToggleBitsAndHarm(LocationAction):
+    TEXT = "Toggle %(location_bits)s and lose {HEALTH}."
+    GLYPHS = (ACTION_GLYPHS.TOGGLE_BITS, ACTION_GLYPHS.DAMAGE)
+
+    def perform_action(self, board, location):
+        board.player.bits.toggle_bits(location.bitwise_operand)
+        self.take_damage(board)
+
+
 class GenericBits(LocationAction):
     GLYPHS = (ACTION_GLYPHS.SET_BITS, ACTION_GLYPHS.CLEAR_BITS)
 
index c4ac45600ec398a5679656eb668dbb3c174d41ce..1cf15d0bcf4601c72d52eb81d871ecedf8b454ec 100644 (file)
@@ -173,6 +173,8 @@ class TextBoxWidget(TextWidget):
             suffix = word[-1]
             word = word[:-1]
 
+        if not word:
+            return None
         if word[0] == '{' and word[-1] == '}':
             subwords = word[1:-1].split(',')
             if all(subword in MARKUP_MAP for subword in subwords):