def __init__(self, main, parent, player2): super(WaitUI, self).__init__(main, parent) self.player2 = player2 self.surface = pygame.Surface((SCREEN_SIZE)) self.smaller_font = pygame.font.Font(None, 28) self.larger_font = pygame.font.Font(None, 108) self.you = get_you_img() self.me = get_me_img() self.adjective = get_adjective() self.noun = get_noun() self.redraw_teammate_words() self.redraw_join_words() self.redraw()
def handle_input(self, slot, message): msg = message.split(" ") if msg[0] == "MOVED": dx, dy = map(int, msg[1:]) p = self.slots[slot].player if p.move(dx, dy): self.broadcast(msg[0], str(slot), msg[1], msg[2]) elif msg[0] == "MSG": if msg[1][:1] == "/": # /commands command = msg[1][1:] if command in self.poll_commands: if command in self.polls and self.polls[command] != slot: del self.polls[command] self.poll_commands[command]() # maybe pass some params else: self.polls[command] = slot self.broadcast("MSG 3 Your " + US + "0" + str(slot) + get_noun() + US + "03 has requested a " + command + ". Type " + US + "0" + str(int(not slot)) + "/" + command + US + "03 to allow.") else: if command == "help": self.slots[slot].send("MSG 2 The following commands are available: " + ', '.join(self.poll_commands)) else: self.slots[slot].send("MSG 2 Unknown command:", command) else: self.broadcast(msg[0], slot, *msg[1:]) elif msg[0] == "HELP": self.slots[int(msg[1])].send("MSG 3 ? " + US + "02" + ' '.join(msg[2:])) elif msg[0] == "LEVELOFF": # propagate self.slots[not slot].send(*msg) elif msg[0] == "LEVELACC": # propagate self.slots[not slot].send(*msg) elif msg[0] == "LEVELULD": self.slots[not slot].send(*msg) elif msg[0] == "STARTGAME": # time to start the game!!! self.broadcast("STARTGAME", msg[1]) self.load_level(msg[1])