Ejemplo n.º 1
0
    def available_actions(self, the_player):
        moves = self.adjacent_moves()
        moves.append(actions.ViewInventory())
        moves.append(actions.Use(tile=self))
        moves.append(actions.Quit())
        if the_player.fsm:
            moves.extend(self.devcommands(the_player))

        return moves
Ejemplo n.º 2
0
    def available_actions(self, the_player):
        if self.enemy.is_alive() and self.enemy.aggro:
            moves = []
            moves.append(actions.ViewInventory())
            moves.append(actions.Use(tile=self))
            moves.append(actions.Flee(tile=self))
            moves.append(actions.Attack(enemy=self.enemy))
            moves.append(actions.Talk(tile=self, enemy=self.enemy))
            moves.append(actions.Quit())
            if the_player.fsm:
                moves.extend(self.devcommands(the_player))

            return moves

        elif self.enemy.is_alive() and not self.enemy.aggro:
            moves = self.adjacent_moves()
            moves.append(actions.ViewInventory())
            moves.append(actions.Use(tile=self))
            moves.append(actions.Quit())
            moves.append(actions.Attack(enemy=self.enemy))
            moves.append(actions.Talk(tile=self, enemy=self.enemy))
            if the_player.fsm:
                moves.extend(self.devcommands(the_player))

            return moves
        else:
            moves = self.adjacent_moves()
            moves.append(actions.ViewInventory())
            moves.append(actions.Use(tile=self))
            moves.append(actions.Quit())
            if len(self.item) != 0:
                moves.append(actions.Grab(tile=self))

            if the_player.fsm:
                moves.extend(self.devcommands(the_player))

            return moves
Ejemplo n.º 3
0
 def available_actions(self):
     """Returns all of the available actions in this room."""
     moves = self.adjacent_moves()
     moves.append(actions.ListCommands())
     moves.append(actions.ViewInventory())
     moves.append(actions.Look())
     moves.append(actions.View())
     moves.append(actions.Equip())
     moves.append(actions.Take())
     moves.append(actions.Use())
     moves.append(actions.Search())
     moves.append(actions.Menu())
     moves.append(actions.Save())
     moves.append(actions.ViewMap())
     return moves
Ejemplo n.º 4
0
    def action(self):
        pressed = self.screen.getch()

        y, x = self._get_direction(pressed=pressed)
        if y and x:
            return actions.Move(self.player, self.map.tiles[y][x])

        # open
        if pressed == ord('o'):

            y, x = self._get_direction("Open what")
            if y and x:
                return actions.Open(self.player, self.map.tiles[y][x])

        # close
        if pressed == ord('c'):
            y, x = self._get_direction("Close what")
            if y and x:
                return actions.Close(self.player, self.map.tiles[y][x])

        y, x = self.player.y, self.player.x

        # pick up
        if pressed == ord('p'):
            return actions.PickUp(self.player, self.map.tiles[y][x])

        # drop
        if pressed == ord('d'):
            item = self._get_item("Drop what")
            return actions.Drop(self.player, self.map.tiles[y][x], item)

        # use
        if pressed == ord('u'):
            item = self._get_item("Use what")
            if item:
                y, x = self._get_direction("Use %s on what" % item)
                if y and x:
                    return actions.Use(self.player, self.map.tiles[y][x], item)

        if pressed == ord('?'):
            return actions.Wait(
                "<arrows>: walk, O: open, C: close, P: pick up, D: drop, U: use"
            )

        return actions.Wait()
Ejemplo n.º 5
0
    def __init__(self, health, location):
        creature.Creature.__init__(self, "player", health)
        self.location = location  # the player's actions derive from its location

        self.settings = {
            "auto-rest": True,
            "auto-scavenge": True,
            "instant input": True,
            "permadeath": False
        }

        # baseActions are actions the player can always take.
        self.baseActions = [actions.Menu(self), actions.Use(self)]
        self.actions = self.baseActions + self.location.actions
        self.levelBonus = actions.LevelBonus(self, [])
        self.abilities = [
            actions.Use(self)
        ]  # the player's abilities list is not a frequency list because the player chooses abilities

        self.states = {}
        self.classInspect = lambda: ""  # additional combat information (ex. rogue could say "Stealthed" or mage could say "Mana 100/100")
        self.classUpdate = lambda: None
        self.combatUpdate = lambda: None

        self.completedQuests = {}

        # The player starts at level 1.
        self.levelUpExperience = [
            # 2  3    4    5    6    7     8     9     10
            100,
            200,
            400,
            600,
            800,
            1000,
            1200,
            1400,
            1700,
            # 11  12    13    14    15    16    17    18    19    20
            2000,
            2300,
            2600,
            3000,
            3400,
            3800,
            4200,
            4600,
            5000,
            5400,
            # 21  22    23    24    25    26    27    28    29    30
            5800,
            6200,
            6600,
            7000,
            7500,
            8000,
            8500,
            9000,
            9500,
            10000
        ]
        self.maxLevel = len(self.levelUpExperience) + 1
        self.experience = 0
        self.level = 1

        self.isPlayer = True
        self.unique = False
        self.alive = True