Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- from classes.game import Person, bcolors
- from classes.magic import Spell
- # Another thing that came to my mind, as i am doing this, is that whatever you're doing here, is you creating your
- # own adversaries. The whole idea of "playing vs. the computer" is simply non-existent.
- # The computer doesn't "understand" the game. It doesn't know what "fire" or a "spell" is.
- # Those are just characters placed in memory blocks. The only one it has any meaning for, it's you.
- # You define the obstacles and their actions. It's a maze where you're doing whatever in order to get yourself lost.
- # Magic Spells
- # Damaging
- # def __init__(self, name, cost, dmg, type):
- fire = Spell("Fire", 10, 100, "damaging")
- thunder = Spell("Thunder", 12, 124, "damaging")
- lightning = Spell("Lightning", 12, 100, "damaging")
- meteor = Spell("Meteor", 20, 200, "damaging")
- quake = Spell("Quake", 14, 120, "damaging")
- # Healing
- cure = Spell("Cure", 12, 120, "healing")
- cura = Spell("Cura", 18, 200, "healing")
- # wanted to name defense as 'def' but apparently Python recognizes it as 'def' from define function even within the brackets and it messes things up.
- # so i had to use 'df' instead. stupid :))
- # def __init__(self, hp, mp, atk, df, magic):
- player = Person(460, 65, 60, 34, [fire, thunder, lightning, meteor, cure, cura])
- enemy = Person(1200, 65, 45, 25, [fire, thunder, lightning, meteor, cure, cura])
- running = True
- i = 0
- # No reason to label the beginning of the game with RED or FAIL. It's just the beginning.
- # It's neither good nor bad.
- # Also the beginning doesn't start with you being attacked, but with you choosing an action.
- # The response only happens afterwards.
- # As far as enemy goes, you don't have a real one. You're making one up, so you have someone to fight with.
- print(bcolors.GREEN + bcolors.BOLD + "Someone has started the game" + bcolors.ENDC)
- while running:
- print("==============================")
- player.choose_action()
- choice = input(bcolors.CYAN + bcolors.BOLD + "Choose your own action: " + bcolors.ENDC)
- index = int(choice)
- # i think it's important to always remember which action generated the result, to see "why" that is happening.
- print(bcolors.CYAN + bcolors.BOLD + "You chose to use: " + player.get_action_name(index) + bcolors.ENDC)
- if index == 0:
- dmg = player.generate_damage()
- enemy.take_damage(dmg)
- print("You attacked for", dmg, "Points of damage.")
- elif index == 1:
- print("==============================")
- player.choose_spell()
- choice = input(bcolors.CYAN + bcolors.BOLD + "Choose spell: " + bcolors.ENDC)
- index = int(choice)
- # i think it's important to always remember which action generated the result, to see "why" that is happening.
- print(bcolors.CYAN + bcolors.BOLD + "You chose to use a: " + player.spells[index].name + bcolors.ENDC)
- dmg = player.spells[index].generate_damage()
- spell = player.spells[index]
- current_mp = player.get_mp()
- if spell.cost > current_mp:
- print(bcolors.RED + "\nNot enough MP\n" + bcolors.ENDC)
- # continue forces to use the next iteration of the loop aka start over at 'if index == 0:...'
- # but i think the idea is that the code below doesn't run unless i've made a choice.
- # continue, as a word, means - moving on, going forward, not stopping. And yet, yere, in Python,
- # it carries a different meaning. It means "Stop the execution of the current loop, whatever instructions"
- # and go to the top of the loop and run the next iteration.
- # it just means a completely different thing.
- # does this mean that with enough iterations,
- # a word meaning would end up being derived from the surrounding context?
- # but then, how does each of the words have any meaning at all?
- continue
- player.reduce_mp(spell.cost)
- if spell.type == "healing":
- player.heal_damage(dmg)
- print(bcolors.BLUE + "\n" + spell.name + " heals for ", str(dmg), "HP." + bcolors.ENDC)
- elif spell.type == "damaging":
- enemy.take_damage(dmg)
- print(bcolors.CYAN + "\n" + spell.name + " deals ", str(dmg), "points of damage" + bcolors.ENDC)
- elif index == 7:
- exit()
- # enemy choice is set to always attack but what if we also gave a choice to the enemy,
- # just as we do have a choice as well ?
- # enemy_choice = random.randrange(0,6)
- # enemy.choose_action(enemy_choice)
- # print(enemy_choice)
- # this time we go with the flow. enemy always attacks regardless
- # but again, to be cheeky, if there's no enemy, there's no choice, because there's no understanding.
- # there is no enemy choice
- enemy_choice = 1
- dmg = enemy.generate_damage()
- player.take_damage(dmg)
- print("Enemy attacked for", dmg, "Points of damage.")
- print("-------------------------------------")
- print("Enemy HP:", bcolors.CYAN + str(enemy.get_hp()) + "/" + str(enemy.get_max_hp()) + bcolors.ENDC)
- print("Your HP:", bcolors.CYAN + str(player.get_hp()) + "/" + str(player.get_max_hp()) + bcolors.ENDC)
- print("Your MP:", bcolors.BLUE + str(player.get_mp()) + "/" + str(player.get_max_mp()) + bcolors.ENDC)
- # The game being over doesn't really mean anything bad or good, so as to color it with
- if enemy.get_hp() == 0:
- print(bcolors.RED + "The game is over" + bcolors.ENDC)
- running = False
- elif player.get_hp() == 0:
- print(bcolors.RED + "The game is over" + bcolors.ENDC)
- running = False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement