Пример #1
0
 def player_move_into(self, player, x, y, mapdef):
     if not self.has_hidden:
         return Door.player_move_into(self, player, x, y, mapdef)
     player.search_skill.observe(self)
     if self.has_hidden:
         gl.message("You bump into wall")
         return False, False, False
     return super(HiddenDoor, self).player_move_into(player, x, y, mapdef)
Пример #2
0
 def player_move_into(self, player, x, y, mapdef):
     if not self.has_hidden:
         return Door.player_move_into(self, player, x, y, mapdef)
     player.search_skill.observe(self)
     if self.has_hidden:
         gl.message("You bump into wall")
         return False, False, False
     return super(HiddenDoor, self).player_move_into(player, x, y, mapdef)
Пример #3
0
 def see(self, tile, tilex, tiley, map):
     if tile.items and len(tile.items):
         item = tile.items[0]
         if not getattr(item, 'seen', False):
             gl.message('You see %s' % item)
             item.seen = True
     if getattr(tile, 'has_hidden', False):
         self.search_skill.observe(tile)
Пример #4
0
 def player_move_into(self, player, x, y, mapdef):
     super(Door, self).player_move_into(player, x, y, mapdef)
     if not self.opened:
         self.opened = True
         self.char = '-'
         self.flags = NONE
         self.name = 'opened door'
         gl.message('You open the door.')
         player.map.update_fov_for(x, y)
         return False, True, True
     return True, True, True
Пример #5
0
 def player_move_into(self, player, x, y, mapdef):
     super(Door, self).player_move_into(player, x, y, mapdef)
     if not self.opened:
         self.opened = True
         self.char = '-'
         self.flags = NONE
         self.name = 'opened door'
         gl.message('You open the door.')
         player.map.update_fov_for(x, y)
         return False, True, True
     return True, True, True
Пример #6
0
 def move(self, dx, dy):
     newx, newy = self.x + dx, self.y + dy
     if self.map.has_critter_at((newx, newy)):
         self.attack(self.map.get_critter_at(newx, newy))
         return True
     next_tile = self.map[newy][newx]
     if next_tile.passable():
         self.x, self.y = newx, newy
         return True
     else:
         gl.message("You bump into wall")
     return False
Пример #7
0
 def move(self, dx, dy):
     newx, newy = self.x + dx, self.y + dy
     if self.map.has_critter_at((newx, newy)):
         self.attack(self.map.get_critter_at(newx, newy))
         return True
     next_tile = self.map[newy][newx]
     if next_tile.passable():
         self.x, self.y = newx, newy
         return True
     else:
         gl.message("You bump into wall")
     return False
Пример #8
0
 def attack(self, whom):
     dmgs = []
     for attack in self.base_dmg:
         dmg = util.roll(*attack)
         #let's roll 1d20 + HD for now, assuming that monster
         # can hit player no lees than 30% of the time
         # (thus checking it to be > 14)
         #TODO add player's/monsters' evade to calculations
         if util.roll(1, 20, self.base_hd) >= 14:
             dmgs.append(dmg)
         else:
             gl.message(self.name.capitalize() + ' misses ' + whom.name, 1)
     whom.take_damage(self, dmgs, attack)
Пример #9
0
 def attack(self, whom):
     dmgs = []
     for attack in self.base_dmg:
         dmg = util.roll(*attack)
         #let's roll 1d20 + HD for now, assuming that monster
         # can hit player no lees than 30% of the time
         # (thus checking it to be > 14)
         #TODO add player's/monsters' evade to calculations
         if util.roll(1, 20, self.base_hd) >= 14:
             dmgs.append(dmg)
         else:
             gl.message(self.name.capitalize() + ' misses ' + whom.name, 1)
     whom.take_damage(self, dmgs, attack)
Пример #10
0
 def pickup(self, map, multi_select_handler=None):
     tile = self.map.tile_at(self.x, self.y)
     items = tile.items
     if not items:
         gl.message('There is nothing to pick up here')
     if len(items) == 1:
         item = items.pop()
         self._item_pickup(item)
     elif multi_select_handler:
         selected_items = multi_select_handler(categorize_items(items))
         if selected_items:
             for item in selected_items:
                 items.remove(item)
                 self._item_pickup(item)
Пример #11
0
 def take_damage(self, mob, dmgs, attack):
     """
     take_damage(source, [int], attack) => None
     This method inflicts damage to a creature of amount specified as dmgs list whic was dealt by mob
     """
     for dmg in dmgs:
         for i in range(0, self.base_ac + 1):
             if util.coinflip(): dmg -= 1
             if dmg <= 0: continue
         if dmg > 0 and self.hp > 0:
             gl.message(mob.name.capitalize() + ' hits ' + self.name + ' for ' + str(dmg) + ' damage.', 5)
             self.hp -= dmg
         elif self.hp > 0:
             gl.message (mob.name.capitalize() + ' fails to harm ' + self.name)
     if self.hp <= 0:
         self.die(mob)
Пример #12
0
 def move(self, dx, dy):
     newx, newy = self.x + dx, self.y + dy
     if not self.map.coords_okay(newx, newy):
         return False, False, None
     if self.map.has_critter_at((newx, newy)):
         cost = self.attack(self.map.get_critter_at(newx, newy))
         return True, False, cost
     next_tile = self.map.tile_at(newx, newy)
     move_to, take_turn, fov_recalc = next_tile.player_move_into(self, newx, newy, self.map)
     if move_to:
         #todo move cost should be changed by the type of tile we're entering
         self.x, self.y = newx, newy
         self.search(self.map, 4)
         return take_turn, fov_recalc, self.action_cost.move
     elif next_tile.is_wall():
         gl.message("You bump into wall")
     return take_turn, fov_recalc, None
Пример #13
0
 def player_move_into(self, player, x, y, map_def):
     """ player_move_into(Player, int, int, map.Map) => (bool, bool, bool)
     Invoked before player steps onto next tile. Must return tuple of 3 values:
     first - if player can occupy square, second if it takes turn,
     third value - denotes if fov should be recalculated
     @player - player or monster stepping on that tile
     @x, @y - coords of tile
     @map_def - link to the map itself
     """
     if self.items:
         for item in self.items[:]:
             item.player_move_into(player, x, y, map_def)
     if self.items:
         if 1<=len(self.items)<3:
             gl.message('There are ' + ', '.join(map(lambda x: x.__repr__(), self.items)) + ' lying here')
         elif len(self.items) > 2:
             gl.message('There are several items lying here')
     return self.passable(), self.passable(), self.passable()
Пример #14
0
    def player_move_into(self, player, x, y, map_def):
        if self.has_hidden:
            player.search_skill.observe(self)
        if self.has_hidden and not self.disarmed:
            gl.message('%s step on a trap' % player.pronoun.capitalize())
            self.found(player)
            player.take_damage(self, self.dmg(), None)
        elif not self.disarmed:
            max_dm = self.max_dmg()
            if max_dm > (min(player.hp, player.base_hp * gl.__trap_low_hp_warning__)): #if this trap can be dangerous
                if gl.render_warn_yn_dialog('Step on the trap (yY/nN)?'): # we ask player
                    player.take_damage(self, self.dmg(), None)
                else:
                    return False, False, False
            else: #if this is wimpy trap - just pass over
                player.take_damage(self, self.dmg(), None)

        return super(_Trap, self).player_move_into(player, x, y, map_def)
Пример #15
0
 def player_move_into(self, player, x, y, map_def):
     """ player_move_into(Player, int, int, map.Map) => (bool, bool, bool)
     Invoked before player steps onto next tile. Must return tuple of 3 values:
     first - if player can occupy square, second if it takes turn,
     third value - denotes if fov should be recalculated
     @player - player or monster stepping on that tile
     @x, @y - coords of tile
     @map_def - link to the map itself
     """
     if self.items:
         for item in self.items[:]:
             item.player_move_into(player, x, y, map_def)
     if self.items:
         if 1 <= len(self.items) < 3:
             gl.message('There are ' +
                        ', '.join(map(lambda x: x.__repr__(), self.items)) +
                        ' lying here')
         elif len(self.items) > 2:
             gl.message('There are several items lying here')
     return self.passable(), self.passable(), self.passable()
Пример #16
0
    def player_move_into(self, player, x, y, map_def):
        if self.has_hidden:
            player.search_skill.observe(self)
        if self.has_hidden and not self.disarmed:
            gl.message('%s step on a trap' % player.pronoun.capitalize())
            self.found(player)
            player.take_damage(self, self.dmg(), None)
        elif not self.disarmed:
            max_dm = self.max_dmg()
            if max_dm > (min(player.hp,
                             player.base_hp * gl.__trap_low_hp_warning__)
                         ):  #if this trap can be dangerous
                if gl.render_warn_yn_dialog(
                        'Step on the trap (yY/nN)?'):  # we ask player
                    player.take_damage(self, self.dmg(), None)
                else:
                    return False, False, False
            else:  #if this is wimpy trap - just pass over
                player.take_damage(self, self.dmg(), None)

        return super(_Trap, self).player_move_into(player, x, y, map_def)
Пример #17
0
 def player_move_into(self, player, x, y, map):
     #todo check player is flying (maybe)
     if self.reacted: return True, True, True #already pressed
     self.reacted = True #todo - take skills in account
     gl.message('%s step on the pressure plate' % player.pronoun.capitalize())
     self.found(player)
     fts = map.current.find_feature(self.affected, multiple=True)
     if fts:
         for ft, x, y in fts:
             if self.action == 'remove':
                 map.current.replace_feature_atxy(x, y, with_what=map.map_src.floor)
         if self.action == 'remove':
             if util.coinflip():
                 gl.message('You hear grinding noise')
             else:
                 gl.message('You hear some strange shrieking noise')
             map.init_fov()
     else:
         gl.message('Nothing seems to happen')
     return True, True, True
Пример #18
0
 def player_move_into(self, player, x, y, map):
     #todo check player is flying (maybe)
     if self.reacted: return True, True, True  #already pressed
     self.reacted = True  #todo - take skills in account
     gl.message('%s step on the pressure plate' %
                player.pronoun.capitalize())
     self.found(player)
     fts = map.current.find_feature(self.affected, multiple=True)
     if fts:
         for ft, x, y in fts:
             if self.action == 'remove':
                 map.current.replace_feature_atxy(
                     x, y, with_what=map.map_src.floor)
         if self.action == 'remove':
             if util.coinflip():
                 gl.message('You hear grinding noise')
             else:
                 gl.message('You hear some strange shrieking noise')
             map.init_fov()
     else:
         gl.message('Nothing seems to happen')
     return True, True, True
Пример #19
0
 def take_damage(self, mob, dmgs, attack):
     for dmg in dmgs:
         for i in range(0, self.base_ac + 1):
             if util.coinflip(): dmg -= 1
             if dmg <= 0: break
         if dmg > 0 and self.hp > 0:
             gl.message(mob.name.capitalize() + ' hits ' + self.name + ' for ' + str(dmg) + ' damage.', 5)
             self.hp -= dmg
             if isinstance(self, Player):
                 if self.hp <= self.base_hp * gl.__hp_warning__:
                     gl.message('Low HP!!!', 'WARN')
         elif self.hp > 0:
             gl.message (mob.name.capitalize() + ' fails to harm ' + self.name, 1)
     if self.hp <= 0:
         self.die(mob)
Пример #20
0
 def take_damage(self, mob, dmgs, attack):
     for dmg in dmgs:
         for i in range(0, self.base_ac + 1):
             if util.coinflip(): dmg -= 1
             if dmg <= 0: break
         if dmg > 0 and self.hp > 0:
             gl.message(
                 mob.name.capitalize() + ' hits ' + self.name + ' for ' +
                 str(dmg) + ' damage.', 5)
             self.hp -= dmg
             if isinstance(self, Player):
                 if self.hp <= self.base_hp * gl.__hp_warning__:
                     gl.message('Low HP!!!', 'WARN')
         elif self.hp > 0:
             gl.message(
                 mob.name.capitalize() + ' fails to harm ' + self.name, 1)
     if self.hp <= 0:
         self.die(mob)
Пример #21
0
 def found(self, player):
     self.has_hidden = False
     self.char = '^'
     gl.message('You found a trap')
Пример #22
0
 def die(self, killer):
     gl.message( 'You die...', 'CRITICAL')
     gl.__game_state__ = "died"
Пример #23
0
 def found(self, player):
     gl.message('You have found %s' % self)
     self.has_hidden = False
Пример #24
0
 def found(self, player):
     gl.message('You have found %s' % self)
     self.has_hidden = False
Пример #25
0
 def found(self, player):
     self.has_hidden = False
     self.char = '^'
     gl.message('You found a trap')
Пример #26
0
 def _item_pickup(self, item):
     self.inventory.add_item(item)
     gl.message('You pick up ' + str(item))
     item.on_pickup(self)
Пример #27
0
 def take_damage(self, mob, dmgs, attack):
     #take evasion into account
     super(Player, self).take_damage(mob, dmgs, attack)
     if self.hitpoints <= self.base_hp * gl.__hp_warning__:
         gl.message('Low HP!!!', 'WARN')
Пример #28
0
 def quaff(self, player):
     super(HealingPotion, self).quaff(player)
     player.hp = util.cap(player.hp + util.roll(2, 10, 1), player.base_hp)
     gl.message('You feel somewhat better')
Пример #29
0
 def quaff(self, player):
     super(HealingPotion, self).quaff(player)
     player.hp = util.cap(player.hp + util.roll(2, 10, 1), player.base_hp)
     gl.message('You feel somewhat better')
Пример #30
0
 def lvl_up(self):
     self.xl += 1
     gl.message("Congratulations! Level up", 'INFO')
Пример #31
0
 def die(self, killer):
     gl.message(self.name.capitalize() + ' dies', 1)
     if isinstance(killer, Critter):
         killer.earn_exp(self)
     self.map.remove_critter(self)
Пример #32
0
 def player_move_into(self, player, x, y, map_src):
     super(Gold, self).player_move_into(player, x, y, map_src)
     player.gold += self.value
     gl.message('You found ' + str(self.value) + ' gold. Now you have ' + str(player.gold))
     self.cell.items.remove(self)
Пример #33
0
 def die(self, killer):
     gl.message('You die...', 'CRITICAL')
     gl.__game_state__ = "died"
Пример #34
0
 def die(self, killer):
     gl.message(self.name.capitalize() + ' dies')
     if isinstance(killer, Critter):
         killer.earn_exp(self)
     self.map.remove_critter(self)
Пример #35
0
 def player_move_into(self, player, x, y, map_src):
     super(Gold, self).player_move_into(player, x, y, map_src)
     player.gold += self.value
     gl.message('You found ' + str(self.value) + ' gold. Now you have ' +
                str(player.gold))
     self.cell.items.remove(self)
Пример #36
0
 def lvl_up(self):
     self.xl += 1
     gl.message ("Congratulations! Level up", 'INFO')