示例#1
0
class Torpedoes:
    is_ready = True

    def __init__(self):
        self.client_fire = Client(TORPEDO_FIRE_DRIVER_PORT)
        self.client_ready = Client(TORPEDO_READY_CLIENT_PORT)
        self.torpedo_handling = TorpedoHandling()

    def fire(self):
        command = self.client_fire.get_data()
        #print(command)
        if command == "FIRE" and self.is_ready:
            self.torpedo_handling.sequence()

            self.client_ready.send_data('WAIT')
            self.is_ready = False
            self.reload_torpedo()

    def reload_torpedo(self):
        reload_time = 2  # czas przeładowywania, do ustawienia
        """
        TUTAJ PRZEŁADOWANIE
        """
        time.sleep(
            reload_time)  # jak umiecie jakieś lepsze czekanie, to zmieńcie
        self.client_ready.send_data('READY')
        self.is_ready = True
示例#2
0
class Lights:

    def __init__(self):
            self.client_brightness = Client(LIGHTS_DRIVER_PORT)
            self.light_handling = LightHandling()

    def set_brightness(self):
        command = self.client_brightness.get_data()
        #print(command) 
        x = int(command['power'])
        self.light_handling.lights_set_brightness(x)