Skip to content

Instantly share code, notes, and snippets.

@ziadsawalha
Created June 6, 2022 10:10
Show Gist options
  • Save ziadsawalha/609b7cbe99950d086d2a82a13604f302 to your computer and use it in GitHub Desktop.
Save ziadsawalha/609b7cbe99950d086d2a82a13604f302 to your computer and use it in GitHub Desktop.
import random
print("")
print(" ### # # # # # ##### ### ####### # # ")
print(" # ## # # # # # # # # # # ## # ")
print(" # # # # # # # # # # # # # # # ")
print(" # # # # # # # # ##### # # # # # # ")
print(" # # # # # # ####### # # # # # # # ")
print(" # # ## # # # # # # # # # # ## ")
print(" ### # # # # # ##### ### ####### # # ")
print("")
countries = ["Ecuador", "Japan", "Andorra", "Ireland","San Marino", "Sudan", "Romania", "Saudi Arabia", "Belarus", "Algeria", "Morrocco", "Cyprus", "USA", "Canada", "Mexico", "Colombia", "Brazil", "Argentina", "Chile", "Gambia", "Kenya", "Nigeria", "South Africa", "Madagascar", "Zimbabwe", "Egypt", "France", "Moldavia", "Spain", "Portugal", "Great Britain", "Czech Republic", "Slovenia", "Serbia", "Slovakia", "Latvia", "Sweden", "Norway", "Finland", "Azerbaizdzjan", "Iceland", "Lithuania", "Italy", "Denmark", "Turkey", "Ukraine", "Russia", "China", "Australia", "Germany", "Luxemburg", "Armenia", "Afghanistan", "India", "Iran", "Iraq", "Israel", "Syria", "Nepal", "Tibet", "Jordan"]
troops = random.randint(100,2000)
money = random.randint(500,100000)
elite_troops = 0
tanks = 0
country_name = input("Choose the name of your country: ")
country_currency = input("Write your country's currency: ")
print ("Now your country,",country_name,", shall conquer the entire world. You must be a good ruler if you want to gain power and wealth and dominate over all the other countries.")
years = 0
while True:
print("Your troops: ",troops)
print("")
print("Your money: ",money)
print("")
print("Your elite troops: ",elite_troops)
print("")
print("Your tanks: ",tanks)
try:
buy_troops = int(input("How many troops do you want to buy for your army? It will cost 100 " + str(country_currency) + "/troop."))
except ValueError:
buy_troops = 0
if buy_troops > 0:
troops += buy_troops
money -= buy_troops * 100
print("You have now purchased",buy_troops,"additional troops for your army.")
print("")
print("Your troops: ",troops)
print("")
print("Your money: ",money)
print("")
print("Your elite troops: ",elite_troops)
print("")
print("Your tanks: ",tanks)
else:
print("No purchases have been made.")
try:
buy_troops_elite = int(input("How many elite troops do you want to buy for your army? It will cost 1000 " + str(country_currency) + "/troop."))
except ValueError:
buy_troops_elite = 0
if buy_troops_elite > 0:
elite_troops += buy_troops_elite
money -= buy_troops_elite * 1000
print("You have now purchased",buy_troops_elite,"additional elite troops for your army.")
print("Your troops: ",troops)
print("Your money: ",money)
print("Your elite troops: ",elite_troops)
print("Your tanks: ",tanks)
else:
print("No purchases have been made.")
try:
buy_tanks = int(input("How many tanks do you want to buy for your army? It will cost 10000 " + str(country_currency) + "/tank."))
except ValueError:
buy_tanks = 0
if buy_tanks > 0:
tanks += buy_tanks
money -= buy_tanks * 10000
print("")
print("You have now purchased",buy_tanks,"additional tanks for your army.")
print("")
print("Your troops: ",troops)
print("Your money: ",money)
print("Your elite troops: ",elite_troops)
print("Your tanks: ",tanks)
else:
print("No purchases have been made.")
if random.randint(1,100) > 70:
country_invasion = (random.choice(countries) + " invaded you!")
print("")
print(country_invasion)
print("")
money = money - random.randint(400,15000)
troops = max(0, troops - random.randint(40,300))
elite_troops = max(0, elite_troops - random.randint(3,8))
tanks = max(0, tanks - random.randint(0,3))
print("Your troops: ",troops)
print("Your money: ",money)
print("Your elite troops: ",elite_troops)
print("Your tanks: ",tanks)
if troops < 100:
print("You don't have enough troops to go to war now. Buy more troops.")
continue
if money < 100:
print("You don't have enough money to survive long. You need to win a war quickly or you will starve.")
invade = input("Write which country you will start invading: ")
if invade.lower().strip("!?'.") in [c.lower() for c in countries]:
years += 1
successfull = [
"After a long time, you succesfully invaded " + invade + ".",
"You quickly and successfully invaded " + invade + ".",
"It was tied for a long time, but after a while " + invade + " lost control, forcing them to retreat."
]
failed = ["You were no match for " + invade +". They totally crushed you and forced you to retreat.",
"After a long battle, your army was to weak, with most of your troops dead. You were forced to retreat.",
"Once in the battlefield, " + invade + "'s war tactics gave them a huge advantage, and they had soon shot down most of your army. You were forced to retreat."
]
success_fail = random.choice([successfull,failed])
if success_fail == successfull:
troops_lost = min(troops, random.randint(100,2000))
troops = troops - troops_lost
money_gained = random.randint(1000,100000)
money = money + money_gained
elite_troops_lost = min(elite_troops, random.randint(4,10))
elite_troops = elite_troops - elite_troops_lost
tanks_lost = min(tanks, random.randint(1,5))
tanks = tanks - tanks_lost
print("")
print(random.choice(success_fail))
print("")
print("Troops lost:", troops_lost)
print("")
print("Money gained:", money_gained)
print("")
print("Elite troops lost: ",elite_troops_lost)
print("")
print("Tanks lost: ",tanks_lost)
else:
troops_lost = min(troops, random.randint(100,2000))
troops = troops - troops_lost
money_lost = random.randint(1000,40000)
money = money - money_lost
elite_troops_lost = min(elite_troops, random.randint(4,10))
elite_troops = elite_troops - elite_troops_lost
tanks_lost = min(tanks, random.randint(1,5))
tanks = tanks - tanks_lost
print("")
print(random.choice(success_fail))
print("")
print("Troops lost:", troops_lost)
print("")
print("Money lost:", money_lost)
print("")
print("Elite troops lost: ",elite_troops_lost)
print("")
print("Tanks lost: ",tanks_lost)
if money < 100:
print("You have run out of money. The entire population of", country_name,", including you, will starve.")
break
else:
print("That country does not exist. Try again. Choose one of these:", ", ".join(countries))
print("You ruled for %i years." % years)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment