# creating white magic actions cure = Spell("Cure", 12, 120, "White") cura = Spell("Cura", 18, 200, "White") player = Person(460, 65, 60, 34, [fire, thunder, blizzard, meteor, quake, cure, cura]) enemy = Person(1200, 65, 45, 25, [fire, thunder, blizzard, meteor, quake]) running = True i = 0 print(Bcolors.FAIL + Bcolors.BOLD + "AN ENEMY ATTACKS!" + Bcolors.ENDC) while running: print("===========================") player.choose_action() choice = input("Choose Actions: ") index = int(choice) - 1 if index == 0: dmg = player.generate_damage() enemy.take_damage(dmg) print("You attack for ", dmg) elif index == 1: player.choose_magic() magic_choice = int(input("Choose magic: ")) - 1 spell = player.magic[magic_choice] magic_dmg = spell.generate_damage() current_mp = player.get_mp()
i = 0 while running: for player in players: player.get_stats() print("\n") for enemy in enemies: enemy.get_enemy_stats() print("\n======================================") for player in players: choose_target = player.choose_enemy_target(enemies) player.choose_action() # select action whether attack or use magic choice = int(input("Enter your choice")) index = choice if index == 1: damage = player.generate_damage() enemies[choose_target].take_damage(damage) print(bcolors.OKBLUE + player.name + " attacked for " + str(damage) + "points of damage. " + enemies[choose_target].name + " hit points " + str(enemies[choose_target].get_hp()) + bcolors.END) if enemies[choose_target].get_hp() == 0: print(enemies[choose_target].name.replace(" ", "") + " has died.") del enemies[choose_target]
# 1. Welcome speech and print the current stats of player and enemy print("=======================================") print("\t Welcome to the game !") print("\t Let's kill the bad guys") main_player.get_stats() enemy.get_stats() print("=======================================") # 2. Start the loop running = True while running: # 2.a Main player starts first print("=======================================") print(f"\t {main_player.name.upper()}") main_player.choose_action() choice_input = input("\t\t\tChoose a number: ") index = int(choice_input) - 1 print(f"\t You chose {main_player.action[index]}") # 2.b Physical attack if index == 0: dmg = main_player.generate_atk_damage() enemy.take_damage(dmg) print("=======================================") print(f"\t You attacked and dealt to {enemy.name} {dmg} points of damage") elif index == 1: main_player.choose_magic() magic_choice = int(input("Choose your magic: ")) magic_index = magic_choice - 1
hielixer = Item("Mega-Elixir", "elixir", "Fully restores party's HP/MP", 9999) grenade = Item("Grenade", "attack", "Deals 500 damage", 500) #Instantiate People pla = Person(1200, 2300000, 123, 34, [fire, thunder, blizzard, meteor, cure, cura], [potion, hipotion, superpotion, elixer, hielixer, grenade]) enemy = Person(700, 9700000, 12, 23, [], []) running = True i=0 print(bcolors.FAIL + bcolors.BOLD + "An enemy attacks!" + bcolors.ENDC) while running: print("*********") pla.choose_action() choice = input("Choose action!") index = int(choice)-1 #print("You chose",pla.get_spell_name(int(index))) if index ==0: dmg=pla.generate_damage() enemy.take_damage(dmg) print("You attacked",dmg,"Points of damage",enemy.get_hp(),"is enemy's health") elif index ==1: pla.choose_magic() magic_choice=int(input("Choose magic"))-1 if magic_choice == -1: continue spell = pla.magic[magic_choice] dmg=spell.generate_damage()
# Instantiate people hero = Person("ARAMIS", 1500, 180, 80, 100, hero_magic, hero_items) enemy = Person("VALDOS", 1200, 120, 60, 50, [], []) print(bcolors.fail + bcolors.bold + "ENEMY ATTACS!" + bcolors.endc) while True: hero.get_stats() enemy.enemy_stats() print(" ") hero.choose_action() choose = input("choose action: ") os.system('clear') if int(choose) == 1: gen = hero.generate_dmg() enemy.get_dmg(gen) print("") print(bcolors.okblue + bcolors.bold + hero.name + ": attacked for " + str(gen) + " point of damage." + bcolors.endc) enm_dmg = enemy.generate_dmg() hero.get_dmg(enm_dmg) print(bcolors.fail + bcolors.bold + enemy.name + ": attacked for " + str(enm_dmg) + " point of damage." + bcolors.endc) print("")
"cost": 10, "dmg": 70 }] arr = {"name": "kartik", "age": 21} Player = Person(460, 65, 60, 34, magic) enemy = Person(1200, 65, 45, 25, magic) running = True print(bcolors.FAIL + bcolors.BOLD + "An Enemy Attacks!" + bcolors.ENDC) while running: print("===========================================") Player.choose_action() choice = input("Choose action: ") index = int(choice) - 1 if index == 0: dmg = Player.generate_damage() enemy.take_damage(dmg) print("You attacked for", dmg, "Points of damage. Enemy HP:", enemy.get_hp()) enemy_choice = 1 enemy_dmg = enemy.generate_damage() Player.take_damage(enemy_dmg) print("Enemy attacked for", enemy_dmg, "Player HP:", Player.get_hp())