示例#1
0
def test_team_reroll_on_block_dice(board):
    home_team, away_team = board.teams
    replay = Replay(home_team, away_team, [], [])
    player = home_team.get_player(0)
    board.set_position(Position(7, 7), player)
    opponent = away_team.get_player(0)
    board.set_position(Position(8, 7), opponent)
    board.setup_complete()
    cmds = iter_([
        TargetPlayerCommand(
            1, 1, TeamType.HOME, 0,
            [TeamType.HOME.value, 0, TeamType.AWAY.value, 0, 8, 7]),
        TargetSpaceCommand(1, 1, TeamType.HOME, 0,
                           [TeamType.HOME.value, 0, 0, 0, 0, 0, 0, 0, 8, 7]),
        RerollCommand(1, 1, TeamType.HOME, 0, [TeamType.HOME.value, 0, 0]),
        DiceChoiceCommand(1, 1, TeamType.HOME, 0, [TeamType.HOME.value, 0, 0]),
        PushbackCommand(1, 1, TeamType.HOME, 0,
                        [TeamType.HOME.value, 0, 9, 8]),
        FollowUpChoiceCommand(1, 1, TeamType.HOME, 0, [1])
    ])
    log_entries = iter_([
        BlockLogEntry(player.team.team_type,
                      player.number).complete([BlockResult.BOTH_DOWN]),
        RerollEntry(TeamType.HOME),
        BlockLogEntry(player.team.team_type,
                      player.number).complete([BlockResult.PUSHED]),
    ])
    events = replay._process_block(player, opponent, cmds, log_entries, board)

    event = next(events)
    assert isinstance(event, Reroll)
    assert event.team == TeamType.HOME

    event = next(events)
    assert isinstance(event, Block)
    assert event.blocking_player == player
    assert event.blocked_player == opponent
    assert event.dice == [BlockResult.PUSHED]
    assert event.result == BlockResult.PUSHED

    event = next(events)
    assert isinstance(event, Pushback)
    assert event.pushing_player == player
    assert event.pushed_player == opponent
    assert event.source_space == Position(8, 7)
    assert event.taget_space == Position(9, 8)

    event = next(events)
    assert isinstance(event, FollowUp)
    assert event.following_player == player
    assert event.followed_player == opponent
    assert event.source_space == Position(7, 7)
    assert event.target_space == Position(8, 7)

    assert not board.is_prone(player)
    assert not board.is_prone(opponent)

    assert not next(events, None)
    assert not next(cmds, None)
    assert not next(log_entries, None)
示例#2
0
def test_frenzy_with_first_block_down(board):
    home_team, away_team = board.teams
    replay = Replay(home_team, away_team, [], [])
    player = home_team.get_player(0)
    player.skills.append(Skills.FRENZY)
    board.set_position(Position(7, 7), player)
    opponent = away_team.get_player(0)
    board.set_position(Position(8, 7), opponent)
    cmds = iter_([
        TargetPlayerCommand(
            1, 1, TeamType.HOME, 0,
            [TeamType.HOME.value, 0, TeamType.AWAY.value, 0, 8, 7]),
        TargetSpaceCommand(1, 1, TeamType.HOME, 0,
                           [TeamType.HOME.value, 0, 0, 0, 0, 0, 0, 0, 8, 7]),
        DiceChoiceCommand(1, 1, TeamType.HOME, 0, [TeamType.HOME.value, 0, 0]),
        PushbackCommand(1, 1, TeamType.HOME, 0, [TeamType.HOME.value, 0, 9, 8])
    ])
    log_entries = iter_([
        BlockLogEntry(player.team.team_type,
                      player.number).complete([BlockResult.DEFENDER_DOWN]),
        ArmourValueRollEntry(opponent.team.team_type, opponent.number, "9+",
                             "8", ActionResult.FAILURE)
    ])
    events = replay._process_block(player, opponent, cmds, log_entries, board)

    event = next(events)
    assert isinstance(event, Block)
    assert event.blocking_player == player
    assert event.blocked_player == opponent
    assert event.dice == [BlockResult.DEFENDER_DOWN]
    assert event.result == BlockResult.DEFENDER_DOWN

    event = next(events)
    assert isinstance(event, Pushback)
    assert event.pushing_player == player
    assert event.pushed_player == opponent
    assert event.source_space == Position(8, 7)
    assert event.taget_space == Position(9, 8)

    event = next(events)
    assert isinstance(event, FollowUp)
    assert event.following_player == player
    assert event.followed_player == opponent
    assert event.source_space == Position(7, 7)
    assert event.target_space == Position(8, 7)

    event = next(events)
    assert isinstance(event, PlayerDown)
    assert event.player == opponent

    event = next(events)
    assert isinstance(event, ArmourRoll)
    assert event.player == opponent
    assert event.result == ActionResult.FAILURE

    assert not next(events, None)
    assert not next(cmds, None)
    assert not next(log_entries, None)
示例#3
0
def test_bug14_pushback_against_sidestep(board):
    home_team, away_team = board.teams
    replay = Replay(home_team, away_team, [], [])
    player = home_team.get_player(0)
    board.set_position(Position(7, 7), player)
    opponent = away_team.get_player(0)
    opponent.skills.append(Skills.SIDE_STEP)
    board.set_position(Position(8, 7), opponent)
    cmds = iter_([
        TargetPlayerCommand(
            1, 1, TeamType.HOME, 0,
            [TeamType.HOME.value, 0, TeamType.AWAY.value, 0, 8, 7]),
        TargetSpaceCommand(1, 1, TeamType.HOME, 0,
                           [TeamType.HOME.value, 0, 0, 0, 0, 0, 0, 0, 8, 7]),
        DiceChoiceCommand(1, 1, TeamType.HOME, 0, [TeamType.HOME.value, 0, 0]),
        SideStepCommand(
            1, 1, TeamType.AWAY, 0,
            [TeamType.HOME.value, 0, TeamType.AWAY.value, 0, 7, 6, 1]),
        PushbackCommand(1, 1, TeamType.HOME, 0,
                        [TeamType.HOME.value, 0, 7, 6]),
        FollowUpChoiceCommand(1, 1, TeamType.HOME, 0, [1])
    ])
    log_entries = iter_([
        BlockLogEntry(player.team.team_type,
                      player.number).complete([BlockResult.PUSHED]),
        SkillEntry(opponent.team.team_type, opponent.number, "Side Step")
    ])
    events = replay._process_block(player, opponent, cmds, log_entries, board)

    event = next(events)
    assert isinstance(event, Block)
    assert event.blocking_player == player
    assert event.blocked_player == opponent
    assert event.dice == [BlockResult.PUSHED]
    assert event.result == BlockResult.PUSHED

    event = next(events)
    assert isinstance(event, Skill)
    assert event.player == opponent
    assert event.skill == Skills.SIDE_STEP

    event = next(events)
    assert isinstance(event, Pushback)
    assert event.pushing_player == player
    assert event.pushed_player == opponent
    assert event.source_space == Position(8, 7)
    assert event.taget_space == Position(7, 6)

    event = next(events)
    assert isinstance(event, FollowUp)
    assert event.following_player == player
    assert event.followed_player == opponent
    assert event.source_space == Position(7, 7)
    assert event.target_space == Position(8, 7)

    assert not next(events, None)
    assert not next(cmds, None)
    assert not next(log_entries, None)
示例#4
0
def test_spell_does_not_consume_following_events(board):
    home_team, away_team = board.teams
    replay = Replay(home_team, away_team, [], [])
    player = home_team.get_player(0)
    board.set_position(Position(7, 7), player)
    board.set_ball_carrier(player)
    cmds = [
        SpellCommand(1, 1, TeamType.AWAY.value, 0,
                     [TeamType.AWAY.value, 0, 255, 7, 7])
    ]
    log_entries = [
        FireballEntry(TeamType.HOME, 1, "4+", "4", ActionResult.SUCCESS.name),
        ArmourValueRollEntry(TeamType.HOME, 1, "8+", "9",
                             ActionResult.SUCCESS.name),
        InjuryRollEntry(TeamType.HOME, 1, "6", InjuryRollResult.STUNNED.name),
        BounceLogEntry(ScatterDirection.NW.value),
        BlockLogEntry(TeamType.HOME, 2)
    ]
    cmds_iter = iter_(cmds)
    log_entries_iter = iter_(log_entries)
    events = replay._process_spell(cmds_iter, log_entries_iter, board)

    event = next(events)
    assert isinstance(event, Spell)
    assert event.target == Position(7, 7)
    assert event.spell == "Fireball"

    event = next(events)
    assert isinstance(event, Action)
    assert event.player == player
    assert event.action == ActionType.SPELL_HIT
    assert event.result == ActionResult.SUCCESS

    event = next(events)
    assert isinstance(event, PlayerDown)
    assert event.player == player

    event = next(events)
    assert isinstance(event, ArmourRoll)
    assert event.player == player
    assert event.result == ActionResult.SUCCESS

    event = next(events)
    assert isinstance(event, InjuryRoll)
    assert event.player == player
    assert event.result == InjuryRollResult.STUNNED

    event = next(events)
    assert isinstance(event, Bounce)
    assert event.start_space == Position(7, 7)
    assert event.end_space == Position(6, 8)
    assert event.scatter_direction == ScatterDirection.NW

    assert board.get_ball_carrier() is None
    assert board.get_ball_position() == Position(6, 8)

    assert not next(events, None)
    assert isinstance(next(log_entries_iter), BlockLogEntry)
示例#5
0
def test_pushback_off_field(board):
    home_team, away_team = board.teams
    replay = Replay(home_team, away_team, [], [])
    player = home_team.get_player(0)
    board.set_position(Position(1, 0), player)
    opponent = away_team.get_player(0)
    board.set_position(Position(0, 0), opponent)
    cmds = iter_([
        TargetPlayerCommand(
            1, 1, TeamType.HOME, 0,
            [TeamType.HOME.value, 0, TeamType.AWAY.value, 0, 8, 7]),
        TargetSpaceCommand(1, 1, TeamType.HOME, 0,
                           [TeamType.HOME.value, 0, 0, 0, 0, 0, 0, 0, 0, 0]),
        DiceChoiceCommand(1, 1, TeamType.HOME, 0, [TeamType.HOME.value, 0, 0]),
        FollowUpChoiceCommand(1, 1, TeamType.HOME, 0, [1])
    ])
    log_entries = iter_([
        BlockLogEntry(player.team.team_type,
                      player.number).complete([BlockResult.PUSHED]),
        InjuryRollEntry(opponent.team.team_type, opponent.number, "4",
                        InjuryRollResult.STUNNED.name)
    ])
    events = replay._process_block(player, opponent, cmds, log_entries, board)

    event = next(events)
    assert isinstance(event, Block)
    assert event.blocking_player == player
    assert event.blocked_player == opponent
    assert event.dice == [BlockResult.PUSHED]
    assert event.result == BlockResult.PUSHED

    event = next(events)
    assert isinstance(event, Pushback)
    assert event.pushing_player == player
    assert event.pushed_player == opponent
    assert event.source_space == Position(0, 0)
    assert event.taget_space == Position(-1, -1)

    event = next(events)
    assert isinstance(event, FollowUp)
    assert event.following_player == player
    assert event.followed_player == opponent
    assert event.source_space == Position(1, 0)
    assert event.target_space == Position(0, 0)

    event = next(events)
    assert isinstance(event, InjuryRoll)
    assert event.player == opponent
    assert event.result == InjuryRollResult.STUNNED

    assert not board.is_prone(player)
    # They were stunned, not injured
    assert not board.is_injured(opponent)

    assert not next(events, None)
    assert not next(cmds, None)
    assert not next(log_entries, None)
示例#6
0
def test_dodge_on_defender_stumbles(board):
    home_team, away_team = board.teams
    replay = Replay(home_team, away_team, [], [])
    player = home_team.get_player(0)
    board.set_position(Position(7, 7), player)
    opponent = away_team.get_player(0)
    opponent.skills.append(Skills.DODGE)
    board.set_position(Position(8, 7), opponent)
    cmds = iter_([
        TargetPlayerCommand(
            1, 1, TeamType.HOME, 0,
            [TeamType.HOME.value, 0, TeamType.AWAY.value, 0, 8, 7]),
        TargetSpaceCommand(1, 1, TeamType.HOME, 0,
                           [TeamType.HOME.value, 0, 0, 0, 0, 0, 0, 0, 8, 7]),
        DiceChoiceCommand(1, 1, TeamType.HOME, 0, [TeamType.HOME.value, 0, 0]),
        PushbackCommand(1, 1, TeamType.HOME, 0,
                        [TeamType.HOME.value, 0, 9, 8]),
        FollowUpChoiceCommand(1, 1, TeamType.HOME, 0, [1])
    ])
    log_entries = iter_([
        BlockLogEntry(player.team.team_type,
                      player.number).complete([BlockResult.DEFENDER_STUMBLES]),
        SkillEntry(opponent.team.team_type, opponent.number, "Dodge")
    ])
    events = replay._process_block(player, opponent, cmds, log_entries, board)

    event = next(events)
    assert isinstance(event, Block)
    assert event.blocking_player == player
    assert event.blocked_player == opponent
    assert event.dice == [BlockResult.DEFENDER_STUMBLES]
    assert event.result == BlockResult.DEFENDER_STUMBLES

    event = next(events)
    assert isinstance(event, Pushback)
    assert event.pushing_player == player
    assert event.pushed_player == opponent
    assert event.source_space == Position(8, 7)
    assert event.taget_space == Position(9, 8)

    event = next(events)
    assert isinstance(event, FollowUp)
    assert event.following_player == player
    assert event.followed_player == opponent
    assert event.source_space == Position(7, 7)
    assert event.target_space == Position(8, 7)

    event = next(events)
    assert isinstance(event, DodgeBlock)
    assert event.blocking_player == player
    assert event.blocked_player == opponent

    assert not next(events, None)
    assert not next(cmds, None)
    assert not next(log_entries, None)
示例#7
0
def test_blitz_with_juggernaut_does_not_trigger_on_block(board):
    home_team, away_team = board.teams
    replay = Replay(home_team, away_team, [], [])
    player = home_team.get_player(0)
    player.skills.append(Skills.JUGGERNAUT)
    board.set_position(Position(7, 7), player)
    opponent = away_team.get_player(0)
    board.set_position(Position(8, 7), opponent)
    cmds = iter_([
        TargetPlayerCommand(
            1, 1, TeamType.HOME, 0,
            [TeamType.HOME.value, 0, TeamType.AWAY.value, 0, 8, 7]),
        TargetSpaceCommand(1, 1, TeamType.HOME, 0,
                           [TeamType.HOME.value, 0, 0, 0, 0, 0, 0, 0, 8, 7]),
        DiceChoiceCommand(1, 1, TeamType.HOME, 0, [TeamType.HOME.value, 0, 0])
    ])
    log_entries = iter_([
        BlockLogEntry(player.team.team_type,
                      player.number).complete([BlockResult.BOTH_DOWN]),
        ArmourValueRollEntry(player.team.team_type, player.number, "9+", "8",
                             ActionResult.FAILURE),
        ArmourValueRollEntry(opponent.team.team_type, opponent.number, "9+",
                             "8", ActionResult.FAILURE),
        TurnOverEntry(player.team.team_type, "Knocked Down!")
    ])
    events = replay._process_block(player, opponent, cmds, log_entries, board)

    event = next(events)
    assert isinstance(event, Block)
    assert event.blocking_player == player
    assert event.blocked_player == opponent
    assert event.dice == [BlockResult.BOTH_DOWN]
    assert event.result == BlockResult.BOTH_DOWN

    event = next(events)
    assert isinstance(event, PlayerDown)
    assert event.player == player

    event = next(events)
    assert isinstance(event, ArmourRoll)
    assert event.player == player
    assert event.result == ActionResult.FAILURE

    event = next(events)
    assert isinstance(event, PlayerDown)
    assert event.player == opponent

    event = next(events)
    assert isinstance(event, ArmourRoll)
    assert event.player == opponent
    assert event.result == ActionResult.FAILURE

    event = next(events)
    assert isinstance(event, EndTurn)
    assert event.reason == "Knocked Down!"

    assert board.is_prone(player)
    assert board.is_prone(opponent)

    assert not next(cmds, None)
    assert not next(log_entries, None)
示例#8
0
def test_frenzy_against_block(board):
    home_team, away_team = board.teams
    replay = Replay(home_team, away_team, [], [])
    player = home_team.get_player(0)
    player.skills.append(Skills.FRENZY)
    player.skills.append(Skills.BLOCK)
    board.set_position(Position(7, 7), player)
    opponent = away_team.get_player(0)
    opponent.skills.append(Skills.BLOCK)
    board.set_position(Position(8, 7), opponent)
    cmds = iter_([
        TargetPlayerCommand(
            1, 1, TeamType.HOME, 0,
            [TeamType.HOME.value, 0, TeamType.AWAY.value, 0, 8, 7]),
        TargetSpaceCommand(1, 1, TeamType.HOME, 0,
                           [TeamType.HOME.value, 0, 0, 0, 0, 0, 0, 0, 8, 7]),
        DiceChoiceCommand(1, 1, TeamType.HOME, 0, [TeamType.HOME.value, 0, 0]),
        DiceChoiceCommand(1, 1, TeamType.HOME, 0, [TeamType.HOME.value, 0, 0]),
        PushbackCommand(1, 1, TeamType.HOME, 0, [TeamType.HOME.value, 0, 9, 7])
    ])
    log_entries = iter_([
        BlockLogEntry(player.team.team_type,
                      player.number).complete([BlockResult.BOTH_DOWN]),
        SkillEntry(player.team.team_type, player.number, "Block"),
        SkillEntry(opponent.team.team_type, opponent.number, "Block"),
        SkillEntry(player.team.team_type, player.number, "Frenzy"),
        BlockLogEntry(player.team.team_type,
                      player.number).complete([BlockResult.PUSHED])
    ])
    events = replay._process_block(player, opponent, cmds, log_entries, board)

    event = next(events)
    assert isinstance(event, Block)
    assert event.blocking_player == player
    assert event.blocked_player == opponent
    assert event.dice == [BlockResult.BOTH_DOWN]
    assert event.result == BlockResult.BOTH_DOWN

    event = next(events)
    assert isinstance(event, BlockBothDown)
    assert event.player == player

    event = next(events)
    assert isinstance(event, BlockBothDown)
    assert event.player == opponent

    event = next(events)
    assert isinstance(event, Skill)
    assert event.player == player
    assert event.skill == Skills.FRENZY

    event = next(events)
    assert isinstance(event, Block)
    assert event.blocking_player == player
    assert event.blocked_player == opponent
    assert event.dice == [BlockResult.PUSHED]
    assert event.result == BlockResult.PUSHED

    event = next(events)
    assert isinstance(event, Pushback)
    assert event.pushing_player == player
    assert event.pushed_player == opponent
    assert event.source_space == Position(8, 7)
    assert event.taget_space == Position(9, 7)

    event = next(events)
    assert isinstance(event, FollowUp)
    assert event.following_player == player
    assert event.followed_player == opponent
    assert event.source_space == Position(7, 7)
    assert event.target_space == Position(8, 7)

    assert not next(events, None)
    assert not next(cmds, None)
    assert not next(log_entries, None)