コード例 #1
0
ファイル: Player.py プロジェクト: reem/commonplace
 def __init__(self, name, description, start_health, base_attack, start_inventory=None, equipment_slots=None):
     BaseObj.__init__(self, name, description)
     self._health = start_health
     self._base_health = start_health
     self._base_attack = base_attack
     self.inventory = [] if start_inventory is None else start_inventory
     self.equipped = DEF_EQUIP_SLOTS if equipment_slots is None else equipment_slots
コード例 #2
0
ファイル: Places.py プロジェクト: reem/commonplace
    def __init__(self, name, description, rooms, start_room=0):
        """
        rooms: a list of Rooms to add to the map
        start_room: optional index of the starting room in the rooms list
        """

        if not isinstance(start_room, int):
            raise TypeError("start_room should be an integer index of rooms.")
        if not 0 <= start_room < len(rooms):
            raise ValueError("start_room should be a valid index of rooms.")

        BaseObj.__init__(self, name, description)
        self.rooms = rooms
        self.start_room = rooms[start_room]
コード例 #3
0
ファイル: Places.py プロジェクト: reem/commonplace
    def __init__(self, name, description, doors):
        """
        doors: the rooms that this room links to, as a dictionary like:
            direction: room
              where direction is a direction such as "right" or "north"
              and room is the room that direction links to.

              NOTE: The burden is on YOU to provide consistent directions.
        """

        if type(doors) != dict:
            raise TypeError("doors should be a dictionary")

        BaseObj.__init__(self, name, description)
        self.doors = doors
        self.directions = set(self.doors.iterkeys())
コード例 #4
0
ファイル: Monster.py プロジェクト: reem/commonplace
 def full_info(self):
     "Full information for prompting."
     return "{}\nHealth: {}\nAttack: {}".format(BaseObj.__str__(self),
                                                self.health,
                                                self.attack)
コード例 #5
0
ファイル: Monster.py プロジェクト: reem/commonplace
 def __init__(self, name, description, start_health, attack, drop):
     BaseObj.__init__(self, name, description)
     self._health = start_health
     self.max_health = start_health
     self.attack = attack
     self.drop = drop
コード例 #6
0
ファイル: Game.py プロジェクト: reem/commonplace
 def __init__(self, name, description, game_map, player):
     BaseObj.__init__(self, name, description)
     self.game_map = game_map
     self.player = player
     self.current_room = self.game_map.start_room
     self.turn_count = 0
コード例 #7
0
ファイル: Items.py プロジェクト: reem/commonplace
 def __init__(self, name, description, item_type):
     BaseObj.__init__(self, name, description)
     self.item_type = item_type