Example #1
0
def main():
    currentRoom = room.startRoom()

    print "Welcome to Pygame.\n"
    char = player.player()

    #while player is alive
    while char.chp > 0:
        #check to see if a monster is in the room, if so set it to monster
        monster = currentRoom.enter(char)
        #if there is a monster in the room, begin combat
        while currentRoom.monCount > 0 and monster != None:
            combat.combat(char, monster)
            currentRoom.monCount -= 1
            if char.chp < 1:
                char.death()
        #check for chance event
        currentRoom.rollChance(char)
        #display next room options
        currentRoom.nextRooms(currentRoom.exits)
        #(re)initialize results to None
        result = None
        #display game prompt. If the user selects a new room, restart the loop
        while not result:
            result = prompt(char, currentRoom)
            if isinstance(result, room.maps):
                currentRoom = result



    if char.chp < 1:
        char.death()
Example #2
0
def main():
    currentRoom = room.startRoom()

    print "Welcome to Pygame.\n"
    char = player.player()

    #while player is alive
    while char.chp > 0:
        #check to see if a monster is in the room, if so set it to monster
        monster = currentRoom.enter(char)
        #if there is a monster in the room, begin combat
        while currentRoom.monCount > 0 and monster != None:
            combat.combat(char, monster)
            currentRoom.monCount -= 1
            if char.chp < 1:
                char.death()
        #check for chance event
        currentRoom.rollChance(char)
        #display next room options
        currentRoom.nextRooms(currentRoom.exits)
        #(re)initialize results to None
        result = None
        #display game prompt. If the user selects a new room, restart the loop
        while not result:
            result = prompt(char, currentRoom)
            if isinstance(result, room.maps):
                currentRoom = result

    if char.chp < 1:
        char.death()
Example #3
0
def main():
    itemSource = items.itemLoader()
    mobSource = mobs.mobLoader()
    currentRoom = room.startRoom()
    print "\033[2J"
    print """           WELCOME
                            ,--.
                           {    }
                           K,   }
                          /  ~Y`
                     ,   /   /
                    {_'-K.__/
                      `/-.__L._
                      /  ' /`\_}
                     /  ' /
             ____   /  ' /
      ,-'~~~~    ~~/  ' /_
    ,'             ``~~~  ',
   (                        Y
  {                         I
 {      -                    `,
 |       ',                   )
 |        |   ,..__      __. Y
 |    .,_./  Y ' / ^Y   J   )|
 \           |' /   |   |   ||
  \          L_/    . _ (_,.'(
   \,   ,      ^^""' / |      )
     \_  \          /,L]     /
       '-_~-,       ` `   ./`
          `'{_            )
              ^^\..___,.--`
    """ #This is super cheesy, but it's a nod to old school MUDs, which inspired this game
    char = player.player()

    #debug
    if char.name == "AlexRocks":
        potion = itemSource.makeItem(0)
        char.inventory.append(potion)
        armor = itemSource.makeArmor(0, "head")
        char.inventory.append(armor)
        armor2 = itemSource.makeArmor(1, "head")
        char.inventory.append(armor2)
        weapon = itemSource.makeWeapon(0, "weapon")
        char.inventory.append(weapon)
        weapon2 = itemSource.makeWeapon(1, "weapon")
        char.inventory.append(weapon2)
        twohand = itemSource.makeWeapon(1, "twohanded")
        char.inventory.append(twohand)
        shield = itemSource.makeArmor(1, "shield")
        char.inventory.append(shield)

    while char.currentHP > 0:
        # check to see if a monster is in the room, if so set it to monster
        monster = currentRoom.enter(char, mobSource, itemSource)
        print "\n" + currentRoom.desc
        # if there is a monster in the room, begin combat
        if not monster:
            print "You appear to be alone here."
        if currentRoom.monCount > 0 and monster:
            print monster.desc + "\n"
            time.sleep(1.5)
            with combat.combat(char, monster, currentRoom) as battle:
                while battle.running is True:
                    battle.getInput(char)
            currentRoom.monCount -= 1
            if char.currentHP < 1:
                char.death()
            del battle
        # check for chance event
        currentRoom.rollChance(char, itemSource)
        # if any items in room, show them
        currentRoom.roomContents()
        # display next room options
        currentRoom.nextRooms(currentRoom.exits)
        # (re)initialize results to None
        result = None
        # display game prompt. If the user selects a new room, restart the loop
        while not result:
            result = prompt.basePrompt(char, currentRoom)
            if isinstance(result, room.maps):
                currentRoom = result



    if char.currentHP < 1:
        char.death()