Ejemplo n.º 1
0
    def heightSelection(self, character):
        # Get height values, differed by sex
        if (character.sex == "Male"):
            heightBase = character.charRace.mHeight[0]
            heightMinus = character.charRace.mHeight[1]
            heightPlus = character.charRace.mHeight[2]
            heightOWeight = character.charRace.mHeight[3]
            heightUWeight = character.charRace.mHeight[4]

        elif (character.sex == "Female"):
            heightBase = character.charRace.fHeight[0]
            heightMinus = character.charRace.fHeight[1]
            heightPlus = character.charRace.fHeight[2]
            heightOWeight = character.charRace.fHeight[3]
            heightUWeight = character.charRace.fHeight[4]

        # Here we roll a d100, if the number is greater than or equal to the OWeight, we add a heightPlus dice.
        #                      if the number is less than or equal to the    UWeight, we subtract a heightMinus dice.
        heightRoll = DiceRoller.rollDice("1d100")

        if (heightRoll >= int(heightOWeight)):
            heightAdd = DiceRoller.rollDice(heightPlus)
            height = int(heightBase) + heightAdd

        elif (heightRoll <= int(heightUWeight)):
            heightSub = DiceRoller.rollDice(heightMinus)
            height = int(heightBase) - heightSub

        else:
            height = int(heightBase)
        # Convert the heightBase into feet
        heightInches = height % 12
        heightFeet = height // 12

        return (str(heightFeet) + "'" + str(heightInches) + "\"")
Ejemplo n.º 2
0
    def weightSelection(self, character):
        # Get height values, differed by sex
        if (character.sex == "Male"):
            weightBase = character.charRace.mWeight[0]
            weightMinus = character.charRace.mWeight[1]
            weightPlus = character.charRace.mWeight[2]
            weightOWeight = character.charRace.mWeight[3]
            weightUWeight = character.charRace.mWeight[4]

        elif (character.sex == "Female"):
            weightBase = character.charRace.fWeight[0]
            weightMinus = character.charRace.fWeight[1]
            weightPlus = character.charRace.fWeight[2]
            weightOWeight = character.charRace.fWeight[3]
            weightUWeight = character.charRace.fWeight[4]

        # Here we roll a d100, if the number is greater than or equal to the OWeight, we add a heightPlus dice.
        #                      if the number is less than or equal to the    UWeight, we subtract a heightMinus dice.
        weightRoll = DiceRoller.rollDice("1d100")

        if (weightRoll >= int(weightOWeight)):
            weightAdd = DiceRoller.rollDice(weightPlus)
            weight = int(weightBase) + weightAdd

        elif (weightRoll <= int(weightUWeight)):
            weightSub = DiceRoller.rollDice(weightMinus)
            weight = int(weightBase) - weightSub

        else:
            weight = int(weightBase)\

        return (str(weight))
Ejemplo n.º 3
0
    def itemSelection(self, character):
        # Declarations
        itemData = self.gameData.items
        eligibleItemsCategories = []
        eligibleItemsList = []
        itemsList = []

        # We want a reference list for item categories
        for item in itemData:
            if item.itemCategory not in eligibleItemsCategories:
                eligibleItemsCategories.append(item.itemCategory)
                eligibleItemsList.append([])

        # We want to append items of that category into a matching slot of the list
        for item in itemData:
            eligibleItemsList[eligibleItemsCategories.index(
                item.itemCategory)].append(item)

        # This gives us a list of items broken down by item category.
        # for now we are just going to roll 1-3 miscellaneous
        amountOfItems = DiceRoller.rollDice("1d3")

        for i in range(0, amountOfItems):
            itemsList.append(
                random.choice(eligibleItemsList[eligibleItemsCategories.index(
                    "Miscellaneous")]))

        return itemsList
Ejemplo n.º 4
0
    def hpSelection(self, character):
        # Used to determine starting HP for the character
        hpDice = character.charClass.initialHitDice
        hpBonus = character.hpBonus

        hp = DiceRoller.rollDice(hpDice) + int(hpBonus)
        return hp
Ejemplo n.º 5
0
    def exceptionalStrength(self, character):
        # Here we determine if the character has exceptional strength
        # Return if we have exceptional strength as a boolean, and the value of it (1d100)

        # Declarations
        exceptionalStrengthRoll = 0
        exceptionalStrengthFlag = False

        # For exceptional strength, character must be a fighter with 18 strength
        if character.charClass.className == "Fighter":
            if character.abilityArray[0] >= 18:
                exceptionalStrengthFlag = True
                exceptionalStrengthRoll = DiceRoller.rollDice("1d100")

        if exceptionalStrengthRoll == 0:
            return exceptionalStrengthFlag, 0

        if (exceptionalStrengthRoll < 51):
            return exceptionalStrengthFlag, 1

        if (exceptionalStrengthRoll >= 51) and (exceptionalStrengthRoll < 76):
            return exceptionalStrengthFlag, 2

        if (exceptionalStrengthRoll >= 76) and (exceptionalStrengthRoll < 91):
            return exceptionalStrengthFlag, 3

        if (exceptionalStrengthRoll >= 91) and (exceptionalStrengthRoll < 100):
            return exceptionalStrengthFlag, 4

        if (exceptionalStrengthRoll == 100):
            return exceptionalStrengthFlag, 5
        print("never get here")
Ejemplo n.º 6
0
    def weightedClassSelection(self):
        # Declarations
        basicClassWeight = self.gameData.gameOptions['basicClassWeight']
        prestigeClassWeight = self.gameData.gameOptions['prestigeClassWeight']
        basicClassMin = self.gameData.gameOptions['basicClassMin']
        prestigeClassMin = self.gameData.gameOptions['prestigeClassMin']
        character = None

        # Get all the classes, their type, and link with the class weight
        classWeights = []
        sum = 0

        for charClass in self.gameData.classes:
            if (charClass.classType == "Basic"):
                sum = sum + int(basicClassWeight)
                classWeights.append([charClass.className, sum])
            elif (charClass.classType == "Prestige"):
                sum = sum + int(prestigeClassWeight)
                classWeights.append([charClass.className, sum])

        # We roll a dice from 1 to the maximum value of sum
        classRoll = DiceRoller.rollDice("1d" + str(sum))
        for i in classWeights:
            if (classRoll <= i[1]):
                charClass = i[0]

        chararacter = self.rollSelection(charClass)
        return character
Ejemplo n.º 7
0
 def goldSelection(self, character):
     goldDice = character.charClass.startingGold
     gold = DiceRoller.rollDice(goldDice) * 10
     return gold
Ejemplo n.º 8
0
    def weaponSelection(self, character):
        # Declarations
        eligibleWeaponsList = []
        charRequiredWeaponsList = []
        weaponsList = []
        rollFlag = False

        # Create a list of weapons that match the specific considerations of the character's class definition
        for weapon in character.charClass.weaponsList:
            # Get the weapon definition
            weaponType = weapon[0]
            weaponWeight = weapon[1]
            weaponTag = weapon[2]
            weaponOrTag = weapon[3].split(" ")
            weaponAndTag = weapon[4].split(" ")
            weaponNotTag = weapon[5].split(" ")

            # If the weapon is required, we roll it definitely.  If the weapon is optional, we roll 1d100 depending on weight
            if (weaponType == "required"):
                rollFlag = True

            if (weaponType == "optional"):
                weaponRoll = DiceRoller.rollDice("1d100")
                if (int(weaponRoll) > int(weaponWeight)):
                    rollFlag = True

            # If we are rolling the weapon...
            if (rollFlag == True):
                # Loop over each weapon loaded into the game during weaponsImporter
                for weaponData in self.gameData.weapons:
                    # If the tag in class definition matches any tag on the weapon...
                    if (weaponTag in weaponData.weaponTags or weaponTag == ""):
                        # If any of the ORTAG in class definition matches any tag on the weapon...
                        if (set(weaponOrTag).intersection(
                                set(weaponData.weaponTags))
                                or weaponOrTag == ['']):
                            # If ALL of the ANDTAG in the class definition matches tags on the weapon...
                            if (set(weaponAndTag).issubset(
                                    set(weaponData.weaponTags))
                                    or weaponAndTag == ['']):
                                # If NONE of the NOTTAG in the class definition matches tags on the weapon...
                                if (not set(weaponNotTag).intersection(
                                        set(weaponData.weaponTags))
                                        or weaponNotTag == ['']):
                                    # Append the weapon to the eligible weapons list
                                    eligibleWeaponsList.append(weaponData)
                # Append a random weapon from the eligible weapons into the character's weapon list
                weaponsList.append(random.choice(eligibleWeaponsList))
                # Reset eligible weapons list
                eligibleWeaponsList = []
            # Reset roll flag
            rollFlag = False

        # Return list of weapons
        return weaponsList

        #def ammoSelection(self, character):
        # If we have a ranged weapon, we need to get the ammo for it.
        # Declarations
        #    weaponsList = character.weaponsList
        #    ammoList = []

        return ammoList
Ejemplo n.º 9
0
    def rollAbilities(self):
        # Game option declarations
        rollMethod = self.gameData.gameOptions['rollMethod']
        minimumReroll = int(self.gameData.gameOptions['minimumReroll'])
        minimumRerollFlag = True

        # Roll until we hit the minimum reroll value
        while (minimumRerollFlag):
            # Declarations
            sum = 0
            abilitySum = 0
            diceArray = []
            abilityArray = []
            # If no method found, default to roll4drop1
            if rollMethod == None:
                rollMethod = "roll4drop1"

            # Roll 4 Drop 1 Method
            if rollMethod == "roll4drop1":
                # Roll for each ability (6 abilities, STR, DEX, CON, WIS, INT, CHA)
                for ability in range(0, 6):
                    for i in range(0, 4):
                        diceArray.append(DiceRoller.rollDice("1d6"))

                    # Drop the lowest value
                    diceArray.remove(min(diceArray))

                    # Sum the remainders
                    for i in diceArray:
                        sum = sum + i

                    # Append the sum to the abilityArray
                    abilityArray.append(sum)

                    # Reset the diceArray and sum
                    sum = 0
                    diceArray = []

            # Roll 3 method
            elif rollMethod == "roll3":
                # Roll for each ability (6 abilities, STR, DEX, CON, WIS, INT, CHA)
                for ability in range(0, 6):
                    for i in range(0, 3):
                        diceArray.append(DiceRoller.rollDice("1d6"))

                    # Sum the stats
                    for i in diceArray:
                        sum = sum + i

                    # Append the sum to the abilityArray
                    abilityArray.append(sum)

                    # Reset the diceArray and sum
                    sum = 0
                    diceArray = []

            # Sum the ability array to compare min reroll
            for i in abilityArray:
                abilitySum = abilitySum + i

            # Compare ability sum to minimum reroll value, end while loop if met
            if (abilitySum >= minimumReroll):
                minimumRerollFlag = False

        return abilityArray
Ejemplo n.º 10
0
    def rollSelection(self, classString):
        # Create a new character
        print("Generating a character...")
        character = Character()

        # Determine sex
        charSexRoll = DiceRoller.rollDice("1d100")
        if charSexRoll >= 51:
            character.sex = "Male"
        else:
            character.sex = "Female"
        print("Sex: " + character.sex)

        # Get name
        character.charName = "Testie McTestFace"

        # Determine class
        character.charClass = self.gameData.getClassByString(classString)
        print("Class: " + character.charClass.className)

        # Determine race
        character.charRace = self.raceSelection(character)
        print("Race: " + character.charRace.raceName)

        # Determine the abilitary array
        character.abilityArray = self.rollAbilities()
        character = self.verifyAbilities(character)

        print("Strength: " + str(character.abilityArray[0]))
        print("Wisdom: " + str(character.abilityArray[1]))
        print("Intelligence: " + str(character.abilityArray[2]))
        print("Dexterity: " + str(character.abilityArray[3]))
        print("Constitution: " + str(character.abilityArray[4]))
        print("Charisma: " + str(character.abilityArray[5]))

        # Determine height
        character.height = self.heightSelection(character)
        print("Height: " + character.height)

        # Determine weight
        character.weight = self.weightSelection(character)
        print("Weight: " + character.weight + " pounds")

        # Determine if we have exceptional strength
        character.exceptionalStrengthFlag, character.exceptionalStrengthVal = self.exceptionalStrength(
            character)
        print("Exceptional Strength: " +
              str(character.exceptionalStrengthFlag))
        print("Exceptional Strength Val: " +
              str(character.exceptionalStrengthVal))

        # Determine skills
        skillsArray = []
        skillsArray = self.skillSelection(character)

        if character.charClass.thiefFlag == True:
            character.thiefFlag = True

        character.toHitBonus = skillsArray[0]
        character.damageBonus = skillsArray[1]
        character.openDoors = skillsArray[2]
        character.bblg = skillsArray[3]
        character.acBonus = skillsArray[4]
        character.stealBonus = skillsArray[5]
        character.locksBonus = skillsArray[6]
        character.trapsBonus = skillsArray[7]
        character.sneakBonus = skillsArray[8]
        character.hideBonus = skillsArray[9]
        character.spellSaveBonus = skillsArray[10]
        character.hpBonus = skillsArray[11]
        print("To Hit Bonus " + str(character.toHitBonus))
        print("Damage Bonus " + str(character.damageBonus))
        print("Open Doors " + str(character.openDoors))
        print("BB/LG " + str(character.bblg))
        print("AC Bonus " + str(character.acBonus))
        print("Spell Save Bonus " + str(character.spellSaveBonus))
        print("HP Bonus " + str(character.hpBonus))
        if character.thiefFlag == True:
            print("Steal Bonus " + str(character.stealBonus))
            print("Locks Bonus " + str(character.locksBonus))
            print("Traps Bonus " + str(character.trapsBonus))
            print("Sneak Bonus " + str(character.sneakBonus))
            print("Hide Bonus " + str(character.hideBonus))

        # Determine saving throw adjustments
        character.saveArray = self.saveSelection(character)
        print("Saves:")
        print("\tPoison Save: " + str(character.saveArray[0]))
        print("\tPetrification Save: " + str(character.saveArray[1]))
        print("\tWand Save: " + str(character.saveArray[2]))
        print("\tBreath Save: " + str(character.saveArray[3]))
        print("\tSpell Save: " + str(character.saveArray[4]))

        # Determine thief skills if applicable
        if character.thiefFlag == True:
            thiefArray = []
            thiefArray = self.thiefSelection(character)
            character.steal = thiefArray[0]
            character.locks = thiefArray[1]
            character.traps = thiefArray[2]
            character.sneak = thiefArray[3]
            character.hide = thiefArray[4]
            character.listen = thiefArray[5]
            character.climb = thiefArray[6]
            character.read = thiefArray[7]
            print("Thief skills: ")
            print("\tSteal: " + str(character.steal))
            print("\tLocks: " + str(character.locks))
            print("\tTraps: " + str(character.traps))
            print("\tSneak: " + str(character.sneak))
            print("\tHide: " + str(character.hide))
            print("\tListen: " + str(character.listen))
            print("\tClimb: " + str(character.climb))
            print("\tRead: " + str(character.read))

        # Determine starting HP
        character.hp = self.hpSelection(character)
        print("Hp: " + str(character.hp))

        # Determine starting gold
        character.gold = self.goldSelection(character)
        print("Gold: " + str(character.gold))

        # Determine alignment
        character.alignment = self.alignmentSelection(character)
        print("Alignment: " + character.alignment)

        # Determine spells
        character.spells = self.spellSelection(character)
        print("Spells: ")
        for spell in character.spells:
            print("\t" + spell.spellName)

        # Determine weapons
        character.weapons = self.weaponSelection(character)
        print("Weapons:")
        for i in character.weapons:
            print("\t" + i.weaponName)
        #character.ammo = self.ammoSelection(character)
        #for i in characters.ammo:
        #    print("\t" + str(i[0]) + "( " + str(i[1]) + " )")

        # Determine armor
        character.armor = self.armorSelection(character)
        character.shield = self.shieldSelection(character)
        character.ac = int(character.armor.ac) + int(character.acBonus)
        print("Armor:")
        print("\t" + character.armor.armorName)
        if (character.shield is not None):
            print("\t" + character.shield.armorName)
            character.ac = int(character.ac) + int(character.shield.ac)
        print("Ac: " + str(character.ac))

        # Determine items
        character.items = self.itemSelection(character)
        print("Items:")
        for item in character.items:
            print("\t" + item.itemName)
        print("\n\n\n")

        return character