Esempio n. 1
0
def main():
    """エントリーポイント."""
    print('main')
    rps = rock_paper_scissors.RockPaperScissors()
    ps = players.Players()
    ps.add(cpu_player.CpuPlayer())
    ps.add(cpu_player.CpuPlayer())
    rps.initialize_game(ps)

    while not rps.is_finished():
        rps.task()
Esempio n. 2
0
def test_length_case_one_hundred():
    """プレイヤーデータ数の取得(100)."""
    ps = players.Players()
    add_count = 100
    for _ in range(add_count):
        p = cpu_player.CpuPlayer()
        ps.add(p)
    assert ps.length() == add_count
Esempio n. 3
0
def test_clear_case_one():
    """プレイヤーデータのクリア."""
    ps = players.Players()
    p = cpu_player.CpuPlayer()
    ps.add(p)
    assert ps.length() == 1
    ps.clear()
    assert ps.length() == 0
Esempio n. 4
0
def test_add_case_two():
    """プレイヤーの追加(2人)."""
    ps = players.Players()
    add_count = 2
    for _ in range(add_count):
        p = cpu_player.CpuPlayer()
        ps.add(p)
    assert ps.length() == add_count
Esempio n. 5
0
def test_get_range():
    """手の公開の範囲チェック(rock,paper,scissorsのいずれかが出る)."""
    c = cpu_player.CpuPlayer()
    c.start_showdown()
    result = c.get()
    assert (result == hand_constant.HandConstant.ROCK
            or result == hand_constant.HandConstant.PAPER
            or result == hand_constant.HandConstant.SCISSORS)
Esempio n. 6
0
def test_get_hand_rock_or_paper_or_scissors():
    """プレイヤーの手の取得."""
    ps = players.Players()
    p = cpu_player.CpuPlayer()
    p.start_showdown()
    ps.add(p)
    h = ps.get_hand(0)
    assert (h == hand_constant.HandConstant.ROCK
            or h == hand_constant.HandConstant.PAPER
            or h == hand_constant.HandConstant.SCISSORS)
Esempio n. 7
0
def test_start_showdown_rock():
    """手の公開(ランダムなので複数回実施してrockが出ることを確認)."""
    c = cpu_player.CpuPlayer()
    try_count = 100
    find_rock = False
    for _ in range(try_count):
        c.start_showdown()
        result = c.get()
        if result == hand_constant.HandConstant.ROCK:
            find_rock = True
            break
    assert find_rock
Esempio n. 8
0
def test_start_showdown_scissors():
    """手の公開(ランダムなので複数回実施してscissorsが出ることを確認)."""
    c = cpu_player.CpuPlayer()
    try_count = 100
    find_scissors = False
    for _ in range(try_count):
        c.start_showdown()
        result = c.get()
        if result == hand_constant.HandConstant.SCISSORS:
            find_scissors = True
            break
    assert find_scissors
Esempio n. 9
0
def test_get_hand_index_one():
    """プレイヤーの手の取得(indexが1)."""
    ps = players.Players()
    add_count = 2
    for _ in range(add_count):
        p = cpu_player.CpuPlayer()
        p.start_showdown()
        ps.add(p)

    h = ps.get_hand(1)
    assert (h == hand_constant.HandConstant.ROCK
            or h == hand_constant.HandConstant.PAPER
            or h == hand_constant.HandConstant.SCISSORS)
Esempio n. 10
0
def test_add_case_one():
    """プレイヤーの追加(1人)."""
    ps = players.Players()
    p = cpu_player.CpuPlayer()
    ps.add(p)
    assert ps.length() == 1
Esempio n. 11
0
def test_length_case_one():
    """プレイヤーデータ数の取得(1)."""
    ps = players.Players()
    p = cpu_player.CpuPlayer()
    ps.add(p)
    assert ps.length() == 1