Changeset 450:e2b43fe37ac4


Ignore:
Timestamp:
04/09/11 18:14:19 (12 years ago)
Author:
Simon Cross <hodgestar@…>
Branch:
default
Phase:
public
Rebase:
34383634663162393534616139336665303264383562393634313561323335343433316630633766
Message:

Sort actionables with items first, then npcs then doorways. Fix flight prep_time bug.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • skaapsteker/sprites/player.py

    r442 r450  
    44import time
    55
    6 from ..sprites.base import find_sprite, Monster, TILE_SIZE, PC_LAYER, MONSTER_LAYER, PROJECTILE_LAYER
     6from ..sprites.base import (find_sprite, Monster, NPC, Item, Doorway, TILE_SIZE,
     7                            PC_LAYER, MONSTER_LAYER, PROJECTILE_LAYER)
    78from ..sprites.projectiles import Fireball, Lightning
    89from ..sprites.items import BreakableItem
     
    284285    def action_double_up(self):
    285286        if self.flying > 0 or 'flight' not in self._me.tails or \
    286                self.prep_flight - time.time() > 2.5 * DOUBLE_TAP_TIME \
     287               time.time() - self.prep_flight > 2.5 * DOUBLE_TAP_TIME \
    287288               or self._me.shape != 'fox':
    288289            return
     
    340341            self.on_solid = False
    341342
     343    def _action_key(self, sprite):
     344        # sort action items so Items are first, then NPCs, then others, then Doorways
     345        # This prevents problems if players drop items on NPCs or Doorways
     346        return (
     347            not isinstance(sprite, Item),
     348            not isinstance(sprite, NPC),
     349            not isinstance(sprite, Doorway))
     350
    342351    def action_down(self):
    343352        if self.flying:
     
    347356        elif self._touching_actionables:
    348357            self.invisible = 0
     358            self._touching_actionables.sort(key=self._action_key)
    349359            self._touching_actionables[0].player_action(self)
    350360        elif self._me.item is not None and self.on_solid:
Note: See TracChangeset for help on using the changeset viewer.