コード例 #1
0
def test_collect_all():
    game = Game()
    game.setPlayers([Player(),Player(),Player()])
    game.collectAll(0,50)
    assert game.getPlayer(0).getMoney() == 100
    assert game.getPlayer(1).getMoney() == -50
    assert game.getPlayer(2).getMoney() == -50
コード例 #2
0
def test_payAll_two():
    game = Game()
    game.setPlayers([Player(),Player(),Player()])
    game.payAll(0,50)
    assert game.getPlayer(0).getMoney() == -100
    assert game.getPlayer(1).getMoney() == 50
    assert game.getPlayer(2).getMoney() == 50
コード例 #3
0
def test_rollJail_three():
    game = Game(players=[Player()])
    game.setBoard([null.Null(), jail.Jail()])
    rule = Rules(game, jail=3)
    rule.roll(0, 6, 6)
    rule.roll(0, 6, 6)
    rule.roll(0, 6, 6)
    assert game.getPlayer(0).getDouble() == 3
    assert game.getPlayer(0).getJail() == True
    assert game.getPlayer(0).getPos() == 1
コード例 #4
0
def test_collectPool():
    game = Game(players=[Player()])
    sq = FreeParking()
    game.setPool(100)
    assert game.getPool() == 100
    sq.run(0,game)
    assert game.getPool() == 0
    assert game.getPlayer(0).getMoney() == 100
コード例 #5
0
def test_moveToJail():
    game = Game(players=[Player()])
    game.setBoard([null.Null(),jail.Jail()])
    game.moveToJail(0)
    assert game.getPlayer(0).getJail() == True
    assert game.getPlayer(0).getPos() == 1
コード例 #6
0
def test_roll_wrap():
    game = Game()
    game.setPlayers([Player()])
    game.move(0,40,6)
    assert game.getPlayer(0).getPos() == 6
コード例 #7
0
def test_roll():
    game = Game(players=[Player()])
    rule = Rules(game)
    rule.roll(0, 6, 6)
    assert game.getPlayer(0).getPos() == 12
    assert game.getPlayer(0).getDouble() == 1
コード例 #8
0
from Game.Game import Game
from Game.TurnOrder import TurnOrder
from Game.rules import Rules
if __name__ == "__main__":
    game = Game()
    turn = TurnOrder(range(len(game.getPlayers())))
    order = iter(turn)
    manager = Rules(game)
    while (not game.getGameOver()):
        currentPlayer = game.getPlayer(next(order))
        roll1 = random()
        roll2 = random()
        manager.roll(currentPlayer, roll1, roll2)
        manager.landSquare()
        #game.action(handleInput())
        #trade . upgrade . end
        #accept end turn or other actions
        #GUI.update(game)
        game.checkGameOver()