Esempio n. 1
0
    def from_json_input(cls, json):
        game_id = json["game"]["id"]
        turn = json["turn"]
        board = Board.from_json_input(json)
        you = Battlesnake.from_json_input(json)

        return cls(game_id=game_id, turn=turn, board=board, you=you)
def test_position_is_available__should_return_true():
    game = Board()
    position = 'mid_center'

    actual = utilities.position_is_available(game, position)

    assert actual is True
Esempio n. 3
0
def start_game():

    board_model: Board = Board()
    player_1: Player = Player(Order.FIRST)
    player_2: Player = Player(Order.SECOND)

    game = Hex(board_model, PlayersController(player_1, player_2))
    game.on_execute()
def test_place_card__should_place_card_in_mid_center():
    game = Board()
    player = Player()
    card = all_cards.BLOBRA
    position = 'mid_center'

    actual = utilities.place_card(game, player, card, position)

    assert actual['mid_center']['card'] == all_cards.BLOBRA
Esempio n. 5
0
def one_food_board():
    return Board(height=11,
                 width=11,
                 food=(Point(x=5, y=5), ),
                 snakes=(Battlesnake(id="snake-508e96ac-94ad-11ea-bb37",
                                     name="My Snake",
                                     health=54,
                                     body=(Point(x=0, y=0), Point(x=1, y=0),
                                           Point(x=2, y=0)),
                                     head=Point(x=0, y=0),
                                     length=3,
                                     shout="why are we shouting??"),
                         Battlesnake(id="snake-b67f4906-94ae-11ea-bb37",
                                     name="Another Snake",
                                     health=16,
                                     body=(Point(x=5, y=4), Point(x=5, y=3),
                                           Point(x=6, y=3), Point(x=6, y=2)),
                                     head=Point(x=5, y=4),
                                     length=4,
                                     shout="I'm not really sure...")))
Esempio n. 6
0
import random
from src.models.board import Board
from src.models.player import Player
from src.models.challenges import challenges
from src.services import utilities

game = Board()
turn_count = 1
P1 = Player()
P2 = Player()
P1.name = input('What is Player 1\'s name? ')
P2.name = input('What is Player 2\'s name? ')
players = [P1, P2]
starting_player = random.choice(players)

while turn_count < 10:
    print(f'The current turn is {turn_count}')
    current_player = utilities.determine_player(turn_count, starting_player,
                                                players)
    print(f'The current player is {current_player.name}.')

    print(f'{P1.name} has {P1.cards}')
    print(f'{P2.name} has {P2.cards}')

    selected_card = input('Choose a card from your hand ... ')
    while not utilities.has_card_in_hand(current_player, selected_card):
        selected_card = input('That card is not in your hand. Try again ... ')

    played_card = [
        item for item in current_player.hand if item['name'] == selected_card
    ][0]
Esempio n. 7
0
 def test_from_json_input(self, json, board):
     assert (Board.from_json_input(json) == board)