示例#1
0
文件: player.py 项目: AlexB138/game
    def rollStats(self):
        """
        generates player stats

        """
        roll = {'strg': 0, 'agi': 0, 'end': 0}
        roll['strg'] = mechanics.roll(18)
        roll['agi'] = mechanics.roll(18)
        roll['end'] = mechanics.roll(18)
        # make sure total stars are between 15 and 45, if not reroll
        while (roll['strg'] + roll['agi'] + roll['end']) > 45 or (roll['strg'] + roll['agi'] + roll['end']) <= 25 or \
                        roll['strg'] < 5 or roll['agi'] < 8 or roll['end'] < 5:
            roll = self.rollStats()
        return roll
示例#2
0
文件: room.py 项目: AlexB138/game
    def rollChance(self, player, itemSource):
        """
        Desc: rolls and enacts chance events.
        Called by: Main game loop in game.

        Notes:
        chance events have a chance of occurring once per room.
        chance events occur after a battle and before the next door is chosen.
        """
        chance = mechanics.roll(100)
        # scaffold for chance events
        if chance in range(1, 25):
            # nothing. 25% chance of no event.
            pass
        elif chance in range(26, 30):
            if player.currentHP < player.hp:
                print "\nThis room has a small fountain containing clean water. You quickly drink it, restoring your health."
                if (player.currentHP + 50) <= player.hp:
                    player.currentHP += 50
                else:
                    player.currentHP = player.hp
            else:
                print "\nThis room has a small fountain containing clean water. You quickly drink it, but your health is already full."
            print player.showHP()

        elif chance in range(31, 35):
            print "\nAn imp throws a rock at you before disappearing in a puff of smoke."
            player.currentHP -= 5
            print player.showHP()

        elif chance in range(36, 38):
            #add a minor healing potion to the room
            self.content.append(itemSource.makeItem(0))

        elif chance in range(39, 40):
            #add a random piece of rarity 2 armor to the room
            armor = itemSource.makeArmor(2,random.choice(["body","head","hands","legs","feet"]))
            self.content.append(armor)

        elif chance in range(41, 96):
            pass

        elif chance in (97, 98):
            # Keep this in mind once levels are implemented
            print '\nA lost spirit appears to you. "Hail, {}. I perished here, like many before me. I give you my blessing, that you may find freedom again". As the spirit disappears, you feel slightly more healthy. (Health permanently increased to {}).'.format(player.name, player.hp + 30)
            player.hp += 30
            if (player.currentHP + 30) <= player.hp:
                player.currentHP += 30
            else:
                player.currentHP = player.hp
            print player.showHP()

        elif chance == 99:
            print "\nYou find a pair of leather shoes to protect your bare feet, allowing you to move slightly more quickly. (Agility increased to {}.)".format(
                player.baseAgi + 1)
            player.baseAgi += 1

        elif chance == 100:
            pass
示例#3
0
文件: mobs.py 项目: AlexB138/game
    def rollLoot(self, itemSource):
        lootRoll = mechanics.roll(100, (self.bdiff * 100))
        lootTable = {1: -1, 71: 0, 101: -1, 146: 0, 176: 1, 201: -1, 226: 0, 256: 1, 281: 2, 301: -1, 311: 0, 341: 1, 366: 2, 386: 3, 401: 0, 431: 1, 456: 2, 476: 3, 491: 4}
        tableKeys = lootTable.keys()
        tableKeys.sort()
        tableKeys.reverse()
        itemRarity = None

        for n in tableKeys:
            if lootRoll >= n and itemRarity is None:
                itemRarity = lootTable[n]

        if itemRarity == -1:
            return
        else:
            if mechanics.roll(2) % 2 == 0:
                newItem = itemSource.makeArmor(itemRarity)
            else:
                newItem = itemSource.makeWeapon(itemRarity)

        return newItem
示例#4
0
文件: combat.py 项目: AlexB138/game
    def combat(self):
        """
        The main loop for combat. Handles updating HP/AP bars, updating the actual AP stats,
        checking for buffered player input and checking for death. Terminates combat upon death.
        :return: None
        """
        self.win.addstr((self.screenY - 13), 1, "Prepare to face the {}!".format(self.mob.name).ljust(self.screenX - 2))
        self.printAllBars()
        self.win.refresh()
        while self.player.currentHP > 0 and self.mob.currentHP > 0:
            while self.player.ap < 100 and self.mob.ap < 100:
                self.player.ap += self.player.agi
                self.mob.ap += self.mob.agi
                self.barPrint(self.player, self.APbar)
                self.barPrint(self.mob, self.mobAPbar)
                sleep(.5)

            if self.player.ap >= 100 and self.mob.ap < 100:
                text = self.actionCheck()
            elif self.mob.ap >= 100 and self.player.ap < 100:
                text = skills.attack(self.mob, self.player)
            elif self.player.ap >= 100 and self.mob.ap >= 100:
                if self.player.agi > self.mob.agi:
                    text = self.actionCheck()
                elif self.player.agi < self.mob.agi:
                    text = skills.attack(self.mob, self.player)
                else:
                    if mechanics.roll(2) == 1:
                        text = self.actionCheck()
                    else:
                        text = skills.attack(self.mob, self.player)
            self.printAllBars()
            self.printWin(text)

        if self.mob.currentHP <= 0:
            text = self.mob.defeat(self.room)
            for t in text:
                self.printWin(t)
            self.player.ap = 0
            self.running = False
            sleep(2)
            self.cleanUp()
        elif self.player.currentHP <= 0:
            self.printWin("You have been defeated by the {}!".format(self.mob.name))
            self.running = False
            sleep(2)
            self.cleanUp()
示例#5
0
文件: mobs.py 项目: AlexB138/game
    def rollPotion(self, itemSource):
        lootRoll = mechanics.roll(100)
        lootTable = {1: -5, 46: -4, 51: -3, 56: -2, 66: -1, 81: 0}
        tableKeys = lootTable.keys()
        tableKeys.sort()
        tableKeys.reverse()
        itemRarity = None

        while itemRarity is None:
            for n in tableKeys:
                if lootRoll >= n:
                    itemRarity = self.bdiff - n

        if itemRarity >= 0:
            return itemSource.makePotion(itemRarity)
        else:
            return