From 8c08ffd9e2d674558bca43d4f709be5f49e46119 Mon Sep 17 00:00:00 2001 From: David Sharpe Date: Sat, 17 May 2014 21:56:07 +0200 Subject: [PATCH] Made game harder, beeeeeches. --- data/location_decks/standard.yaml | 47 +++++++++++++++++++++++++++++++ naja/actions.py | 25 ++++++++++++++-- naja/widgets/text.py | 2 ++ 3 files changed, 72 insertions(+), 2 deletions(-) diff --git a/data/location_decks/standard.yaml b/data/location_decks/standard.yaml index 150a6e1..0e95c85 100644 --- a/data/location_decks/standard.yaml +++ b/data/location_decks/standard.yaml @@ -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 diff --git a/naja/actions.py b/naja/actions.py index 4064947..7ae189e 100644 --- a/naja/actions.py +++ b/naja/actions.py @@ -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) diff --git a/naja/widgets/text.py b/naja/widgets/text.py index c4ac456..1cf15d0 100644 --- a/naja/widgets/text.py +++ b/naja/widgets/text.py @@ -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): -- 2.34.1