Advertisement
Kalidor_Vorlich

python txt 1

Apr 12th, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.54 KB | None | 0 0
  1. #HERO CLASSES
  2. #character = ''
  3. class warrior(object):
  4.     name = 'Warrior'
  5.     health = 150
  6.     attack = 50
  7.     defense = 100
  8.     ranged = 10
  9.     magic = 0
  10.     gold = 0
  11.  
  12. class archer(object):
  13.     name = 'Archer'
  14.     health = 125
  15.     attack = 40
  16.     defense = 80
  17.     ranged = 50
  18.     magic = 0
  19.     gold = 0
  20.  
  21. class wizard(object):
  22.     name = 'Wizard'
  23.     health = 100
  24.     attack = 30
  25.     defense = 70
  26.     ranged = 20
  27.     magic = 100
  28.     gold = 0
  29.  
  30.  
  31. #ENEMY CLASSES
  32. class golblin(object):
  33.     health = 50
  34.     attack = 5
  35.     defense = 5
  36.     rarity = 0
  37.  
  38. class ghost(object):
  39.     health = 60
  40.     attack = 12
  41.     defense = 6
  42.     rarity = 1
  43.  
  44. class dragon(object):
  45.     health = 70
  46.     attack = 10
  47.     defense = 15
  48.     rarity = 2
  49.  
  50. class demonDog(object):
  51.     health = 30
  52.     attack = 2
  53.     defense = 2
  54.     rarity = 0
  55.  
  56.  
  57. def inventoryWipe():
  58.     file = open("inventory.txt","w")
  59.     file.close()
  60.  
  61. def inventoryShow():
  62.     print("You have the following in your Inventory")
  63.     file = open("inventory.txt","r")
  64.     contents = file.read()
  65.     contents = contents.split(",")
  66.     print(contents)
  67.     #global contents
  68.     length = len(contents)-1
  69.     for i in range(length):
  70.         print(contents[i])
  71.  
  72.  
  73. def lootCheck(lootX):
  74.     file = open("inventory.txt","r")
  75.     contents = file.read()
  76.     contents = contents.split(",")
  77.     if lootX in contents:
  78.         print("You already have this item, so you leave it for another adventurer.")
  79.     else:
  80.         inventory(lootX)
  81.  
  82. def inventory(lootX):
  83.     file = open("inventory.txt","a")
  84.     file.write(str(lootX + ","))
  85.     file.close()
  86.  
  87. def inventoryDelete(decisionX):
  88.     file = open("inventory.txt","r")
  89.     contents = file.read()
  90.     contents = contents.split(",")
  91.     file.close()
  92.     print(contents)
  93.     if decisionX in contents:
  94.         i = contents.index(decisionX)
  95.         del contents[i]
  96.         print(contents)
  97.         print(decisionX)
  98.         contents = contents[:-1]
  99.         print(contents)
  100.  
  101.         file = open("inventory.txt","w")
  102.         for x in range (0, len(contents)):
  103.             print(contents[x])
  104.             file.write(contents[x]+",")
  105.         file.close()
  106.    
  107.    
  108. #def start():
  109. print("But first, who are you.....\n")
  110. choice = int(input("1. Warrior\n2. Archer\n3. Wizard\n"))
  111.  
  112. if choice == 1:
  113.     character = (warrior)
  114. elif choice == 2:
  115.     character = (archer)
  116. elif choice == 3:
  117.     character = (wizard)
  118.     #return character
  119. else:
  120.     print("INVALID CHOICE")
  121.         #start()
  122.  
  123. #start()
  124.  
  125.  
  126. print("You are a ", character.name)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement