当前位置: 首页>>代码示例>>Python>>正文


Python Inventory.get方法代码示例

本文整理汇总了Python中inventory.Inventory.get方法的典型用法代码示例。如果您正苦于以下问题:Python Inventory.get方法的具体用法?Python Inventory.get怎么用?Python Inventory.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在inventory.Inventory的用法示例。


在下文中一共展示了Inventory.get方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Player

# 需要导入模块: from inventory import Inventory [as 别名]
# 或者: from inventory.Inventory import get [as 别名]
class Player(Actor):
    def __init__(
        self,
        xpos,
        ypos,
        level,
        *,
        playerName=None,
        title=None,
        worshipping=None,
        healCost=10,
        healValue=30,
        collideType={},
        **kwargs
    ):
        # EQUIPPING SHIT MUST CHANGE SELF.ATTACKCOST,
        # SELF.POISE, .POISEREGEN, .POISEDAMAGE, .STAGGERCOST
        # ATTACKCOST, MOVECOST, POISERECOVERY, ETC.
        defaults = {
            "damage": 1,
            "description": "It's you.",
            "display": "@",
            "displayColor": "player",
            "displayPriority": 3,
            "health": 100,
            "moveCost": 10,
            "name": "player",
            "collideType": {"isPlayer": True, "initiatesCombat": True, "blocksWalking": True},
            "canOpenDoors": True,
            "poiseRegen": 1,
            "damage": 15,
        }
        defaults.update(kwargs)
        super().__init__(xpos, ypos, level, **defaults)
        # default name/class
        self.title = "Chosen of Brand"
        self.playerName = "Roderick"
        self.worshipping = worshipping
        self.lastObelisk = None
        self.shardCount = 0
        self.inventory = Inventory(self, self.level)
        self.boonList = []
        self.healCost = healCost
        self.healValue = healValue

    def act(self):
        self.level.draw()
        temp = masterInputParser(self, self.level)
        self.poise = min(self.poise + self.poiseRegen * temp, self.maxPoise)

    def heal(self):
        if self.shardCount > 0 and self.health != self.maxHealth:
            self.health = min(self.maxHealth, self.health + self.healValue)
            self.shardCount = self.shardCount - 1
            self.andWait(self.healCost)
            self.level.output_buffer.add("You heal.")
            return self.healCost
        elif self.shardCount == 0:
            self.andWait(0)
            self.level.output_buffer.add("You don't have any shards!")
            return 0
        elif self.health == self.maxHealth and self.shardCount > 0:
            self.andWait(0)
            self.level.output_buffer.add("You're already at max health.")
            return 0

    def move(self, direction):
        temp = config.collideType.copy()
        config.temp = temp
        for entity in self.level.grid.get(
            self.xpos + config.directions[direction][0], self.ypos + config.directions[direction][1]
        ):
            collideType = entity.collide()
            for key in collideType:
                if collideType[key]:
                    temp[key] = collideType[key]
        if temp["isPortal"]:
            return 0
        if temp["isObelisk"]:
            return self.andWait(0)
        if temp["isDoor"] and not temp["isOpen"]:
            self.openDoor(config.directions[direction][0], config.directions[direction][1])
            return 0
        if not temp["blocksWalking"] and not temp["isEnemy"]:
            tempNum = self.doMove(config.directions[direction][0], config.directions[direction][1])
            self.postMoveDescribe()
            return tempNum
        elif temp["isEnemy"] and temp["initiatesCombat"]:
            return self.doAttack(config.directions[direction][0], config.directions[direction][1])
        else:
            return self.andWait(0)

    def postMoveDescribe(self):
        # generalize this!
        cell = self.level.grid.getCell(self.xpos, self.ypos)
        for content in cell.getContents():
            if isinstance(content, Item):
                if content.name[0] in "aeiouy":
                    self.level.output_buffer.add("You're standing on an " + content.name + ".")
                else:
#.........这里部分代码省略.........
开发者ID:Trial-In-Error,项目名称:raidlike,代码行数:103,代码来源:entity.py


注:本文中的inventory.Inventory.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。