for command in command_sequence: if not isinstance(command, Command): raise Exception("command_sequence contains an invalid command type: " + str(command.__class__())) if not command.command_type in self.command_types: raise Exception( """ Invalid command type in command_sequence. Valid values are {0}. Got {1}""".format( self.command_types, command.command_type ) ) serializable.register(Command) if __name__ == "__main__": import unittest class CommandTest(unittest.TestCase): def setUp(self): self.command1 = Command("1", CommandDurations.TAP) self.command1_2 = Command("1", CommandDurations.TAP) self.command2 = Command("2", CommandDurations.TAP) self.command_state = CommandState(["1", "2"]) self.command_state_2 = CommandState(["1", "2"]) self.command_state2 = CommandState(["2", "3"]) self.command_types = ["1", "2"] self.handler = handler = CommandHandler(self.command_types) self.command_sequence = [self.command1, self.command2]
for command_type in command_types: command_states.set_command_state(command_type, True) return command_states def _update_attack(self, command_types): """Returns an attack Action that matches the command types in command_types.""" command_state = self._create_attack_command_states( command_types ) self.attack_command_handler.update_current_commands( command_state ) def _create_attack_command_states(self, command_types): """Creates a CommandState object from a list command_types for the attack command handler.""" command_states = self.attack_command_handler.get_command_state() for command_type in command_types: command_states.set_command_state(command_type, True) return command_states serializable.register(InputCommandTypes)
import stick import animation from movesetdata import Moveset from wotsprot.rencode import serializable from record import Recording from simulation import SimulationRenderingInfo, PlayerRenderingInfo, AttackResultRenderingInfo from physics import Model serializable.register(SimulationRenderingInfo) serializable.register(PlayerRenderingInfo) serializable.register(AttackResultRenderingInfo) serializable.register(Model) serializable.register(Recording) serializable.register(stick.Point) serializable.register(stick.Line) serializable.register(stick.Circle) serializable.register(animation.Animation) serializable.register(animation.Frame) serializable.register(Moveset)