action_class: 'GainHealth'
required_bits: [RED, BLUE]
+ - &BITSHIFT-L
+ action_class: 'ShiftBits'
+ required_bits: [RED, BLUE]
+ data: {
+ 'direction': 'left',
+ 'shift': 1,
+ }
+ - &BITSHIFT-R
+ action_class: 'ShiftBits'
+ required_bits: [GREEN, BLUE]
+ data: {
+ 'direction': 'right',
+ 'shift': 1,
+ }
+
# Three-colour actions.
- &ACQUIRE-WIN-TOKEN
action_class: 'AcquireWinToken'
- *ROT-CCW
- *SET-BITS-G
+ - &SHIFT-E-BITSHIFT
+ actions:
+ - *SHIFT-E
+ - *BITSHIFT-R
+ - &SHIFT-W-BITSHIFT
+ actions:
+ - *SHIFT-W
+ - *BITSHIFT-L
+
cards:
- *WIN-CARD-1
- *WIN-CARD-2
- *SHIFT-S-AND-HEAL
- *SHIFT-E-AND-HEAL
- *SHIFT-W-AND-HEAL
+ - *SHIFT-E-BITSHIFT
+ - *SHIFT-W-BITSHIFT
- *ROT-CW-AND-SET
- *ROT-CCW-AND-SET
def get_text(self, location=None):
substitutions = self.data.copy()
- if 'direction' in self.data:
+ if 'shift' in self.data:
+ substitutions['shift'] = self.data['shift']
+ substitutions['direction'] = self.data['direction']
+ elif 'direction' in self.data:
substitutions['rowcol'] = {
'NORTH': 'column',
'SOUTH': 'column',
board.player.bits.toggle_bits(location.bitwise_operand)
+class ShiftBits(LocationAction):
+ TEXT = "Barrel-shift player %(shift)s bits %(direction)s."
+ GLYPHS = (ACTION_GLYPHS.CHANGE_BOARD,)
+
+ def perform_action(self, board, location):
+ shift = self.data['shift']
+ if self.data['direction'] == 'left':
+ board.player.bits.shift_bits_left(shift)
+ else:
+ board.player.bits.shift_bits_right(shift)
+
+
class LoseHealthOrMSBAndSetBits(LocationAction):
TEXT = "Lose {HEALTH} or {MSB}, then set %(location_bits)s."
GLYPHS = (ACTION_GLYPHS.SET_BITS,)