I am making a text game, and I have made up a basic framework.
I have 2 questions
1) Sometimes, the python interpreter bugs out, like saying that I misspelt a variable 'Item' as 'item' even though I can see the correct spelling infront of me, and the only way to fix it is to restart IDLE, but then it does it again for some other bit of innocent code, Is there any way to fix this permenantly?
2) I run my code, and I get this error:
Traceback (most recent call last): File "E:\Tom's Personal Project\src\scenario.py", line 34, in <module> s.run() File "E:\Tom's Personal Project\src\scenario.py", line 28, in run menu.combat_menu(enemy, self.player, action, menu) File "E:\Tom's Personal Project\src\gamemain.py", line 21, in combat_menu actions.attack(enemy, player, menus) File "E:\Tom's Personal Project\src\gamemain.py", line 44, in attack menus.combat_menu(enemy, player, self) TypeError: combat_menu() takes exactly 5 arguments (4 given)
Here is the relevant code:
gamemain.py(part of it):
class Menus(): def __init__(self): pass def combat_menu(self, enemy, player, actions, menus): print 'You find a fearsome',enemy.name,'!' print print_monster_stats(enemy) print print_menu_title('COMBAT MENU') print '] Attack' print '] Heal' print '] Stats' print '] Equip' print '] Run Away(doesn\'t keep exp)' choice = raw_input('>> ') inputs = choice.split(' ') if inputs == 'attack' or inputs == 'Attack': actions.attack(enemy, player, menus) if inputs == 'equip' or inputs == 'Equip': actions.equip(enemy, player)
scenario.py(part of it):
global menu menu = Menus() global action action = Actions() class Scenario: def __init__(self, number, player): self.things = wl.loadWorlds()[str(number)] self.badguys = self.things self.items = self.things self.player = player def run(self): print print 'You start searching for a monster...' for guy in self.badguys: enemy = Monster(guy) menu.combat_menu(enemy, self.player, action, menu)
I have been trying to fix 2) for days.
Any help would be greatly appreciated :)
Thanks in advance :)