Exemplo n.º 1
0
 def update(self, mouse_pos):
     self.updates += 1
     self.father.combat_ui.update(self.father.combat, mouse_pos)
     range_hint = self.father.combat.get_range_hint(
         self.father.combat.to_act, self.ability)
     for target in range_hint:
         self.father.combat_ui.arena.board[target].animate(
             'tiles/GreyTile2.png')
     splash_hint = self.father.combat.get_splash_hint(
         self.father.combat.to_act, self.ability, self.target)
     for target in splash_hint:
         self.father.combat_ui.arena.board[target].animate(
             'tiles/Yellow2.png')
     targets_hint = []
     backgrounds = []
     for i, target in enumerate(self.valid_targets):
         key = i + 1 if i < 9 else 0
         x, y = target.display_location()
         t = TextSprite('[%d]' % key, '#ffff00', x=x + 4, y=y + 6)
         background = Gauge(32, 32, '#000000')
         background.move_to(x, y)
         background.image.set_alpha(50)
         backgrounds.append(background)
         targets_hint.append(t)
     tile = GameTile.get_tile_for_mouse(mouse_pos)
     if tile and tile in self.valid_targets:
         self.target = tile
     self.father.combat_ui.display()
     for t in backgrounds:
         t.display()
     for t in targets_hint:
         t.display()
     self.father.combat_ui.cursor.display()
Exemplo n.º 2
0
 def update(self, combat, mouse_pos):
     self.game_frame += 1
     self.cursor.rect.x, self.cursor.rect.y = mouse_pos[0] - 10, mouse_pos[
         1] - 10
     tile = GameTile.get_tile_for_mouse(mouse_pos)
     self.hover_xair.update(tile)
     self.selected_xair.update(combat.selected)
     for creature in combat.creatures.values():
         if creature not in self.subsprites:
             self.subsprites.insert(3, creature)
     creature = combat.creatures.get(
         tile, combat.creatures.get(combat.selected, combat.to_act))
     if creature:
         self.hover_display.update(creature, mouse_pos)
         self.hover_display.must_show = True
     else:
         self.hover_display.must_show = False
     self.arena.update(combat.to_act)
Exemplo n.º 3
0
 def on_click(self, mouse_pos):
     tile = GameTile.get_tile_for_mouse(mouse_pos)
     if self.combat.selected and self.combat.selected == tile:
         self.combat.selected = None
     else:
         self.combat.selected = tile
Exemplo n.º 4
0
 def on_click(self, mouse_pos):
     self.target = GameTile.get_tile_for_mouse(mouse_pos)
     if self.target and self.target in self.valid_targets:
         self.father.combat.selected = None
         self.done()
Exemplo n.º 5
0
    def test_mouse_location(self):
        xt1, yt1 = self.t1.display_location()

        assert GameTile.get_tile_for_mouse((xt1, yt1)) == self.t1
        assert GameTile.get_tile_for_mouse((xt1 + 20, yt1 + 20)) == self.t1