Beispiel #1
0
    async def player_1():
        b = Battleship()

        b.put_ship(0, 0, 5, True)
        b.put_ship(1, 0, 4, True)
        b.put_ship(2, 0, 3, True)
        b.put_ship(3, 0, 3, True)
        b.put_ship(4, 0, 2, True)

        await b.connect(nick="alice")

        await b.start()
        check_states_empty(b)

        while not b.finished():
            await b.round(0, 0)

        check_lost(b)
Beispiel #2
0
    async def player_2():
        b = Battleship()

        b.put_ship(0, 0, 5, True)
        b.put_ship(1, 0, 4, True)
        b.put_ship(2, 0, 3, True)
        b.put_ship(3, 0, 3, True)
        b.put_ship(4, 0, 2, True)

        await b.connect(nick="rabbit")
        await b.join("alice")
        check_states_empty(b)

        while not b.finished():
            await shoot_layout(b, [
                (0, 0, 5, True),
                (1, 0, 4, True),
                (2, 0, 3, True),
                (3, 0, 3, True),
                (4, 0, 2, True),
            ])

        check_win(b)
Beispiel #3
0
def check_abort(b: Battleship):
    assert b.finished()
    assert not b.won()
    assert not b.draw()
    assert b.aborted()