/*---------------------------------------------------------/
/ "NOT Roulette" game for Dr.Jummybummy's Space Adventure 2
/ Coded By Eigen Lenk
/ You may use the code in your own game, but then let me know.
/----------------------------------------------------------/
/ Uses two global variables:  'money'  and  'bet'
----------------------------------------------------------------------*/
(include "sci.sh")
(include "game.sh")
(script 90)
(use "controls")
(use "cycle")
(use "door")
(use "feature")
(use "game")
(use "inv")
(use "main")
(use "obj")
(local
GameInProg
roll
ranNum
played
)
(instance public rm090 of Rm
	(properties
		picture scriptNumber
		north 0
		east 0
		south 0
		west 0
	)
	(method (init)
		(super:init())
		(self:setScript(RoomScript))

		(switch(gPreviousRoomNumber)

			)

 = GameInProg FALSE
  ProgramControl()
(SL: doit())
  (aB: init())
  (aRoll: init())
  (aNum: init())
     = played FALSE
      Display("Change Bet" dsCOORD 200 95 dsCOLOUR clBLACK dsBACKGROUND clTRANSPARENT dsFONT 900)
      Display("Roll" dsCOORD 200 60 dsCOLOUR clBLACK dsBACKGROUND clTRANSPARENT dsFONT 900)
      Display("Bet A Number" dsCOORD 200 110 dsCOLOUR clBLACK dsBACKGROUND clTRANSPARENT dsFONT 900)


 )
)
/******************************************************************************/
(instance End1 of Script
	(properties)
 (method(changeState newState)
 = newState 0
 = state newState
 (switch(state)
 (case 0
 = ranNum Random(1 16)
 (aNum: dispose())
 (aNum2: init() view(133) cel(ranNum))
 FormatPrint("The winning number is: %d " ranNum)
 (if(== ranNum numm2)
 Print("You win!")
 += money bet
 (SL: doit())
  = GameInProg FALSE
 return
 )
 -= money bet
  (SL: doit())
  = GameInProg FALSE

 )
 )
 )
 )
(instance RoomScript of Script
	(properties)
 (method(doit)
  (if(== money 0)
  (if(not(GameInProg))
 = bet 0
 (SL: doit())
 )
 )
 (if(> bet money)
 (if(not(GameInProg))
 (if(> money 100)
 = bet 100
 (SL: doit())
 return
 )
 = bet money
 (SL: doit())
 )
 )
  (if(<= money -1)
  = money 0
  (SL: doit())
  )
      Display("Change Bet" dsCOORD 200 95 dsCOLOUR clBLACK dsBACKGROUND clTRANSPARENT dsFONT 900)
      Display("Roll" dsCOORD 200 60 dsCOLOUR clBLACK dsBACKGROUND clTRANSPARENT dsFONT 900)
      Display("Bet A Number" dsCOORD 200 110 dsCOLOUR clBLACK dsBACKGROUND clTRANSPARENT dsFONT 900)
 (if(GameInProg)
 (if(== gTimeSeconds 0)
 (send gGame:setSpeed(2))
 )
 (if(== gTimeSeconds 1)
 (send gGame:setSpeed(3))
 )
 (if(== gTimeSeconds 2)
 (send gGame:setSpeed(4))
  )
 (if(== gTimeSeconds 3)
 (send gGame:setSpeed(6))
   )
 (if(== gTimeSeconds 4)
 (send gGame:setSpeed(7))
   )
 (if(== gTimeSeconds 5)
 (send gGame:setSpeed(8))
    )
 (if(== gTimeSeconds 6)
 (send gGame:setSpeed(10))
    )
 (if(== gTimeSeconds 7)
 = gTimeSeconds 8
 (send gGame:setSpeed(11))
  (aRoll: setCycle(End End1))

 )
 )
 )
 /*----------------------------------------------------*/
 
 
  (method (handleEvent pEvent)
(if( not (super:handleEvent(pEvent)) )
  (if(not (& (send pEvent:modifiers) emRIGHT_BUTTON))
  (if(> (send pEvent:y) 6  and (if(< (send pEvent:y) 18)))   //   BACK
  (if(> (send pEvent:x) 8 and (if(< (send pEvent:x) 38)))
    (if(not(GameInProg))
  (send gRoom: newRoom(88))
  )
  )
  )
  (if(> (send pEvent:y) 60 and (if(< (send pEvent:y) 70)))   //   ROLL
  (if(> (send pEvent:x) 200 and (if(< (send pEvent:x) 236)))
  (if(not(GameInProg))
  (if(== numm2 0)
  Print("The number must be higher than 0.")
  return
  )
     (if(== bet 0)
  Print("The bet must be higher than 0.")
  return
  )
  = GameInProg TRUE
  = gTimeSeconds 0
  (aNum2: dispose())
  (aNum: init() view(134) setCycle(Fwd))
  (aRoll: setCycle(Fwd))

   )
  )
  )
    (if(> (send pEvent:y) 110 and (if(< (send pEvent:y) 120)))   //   BET NUM
  (if(> (send pEvent:x) 200 and (if(< (send pEvent:x) 285)))
  (if(not(GameInProg))
  = numm2 GetNumber("Enter the number that you think will come next (1-16):\n")
  (if(== numm2 0)
  Print("The number must be higher than 0.")
  = numm2 1
   (SL: doit())
  return
  )
  (if(> numm2 16)
  Print("The maximum number is 16.")
  = numm2 16
   (SL: doit())
  return
  )
  (SL: doit())
  )
  )
  )
  (if(> (send pEvent:y) 95  and (if(< (send pEvent:y) 105)))   //   BET
  (if(> (send pEvent:x) 200 and (if(< (send pEvent:x) 272)))
  (if(not(GameInProg))
  = bet GetNumber("Enter your new bet:\n\n")
  (if(<= bet -1)
 = bet 0
 (SL: doit())
 return
 )
 (if(> bet 100)
 Print("The maximum bet is 100.")
 = bet 100
 (SL: doit())
 return
 )
  (if(> bet money)
 Print("You can't bet more than you have.")
 = bet money
 (SL: doit())
 return
 )
 (SL: doit())
 )
 )

  )
  )
  )
  )

)
 (instance aB of Prop
 (properties
 view 104
 x 23
 y 18
 ))
 (instance aRoll of Act
 (properties
 view 132
 x 91
 y 151
 ))
  (instance aNum of Act
 (properties
 view 133
 x 148
 y 154
 ))
   (instance aNum2 of Act
 (properties
 view 133
 x 148
 y 154
 ))
/******************************************************************************/
