From b20532ae4abbf519a5dc0ec8b61b039cdd8aab9f Mon Sep 17 00:00:00 2001 From: Kwarde Date: Mon, 15 Jan 2024 14:11:24 +0100 Subject: [PATCH] Add methods and variables for running game --- game.py | 31 +++++++++++++++++++++++++++++++ player.py | 15 +++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 game.py diff --git a/game.py b/game.py new file mode 100644 index 0000000..23b51b4 --- /dev/null +++ b/game.py @@ -0,0 +1,31 @@ +from player import * +from spells import * +from wands import * + +## +## Definitions +## +input_messages = ( + "{name}, what's your spell? ", + "{name}, how will you obliviate your opponent? ", + "{name}, go for it! Enter a spell! ", + "{name}, hit me with your best spell: ", + "{name}, go time! ", + "{name}, it's your turn to enter a spell: " +) +def print_turn_message(player: Player): + return random.choice(input_messages).format(name=player.name) + +current_round = 1 +def round_end(player1: Player, player2: Player): + if (player1.stunned_rounds > 0): player1.stunned_rounds -= 1 + if (player2.stunned_rounds > 0): player2.stunned_rounds -= 1 + + print(" Round {round} ended! Current stats:\n\ + - {p1_name}: Health: {p1_hp} | Queued effects: {p1_effects} | Round being stunned: {p1_stunned}\n\ + - {p2_name}: Health: {p2_hp} | Queued effects: {p2_effects} | Rounds being stunned: {p2_stunned}".format( + round=current_round, + p1_name=player1.name, p1_hp=player1.health, p1_effects=player1.get_queued_effects(), p1_stunned=player1.stunned_rounds, + p2_name=player2.name, p2_hp=player2.health, p2_effects=player2.get_queued_effects(), p2_stunned=player2.stunned_rounds + ) + ) \ No newline at end of file diff --git a/player.py b/player.py index a9edb55..e4f4c1b 100644 --- a/player.py +++ b/player.py @@ -30,6 +30,21 @@ class Player: def get_spell_succes_rate(self, spell: Spell): return 1 * self.wand.succes_rate * spell.succes_rate + def get_queued_effects(self): + output = "" + effect_slowed = "Slowed" + effect_blinded = "Blinded" + + if (self.decreased_spell_speed): + output = effect_slowed + if (self.decreased_spell_damage): + if not output: + output = effect_blinded + else: output += ", " + effect_blinded + + if not output: output = "None" + return output + def cast_spell_result(self, spell: Spell, succes: bool): if (succes): message = "{name} casted '{spell}' with succes"