Пример #1
0
    def rollChance(self, player):
        """
        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.roll100()
        # 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.chp < player.hp:
                print "\nThis room has a small fountain containing clean water. You quickly drink it, restoring your health."
                if (player.chp + 50) <= player.hp:
                    player.chp += 50
                else:
                    player.chp = 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.chp -= 5
            print player.showHP()

        elif chance in range(36, 50):
            pass

        elif chance in (51, 52):
            print "\nYou find a piece of armor on the floor in this room. You strap it onto yourself as best you can. You feel more protected. (Armor increased to {}).".format(
                player.arm + 2)
            player.arm += 2

        elif chance in range(53, 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.chp + 30) <= player.hp:
                player.chp += 30
            else:
                player.chp = 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.agi + 1)
            player.agi += 1

        elif chance == 100:
            pass
Пример #2
0
    def rollChance(self, player):
        """
        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.roll100()
        # 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.chp < player.hp:
                print "\nThis room has a small fountain containing clean water. You quickly drink it, restoring your health."
                if (player.chp + 50) <= player.hp:
                    player.chp += 50
                else:
                    player.chp = 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.chp -= 5
            print player.showHP()

        elif chance in range(36, 50):
            pass

        elif chance in (51, 52):
            print "\nYou find a piece of armor on the floor in this room. You strap it onto yourself as best you can. You feel more protected. (Armor increased to {}).".format(
                player.arm + 2)
            player.arm += 2

        elif chance in range(53, 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.chp + 30) <= player.hp:
                player.chp += 30
            else:
                player.chp = 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.agi + 1)
            player.agi += 1

        elif chance == 100:
            pass
Пример #3
0
 def rollExits(self):
     """
     Desc: determines how many exits a given room has.
     Called by: room.maps.miscRoom.__init__()
     """
     exitsRoll = mechanics.roll100()
     # exits are bucketed similar to difficulty
     if exitsRoll in range(1, 5):
         return 1
     elif exitsRoll in range(6, 55):
         return 2
     elif exitsRoll in range(56, 90):
         return 3
     else:
         return 4
Пример #4
0
 def rollExits(self):
     """
     Desc: determines how many exits a given room has.
     Called by: room.maps.miscRoom.__init__()
     """
     exitsRoll = mechanics.roll100()
     # exits are bucketed similar to difficulty
     if exitsRoll in range(1, 5):
         return 1
     elif exitsRoll in range(6, 55):
         return 2
     elif exitsRoll in range(56, 90):
         return 3
     else:
         return 4
Пример #5
0
    def rollDiff(self):
        """
        Desc: determines the difficulty of a room.
        Called by: room.maps.rollNextRooms()

        Notes:
        the difficulty will be used to modify monster stats, and perhaps item drops.
        it uses ranges so that chances can be modified easily and is then bucketed for use.
        """
        diffRoll = mechanics.roll100()
        if diffRoll in range(1, 25):
            return 0
        elif diffRoll in range(26, 75):
            return 1
        elif diffRoll in range(76, 90):
            return 2
        else:
            return 3
Пример #6
0
    def rollDiff(self):
        """
        Desc: determines the difficulty of a room.
        Called by: room.maps.rollNextRooms()

        Notes:
        the difficulty will be used to modify monster stats, and perhaps item drops.
        it uses ranges so that chances can be modified easily and is then bucketed for use.
        """
        diffRoll = mechanics.roll100()
        if diffRoll in range(1, 25):
            return 0
        elif diffRoll in range(26, 75):
            return 1
        elif diffRoll in range(76, 90):
            return 2
        else:
            return 3
Пример #7
0
def pickMob(diff, debug=0):
    """
    Desc: handles rules for spawning monsters when entering a room. Logic is documented in readme.
    Called by: room.enter().

    Notes:
    spawnRoll will determine if a monster will spawn. mightRoll will determine the might of a monster if it does spawn.
    both spawnRoll and mightRoll are handled differently based on difficulty of room.
    if a monster is spawned, a mob of appropriate might will be chosen and returned. If a monster is not spawned, None will be returned.
    set debug = 1 for roll details
    diff -1 is for rooms that should never spawn a mob
    """
    spawnRoll = mechanics.roll100()
    mightRoll = mechanics.roll100()
    if diff == -1:
        return None
    elif diff == 0:
        if debug == 1:
            print "Diff: {} \nmightRoll: {} \nspawnRoll: {}".format(diff, mightRoll, spawnRoll)
        if spawnRoll > 50:
            if mightRoll in range(1, 67):
                return mobLoader(0)
            elif mightRoll in range(68, 99):
                return mobLoader(1)
            elif mightRoll == 100:
                return mobLoader(2)
        else:
            return None
    elif diff == 1:
        if debug == 1:
            print "Diff: {} \nmightRoll: {} \nspawnRoll: {}".format(diff, mightRoll, spawnRoll)
        if spawnRoll > 50:
            if mightRoll in range(1, 20):
                return mobLoader(0)
            elif mightRoll in range(21, 86):
                return mobLoader(1)
            elif mightRoll in range(87, 99):
                return mobLoader(2)
            elif mightRoll == 100:
                return mobLoader(3)
        else:
            return None
    elif diff == 2:
        if debug == 1:
            print "Diff: {} \nmightRoll: {} \nspawnRoll: {}".format(diff, mightRoll, spawnRoll)
        if spawnRoll > 20:
            if mightRoll in range(1, 20):
                return mobLoader(1)
            elif mightRoll in range(21, 86):
                return mobLoader(2)
            elif mightRoll in range(87, 100):
                return mobLoader(3)
        else:
            return None
    else:
        # Difficulty 4 rooms have 100% spawn rate, so spawnRoll is not considered
        if debug == 1:
            print "Diff: {} \nmightRoll: {} \nspawnRoll: {}".format(diff, mightRoll, spawnRoll)
        if mightRoll in range(1, 40):
            return mobLoader(2)
        elif mightRoll in range(41, 95):
            return mobLoader(3)
        elif mightRoll in range(96, 100):
            return mobLoader(4)