Dec-04-2017, 02:38 AM
This is a basic RPG where you fight Goblins and Giant Rats until you die. I will make this a part of a larger more interesting game in the future maybe. The stat calculations are unbalanced, and it's really unpolished, but it's basically just my way of trying to teach myself Python.
import random import sys #Enemies goblin = {} goblin['Name'] = 'Goblin' goblin['Health'] = 50.0 goblin['Agility'] = 40.0 goblin['Strength'] = 35.0 goblin['Level'] = 1 giant_rat = {} giant_rat['Name'] = 'Giant Rat' giant_rat['Health'] = 40.0 giant_rat['Agility'] = 55.0 giant_rat['Strength'] = 30.0 giant_rat['Level'] = 1 def Death(): print("You have died!") print("GAME OVER") exit_game = raw_input() sys.exit() def Fight(enemy): print("All of a sudden a " + str(enemy['Name']) + " attacks you!") Enemy = enemy.copy() while Enemy['Health'] > 0: Attack = False A = raw_input("Type A to attack the " + str(Enemy['Name']) + ". ") if A == "Attack" or "attack" or "A" or "a": Attack = True else: pass if Attack == True: print("You swing at the " + str(Enemy['Name']) + " with your sword!...") Player_attack_lands = False Enemy_attack_lands = False if (Enemy['Agility'] - player['Agility'] + (random.random() - random.random()) * 100) <= 0: Player_attack_lands = True else: pass if Player_attack_lands == True: print("You strike the " + str(Enemy['Name']) + "!") Enemy['Health'] = Enemy['Health'] - player['Strength'] print("You've done " + str(player['Strength']) +" damage! ") print("The " + str(Enemy['Name']) + " now has " + str(Enemy['Health']) + " left. ") if Enemy['Health'] <= 0: pass else: print("The " + str(Enemy['Name']) + " launches an attack at you! ") if (Enemy['Agility'] - player['Agility'] + (random.random() - random.random()) * 100) <= 0: Enemy_attack_lands = True else: print("The " + str(Enemy['Name']) + " missed! ") if Enemy_attack_lands == True: print("The " + str(Enemy['Name']) + " lands its attack! ") player['Health'] = player['Health'] - Enemy['Strength'] print("The " + str(Enemy['Name']) + " deals " + str(Enemy['Strength']) + " damage to you. ") print("You have " + str(player['Health']) + " Health left. ") if player['Health'] <= 0: Death() else: pass else: pass else: print("You miss!") print("The " + str(Enemy['Name']) + " launches an attack at you! ") if (Enemy['Agility'] - player['Agility'] + (random.random() - random.random()) * 100) <= 0: Enemy_attack_lands = True else: print("The " + str(Enemy['Name']) + " missed! ") if Enemy_attack_lands == True: print("The " + str(Enemy['Name']) + " lands its attack! ") player['Health'] = player['Health'] - Enemy['Strength'] print("The " + str(Enemy['Name']) + " deals " + str(Enemy['Strength']) + " damage to you. ") print("You have " + str(player['Health']) + " Health left. ") if player['Health'] <= 0: Death() else: pass print("You've killed the " + str(enemy['Name']) + "!") #Character Creaion player={} player['Name'] = raw_input("Please enter your character's name. ") player['Sex'] = raw_input("Please enter your character's sex. ") player['Experience'] = 0 player['Level'] = 1 if player['Sex'] == 'female' or 'f' or 'F': player['Sex'] = 'Female' elif player['Sex'] == 'male' or 'm' or 'M': player['Sex'] = 'Male' else: pass if player['Sex'] != 'Female' and player['Sex'] != 'Male': player['Sex'] = raw_input("Please enter your character's sex again. Please enter Male or Female. ") else: pass player['Strength'] = (random.random() * 100) player['Agility'] = ((random.random() * 100) + 70) / 2 player['Health'] = (random.random() * 100 + 100) #End Character Creation while player['Health'] > 0: Fight(goblin) print("") Fight(giant_rat) print("")