/******************************************************************************/
(include "sci.sh")
(include "game.sh")
/******************************************************************************/
(script 87)
/******************************************************************************/
(use "controls")
(use "cycle")
(use "door")
(use "feature")
(use "game")
(use "inv")
(use "main")
(use "obj")
(local
random1
random2
random3
roll
rolling
bet2
cash2
cash3
r1
r2
r3
over
win
gameOver
)
/******************************************************************************/
(instance public rm087 of Rm
	(properties
		picture 95
		north 0
		east 0
		south 0
		west 0
	)
	(method (init)
		(super:init())
		(self:setScript(RoomScript))

    (aB: init())
    (Slot1: init())
    (Slot2: init())
    (Slot3: init())
    (aR: init())
    (aC: init())
   PlayerControl()
   (SL: doit())
= r1 FALSE
= r2 FALSE
= r3 FALSE
= random1 100
= random2 100
= random3 100
= roll FALSE
= rolling FALSE
= over FALSE
= win 0
= gameOver FALSE
 ProgramControl()
= gTimeSeconds2 0
	)
)
/******************************************************************************/
 (instance end1 of Script
 (properties)
 (method(changeState newState)
 = newState 0
 = state newState
 (switch(state)
 (case 0
 (Slot1: view(117))
 = random1 Random(1 8)
 (if(>= random1 6)
 = random1 Random(1 4)
 )

 (Slot1: cel(random1))
 )
 )
 )
 )
  (instance end2 of Script
 (properties)
 (method(changeState newState)
 = newState 0
 = state newState
 (switch(state)
 (case 0
 (Slot2: view(117))
 = random2 Random(1 8)
 (if(>= random2 6)
 = random2 Random(1 4)
 )

 (Slot2: cel(random2))
 )
 )
 )
 )
    (instance end3 of Script
 (properties)
 (method(changeState newState)
 = newState 0
 = state newState
 (switch(state)
 (case 0
 (Slot3: view(117))
 = random3 Random(1 8)
 (if(>= random3 6)
 = random3 Random(1 4)
 )

 (Slot3: cel(random3))
 = over TRUE
 )
 )
 )
 )
 (instance RoomScript of Script
 (properties)
 (method(doit)
 (if(== win 1)
 (if(not(gameOver))
 = gameOver TRUE
 //------------//
 += money bet
 = bet2 bet
 /= bet2 2
 += money bet2
 += money bet
 Reset()
 return
 )
 )
  (if(== win 2)
 (if(not(gameOver))
 = gameOver TRUE
 //------------//
  += money bet
 = cash2 bet
 /= cash2 2
 += money bet
 += money cash2
 Reset()
 return
 )
 )
  (if(== win 3)
 (if(not(gameOver))
 = gameOver TRUE
  += money bet
 = cash2 cash
 /= cash2 2
 += money cash2
 = cash3 bet
 /=cash2 2
 *=cash2 3
 += money cash3
 Reset()
 return
 )
 )
   (if(== win 4)
 (if(not(gameOver))
 = gameOver TRUE
  += money bet
  = cash2 cash
 /= cash2 2
 += money cash2

 Reset()
 return
 )
 )
  (if(== win 5)
 (if(not(gameOver))
 = gameOver TRUE
  += money bet
  = cash2 bet
  = bet2 bet
  /= bet2 2
  += money bet2
 += money cash2

 Reset()
 return
 )
 )
   (if(== win 6)
 (if(not(gameOver))
 = gameOver TRUE
  += money bet
  = cash2 cash
 += money cash2
  = bet2 bet
  *= bet2 2
  += money bet2
 Reset()
 return
 )
 )
 (if(over)
//--------------------------------------------/
 (if(== random1 1 and (if(== random2 1)))
 (if(not(== random3 5)
 (if(== win 0)
 (if(== random3 1)

 = win 1
 return
 )
 (if(== random3 2)

 = win 2
 return
 )
  (if(== random3 3)

 = win 3
 return
 )
 (if(== random3 4)

 = win 4
 return
 ))))Reset())
//--------------------------------------------/
(if(== random2 1 and (if(== random3 1)))
 (if(not(== random1 5)
 (if(== win 0)
 (if(== random1 1)

 = win 1
 return
 )
 (if(== random1 2)

 = win 2
 return
 )
  (if(== random1 3)

 = win 3
 return
 )
 (if(== random1 4)

 = win 4
 return
 ))))Reset())
//-----------------------------------------------/
//-----------------------------------------------/
 (if(== random1 2 and (if(== random2 2)))
 (if(not(== random3 5)
 (if(== win 0)
 (if(== random3 2)

 = win 2
 return
 )
 (if(== random3 1)

 = win 2
 return
 )
  (if(== random3 3)

 = win 3
 return
 )
 (if(== random3 4)

 = win 4
 return
 ))))Reset())
//--------------------------------------------/
(if(== random2 2 and (if(== random3 2)))
 (if(not(== random1 5)
 (if(== win 0)
 (if(== random1 2)

 = win 1
 return
 )
 (if(== random1 1)

 = win 2
 return
 )
  (if(== random1 3)

 = win 3
 return
 )
 (if(== random1 4)

 = win 4
 return
 ))))Reset())
/*-------------------------------------------
-------------------------------------------*/
 (if(== random1 3 and (if(== random2 3)))
 (if(not(== random3 5)
 (if(== win 0)
 (if(== random3 3)

 = win 5
 return
 )
 (if(== random3 2)

 = win 2
 return
 )
  (if(== random3 1)

 = win 1
 return
 )
  (if(== random3 3)

 = win 3
 return
 )
 (if(== random3 4)

 = win 4
 return
 ))))Reset())
//--------------------------------------------/
(if(== random2 3 and (if(== random3 3)))
 (if(not(== random1 5)
 (if(== win 0)
 (if(== random1 3)

 = win 5
 return
 )
 (if(== random1 1)

 = win 2
 return
 )
  (if(== random1 2)

 = win 3
 return
 )
 (if(== random1 4)

 = win 4
 return
 ))))Reset())
/*-------------------------------------------
-------------------------------------------*/
 (if(== random1 4 and (if(== random2 4)))
 (if(not(== random3 5)
 (if(== win 0)
 (if(== random3 4)

 = win 6
 return
 )
  (if(== random3 1)
 = win 1
 return
 )
 (if(== random3 2)

 = win 2
 return
 )
  (if(== random3 3)

 = win 3
 return
 )
 (if(== random3 4)

 = win 4
 return
 ))))
 Reset())
 ////
 (if(== random2 4 and (if(== random3 4)))
 (if(not(== random1 5)
 (if(== win 0)
 (if(== random1 4)

 = win 6
 return
 )
 (if(== random1 1)

 = win 1
 return

 )
 (if(== random1 2)

 = win 2
 return
 )
  (if(== random1 3)

 = win 3
 return
 )
 (if(== random1 4)

 = win 4
 return
 ))))
 Reset()
 )
/*-------------------------------------------
-------------------------------------------*/
 (if(== random1 4 and (if(== random3 4)))
 (if(not(== random2 5)
 (if(== win 0)
 (if(== random2 3)

 = win 5
 return
 )
 (if(== random2 2)

 = win 3
 return
 )
  (if(== random2 1)
 = win 2
 return
 )
 )))
 Reset()
 )
/*-------------------------------------------
-------------------------------------------*/
 (if(== random1 3 and (if(== random3 3)))
 (if(not(== random2 5)
 (if(== win 0)
 (if(== random2 4)

 = win 4
 return
 )
 (if(== random2 1)
 = win 1
 return
 )
  (if(== random2 2)

 = win 2
 return
 )
 )))Reset())
 ///
  (if(== random1 1 and (if(== random3 1)))
 (if(not(== random2 5)
 (if(== win 0)
 (if(== random2 4)

 = win 2
 return
 )
  (if(== random2 2)

 = win 1
 return
 )
 (if(== random2 3)
  = win 1
 return
 ))))
 Reset()
 )
   (if(== random1 2 and (if(== random3 2)))
 (if(not(== random2 5)
 (if(== win 0)
 (if(== random2 1)

 = win 1
 return
 )
 (if(== random2 3)

 = win 3
 return
 )
  (if(== random2 4)

 = win 3
 return
 ))))
 Reset()
 )
 ////////////////////--------END---------------
 Reset()
 )
 (if(== gTimeSeconds2 2)
 (if(roll)
 = gTimeSeconds2 3
 (Slot1: setCycle(End end1))
 )
 )
  (if(== gTimeSeconds2 5)
 (if(roll)
 = gTimeSeconds2 6
 (Slot2: setCycle(End end2))
 )
 )
   (if(== gTimeSeconds2 8)
 (if(roll)
 = gTimeSeconds2 9
 (Slot3: setCycle(End end3))
 )
 )
 (if(== money 0)
  (if(not(roll))
 = bet 0
 (SL: doit())
 )
 )
 (if(> bet money)
 (if(not(roll))
 (if(> money 100)
 = bet 100
 (SL: doit())
 return
 )
 = bet money
 (SL: doit())
 )
 )
  (if(<= money -1)
  = money 0
  (SL: doit())
 )

 (if(roll)
 (if(not(rolling))
 = rolling TRUE
 = gTimeSeconds2 0
 (Slot1: view(118) setCycle(Fwd))
 (Slot2: view(118) setCycle(Fwd))
 (Slot3: view(118) setCycle(Fwd))
 return
 )
 )

 )
 (method (handleEvent pEvent)
(if( not (super:handleEvent(pEvent)) )
  (if(not (& (send pEvent:modifiers) emRIGHT_BUTTON))
  (if(> (send pEvent:y) 3  and (if(< (send pEvent:y) 15)))   //   BACK
  (if(< (send pEvent:x) 45 and (if(> (send pEvent:x) 15)))
  (if(not(rolling))
 (send gRoom: newRoom(88))
 )
 )
 )
 (if(> (send pEvent:y) 150  and (if(< (send pEvent:y) 160)))  ///   CHANGE BET
 (if(< (send pEvent:x) 235 and (if(> (send pEvent:x) 155)))
  (if(not(rolling))
 = 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())
 )
 )
 )
 (if(> (send pEvent:y) 150  and (if(< (send pEvent:y) 160)))  //    ROLL
 (if(< (send pEvent:x) 110 and (if(> (send pEvent:x) 81)))
 (if(not(rolling))
 (if(== money 0)
 Print("You don't have enough cash to play.")
 return
 )
 (if(== bet 0)
 Print("Bet must be higher than 0.")
 return
 )
 = roll TRUE
 = cash money
 -= money bet
= gTimeSeconds2 0
 (SL: doit())
 return
 )
 )
 )

 )))


)
  (instance aB of Prop
 (properties
 view 104
 x 30
 y 15
 ))
   (instance aR of Prop
 (properties
 view 120
 x 95
 y 160
 cel 0
 ))
    (instance aC of Prop
 (properties
 view 120
 x 195
 y 160
 cel 1
 ))
  (instance Slot1 of Prop
 (properties
 view 117
 x 90
 y 100
 cel 0
 ))
  (instance Slot2 of Prop
 (properties
 view 117
 x 155
 y 100
 cel 0
 ))
  (instance Slot3 of Prop
 (properties
 view 117
 x 220
 y 100
 cel 0
 ))

 (procedure public (Reset)
 (SL: doit())
= random1 100
= random2 100
= random3 100
= roll FALSE
= rolling FALSE
= r1 FALSE
= r2 FALSE
= r3 FALSE
= over FALSE
= win 0
= gameOver FALSE
)
/******************************************************************************/
