Skip to the content.

Sprint 2 - Running From Mongols

Project Game

# Running From The Mongols
import sys
import random

health = 100
experience = 0

print("Hello explored traveler!")
print("My name is Ivan I, prince of the Rus, in 13th century. These lands have been torn down and broken apart by the Mongols, please, do something!")
print("As you help prevent and defend attacks from the Mongols, your stats change: health: ", health, ", experience: ", experience, ", reputation: ", reputation)

ans1 = input("Are you ready for the journey? (yes/no): ").lower()
if ans1 != "yes":
    sys.exit()
    
print("Now it's time to choose your main weapon!")

# Weapon Dictionary values for each key: index 0: damage, index 1: attack distance
weapon_dict = {
    "Sword": [25, 10],
    "Bow_Arrow": [20, 40],
    "Spear": [50, 5]
}

# List of catchphrases
catchphrases = ["Bam!", "Slash!", "Hit!", "Smack!", "Strike!", "Wham!"]

while True:
    learning_weapons = input("Let's look at the different types of weapons, the Sword(0), the Bow and Arrow(1), and the Spear(2). Type 3 to stop: ")
    
    if learning_weapons == '0':
        print("Good choice, a sword is used in closer combat. The damage it can deal is ", weapon_dict["Sword"][0], ", and its attack distance is", weapon_dict["Sword"][1])
    elif learning_weapons == '1':
        print("Good choice, a bow and arrow is used in longer range combat. The damage it can deal is ", weapon_dict["Bow_Arrow"][0], ", and its attack distance is", weapon_dict["Bow_Arrow"][1])
    elif learning_weapons == '2':
        print("Good choice, a spear is used in very close combat. The damage it can deal is ", weapon_dict["Spear"][0], ", and its attack distance is", weapon_dict["Spear"][1])
    elif learning_weapons == '3':
        break
    else:
        print("Invalid input. Please choose a valid weapon or type 3 to stop.")

main_weapon = input("So which one do you choose: 0 for sword, 1 for bow and arrow, and 2 for spear: ")


print("10 years later ....")
print("OH NO, GENGHIS KHAN IS ATTACKING!")
print("DEPLOY ALL FORCES")


'''
Peusdocode for function strucutre:

define combat method (parameters are distance and health):
    if the distance of the enemy is <= weapon distance:
        while the enemy health is > 0:
            print random catchphrase
            Subtract from enemy health with weapon damage
        print enemy is defeated
    else:
        print the enemy is too far away
'''

def take_damage(player_health, missed_shots):
    player_health -= missed_shots * 10
    print("You missed ", missed_shots, "times! Your health is now: ", player_health)
    return player_health

def sword_combat(distance_to_enemy, enemy_health, player_health, missed_shots):
    if distance_to_enemy <= weapon_dict["Sword"][1]:
        while enemy_health > 0:
            print(random.choice(catchphrases))
            enemy_health -= weapon_dict["Sword"][0]
        print("Enemy defeated with the sword!")
    else:
        print("The enemy is too far for a sword attack.")
        missed_shots += 1
        player_health = take_damage(player_health, missed_shots)
    return player_health, missed_shots

def bow_arrow_combat(distance_to_enemy, enemy_health, player_health, missed_shots):
    if distance_to_enemy <= weapon_dict["Bow_Arrow"][1]:
        while enemy_health > 0:
            print(random.choice(catchphrases))
            enemy_health -= weapon_dict["Bow_Arrow"][0]
        print("Enemy defeated with the bow and arrow!")
    else:
        print("The enemy is too far for a bow and arrow attack.")
        missed_shots += 1
        player_health = take_damage(player_health, missed_shots)
    return player_health, missed_shots

def spear_combat(distance_to_enemy, enemy_health, player_health, missed_shots):
    if distance_to_enemy <= weapon_dict["Spear"][1]:
        while enemy_health > 0:
            print(random.choice(catchphrases))
            enemy_health -= weapon_dict["Spear"][0]
        print("Enemy defeated with the spear!")
    else:
        print("The enemy is too far for a spear attack.")
        missed_shots += 1
        player_health = take_damage(player_health, missed_shots)
    return player_health, missed_shots

weapon_final_choice = int(input("What weapon are you using? For every time you miss a shot, you lose health. (0 for sword, 1 for bow and arrow, 2 for spear): "))

enemy_distance = random.randint(1, 40)
enemy_health = 50
missed_shots = 0

if weapon_final_choice == 0:
    health, missed_shots = sword_combat(enemy_distance, enemy_health, health, missed_shots)
elif weapon_final_choice == 1:
    health, missed_shots = bow_arrow_combat(enemy_distance, enemy_health, health, missed_shots)
elif weapon_final_choice == 2:
    health, missed_shots = spear_combat(enemy_distance, enemy_health, health, missed_shots)

if health <= 0:
    print("Oh no, your health is too low, you perished with the Mongols!")
    sys.exit()
else:
    print("Great job, you completed your first fight! You increased your expierence!")
    experience += 10
    print(experience, " points!")
    pass

print("     _____")
print("    /     \\")
print("   /       \\")
print("  |   /\\_/\\ |")
print("  |  ( O O )|")
print("  |   \\_v_/ |")
print("   \\_______/")
print("     |   |")
print("     |   |")
print("   __|   |__")
print("  /  |   |  \\")
print(" /   |   |   \\")
print("|    |   |    |")
print("     |   |")
print("    /     \\")
print("   /       \\")
print("  /__     __\\")
print("     |___|")



        






Hello explored traveler!
My name is Ivan I, prince of the Rus, in 13th century. These lands have been torn down and broken apart by the Mongols, please, do something!
As you help prevent and defend attacks from the Mongols, your stats change: health:  100 , experience:  0 , reputation:  0
Now it's time to choose your main weapon!
Good choice, a sword is used in closer combat. The damage it can deal is  25 , and its attack distance is 10
Good choice, a sword is used in closer combat. The damage it can deal is  25 , and its attack distance is 10
Good choice, a bow and arrow is used in longer range combat. The damage it can deal is  20 , and its attack distance is 40
Good choice, a spear is used in very close combat. The damage it can deal is  50 , and its attack distance is 5
Good choice, a spear is used in very close combat. The damage it can deal is  50 , and its attack distance is 5
10 years later ....
OH NO, GENGHIS KHAN IS ATTACKING!
DEPLOY ALL FORCES
Slash!
Wham!
Smack!
Enemy defeated with the bow and arrow!
Great job, you completed your first fight! You increased your expierence!
10  points!
     _____
    /     \
   /       \
  |   /\_/\ |
  |  ( O O )|
  |   \_v_/ |
   \_______/
     |   |
     |   |
   __|   |__
  /  |   |  \
 /   |   |   \
|    |   |    |
     |   |
    /     \
   /       \
  /__     __\
     |___|