required_bits: []
toggle_bits_c: &TOGGLE-BITS-C
action_class: 'ToggleBits'
- required_bits: [CYAN]
+ required_bits: [BLUE]
set_bits_ym: &SET-BITS-YM
action_class: 'SetBits'
- required_bits: [YELLOW, MAGENTA]
+ required_bits: [RED, GREEN]
acquire_win_token: &ACQUIRE-WIN-TOKEN
action_class: 'AcquireWinToken'
- required_bits: [CYAN, MAGENTA, YELLOW]
+ required_bits: [RED, GREEN, BLUE]
cards:
- actions:
- *SET-BITS-YM
- actions:
- action_class: 'ToggleBits'
- required_bits: [YELLOW]
+ required_bits: [RED]
- actions:
- *SET-BITS-YM
- actions:
- *TOGGLE-BITS-C
- actions:
- action_class: 'ShiftLocations'
- required_bits: [CYAN, MAGENTA]
+ required_bits: [GREEN, BLUE]
data: {'direction': NORTH}
def perform_action(self, board, location):
board.acquire_win_token()
board.player.bits.clear_bits(set([
- BITS.CYAN, BITS.MAGENTA, BITS.YELLOW,
+ BITS.RED, BITS.GREEN, BITS.BLUE,
]))
'EAST': 2,
'WEST': 3,
# Condition bits
- 'CYAN': 4,
- 'MAGENTA': 5,
- 'YELLOW': 6,
+ 'BLUE': 4,
+ 'GREEN': 5,
+ 'RED': 6,
'MSB': 7,
})
DIRECTION_BITS = AttrDict((k, v) for k, v in BITS.items() if v < 4)
def test_LoseHealthOrMSBAndSetBits_MSB_clear(self):
board = self.make_board(player_bits=[])
state_before = board.export()
- card = LocationCard(set([BITS.CYAN, BITS.NORTH]), [])
+ card = LocationCard(set([BITS.BLUE, BITS.NORTH]), [])
actions.LoseHealthOrMSBAndSetBits(set()).perform_action(board, card)
state_after = board.export()
self.assertEqual(state_after['health'], state_before['health'] - 1)
- self.assert_player_bits(board, BITS.CYAN, BITS.NORTH)
+ self.assert_player_bits(board, BITS.BLUE, BITS.NORTH)
self.assert_state(
state_before, state_after, exclude=['health'],
player_exclude=['bits'])
def test_LoseHealthOrMSBAndSetBits_MSB_set(self):
board = self.make_board(player_bits=[BITS.MSB])
state_before = board.export()
- card = LocationCard(set([BITS.CYAN, BITS.NORTH]), [])
+ card = LocationCard(set([BITS.BLUE, BITS.NORTH]), [])
actions.LoseHealthOrMSBAndSetBits(set()).perform_action(board, card)
state_after = board.export()
- self.assert_player_bits(board, BITS.CYAN, BITS.NORTH)
+ self.assert_player_bits(board, BITS.BLUE, BITS.NORTH)
self.assert_state(state_before, state_after, player_exclude=['bits'])
def test_LoseHealthOrMSBAndSetBits_MSB_set_and_on_card(self):
def test_AcquireWinToken(self):
board = self.make_board(
- player_bits=[BITS.CYAN, BITS.MAGENTA, BITS.YELLOW])
+ player_bits=[BITS.RED, BITS.GREEN, BITS.BLUE])
state_before = board.export()
actions.AcquireWinToken(set()).perform_action(board, None)
state_after = board.export()
board = self.make_board(player_bits=[BITS.NORTH])
board.lose_health()
state_before = board.export()
- card = LocationCard(set([BITS.CYAN, BITS.NORTH]), [])
+ card = LocationCard(set([BITS.BLUE, BITS.NORTH]), [])
actions.GainHealthAndClearBitsOrMSB(set()).perform_action(board, card)
state_after = board.export()
self.assertEqual(state_after['health'], state_before['health'] + 1)
board = self.make_board(player_bits=[BITS.MSB, BITS.NORTH])
board.lose_health()
state_before = board.export()
- card = LocationCard(set([BITS.CYAN, BITS.NORTH]), [])
+ card = LocationCard(set([BITS.BLUE, BITS.NORTH]), [])
actions.GainHealthAndClearBitsOrMSB(set()).perform_action(board, card)
state_after = board.export()
self.assertEqual(state_after['health'], state_before['health'] + 1)
bits = PlayerBits(0x03)
self.assertEqual(bits.check_bits([BITS.NORTH]), True)
self.assertEqual(bits.check_bits([BITS.NORTH, BITS.SOUTH]), True)
- self.assertEqual(bits.check_bits([BITS.CYAN]), False)
- self.assertEqual(bits.check_bits([BITS.CYAN, BITS.MSB]), False)
+ self.assertEqual(bits.check_bits([BITS.BLUE]), False)
+ self.assertEqual(bits.check_bits([BITS.BLUE, BITS.MSB]), False)
self.assertEqual(
- bits.check_bits([BITS.NORTH, BITS.SOUTH, BITS.CYAN]), False)
+ bits.check_bits([BITS.NORTH, BITS.SOUTH, BITS.BLUE]), False)
def test_set_bits(self):
bits = PlayerBits(0x03)
self.assertEqual(bits._bits, 0x03)
- bits.set_bits([BITS.NORTH, BITS.CYAN])
+ bits.set_bits([BITS.NORTH, BITS.BLUE])
self.assertEqual(bits._bits, 0x13)
- bits.set_bits([BITS.NORTH, BITS.CYAN, BITS.MSB])
+ bits.set_bits([BITS.NORTH, BITS.BLUE, BITS.MSB])
self.assertEqual(bits._bits, 0x93)
def test_clear_bits(self):
bits = PlayerBits(0x03)
self.assertEqual(bits._bits, 0x03)
- bits.clear_bits([BITS.NORTH, BITS.CYAN])
+ bits.clear_bits([BITS.NORTH, BITS.BLUE])
self.assertEqual(bits._bits, 0x02)
- bits.clear_bits([BITS.NORTH, BITS.CYAN, BITS.MSB])
+ bits.clear_bits([BITS.NORTH, BITS.BLUE, BITS.MSB])
self.assertEqual(bits._bits, 0x02)
def test_toggle_bits(self):
bits = PlayerBits(0x03)
self.assertEqual(bits._bits, 0x03)
- bits.toggle_bits([BITS.NORTH, BITS.CYAN])
+ bits.toggle_bits([BITS.NORTH, BITS.BLUE])
self.assertEqual(bits._bits, 0x12)
- bits.toggle_bits([BITS.NORTH, BITS.CYAN])
+ bits.toggle_bits([BITS.NORTH, BITS.BLUE])
self.assertEqual(bits._bits, 0x03)
- bits.toggle_bits([BITS.NORTH, BITS.CYAN, BITS.MSB])
+ bits.toggle_bits([BITS.NORTH, BITS.BLUE, BITS.MSB])
self.assertEqual(bits._bits, 0x92)
bits = (
(BITS.MSB, 'msb', ()),
- (BITS.YELLOW, 'yellow', ()),
- (BITS.MAGENTA, 'magenta', ()),
- (BITS.CYAN, 'cyan', ()),
+ (BITS.RED, 'red', ()),
+ (BITS.GREEN, 'green', ()),
+ (BITS.BLUE, 'blue', ()),
(BITS.WEST, 'arrow', (R90,)),
(BITS.EAST, 'arrow', (R270,)),
(BITS.SOUTH, 'arrow', (R180,)),
"""Widget to draw the player on the screen"""
-import pygame.locals as pgl
-
from naja.constants import (PLAYER_SIZE, BIT_SIZE, TILE_SIZE, BITS)
-from naja.events import finish_event
from naja.resources import resources
from naja.resources.mutators import EIGHT_BIT
from naja.widgets.base import Widget
IMG_MAP = {
- BITS.CYAN: 'board/robot_cyan.png',
- BITS.YELLOW: 'board/robot_yellow.png',
- BITS.MAGENTA: 'board/robot_magenta.png',
- }
+ BITS.RED: 'board/robot_red.png',
+ BITS.GREEN: 'board/robot_green.png',
+ BITS.BLUE: 'board/robot_blue.png',
+}
class RobotWidget(Widget):
# These will probably need to go away when we have images
import pygame
-import pygame.locals as pgl
from naja.constants import TILE_SIZE, BITS, LOCK_HEIGHT, EXAMINE
from naja.resources import resources
BIT_MAP = {
- frozenset([BITS.CYAN]): 'board/tile_cyan.png',
- frozenset([BITS.MAGENTA]): 'board/tile_magenta.png',
- frozenset([BITS.YELLOW]): 'board/tile_yellow.png',
- frozenset([BITS.CYAN, BITS.MAGENTA]): 'board/tile_cyan_magenta.png',
- frozenset([BITS.CYAN, BITS.YELLOW]): 'board/tile_cyan_yellow.png',
- frozenset([BITS.MAGENTA, BITS.YELLOW]): 'board/tile_magenta_yellow.png',
- frozenset([BITS.CYAN, BITS.MAGENTA, BITS.YELLOW]): 'board/tile_cyan_magenta_yellow.png',
- }
+ frozenset([BITS.RED]): 'board/tile_red.png',
+ frozenset([BITS.GREEN]): 'board/tile_green.png',
+ frozenset([BITS.BLUE]): 'board/tile_blue.png',
+ frozenset([BITS.RED, BITS.GREEN]): 'board/tile_red_green.png',
+ frozenset([BITS.RED, BITS.BLUE]): 'board/tile_red_blue.png',
+ frozenset([BITS.GREEN, BITS.BLUE]): 'board/tile_green_blue.png',
+ frozenset([BITS.RED, BITS.GREEN, BITS.BLUE]):
+ 'board/tile_red_green_blue.png',
+}
class TileWidget(Widget):