Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from Classes.Game import Person, Bcolor
- from Classes.Magic import Spell
- from Classes.inventory import Item
- print("\n")
- print("NAME HP MP")
- # Black Magic
- Fire = Spell("Fire", 10, 50, "b")
- Thunder = Spell("Thunder", 20, 100, "b")
- Blizzard = Spell("Blizzard", 30, 150, "b")
- Earthquake = Spell("Earthquake", 40, 200, "b")
- Water = Spell("Water", 50, 250, "black")
- # White Magic
- Cure = Spell("Cure", 40, 90, "w")
- MAXcure = Spell("MAXcure", 80, 120, "w")
- # Create some items
- potion = Item("Potion", "potion", "Heals 50 HP", 50)
- hipotion = Item("HI-Potion", "potion", "Heals 100 HP", 100)
- superpotion = Item("SUPER-Potion", "potion", "Heals 200 HP", 200)
- elixr = Item("Elixr", "elixr", "Complete restoration of HP/MP for 1 player member", 9999)
- megaelixr = Item("MEGA-Elixr", "elixr", "Complete restoration of HP/MP", 9999)
- grenade = Item("Grenade", "attack", " Deals 500 damage", 500)
- p_s = [Fire, Blizzard, Thunder, Cure, MAXcure]
- p_i = [{"item":potion, "quantity":15},
- {"item":hipotion, "quantity":5},
- {"item":superpotion, "quantity":5},
- {"item":elixr, "quantity":2},
- {"item":megaelixr, "quantity":1},
- {"item":grenade, "quantity":3}]
- # Instantiate People
- Player1 = Person("Nitin", 860, 180, 60 , 34, p_s, p_i)
- Player2 = Person("Putti", 1060, 380, 80 , 44, p_s, p_i)
- Player3 = Person("Budda", 560, 280, 130 , 94, p_s, p_i)
- Player = [Player1, Player2, Player3]
- Enemy = Person("Thima", 1200, 65, 45, 25, [], [])
- run = True
- i = 0
- print(Bcolor.FAIL + Bcolor.BOLD + "An Enemy attacks!" + Bcolor.ENDC)
- while run:
- print("-------")
- for player in Player:
- Player.g_s()
- for player in Player:
- Player.choose_actions()
- choice = input("Choose action : ")
- index = int(choice) - 1
- if index ==0:
- dm = Player.gen_dm()
- Enemy.take_dm(dm)
- print("You attacked for ", dm, "points of damage.")
- elif index == 1:
- print(Bcolor.OKBLUE + "Magic" + Bcolor.ENDC)
- i = 1
- for Spell in Player.magic:
- print(" ", str(i) + ":", Spell.name, " cost : ", Spell.cost)
- i += 1
- magic_choice = int(input("Choose magic: ")) - 1 # Line 18 and 19 code style merged in a single line
- if magic_choice == -1: # To switch back to the previous menu page
- continue
- Spell = Player.magic[magic_choice]
- magic_dm = Spell.gen_dm()
- current_mp = Player.get_mp()
- if Spell.cost > current_mp:
- print(Bcolor.FAIL + "\nNot enough MP\n" + Bcolor.ENDC)
- continue
- Player.reduce_mp(Spell.cost)
- if Spell.type == "w":
- Player.heal(magic_dm)
- print(Bcolor.OKBLUE + Spell.name + " heals for", str(magic_dm), " HP" + Bcolor.ENDC)
- elif Spell.type == "b":
- Enemy.take_dm(magic_dm)
- print(Bcolor.OKBLUE + Spell.name + " deals", str(magic_dm), " points of damage" + Bcolor.ENDC)
- elif index == 2:
- Player.item_choice()
- i_c = int(input("Choose item: ")) - 1
- if i_c == -1:
- continue # To switch back to the previous menu page
- item = Player.items[i_c]["item"]
- if Player.items[i_c]["quantity"] == 0:
- print(Bcolor.FAIL + "Not enough items" + Bcolor.ENDC)
- continue
- Player.items[i_c]["quantity"] -= 1
- if item.type == "potion":
- Player.heal(item.prop)
- print(Bcolor.OKBLUE + item.name + " heals for", str(item.prop), " HP" + Bcolor.ENDC)
- elif item.type == "elixr":
- Player.hp = Player.maxhp
- Player.mp = Player.maxmp
- print(Bcolor.OKGREEN + item.name + " restores full HP/MP" + Bcolor.ENDC)
- elif item.type == "attack":
- Enemy.take_dm(item.prop)
- print(Bcolor.FAIL + item.name + " deals", str(item.prop), "points of damage" + Bcolor.ENDC)
- Enemy_choice = 1
- Enemy_dm = Enemy.gen_dm()
- Player.take_dm(Enemy_dm)
- print("Enemy attacks for ", Enemy_dm)
- print("------")
- print("Enemy HP: ", Bcolor.FAIL + str(Enemy.get_hp()) + Bcolor.ENDC)
- if Enemy.get_hp() == 0:
- print(Bcolor.OKGREEN + "You win!!" + Bcolor.ENDC)
- run = False
- elif Player.get_hp() == 0:
- print(Bcolor.FAIL + "You are defeated!!" + Bcolor.ENDC)
- run = False
Add Comment
Please, Sign In to add comment