swinefire

Troops vs Troops2.py

Apr 11th, 2013
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.42 KB | None | 0 0
  1. # file Name: Troops vs Troops.py
  2.  
  3. def main():
  4.  
  5. # Determines user-input variables for attack
  6.     print "Enter the number of each type of attacking troop."
  7.     print
  8.     print "TIER 1"
  9.     #attack = 1
  10.     #life = 1
  11.     mountedElves = input("Mounted Elves: ")
  12.     elvenMilitia = input("Elven Militia: ")
  13.     elvenArchers = input("Elven Archers: ")
  14.     attackTier1Num = (mountedElves + elvenMilitia + elvenArchers)
  15.  
  16.     print
  17.     print "TIER 2"
  18.     #attack = 2
  19.     #life = 2
  20.     mountedHunters = input("Mounted Hunters: ")
  21.     elvenWarriors = input("Elven Warriors: ")
  22.     scorpions = input("Scorpions: ")
  23.     attackTier2Num = (mountedHunters + elvenWarriors + scorpions)
  24.        
  25.     print
  26.     print "TIER 3"
  27.     #attack = 4
  28.     #life = 4
  29.     mountedGaladhrim = input("Mounted Galadhrim: ")
  30.     batteringRams = input("Battering Rams: ")
  31.     ents = input("Ents: ")
  32.     attackTier3Num = (mountedGaladhrim + batteringRams + ents)
  33.  
  34.     attackPwr = ((attackTier1Num * 1) + (attackTier2Num * 2) + (attackTier3Num * 4))
  35.    
  36.     print
  37.  
  38.  
  39. # Determines user-input variables for defense
  40.     print "Enter the number of each type of defending troop."
  41.     print
  42.     print "TIER 1"
  43.     #attack = 1
  44.     #life = 1
  45.     mountedElves = input("Mounted Elves: ")
  46.     elvenMilitia = input("Elven Militia: ")
  47.     elvenArchers = input("Elven Archers: ")
  48.     defendTier1Num = (mountedElves + elvenMilitia + elvenArchers)
  49.  
  50.     print
  51.     print "TIER 2"
  52.     #attack = 2
  53.     #life = 2
  54.     mountedHunters = input("Mounted Hunters: ")
  55.     elvenWarriors = input("Elven Warriors: ")
  56.     scorpions = input("Scorpions: ")
  57.     defendTier2Num = (mountedHunters + elvenWarriors + scorpions)
  58.        
  59.     print
  60.     print "TIER 3"
  61.     #attack = 4
  62.     #life = 4
  63.     mountedGaladhrim = input("Mounted Galadhrim: ")
  64.     batteringRams = input("Battering Rams: ")
  65.     ents = input("Ents: ")
  66.     defendTier3Num = (mountedGaladhrim + batteringRams + ents)
  67.  
  68.     defendPwr = ((defendTier1Num * 1) + (defendTier2Num * 2) + (defendTier3Num * 4))
  69.    
  70.     print
  71.  
  72.  
  73. # Calculates outcome for attackers and defenders    
  74.     attackOutcome = (attackPwr - defendPwr)
  75.     if attackOutcome <= 0:
  76.         attackOutcome = 0
  77.  
  78.     defendOutcome = (defendPwr - attackPwr)
  79.     if defendOutcome <= 0:
  80.         defendOutcome = 0
  81.  
  82.     print
  83.     print "Surviving attackers: " + str(attackOutcome)
  84.     print "Surviving defenders: " + str(defendOutcome)
  85.  
  86.  
  87. main()
Advertisement
Add Comment
Please, Sign In to add comment