0rx

Python3 RPG game

0rx
Apr 25th, 2014
572
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 7.18 KB | None | 0 0
  1. ##################################################
  2. ##################################################
  3. ###                                           ####  
  4. ###             Python3 RPG Hero              ####
  5. ### Version 1.4                               ####
  6. ### Codes By: 0rX                             ####
  7. ### Description:                              ####
  8. ###   This a simple RPG game for you.         ####
  9. ###   Coded in Python3 language.              ####
  10. ###   You need some help with this script ?   ####
  11. ###   Come ask me at:                         ####
  12. ###       http://0rx.chatango.com/            ####
  13. ###      or:                                  ####
  14. ###       http://monosekai.chatango.com/      ####
  15. ###                                           ####
  16. ###                                           ####
  17. ##################################################
  18. ##################################################
  19.  
  20.  
  21.  
  22. import random
  23. import re
  24.  
  25. def rpg():
  26.     class Hero:
  27.         def __init__(self, name):
  28.             self.name = name
  29.             self.level = 1
  30.             self.job = "Priest"
  31.             self.title = "Strider of the East"
  32.             if self.job == "Cleric":
  33.                 self.critical = 125
  34.                 self.str = 50
  35.                 self.exp = 254
  36.                 self.max1 = 3154
  37.                 max2 = self.level*self.max1*2/3
  38.                 self.maxHp = int(max2)
  39.             if self.job == "Priest":
  40.                 self.critical = 95
  41.                 self.str = 20
  42.                 self.exp = 254
  43.                 self.max1 = 4478
  44.                 max2 = self.level*self.max1*2/3
  45.                 self.maxHp = int(max2)
  46.             self.health = self.maxHp
  47.  
  48.         def expGauge(self):
  49.             rexp1 = 3500
  50.             rexp2 = self.level*rexp1*2/3
  51.             gauge1 = self.exp/rexp2
  52.             gauge2 = float(gauge1)*100.00
  53.             self.gauge = int(gauge2)
  54.  
  55.         def lvl(self):
  56.             rexp1 = 3500
  57.             rexp2 = self.level*rexp1*2/3
  58.             if self.exp >= rexp2:
  59.                 self.level = self.level+1
  60.                 self.exp = self.exp - rexp2
  61.                 max2 = self.level*self.max1*2/3
  62.                 self.maxHp = int(max2)
  63.                 print("You just leveled up !! Congratulations %s"% self.name)
  64.             else:
  65.                 pass
  66.  
  67.  
  68.         def heal(self):
  69.             if self.health < self.maxHp:
  70.                 if self.job == "Cleric":
  71.                     heal1 = 200
  72.                     heal2 = self.level*heal1*2
  73.                     hell = heal2/3
  74.                     heal3 = int(hell)
  75.                     heal4 = random.randint(heal3,heal2)
  76.                     self.health += heal4
  77.                 if self.job == "Priest":
  78.                     heal1 = 300
  79.                     heal2 = self.level*heal1*2
  80.                     hell = heal2/3
  81.                     heal3 = int(hell)
  82.                     heal4 = random.randint(heal3,heal2)
  83.                     self.health += heal4
  84.                 if self.health > self.maxHp:
  85.                     self.health = self.maxHp
  86.                     print ("hp full")
  87.             else:
  88.                 print ("hp full")
  89.  
  90.         def attack(self):
  91.             atta = player.level*player.str
  92.             atte = atta + (self.critical*self.level)
  93.             atti = atte + atta * 2 / 3
  94.             self.dmg = random.randint(atta,int(atti))
  95.             momon.health -= self.dmg
  96.  
  97.  
  98.  
  99.     class Enemy:
  100.    
  101.         def __init__(self, name):
  102.             self.name = "Zombie"
  103.             self.health = 5000
  104.             self.critical = 35
  105.             self._tasks = set()
  106.  
  107.         def attack(self):
  108.             self.dmg = random.randint(300,500)
  109.             dmg = self.dmg
  110.             miss = "Zombie attacks but misses"
  111.             atks = ("Zombie attacks and dealt %s damage !!"% dmg)
  112.             chose = random.choice([miss,miss,miss,atks,miss,atks,miss])
  113.             if chose == miss:
  114.                 pass
  115.             if chose == atks:
  116.                 print(atks)
  117.                 player.health -= dmg
  118.  
  119.     global war
  120.  
  121.     war = False
  122.  
  123.  
  124.     momon = Enemy("Zombie")
  125.  
  126.     heroname = str(input("Please enter your name: "))
  127.     player = heroname
  128.     if heroname == player:
  129.             player = Hero(heroname)
  130.             print ("Welcome to another world %s !!" %heroname)
  131.  
  132.     opt = ["help","rest","job 1","job 2","hunt","atk","heal","status"]
  133.  
  134.     while True:
  135.         choice = str(input("-->"))
  136.         if not choice in opt:
  137.             print("Fail command !")
  138.         player.expGauge()
  139.         if war == True:
  140.             momon.attack()
  141.             if choice == "atk":
  142.                 if player.health <= 0:
  143.                     player.health = 0
  144.                 if player.health and momon.health > 0:
  145.                     player.attack()
  146.                     if momon.health <= 0 and not player.health <= 0:
  147.                         momon.health = 0
  148.                         print("You won !!!")
  149.                         war = False
  150.                     if player.health <= 0:
  151.                         player.health = 0
  152.                         print("You are dead")
  153.                         war = False
  154.                     if war == True:
  155.                         randex1 = 50
  156.                         randex2 = 200
  157.                         randex = random.randint(randex1,randex2)
  158.                         player.lvl()
  159.                         player.exp = player.exp+randex
  160.                         php = str(player.health)
  161.                         mhp = str(momon.health)
  162.                         print("%s's ~Hp: %s  ~Damage: %s |  %s's ~Hp: %s"% (player.name,php,player.dmg,momon.name,mhp))
  163.             if choice == "heal":
  164.                 player.heal()
  165.                 php = str(player.health)
  166.                 mhp = str(momon.health)
  167.                 if player.health < player.maxHp:
  168.                     print("%s's HP: %s |  %s ~hp: %s"% (player.name,php,momon.name,mhp))
  169.                 else:
  170.                     pass
  171.         else:
  172.             momon.health = 5000
  173.             if choice == "status":
  174.                 apus = ("%s's status :\n~Hp       : %s\n~Level    : %s\n~Job      : %s\n~Title    : %s\n~Exp      : %i%s"% (player.name,player.health,player.level,player.job,player.title,player.gauge,str("%")))
  175.                 print (str(apus))
  176.    
  177.             if choice == "help":
  178.                 print("Here are available commands for you honey: help, rest, job 1, job 2, hunt, atk, heal")
  179.            
  180.             if choice == "rest":
  181.                 player.health = int(player.maxHp)
  182.                 print("%s rests under a big cherry tree and recovers from all his wounds"% player.name)
  183.  
  184.             if choice == "atk":
  185.                 print("%s started a fight with a thug and got trashed"% player.name)
  186.  
  187.             if choice == "job 1":
  188.                     player.job = "Priest"
  189.                     print("You switched your Job and becomes a holy Priest")
  190.             if choice == "job 2":
  191.                     player.job = "Cleric"
  192.                     print("You switched your Job and becomes a Mighty Cleric")
  193.  
  194.             if choice == "hunt":
  195.                 print("You approaches a Zombie and initiates a battle !!")
  196.                 war = True
  197.  
  198. rpg()
Advertisement
Add Comment
Please, Sign In to add comment