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


Python Character.setRace方法代码示例

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


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

示例1: __init__

# 需要导入模块: from Character import Character [as 别名]
# 或者: from Character.Character import setRace [as 别名]
class Character_Creator:

    def __init__(self):
        self.character = Character()
        self.tuples = Character_Tuples()
        self.skillCount = 0
        self.mainHandTuple = self.tuples.BARBARIAN_MAIN_HAND
        self.offHandTuple = self.tuples.BARBARIAN_OFF_HAND
        self.rangedTuple = self.tuples.BARBARIAN_RANGED_WEAPON
        self.armorTuple = self.tuples.BARBARIAN_ARMOR

    def pointBuyCallback(self, statIndex, additionMode):
        """
        Callback for the increment buttons that checks if the amount of points after the increment would be negative then
        if negative makes the increment button inactive and if not negative increments the label for the respective stat and
        subtracts from the available point total
        :param statPage:
        :param statCharacter:
        :param statIndex:
        :return:
        """
        #  True triggers addition
        if additionMode:
            self.character.Increment(statIndex)
            self.pointsTotalLabel.config(text=self.character.points)
            self.statLabelList[statIndex].config(text=self.character.stats[statIndex])
            self.statModList[statIndex].config(text=self.strFormat(self.character.modifiers[statIndex]))
            self.minusButtonList[statIndex].config(state='active')
            for i in range(len(self.tuples.STAT_TUPLE)):
                if self.character.canIncrement(i) == False:
                    self.plusButtonList[i].config(state='disabled')
            self.calculateResults()
        #  False triggers subtraction
        else:
            self.character.Decrement(statIndex)
            self.pointsTotalLabel.config(text=self.character.points)
            self.statLabelList[statIndex].config(text=self.character.stats[statIndex])
            self.statModList[statIndex].config(text=self.strFormat(self.character.modifiers[statIndex]))
            for i in range(len(self.character.tuples.STAT_TUPLE)):
                self.plusButtonList[i].config(state='active')
            if self.character.canDecrement(statIndex) == False:
                self.minusButtonList[statIndex].config(state='disabled')
            self.calculateResults()

    #def statsCallback(self):
    #    statsDict = self.character.assignRandomStats()

    def calculateResults(self):
        # Updates information when button Calculate Stats is pressed
        # Saving throw modifiers
        for i in range(len(self.tuples.STAT_TUPLE)):
            self.savingThrowValues[i].config(text=self.strFormat(self.character.modifiers[i]))
        self.character.assignAC()
        self.ACValue.config(text=(self.character.armorClass))
        self.initiativeValue.config(text=self.strFormat(self.character.modifiers[1]))

        # Skill checks refresh
        for i in range(len(self.tuples.SKILLS_TUPLE)):
            if self.tuples.SKILLS_MOD_TUPLE[i] == 'str':
                if self.skillVar[i].get() == 1:
                    self.skillsValue[i].config(text=self.strFormat(self.character.modifiers[0] +
                                                                   int(self.proficiencyValue.cget('text'))))
                else:
                    self.skillsValue[i].config(text=self.strFormat(self.character.modifiers[0]))
            elif self.tuples.SKILLS_MOD_TUPLE[i] == 'dex':
                if self.skillVar[i].get() == 1:
                    self.skillsValue[i].config(text=self.strFormat(self.character.modifiers[1] +
                                                                   int(self.proficiencyValue.cget('text'))))
                else:
                    self.skillsValue[i].config(text=self.strFormat(self.character.modifiers[1]))
            elif self.tuples.SKILLS_MOD_TUPLE[i] == 'int':
                if self.skillVar[i].get() == 1:
                    self.skillsValue[i].config(text=self.strFormat(self.character.modifiers[3] +
                                                                   int(self.proficiencyValue.cget('text'))))
                else:
                    self.skillsValue[i].config(text=self.strFormat(self.character.modifiers[3]))
            elif self.tuples.SKILLS_MOD_TUPLE[i] == 'wis':
                if self.skillVar[i].get() == 1:
                    self.skillsValue[i].config(text=self.strFormat(self.character.modifiers[4] +
                                                                   int(self.proficiencyValue.cget('text'))))
                else:
                    self.skillsValue[i].config(text=self.strFormat(self.character.modifiers[4]))
            elif self.tuples.SKILLS_MOD_TUPLE[i] == 'cha':
                if self.skillVar[i].get() == 1:
                    self.skillsValue[i].config(text=self.strFormat(self.character.modifiers[5] +
                                                                   int(self.proficiencyValue.cget('text'))))
                else:
                    self.skillsValue[i].config(text=self.strFormat(self.character.modifiers[5]))
        self.perceptionValue.config(text=self.strFormat(self.character.modifiers[4]))

    def calculateStatsLevel(self, selected):
        # Proficiency modifier changes
        self.proficiencyValue.config(text=self.strFormat(self.tuples.PROFICIENCY_TUPLE[selected-1]))
        self.calculateHP()

    def calculateStatsRace(self, selected):
        self.character.setRace(selected)
        for i in range(len(self.tuples.STAT_TUPLE)):
            self.character.adjustModifiers(i)
        self.calculateResults()
#.........这里部分代码省略.........
开发者ID:glennqhurd,项目名称:Character_Creator,代码行数:103,代码来源:Character_Creator.py


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