def on_start_dealing(self, message): world = self.world for player in world.players: kxg.info("Dealing to player {player}).") new_hand = self.draw_cards(6) self >> messages.DealToPlayer(player, new_hand)
def on_execute(self, world): for card in self.cards: card.in_play = True self.player.hand = self.cards[:] codes = [card.code for card in self.cards] kxg.info("Dealing cards to {self.player}. Cards: {codes}")
def on_deal_to_player(self, message): (card_x, card_y) = self.world.card_size if self.player == message.player: codes = [card.code for card in self.player.hand] kxg.info("Cards deltith to {self.player}. Cards: {codes}") for (i, card) in enumerate(self.player.hand): self.hand_buttons[i].assign_card(card)
def on_mouse_press(self, x, y, button, modifiers): # Send a "ShootBullet" signal when the user left-clicks. if button == 1: target = self.focus_point cannon = self.player.cannons[0] direction = (target - cannon.position).unit velocity = cannon.muzzle_speed * direction position = cannon.position + 40 * direction bullet = tokens.Bullet(cannon, position, velocity) if self.player.can_shoot(bullet): self >> messages.ShootBullet(bullet) else: kxg.info("Not enough arsenal to shoot bullet!")
def on_create_player(self, message): num_players_joined = len(self.world.players) kxg.info("{num_players_joined} of {self.num_players_expected} players created.") if num_players_joined == self.num_players_expected: self >> messages.StartGame(self.world)
def log_something(): kxg.info("Hello World!")