Advertisement
jdalbey

Cooties.py

Mar 29th, 2016
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.47 KB | None | 0 0
  1. def main():
  2.     i = 0
  3.     numLegs = 0
  4.     maxLegs=6
  5.     numEyes = 0
  6.     maxEyes=2
  7.     head = 0
  8.     numAnt = 0
  9.     maxAnt = 2
  10.     tail = 0
  11.     body = 0
  12.     done = False
  13.     error = 0
  14.     diceRoll = 0
  15.     turns = 0
  16.  
  17.     while not done:
  18.         error = False
  19.         diceRoll = input (" Input dice roll: ")
  20.         if diceRoll == 1:
  21.             if body == 0:
  22.                 body = 1
  23.             else:
  24.                 error = True
  25.         elif diceRoll ==2:
  26.             if body == 1 and head == 0:
  27.                 head = 1
  28.             else:
  29.                 error = True
  30.         elif diceRoll == 3:
  31.             if body == 1 and numLegs < maxLegs:
  32.                 numLegs = 1
  33.             else:
  34.                 error = True
  35.         elif diceRoll == 4:
  36.             if head == 1 and numAnt < maxAnt:
  37.                 numAnt += 1
  38.             else:
  39.                 error = True
  40.         elif diceRoll == 5:
  41.             if head == 1 and numEyes < maxEyes:
  42.                 numEyes += 1
  43.             else:
  44.                 error = True
  45.         elif diceRoll == 6:
  46.             if body == 1 and tail == 0 :
  47.                 tail = 1
  48.             else:
  49.                 error = True
  50.         else:
  51.             print " Invalid input."
  52.  
  53.         antOut = ""
  54.         if numAnt > 0:
  55.             antOut += "  !"
  56.         if numAnt == 2:
  57.             antOut += " |"
  58.  
  59.         print antOut
  60.  
  61.         headOut = ""
  62.         if head == 1:
  63.             headOut += " ("
  64.  
  65.         if numEyes > 0:
  66.             headOut += "o "
  67.         else:
  68.             headOut += "  "
  69.  
  70.         if numEyes == 2:
  71.             headOut += "o"
  72.         print headOut
  73.  
  74.         for i in range(0, maxLegs, 2):
  75.             bodyOut = ""
  76.             if numLegs > i:
  77.                 bodyOut += "- "
  78.             else:
  79.                 bodyOut += "  "
  80.  
  81.             if body == 1:
  82.                 bodyOut += "[ ]"
  83.  
  84.             if numLegs > i + 1:
  85.                 bodyOut += " _ "
  86.             else:
  87.                 bodyOut += " "
  88.             print bodyOut
  89.  
  90.         if tail == 1:
  91.             print "  T"
  92.  
  93.         if error:
  94.             print " Can't add a part.\n"
  95.  
  96.         turns += 1
  97.  
  98.         if body == 1 and numLegs == maxLegs and numEyes == maxEyes and numAnt == maxAnt and tail == 1:
  99.             print " Congratulations you have completed your cootie!"
  100.             print " It took you ", turns, " turns to finish your cootie."
  101.             done = True
  102.     return 0
  103.  
  104. if __name__ == "__main__":
  105.    main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement