I have a problem here.
class Player:
def __init__(self,name):
self.armed = 0
self.arms = 1
self.bombs = 0
self.exposed = 0
self.foodDrink = 20
self.gold = 350
self.happy = 50
self.heat = 0
self.heatTier = 0
self.month = 1
self.name = name
self.nameWait = 0
self.path = 'None'
self.poster = 5
self.propa = 0
self.raidPts = 0
self.status = 'Citizen'
self.successRiot = 0
self.support = 0
self.raidPts = 0
self.triedVote = 0
# stuff, mainly for fixing variables down from here...
Another, related block of code.
def nameType():
print('▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n')
CharName = input()
if CharName != '':
if len(CharName) > 20:
print('► The name is too long!')
nameType()
else:
print('► Are you sure this is what you want as a name?\nIf so, type "yes".\nOtherwise, type "no".')
confirmName = input()
if confirmName == 'yes':
PlayerIG = Player(CharName)
print('► Crew Member: Thanks for travelling with us, and have a great time,',PlayerIG.name,'.')
MainMenu()
if confirmName == 'no':
nameType()
else:
print('► Invalid Input!')
nameType()
else:
print('► Empty! Please type again.')
nameType()
And one last related one (there may be more).
def MainMenu():
blankSmall()
print('▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\nMonth',PlayerIG.month,'\n▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬')
blankSmall()
print('► You can buy items at the store by typing "store",\nadd propaganda by typing "propa",\nmanage the party by typing "manage", or if you have at least 1 bomb and 5 armed supporters,\nyou can conduct a raid by typing "raid".\nWhen you are done for the month, type "end".\nIf you are at rank President, you can participate in an election with "vote".\nIf you are Chief of Revolution, you can conduct a riot with "riot".\nTo save the game and leave, type "save".')
Option = input()
# Again, more stuff down here that may be included...
The problem is, when I load the main menu with MainMenu()
, it raises this error:
Traceback (most recent call last):
File "C:\Users\ONIE\AppData\Local\Programs\Python\Python36-
32\TheGameOfHierarchyAndAnarchy.py", line 791, in <module>
TitleScreen()
File "C:\Users\ONIE\AppData\Local\Programs\Python\Python36-
32\TheGameOfHierarchyAndAnarchy.py", line 144, in TitleScreen
nameType()
File "C:\Users\ONIE\AppData\Local\Programs\Python\Python36-
32\TheGameOfHierarchyAndAnarchy.py", line 168, in nameType
MainMenu()
File "C:\Users\ONIE\AppData\Local\Programs\Python\Python36-
32\TheGameOfHierarchyAndAnarchy.py", line 181, in MainMenu
print('▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\nMonth',PlayerIG.month,'\n▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬')
NameError: name 'PlayerIG' is not defined
Is there any solution to this?
EDIT: The MainMenu()
function was supposed to be indented, but the formatting was a bit stubborn.