#!/usr/bin/env python
#
# while statement
#
import time
import datetime

print "Your objective is to guide your 'o' through this maze."
print "At its end, you'll find $1,000 in fake money for every life you have left. "
print "The stars that you see are actually spinning ninja stars. "
print "If you run into one, it will kill you. "
print "If you do not complete the maze in 60 seconds, the gates at the start and the "
print "finish will close and you will be trapped inside the maze to die of starvation. "
print "You have 5 chances to make it out of the maze alive and collect your fake money."
print "Good luck."
 
arr1 = "    ******************************************************************"
arr2 = "*                                     *                              *"
arr3 = "*       **    *****            ***           ********      ********  *"
arr4 = "*   **       ***     ********   *****     *    ********      *****   *"
arr5 = "***     ***    ************       *****       **********             *"
arr6 = "******    **         ******          *************          **********"
arr7 = "*****    ********                    ********       *******      *****"
arr8 = "***     *********        ***          ***********  ************* *****"
arr9 = "*****                 *************        ****** *************    ***"
arr10 = "***       *****************************                 *********    *"
arr11 = "***                   ***********                *****************   *"
arr12 = "********       ******        ******          **************         **"
arr13 = "***********   ********************************************************"
arr14 = "************                ********           *********             *"
arr15 = "**********************                ****                ********   $"
arr16 = "**********************************************************************"
arr = arr1, arr2, arr3, arr4, arr5, arr6, arr7, arr8, arr9, arr10, arr11, arr12, arr13, arr14, arr15, arr16
hpos = 0
vpos = 0
lifecount = 5

origscreen = [] # screen without a "o"
origscreen = arr
  
def printscreen():
   global vpos
   global hpos
   global lifecount
   screen = []
   mylen = len(origscreen)
   i = 0
   loseflag = 0
   winflag = 0
   while (i < mylen):
	x = origscreen[i]
	screen.append(x)
	if i == vpos:
                if (x[hpos] == "*"):
                        loseflag = 1
                if (x[hpos] == "$"):
                        winflag = 1
                x = x[:hpos] + ("o") + x[hpos+1:]
                screen[i] = x
	i = i+1
   for s in screen:
	print s
   if loseflag == 1:
      lifecount = lifecount - 1
      if lifecount > 0:
         print "You died. Try again."
         print "You have", lifecount, "lives remaining."
         totaltime = 0
         hpos = 0
         vpos = 0
         printscreen()
      if lifecount == 0:
         print "You failed to complete the maze. That means you suck."
         print "I'd give you a fake penny or something just for trying,"
         print "but you couldn't buy anything with it anyway,"
         print "so go waste someone else's time. And fake money."
   if winflag == 1:
      print "Congratulations! For surviving my maze with", lifecount, "lives,"
      print "I will award you $", lifecount,",000 in fake money."
      print "And be glad it's not real, because if it was, you'd have to pay tax on it."
      print "Go buy yourself some fake Kit Kats or something."

totaltime = 0
i = 0
x = ""
hpos = 0
vpos = 0
loseflag = 0
winflag = 0
while x != "s":
    printscreen()
    mybeforetime = time.time()
    # print mybeforetime
    x = raw_input("Please hit u(up), d(down), l(left), r(right), or s(stop):")
    myaftertime = time.time()
    diff = myaftertime - mybeforetime
    print ("You hit the letter: ") + x
    if x == "u":
	vpos = vpos-1
    if x == "d":
	vpos = vpos+1
    if x == "l":
        hpos = hpos-1
    if x == "r":
        hpos = hpos+1
    totaltime = totaltime + diff
    print totaltime
    if totaltime >= int(60):
       loseflag = 1
       lifecount = lifecount - 1
       if lifecount > 0:
          print "You died. Try again."
          print "You have", lifecount, "lives remaining."
          totaltime = 0
          hpos = 0
          vpos = 0
       if lifecount == 0:
         print "You failed to complete the maze. That means you suck."
         print "I'd give you a fake penny or something just for trying,"
         print "but you couldn't buy anything with it anyway,"
         print "so go waste someone else's time. And fake money."
    if winflag == 1:
      print "Congratulations! For surviving my maze with", lifecount, "lives,"
      print "I will award you $", lifecount,",000 in fake money."
      print "And be glad it's not real, because if it was, you would have to pay tax on it."
      print "Go buy yourself some fake Kit Kats or something."

    i = i+1
if x == "s":
   print "Good. Go away, quitter. You don't even deserve my fake money."
   print "Now go run home and cry to your mommy."
     
print totaltime


 
