def showEndGameState(thieves_won, players):
    if thieves_won:
        for player in players:
            player.entity.send_command(
                vibration_motor.vibrate(
                    vibration_motor.PremadeVibrationPatterns.LONG_BLIP))
            player.entity.send_command(
                led.solid_state(led.PredefinedColors.DARK_RED))
    else:
        for player in players:
            player.entity.send_command(
                vibration_motor.vibrate(
                    vibration_motor.PremadeVibrationPatterns.LONG_BLIP))
            player.entity.send_command(
                led.solid_state(led.PredefinedColors.ALICE_BLUE))
Пример #2
0
def on_thief_pressed(player, players, engine):
    player.type = PlayerType.CAUGHT
    player.entity.send_command(led.solid_state(led.PredefinedColors.GREEN))
    found = False
    for item in players:
        if item.type == PlayerType.THIEF:
            found = True
            item.entity.send_command(vibration_motor.vibrate(vibration_motor.PremadeVibrationPatterns.LONG_BLIP))
    if found:
        return False
    # All thiefs are caught so endgame state is reached

    # Send game ended due to thieves caught
    return True
def execute_button(button_type, entity, engine, team):
    if button_type == ButtonType.ATTACK:
        # Call attack mode vibrate for the whole team
        for player in team.players:
            if player.entity != entity:
                player.entity.send_command(vibration_motor.vibrate(vibration_motor.PremadeVibrationPatterns.TWO_LONG_BLIPS))

    elif button_type == ButtonType.DEFENSE:
        # Call defense mode vibrate for the whole team
        for player in team.players:
            if player.entity != entity:
                player.entity.send_command(vibration_motor.vibrate(vibration_motor.PremadeVibrationPatterns.THREE_SHORT_BLIPS))

    elif button_type == ButtonType.HIT:
        # Switch between hitted and not hitted for a player
        for player in team.players:
            if player.entity == entity:
                if not player.hitted:
                    entity.send_command(led.solid_state(led.PredefinedColors.RED))
                    player.hitted = True
                else:
                    entity.send_command(led.solid_state(team.color))
                    player.hitted = False
                entity.send_command(vibration_motor.vibrate(vibration_motor.PremadeVibrationPatterns.SHORT_BLIP))
Пример #4
0
def switch_player_team(player, counts):
    if player.type == PlayerType.THIEF and counts[0] > 1:
        player.type = PlayerType.POLICE
        counts[1] += 1
        counts[0] -= 1
        player.entity.send_command(
            led.solid_state(led.PredefinedColors.ALICE_BLUE))
    elif player.type == PlayerType.POLICE and counts[1] > 1:
        player.type = PlayerType.THIEF
        counts[0] += 1
        counts[1] -= 1
        player.entity.send_command(
            led.solid_state(led.PredefinedColors.DARK_RED))
    player.entity.send_command(
        vibration_motor.vibrate(
            vibration_motor.PremadeVibrationPatterns.SHORT_BLIP))
Пример #5
0
def test_command_string():
    command, _ = vibration_motor.vibrate(
        vibration_motor.VibrationPattern("101", 150))
    assert command == "0|1|5|3|150"