From: Jeremy Thurgood Date: Fri, 16 May 2014 13:28:06 +0000 (+0200) Subject: Start of standard deck. X-Git-Tag: 0.1~225 X-Git-Url: https://git.ctpug.org.za/?p=naja.git;a=commitdiff_plain;h=acd4bdc5372677dd7f904fdb26cbfcc81c6b51ea Start of standard deck. --- diff --git a/data/location_decks/standard.yaml b/data/location_decks/standard.yaml new file mode 100644 index 0000000..ef8ecf9 --- /dev/null +++ b/data/location_decks/standard.yaml @@ -0,0 +1,143 @@ +description: "Standard location deck." + +# This field is ignored, but it's a useful place to put some action definitions +# we can reference later. +_standard_actions: + # No-colour actions. + - &SET-BITS-DEFAULT + action_class: 'LoseHealthOrMSBAndSetBits' + required_bits: [] + - &GAIN-HEALTH-DEFAULT + action_class: 'GainHealthAndClearBitsOrMSB' + required_bits: [] + - &TOGGLE-BITS-DEFAULT + action_class: 'ToggleBits' + required_bits: [] + - &BAD-DEFAULT + action_class: 'LoseHealthOrMSB' + required_bits: [] + + # One-colour actions. + - &SET-BITS-R + action_class: 'SetBits' + required_bits: [RED] + - &SET-BITS-G + action_class: 'SetBits' + required_bits: [GREEN] + - &SET-BITS-B + action_class: 'SetBits' + required_bits: [BLUE] + + - &SHIFT-N + action_class: 'ShiftLocations' + required_bits: [BLUE] + data: {'direction': NORTH} + - &SHIFT-S + action_class: 'ShiftLocations' + required_bits: [BLUE] + data: {'direction': SOUTH} + - &SHIFT-E + action_class: 'ShiftLocations' + required_bits: [GREEN] + data: {'direction': EAST} + - &SHIFT-W + action_class: 'ShiftLocations' + required_bits: [GREEN] + data: {'direction': WEST} + + # Two-colour actions. + - &KNIGHT-MOVE + action_class: 'AllowChessMove' + required_bits: [RED, GREEN] + data: {'chesspiece': KNIGHT} + - &CASTLE-MOVE + action_class: 'AllowChessMove' + required_bits: [RED, BLUE] + data: {'chesspiece': CASTLE} + - &BISHOP-MOVE + action_class: 'AllowChessMove' + required_bits: [GREEN, BLUE] + data: {'chesspiece': BISHOP} + + - &HEAL-RG + action_class: 'GainHealth' + required_bits: [RED, GREEN] + - &HEAL-RB + action_class: 'GainHealth' + required_bits: [RED, BLUE] + + # Three-colour actions. + - &ACQUIRE-WIN-TOKEN + action_class: 'AcquireWinToken' + required_bits: [RED, GREEN, BLUE] + +# This field is ignored, but it's a useful place to put some action definitions +# we can reference later. +_standard_cards: + - &WIN-CARD + actions: + - *ACQUIRE-WIN-TOKEN + + - &KNIGHT-AND-SET + actions: + - *BAD-DEFAULT + - *SET-BITS-B + - *KNIGHT-MOVE + - &CASTLE-AND-SET + actions: + - *BAD-DEFAULT + - *SET-BITS-G + - *CASTLE-MOVE + - &BISHOP-AND-SET + actions: + - *BAD-DEFAULT + - *SET-BITS-R + - *BISHOP-MOVE + + - &TOGGLE-RG-R + bits: [RED, GREEN] # Colour-blind robot! + actions: + - action_class: 'ToggleBits' + required_bits: [RED] + - action_class: 'SetBits' + required_bits: [GREEN, BLUE] + - &TOGGLE-RG-G + bits: [RED, GREEN] # Colour-blind robot! + actions: + - action_class: 'ToggleBits' + required_bits: [GREEN] + - action_class: 'SetBits' + required_bits: [RED, BLUE] + + - &SHIFT-N-AND-HEAL + actions: + - *TOGGLE-BITS-DEFAULT + - *SHIFT-N + - *HEAL-RG + - &SHIFT-S-AND-HEAL + actions: + - *TOGGLE-BITS-DEFAULT + - *SHIFT-S + - *HEAL-RG + - &SHIFT-E-AND-HEAL + actions: + - *TOGGLE-BITS-DEFAULT + - *SHIFT-E + - *HEAL-RB + - &SHIFT-W-AND-HEAL + actions: + - *TOGGLE-BITS-DEFAULT + - *SHIFT-W + - *HEAL-RB + +cards: + - *WIN-CARD + - *KNIGHT-AND-SET + - *CASTLE-AND-SET + - *BISHOP-AND-SET + - *TOGGLE-RG-R + - *TOGGLE-RG-G + - *SHIFT-N-AND-HEAL + - *SHIFT-S-AND-HEAL + - *SHIFT-E-AND-HEAL + - *SHIFT-W-AND-HEAL diff --git a/data/location_decks/test.yaml b/data/location_decks/test.yaml index 3c65032..d88978d 100644 --- a/data/location_decks/test.yaml +++ b/data/location_decks/test.yaml @@ -3,22 +3,22 @@ description: "Test location deck." # This field is ignored, but it's a useful place to put some action definitions # we can reference later. _standard_actions: - set_bits_default: &SET-BITS-DEFAULT + - &SET-BITS-DEFAULT action_class: 'LoseHealthOrMSBAndSetBits' required_bits: [] - gain_health_default: &GAIN-HEALTH-DEFAULT + - &GAIN-HEALTH-DEFAULT action_class: 'GainHealthAndClearBitsOrMSB' required_bits: [] - bad_default: &BAD-DEFAULT + - &BAD-DEFAULT action_class: 'LoseHealthOrMSB' required_bits: [] - toggle_bits_c: &TOGGLE-BITS-C + - &TOGGLE-BITS-C action_class: 'ToggleBits' required_bits: [BLUE] - set_bits_ym: &SET-BITS-YM + - &SET-BITS-YM action_class: 'SetBits' required_bits: [RED, GREEN] - acquire_win_token: &ACQUIRE-WIN-TOKEN + - &ACQUIRE-WIN-TOKEN action_class: 'AcquireWinToken' required_bits: [RED, GREEN, BLUE] diff --git a/naja/actions.py b/naja/actions.py index cf916b9..0626b34 100644 --- a/naja/actions.py +++ b/naja/actions.py @@ -113,6 +113,14 @@ class AcquireWinToken(LocationAction): ])) +class GainHealth(LocationAction): + TEXT = "Gain {HEALTH}." + GLYPHS = (ACTION_GLYPHS.HEAL,) + + def perform_action(self, board, location): + board.gain_health() + + class GainHealthAndClearBitsOrMSB(LocationAction): TEXT = "Gain {HEALTH}, then clear %(location_bits)s or {MSB}." GLYPHS = (ACTION_GLYPHS.HEAL,) diff --git a/naja/gamestate.py b/naja/gamestate.py index c8bbbc7..a2ed6e0 100644 --- a/naja/gamestate.py +++ b/naja/gamestate.py @@ -21,7 +21,8 @@ class GameState(object): def __init__(self): # This is a very simple deck to allow testing more drawing logic # on tiles. These will need to be replaced with better stuff. - locations_deck = load_location_deck('test') + locations_deck = load_location_deck('standard') + # locations_deck = load_location_deck('test') self.gameboard = GameBoard.new_game(locations_deck['cards']) @property