-from naja.constants import BITS, MOVES, CHESS_PIECES
+from naja.constants import BITS, MOVES
class PlayerBits(object):
@classmethod
def import_player(cls, definition):
- return cls(definition['bits'], tuple(definition['position']), definition['movement_mode'])
+ return cls(
+ definition['bits'],
+ tuple(definition['position']),
+ definition['movement_mode'])
def export(self):
return {
run_game.add_callback('click',
lambda event: SceneChangeEvent.post(GameScene))
selector.add(run_game)
- credits = TextWidget((100, 200), 'Credits', fontsize=32, colour='white')
+ credits = TextWidget(
+ (100, 200), 'Credits', fontsize=32, colour='white')
credits.add_callback('click',
lambda event: SceneChangeEvent.post(CreditsScene))
selector.add(credits)
def test_AllowKnightMove(self):
board = self.make_board(player_bits=[BITS.RED, BITS.BLUE])
- actions.AllowChessMove(set([BITS.RED, BITS.BLUE]), chesspiece="KNIGHT").perform_action(board, None)
+ actions.AllowChessMove(
+ set([BITS.RED, BITS.BLUE]), chesspiece="KNIGHT"
+ ).perform_action(board, None)
self.assertEqual(board.player.movement_mode, MOVES.KNIGHT)
-
def test_AllowBishopMove(self):
board = self.make_board(player_bits=[BITS.RED, BITS.BLUE])
- actions.AllowChessMove(set([BITS.RED, BITS.BLUE]), chesspiece="BISHOP").perform_action(board, None)
+ actions.AllowChessMove(
+ set([BITS.RED, BITS.BLUE]), chesspiece="BISHOP"
+ ).perform_action(board, None)
self.assertEqual(board.player.movement_mode, MOVES.BISHOP)
-
def test_AllowCastleMove(self):
board = self.make_board(player_bits=[BITS.RED, BITS.BLUE])
- actions.AllowChessMove(set([BITS.RED, BITS.BLUE]), chesspiece="CASTLE").perform_action(board, None)
+ actions.AllowChessMove(
+ set([BITS.RED, BITS.BLUE]), chesspiece="CASTLE"
+ ).perform_action(board, None)
self.assertEqual(board.player.movement_mode, MOVES.CASTLE)
def test_export_new_board(self):
board = GameBoard.new_game([{'actions': [{
- 'action_class': 'LoseHealthOrMSB',
- 'required_bits': [],
+ 'action_class': 'LoseHealthOrMSB',
+ 'required_bits': [],
}]}])
exported_state = board.export()
board_locations = exported_state.pop('board_locations')
self.assertEqual(board.player.movement_mode, MOVES.CASTLE)
-
class TestLocationCard(TestCase):
def test_generate_bitwise_operand(self):
# This is testing a random process, so it may fail occasionally.
def test_legal_moves_castle(self):
player = Player(0x0f, (1, 3), MOVES.CASTLE)
- self.assertEqual(player.legal_moves(), [(0, 3), (1, 0), (1, 1), (1, 2),
- (1, 3), (1, 4), (2, 3), (3, 3), (4, 3)])
+ self.assertEqual(player.legal_moves(), [
+ (0, 3), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, 3), (3, 3),
+ (4, 3)])
def test_legal_moves_bishop(self):
player = Player(0x0f, (1, 3), MOVES.BISHOP)
- self.assertEqual(player.legal_moves(), [(0, 2), (0, 4), (1, 3), (2, 2),
- (2, 4), (3, 1), (4, 0)])
+ self.assertEqual(player.legal_moves(), [
+ (0, 2), (0, 4), (1, 3), (2, 2), (2, 4), (3, 1), (4, 0)])
def test_legal_moves_knight(self):
player = Player(0x0f, (1, 3), MOVES.KNIGHT)
- self.assertEqual(player.legal_moves(), [(0, 1), (1, 3), (2, 1), (3, 2), (3, 4)])
+ self.assertEqual(player.legal_moves(), [
+ (0, 1), (1, 3), (2, 1), (3, 2), (3, 4)])
def test_set_position(self):
player = Player(0x0f, (3, 3), MOVES.BISHOP)
import pygame
from naja.constants import (
- TILE_SIZE, BITS, LOCK_HEIGHT, SMALL_LOCK_HEIGHT, EXAMINE, ACTION_GLYPHS, PALETTE)
+ TILE_SIZE, BITS, LOCK_HEIGHT, SMALL_LOCK_HEIGHT, EXAMINE, ACTION_GLYPHS,
+ PALETTE)
from naja.resources import resources
from naja.resources.mutators import EIGHT_BIT, blender
from naja.widgets.base import Widget
if self.state.gameboard.player_mode == EXAMINE and legal_move:
overlays.append(resources.get_image('board/tile_available.png',
- transforms=(EIGHT_BIT,)))
+ transforms=(EIGHT_BIT,)))
if self.highlighted:
overlays.append(resources.get_image('board/tile_selected.png',
- transforms=(EIGHT_BIT,)))
+ transforms=(EIGHT_BIT,)))
self.surface = pygame.surface.Surface(TILE_SIZE)
self.surface.blit(bg, (0, 0))
if y_offset == LOCK_HEIGHT:
y_offset = 0 # middle -> top
elif y_offset == 2 * LOCK_HEIGHT:
- y_offset += LOCK_HEIGHT - SMALL_LOCK_HEIGHT - 2 # bottom -> further down
+ # bottom -> further down
+ y_offset += LOCK_HEIGHT - SMALL_LOCK_HEIGHT - 2
img = resources.get_image(img_name, transforms=(EIGHT_BIT,))
self.surface.blit(img, (x_offset, y_offset))