So I'm making a simple game in which the user attacks a nation from a bordering nation, but I have run into an issue in that I can't think of an easy way to expand on this code because I am planning on adding more nations to the game. The end product will be similar to Risk but, if all goes as planned, more complex. This code works fine, but I'm looking to make it easier to expand. Think of this as a rough draft.
countries=['USA','MEXICO','CANADA']
#ignore MILITARYGROWTHRATE, that will be put to use later in production, I just added it in early
USA_REGION_DATA={'Bordering':['MEXICO','CANADA'],'MILITARYGROWTHRATE':1.03}
MEXICO_REGION_DATA={'Bordering':['USA'],'MILITARYGROWTHRATE':1.01}
CANADA_REGION_DATA={'Bordering':['USA'],'MILITARYGROWTHRATE':1.01}
def attack(origin,target):
'''Origin is where you are attacking from,
target is who you are attacking'''
x=origin.upper()
y=target.upper()
if x not in countries:
print("You must attack from somewhere!")
elif x=='USA':
if y not in USA_REGION_DATA['Bordering']:
print("Not a valid target")
else:
print("Attack is underway!")
elif x=='MEXICO':
if y not in MEXICO_REGION_DATA['Bordering']:
print("Not a valid target")
else:
print("Attack is underway!")
elif x=='Canada':
if y not in CANADA_REGION_DATA['Bordering']:
print("Not a valid target")
else:
print("Attack is underway!")
print("Are you attacking from the USA, Mexico, or Canada?")
origin=raw_input()
if origin.upper()=='USA':
print("Are you attacking Mexico or Canada?")
target=raw_input()
print("Are you sure you want to attack "+target+"? (Yes or No)")
answer=raw_input()
if answer.upper()=='YES':
attack(origin,target)
else:
print("You'll never get anything done by sitting around...")
else:
print("Are you sure you want to attack the USA?(Yes or No)")
if raw_input().upper()=='YES':
target='USA'
attack(origin,target)
else:
print("You'll never get anything done by sitting around...")