コード例 #1
0
def test_owner_is():
    p1 = Player(0)
    p2 = Player(0)
    r = RealState(50, 5, owner=p1)

    assert r.owner_is(p1) == True
    assert r.owner_is(p2) == False
コード例 #2
0
def test_deal_sell():
    p1 = Player(100)
    r1 = RealState(50, 5)

    r1.deal(p1)
    assert r1.owner_is(p1)
    assert p1.balance == 50
コード例 #3
0
def test_rent():
    p1, p2 = Player(0), Player(5)
    r = RealState(50, 5, owner=p1)

    r.rent_to(p2)
    assert p1.balance == 5
    assert p2.balance == 0
コード例 #4
0
def test_sell():
    p = Player(100)
    r = RealState(50, 5)

    r.sell_to(p)

    assert r.owner_is(p)
    assert p.balance == 50
コード例 #5
0
def test_deal_rent():
    p1 = Player(100)
    p2 = Player(0)
    r2 = RealState(50, 5, owner=p2)

    r2.deal(p1)
    assert p2.balance == 5
    assert p1.balance == 95
コード例 #6
0
ファイル: test_game.py プロジェクト: virb30/monopoly
def test_init():
    players = Player.from_strategies(300)
    r = RealState(100,10)
    g = Game(players, [r])

    assert [p.balance for p in players] == [300] * 4
    assert g.board
コード例 #7
0
ファイル: simulation.py プロジェクト: virb30/monopoly
def generate_properties(how_many,
                        median=5,
                        stdv=1,
                        price_scale=20,
                        rent_scale=10):
    distribution = (round(random.gauss(median, stdv)) for _ in range(how_many))
    params = ((value * price_scale, value * rent_scale)
              for value in distribution)
    return tuple(RealState(price, rent) for price, rent in params)
コード例 #8
0
ファイル: test_game.py プロジェクト: virb30/monopoly
def test_leader():
    players = Player.from_strategies(0)
    players[1].receive(1)
    players[2].receive(2)
    players[3].receive(3)
    r = RealState(100, 10)
    g = Game(players, [r])

    assert g.leader == players[3]
コード例 #9
0
ファイル: test_game.py プロジェクト: virb30/monopoly
def test_run_tie():
    p1 = Player(100)
    p2 = Player(100)
    r = RealState(100, 10)
    g = Game([p1, p2], [r])

    g.dice = lambda: 1

    winner = g.run(998)

    assert winner is p2
コード例 #10
0
ファイル: test_game.py プロジェクト: virb30/monopoly
def test_run_winner(mocker):
    p1 = Player(100)
    p2 = Player(0)
    r = RealState(100, 10)
    g = Game([p1, p2], [r])

    g.dice = lambda: 1

    winner = g.run()

    assert winner is p1
コード例 #11
0
def test_has_owner():
    p = Player(0)
    r = RealState(50, 5, owner=p)
    assert r.has_owner() == True
コード例 #12
0
ファイル: test_game.py プロジェクト: virb30/monopoly
def test_leader_tie():
    players = Player.from_strategies(0)
    r = RealState(100, 10)
    g = Game(players, [r])

    assert g.leader == players[0]
コード例 #13
0
def test_foreclose():
    p = Player(0)
    r = RealState(50, 5, owner=p)

    r.foreclose()
    assert r.has_owner() == False
コード例 #14
0
def test_init():
    r = RealState(50, 5)
    assert r.price == 50
    assert r.rent == 5
    assert r.owner is None
コード例 #15
0
def test_rent_player_is_owner():
    p1 = Player(4)
    r1 = RealState(50, 5, owner=p1)

    r1.rent_to(p1)
    assert p1.balance == 4
コード例 #16
0
def test_not_has_owner():
    r = RealState(50, 5)
    assert r.has_owner() == False
コード例 #17
0
def test_sell_error():
    p1, p2 = Player(100), Player(0)
    r = RealState(50, 5, owner=p2)

    with pytest.raises(AssertionError):
        r.sell_to(p1)