83 lines
2.9 KiB
Python
83 lines
2.9 KiB
Python
|
#! /usr/bin/python3
|
||
|
|
||
|
"""This is just a POC test of the spelling game.
|
||
|
Thus, the name is temporary.
|
||
|
v0.1:0067"""
|
||
|
|
||
|
import random
|
||
|
import spell
|
||
|
import status
|
||
|
|
||
|
class Player(spell.Spelling_Player):
|
||
|
"""A player."""
|
||
|
|
||
|
def cast_spell(self):
|
||
|
prompt = "Cast a spell! (up to " + str(self.max_letters) + " letters) "
|
||
|
casted_spell = str(input(prompt)).lower()
|
||
|
if(len(casted_spell) > self.max_letters):
|
||
|
casted_spell = casted_spell[:self.max_letters]
|
||
|
|
||
|
while(not self.is_valid(casted_spell)):
|
||
|
prompt = "Cast a different spell -\nYou can't cast that one more than " + str(max(16 / len(casted_spell), 1))
|
||
|
if(max(16 / len(casted_spell), 1) == 1): prompt += " time! "
|
||
|
else: prompt += " times! "
|
||
|
casted_spell = str(input(prompt)).lower()
|
||
|
if(len(casted_spell) > self.max_letters):
|
||
|
casted_spell = casted_spell[:self.max_letters]
|
||
|
|
||
|
return spell.Spell(casted_spell), casted_spell
|
||
|
|
||
|
def is_valid(self, spell):
|
||
|
if(spell in self.casted):
|
||
|
if(self.casted[spell] < max(16 / len(spell), 1)):
|
||
|
self.record(spell)
|
||
|
return True
|
||
|
else:
|
||
|
return False
|
||
|
else:
|
||
|
is_vowel = False
|
||
|
for i in "aeiouy":
|
||
|
if(i in spell):
|
||
|
is_vowel = True
|
||
|
break
|
||
|
if(not is_vowel): return False
|
||
|
else:
|
||
|
self.record(spell)
|
||
|
return True
|
||
|
|
||
|
def record(self, spell):
|
||
|
if(spell in self.casted):
|
||
|
self.casted[spell] += 1
|
||
|
else:
|
||
|
self.casted[spell] = 1
|
||
|
|
||
|
def main():
|
||
|
player1 = Player()
|
||
|
player2 = Player()
|
||
|
|
||
|
while(min(player1.hp, player2.hp) > 0):
|
||
|
print("Player 1: " + str(player1.hp) + " hp", end = " ")
|
||
|
if(player1.status): print("status " + str(player1.status))
|
||
|
else: print()
|
||
|
spell1, word1 = player1.cast_spell()
|
||
|
print("Player 2: " + str(player2.hp) + " hp", end = " ")
|
||
|
if(player2.status): print("status " + str(player2.status))
|
||
|
else: print()
|
||
|
spell2, word2 = player2.cast_spell()
|
||
|
spell.compare_spells(spell1, spell2)
|
||
|
spell1.affect(spell2, player1)
|
||
|
spell2.affect(spell1, player2)
|
||
|
status.apply(player1)
|
||
|
status.apply(player2)
|
||
|
print("\nPlayer 1 took " + str(spell2.total_damage) + " damage, and healed " + str(spell1.values["o"]) + " hp!")
|
||
|
print("Player 1 now has " + str(player1.hp) + " hp!\n")
|
||
|
print("Player 2 took " + str(spell1.total_damage) + " damage, and healed " + str(spell2.values["o"]) + " hp!")
|
||
|
print("Player 2 now has " + str(player2.hp) + " hp!\n")
|
||
|
|
||
|
if(player1.hp > 0): print("Player 1 wins!")
|
||
|
elif(player2.hp > 0): print("Player 2 wins!")
|
||
|
else: print("Draw!")
|
||
|
|
||
|
main()
|
||
|
input("Press any key to exit.")
|