Exemplo n.º 1
0
 def test_fumble_resolved(self):
     ''' test placement of piece after a fumble '''
     board = br.create_gameboard()
     location = (1, 1)
     resolved = br.resolve_fumble(location, board)
     self.assertEqual(board[1][1], 'B')
     self.assertEqual(resolved, True)
Exemplo n.º 2
0
def create_game_file(game_id):
    '''
    This function creates a file called <id>_board.json
    which maintains the state of the board
    '''

    # Create board
    board = bb.create_gameboard()

    # create two pieces for board
    home_piece = gp.create_piece()
    away_piece = gp.create_piece()

    game_dict = {'game' : {'board' : board,
                           'home' : vars(home_piece),
                           'away' : vars(away_piece)
                          }
                }

    game_json = json.dumps(game_dict)
    filename = str(game_id) + '_board.json'
    with open(filename, 'w') as wfile:
        wfile.write(game_json)

    return filename
Exemplo n.º 3
0
 def test_full_space(self):
     ''' test a full space '''
     board = br.create_gameboard()
     posx = 9
     posy = 3
     board[posx][posy] = '0'
     self.assertEqual(br.empty_space(board, posx, posy), False)
Exemplo n.º 4
0
 def test_fumble_not_resolved(self):
     ''' test placement of piece after a fumble '''
     board = br.create_gameboard()
     location = (1, 1)
     br.place_piece('0', location, board)
     location = (1, 1)
     resolved = br.resolve_fumble(location, board)
     self.assertEqual(board[1][1], '0')
     self.assertEqual(resolved, False)
Exemplo n.º 5
0
 def test_board_size(self):
     ''' Test individual spots created '''
     self.assertEqual(len(br.create_gameboard()), 13)
Exemplo n.º 6
0
 def test_for_ball(self):
     ''' Test that ball is on board '''
     self.assertEqual(br.create_gameboard()[6][2], 'B')
Exemplo n.º 7
0
 def test_length_of_row11(self):
     ''' Test individual spots created '''
     self.assertEqual(len(br.create_gameboard()[11]), 6)
Exemplo n.º 8
0
 def test_empty_space(self):
     ''' test an empty space '''
     board = br.create_gameboard()
     posx = 9
     posy = 4
     self.assertEqual(br.empty_space(board, posx, posy), True)
Exemplo n.º 9
0
 def test_place_piece_on_piece(self):
     ''' test that you cannot place a piece on a piece '''
     board = br.create_gameboard()
     location = (1, 1)
     br.place_piece('0', location, board)
     self.assertEqual(br.place_piece('2', location, board), False)
Exemplo n.º 10
0
 def test_place_piece(self):
     ''' test the placement of a piece '''
     board = br.create_gameboard()
     location = (0, 0)
     br.place_piece('0', location, board)
     self.assertEqual(board[0][0], '0')
Exemplo n.º 11
0
 def test_print_board(self):
     board = br.create_gameboard()
     printed = br.print_board(board)
     self.assertEqual(printed, True)
Exemplo n.º 12
0
 def test_length_of_endzone2(self):
     ''' Test individual spots created '''
     self.assertEqual(len(br.create_gameboard()[12]), 6)
Exemplo n.º 13
0
'''
inline full gameplay
'''
import battleball.game_cli.battle_board as bb
import battleball.game_cli.game_pieces as gp
#import battleball.game_cli.game_actions as ga

# Set up initial board and pieces
PDICTIONARY = gp.instatiate_pieces()
TEAMS = ['home', 'away']
SCORES = {'home': 0, 'away': 0}
GAMEBOARD = bb.create_gameboard()

while not (SCORES['home'] == 2 or SCORES['away'] == 2):

    for team in TEAMS:
        print team + ' team, place your pieces behind the 20 yard line'
        for piece_index in range(len(PDICTIONARY[team])):

            piece = PDICTIONARY[team][piece_index]
            #ga.prompt_place_piece(piece, piece_index, GAMEBOARD, team)
            bb.print_board(GAMEBOARD)

    SCORED = False
    while not SCORED:
        for team in TEAMS:
            print team + ' team, choose a piece to move'
            #piece_index = ga.choose_piece_to_move(PDICTIONARY, team)
            piece = PDICTIONARY[team][piece_index]
            rolled_value = piece.roll()
            print 'You rolled a ' + str(rolled_value) + ' for ' + piece.name