-----------card41----------
On opencard 41

 if game_on is not 1 then
  play cakewo
   put 3 into ntx
   naratoranimex
wait 2 seconds
  play bokuwo
   put 5 into ntx
   naratoranimex
  end if
  put 41 into presentcard
put 0 into init41
put 1 into CastraDivideLevel
put 1 into CastraDivideLevelr
put 0 into getcastraylevel
put 0 into getcastrarlevel
put 0 into getcastrablevel
repeat with i = 1 to 10
  put 0 into Item i of arrayb
  put 0 into Item i of arrayr
  put 20 + i into Item i of arrayPlate
end repeat

put LocH of btn castra1 into xcastra1
put LocV of btn castra1 into ycastra1

put LocH of btn castra1r into xcastra1r
put LocV of btn castra1r into ycastra1r


setOnlytwoDishes
 
end opencard


On startshare
play click
put 1 into CastraDivideLevel
put 1 into CastraDivideLeve2
put 0 into getcastraylevel
put 0 into getcastrarlevel
put 0 into getcastrablevel
lock screen
 hidecastraall
set loc of btn castra1 to 186, 223
show btn castra1
show btn castraClick
unlock screen
End startshare

On setOneDishes
put 1 into DishSuu
showyellowdish
 put random(10) into click41
 repeat  click41 times
end repeat
put random( click41 ) into any41
 repeat any41 times
   getcastray
 end repeat
lock screen
hide btn 40
hide btn 41
hide btn 43
hide btn 44
show btn 17
unlock screen
End setOneDishes

On setOnlyOneDishes
put 1 into DishSuu
showyellowdish
 put random(10) into click41
 repeat  click41 times
  clickcastra
end repeat
lock screen
hide btn 40
hide btn 43
hide btn 44
show btn 17
unlock screen
End setOnlyOneDishes

On  showyellowdish
put 1 into CastraDivideLevel
put 0 into getcastraylevel
put 0 into getcastrarlevel
put 0 into getcastrablevel
lock screen
 hidecastraall
set loc of btn castra1 to 309, 285
show btn castra1
show btn castraClick
show btn yeldish
show btn 38
hide btn reddish
hide btn bluedish
unlock screen
End showyellowdish



On setTwoDishes
put 2 into DishSuu
showredbluedish
 put random(10) into click41
 repeat  click41 times
  clickcastra
end repeat
put random( click41 ) into any41
 repeat any41 times
   getcastrab
 end repeat

if click41 is not any41 then
   put click41 - any41 into extra41
  repeat extra41 times
   getcastrar
  end repeat
end if
lock screen
show btn 40
show btn 41
show btn 43
show btn 44
hide btn 17
unlock screen
End setTwoDishes

















On setOnlyTwoDishes
put 2 into DishSuu
showredbluedish
 put random(10) into click41
 put random(10) into click41r
 repeat  click41 times
  clickcastra
end repeat
 repeat  click41r times
  clickcastrar
end repeat
lock screen
unlock screen
End setOnlyTwoDishes














On  showredbluedish
put 1 into CastraDivideLevel
put 1 into CastraDivideLevelr
put 0 into getcastrarlevel
put 0 into getcastrablevel
lock screen
 hidecastraall
 hidecastraallr
set loc of btn castra1 to 186,223
set loc of btn castra1r to 446,286
show btn castra1
show btn castra1r
hide btn 38
unlock screen
repeat with i = 1 to 10
  put 0 into Item i of arrayb
  put 0 into Item i of arrayr
  put 19 + i into Item i of arrayPlate
  put 49 + i into Item i of arrayPlate
end repeat

End showredbluedish










On hidecastraall

   hide btn Castra1
  repeat with i = 20 to 29
     hide btn %i%
  end repeat

End hidecastraall


On hidecastraallr

   hide btn Castra1r
  repeat with i = 50 to 59
     hide btn %i%
  end repeat

End hidecastraallr






On ShowCastra

End ShowCastra



On ClickCastra
if  getcastrablevel = 0   then
lock screen
 if CastraDivideLevel >=1  and CastraDivideLevel <=9 then
      hidecastraall
      if CastraDivideLevel + 1 = 2 then
             repeat with j = 1 to CastraDivideLevel + 1
                 put j+19 into btn_j
              set bitmap of btn %btn_j% to Castra2
              set loc of btn %btn_j% to 267 - 160 *(j-1), 223
              show btn %btn_j%
             end repeat
         end if
         if CastraDivideLevel + 1 = 3 then
             repeat with j = 1 to CastraDivideLevel + 1
                 put j+19 into btn_j
              set bitmap of btn %btn_j% to Castra3
              set loc of btn %btn_j% to 295 - 107 *(j-1), 223
              show btn %btn_j%
             end repeat
         end if
         if CastraDivideLevel + 1 = 4 then
             repeat with j = 1 to CastraDivideLevel + 1
                 put j+19 into btn_j
              set bitmap of btn %btn_j% to Castra4
              set loc of btn %btn_j% to 307 - 80 *(j-1), 223
              show btn %btn_j%
               end repeat
       end if
         if CastraDivideLevel + 1 = 5 then
             repeat with j = 1 to CastraDivideLevel + 1
                 put j+19 into btn_j
              set bitmap of btn %btn_j% to Castra5
              set loc of btn %btn_j% to 315 - 64 *(j-1), 223
              show btn %btn_j%
             end repeat
         end if
         if CastraDivideLevel + 1 = 6 then
             repeat with j = 1 to CastraDivideLevel + 1
                 put j+19 into btn_j
              set bitmap of btn %btn_j% to Castra6
              set loc of btn %btn_j% to 320 - 53 *(j-1), 223
              show btn %btn_j%
             end repeat
         end if
         if CastraDivideLevel + 1 = 7 then
             repeat with j = 1 to CastraDivideLevel + 1
                 put j+19 into btn_j
              set bitmap of btn %btn_j% to Castra7
              set loc of btn %btn_j% to 324 - 46 *(j-1), 223
              show btn %btn_j%
             end repeat
         end if
         if CastraDivideLevel + 1 = 8 then
             repeat with j = 1 to CastraDivideLevel + 1
                 put j+19 into btn_j
              set bitmap of btn %btn_j% to Castra8
              set loc of btn %btn_j% to 327 - 40 *(j-1), 223
              show btn %btn_j%
             end repeat
         end if
         if CastraDivideLevel + 1 = 9 then
             repeat with j = 1 to CastraDivideLevel + 1
                 put j+19 into btn_j
              set bitmap of btn %btn_j% to Castra9
              set loc of btn %btn_j% to 329 - 36 *(j-1), 223
              show btn %btn_j%
             end repeat
         end if
         if CastraDivideLevel + 1 = 10 then
             repeat with j = 1 to CastraDivideLevel + 1
                 put j+19 into btn_j
              set bitmap of btn %btn_j% to Castra10
              set loc of btn %btn_j% to 331 - 32 *(j-1), 223
              show btn %btn_j%
              end repeat
         end if

           put  CastraDivideLevel + 1 into CastraDivideLevel

        else
              put 1 into CastraDivideLevel
              set loc of btn castra1 to 187,223
             repeat with i = 20 to 29
               hide btn %i%
             end repeat
             show btn castra1
        end if
    if CastraDivideLevel is not 1 then
          put LocH of btn 20 - locH of btn 21 into CastraDiff
          put 19 +  CastraDivideLevel into MostLeftBtnNo
          put 20 into MostRightBtnNo
          put LocH of btn %MostLeftBtnNO% into xofLeftBTn
          put LocV of btn %MostLeftBtnNO% into yofLeftBTn
          put LocH of btn %MostRightBtnNO% into xofRightBTn
          put LocV of btn %MostRightBtnNO% into yofRightBTn

    end if
unlock screen
 
end if
end ClickCastra






On ClickCastrar
if  getcastrarlevel = 0   then
lock screen
 if CastraDivideLevelr >=1  and CastraDivideLevelr <=9 then
      hidecastraallr
      if CastraDivideLevelr + 1 = 2 then
             repeat with j = 1 to CastraDivideLevelr + 1
                 put j+49 into btn_j
              set bitmap of btn %btn_j% to Castra2
              set loc of btn %btn_j% to 526 - 160 *(j-1), 286
              show btn %btn_j%
             end repeat
         end if
         if CastraDivideLevelr + 1 = 3 then
             repeat with j = 1 to CastraDivideLevelr + 1
                 put j+49 into btn_j
              set bitmap of btn %btn_j% to Castra3
              set loc of btn %btn_j% to 554 - 107 *(j-1), 286
              show btn %btn_j%
             end repeat
         end if
         if CastraDivideLevelr + 1 = 4 then
             repeat with j = 1 to CastraDivideLevelr + 1
                 put j+49 into btn_j
              set bitmap of btn %btn_j% to Castra4
              set loc of btn %btn_j% to 566 - 80 *(j-1), 286
              show btn %btn_j%
               end repeat
       end if
         if CastraDivideLevelr + 1 = 5 then
             repeat with j = 1 to CastraDivideLevelr + 1
                 put j+49 into btn_j
              set bitmap of btn %btn_j% to Castra5
              set loc of btn %btn_j% to 574 - 64 *(j-1), 286
              show btn %btn_j%
             end repeat
         end if
         if CastraDivideLevelr + 1 = 6 then
             repeat with j = 1 to CastraDivideLevelr + 1
                 put j+49 into btn_j
              set bitmap of btn %btn_j% to Castra6
              set loc of btn %btn_j% to 579 - 53 *(j-1), 286
              show btn %btn_j%
             end repeat
         end if
         if CastraDivideLevelr + 1 = 7 then
             repeat with j = 1 to CastraDivideLevelr + 1
                 put j+49 into btn_j
              set bitmap of btn %btn_j% to Castra7
              set loc of btn %btn_j% to 583 - 46 *(j-1), 286
              show btn %btn_j%
             end repeat
         end if
         if CastraDivideLevelr + 1 = 8 then
             repeat with j = 1 to CastraDivideLevelr + 1
                 put j+49 into btn_j
              set bitmap of btn %btn_j% to Castra8
              set loc of btn %btn_j% to 586 - 40 *(j-1), 286
              show btn %btn_j%
             end repeat
         end if
         if CastraDivideLevelr + 1 = 9 then
             repeat with j = 1 to CastraDivideLevelr + 1
                 put j+49 into btn_j
              set bitmap of btn %btn_j% to Castra9
              set loc of btn %btn_j% to 588 - 36 *(j-1), 286
              show btn %btn_j%
             end repeat
         end if
         if CastraDivideLevelr + 1 = 10 then
             repeat with j = 1 to CastraDivideLevelr + 1
                 put j+49 into btn_j
              set bitmap of btn %btn_j% to Castra10
              set loc of btn %btn_j% to 590 - 32 *(j-1), 286
              show btn %btn_j%
              end repeat
         end if

           put  CastraDivideLevelr + 1 into CastraDivideLevelr

        else
              put 1 into CastraDivideLevelr
              set loc of btn castra1r to 446,286
             repeat with i = 50 to 59
               hide btn %i%
             end repeat
             show btn castra1r
        end if
    if CastraDivideLevelr is not 1 then






          put LocH of btn 50 - locH of btn 51 into CastraDiffr
          put 49 +  CastraDivideLevelr into MostLeftBtnNor
          put 50 into MostRightBtnNor
          put LocH of btn %MostLeftBtnNor% into xofLeftBTnr
          put LocV of btn %MostLeftBtnNor% into yofLeftBTnr
          put LocH of btn %MostRightBtnNor% into xofRightBTnr
          put LocV of btn %MostRightBtnNor% into yofRightBTnr










    end if
unlock screen
 
end if
end ClickCastrar










On getCastrab
if CastraDivideLevel = 1 and  getcastralevel = 0 then
     
   set loc of btn castra1 to LocH of btn bluedish, LocV of btn bluedish - 17
   put getcastrablevel + 1 into getcastrablevel
end if

   if CastraDivideLevel > 1 and  getcastrablevel + 1 <= CastraDivideLevel then
      if getcastrablevel  < 5 then
                 if getcastrablevel = 0 then
                       set loc of btn 20 to LocH of btn bluedish, LocV of btn bluedish - 17
                    end if
                  if getcastrablevel = 1 then
                
                       set loc of btn 21 to LocH of btn bluedish - CastraDiff , LocV of btn bluedish - 17
                    end if
                     if getcastrablevel = 2   then
                        set loc of btn 22 to LocH of btn bluedish + CastraDiff, LocV of btn bluedish - 17
                    end if
                   if getcastrablevel = 3 then
                           set loc of btn 23 to LocH of btn bluedish - (CastraDiff * 2) , LocV of btn bluedish - 17
                       end if
                     if getcastrablevel = 4 then
                      set loc of btn 24 to LocH of btn bluedish + (CastraDiff * 2), LocV of btn bluedish - 17
                      end if
            else
                    if getcastrablevel = 5 then
                       set loc of btn 25 to LocH of btn bluedish, LocV of btn bluedish - 50
                   end if
                    if getcastrablevel = 6 then
                
                        set loc of btn 26 to LocH of btn bluedish - CastraDiff, LocV of btn bluedish - 50
                      end if
                    if getcastrablevel = 7   then
                         set loc of btn 27 to LocH of btn bluedish + CastraDiff, LocV of btn bluedish - 50
                     end if
                    if getcastrablevel = 8 then
                      set loc of btn 28 to LocH of btn bluedish - CastraDiff * 2 , LocV of btn bluedish - 50
                     end if
                     if getcastrablevel = 9 then
                       set loc of btn 29 to LocH of btn bluedish + CastraDiff * 2, LocV of btn bluedish - 50
                     end if
            end if
 
      put getcastrablevel + 1 into getcastrablevel


end if
 
End getCastrab


On ReturnCastrab
          put 19 + getcastrablevel + 1 into JustLeftPlateCastra
           put 19 + getcastrablevel  into LastDishCastra
if CastraDivideLevel = 1 and  getcastrablevel = 1 then
     
   set loc of btn castra1 to  187, 223
   put getcastrablevel - 1 into getcastrablevel
end if

if CastraDivideLevel > 1 and  getcastrablevel - 1 >= 0 and  (getcastrablevel is not CastraDivideLevel) then
          set loc of btn %LastDishCastra% to LocH of btn %JustLeftPlateCastra% + CastraDiff, LocV of btn  %JustLeftPlateCastra%
          put  getcastrablevel - 1 into getcastrablevel 
        end if

 if CastraDivideLevel > 1 and  getcastrablevel - 1 >= 0 and  (getcastrablevel is CastraDivideLevel) then
          set loc of btn %LastDishCastra% to xofLeftBTn, yofLeftBTn
          put  getcastrablevel - 1 into getcastrablevel 
        end if


End ReturnCastrab



--------------------




On getCastrar
if CastraDivideLevelr = 1 and  getcastrarlevel = 0 then
     
   set loc of btn castrar1 to LocH of btn reddish, LocV of btn reddish - 17
   put getcastrarlevel + 1 into getcastrarlevel
end if

   if CastraDivideLevelr > 1 and  getcastrarlevel + 1 <= CastraDivideLevelr then
      if getcastrarlevel  < 5 then
                 if getcastrarlevel = 0 then
                       set loc of btn 50 to LocH of btn reddish, LocV of btn reddish - 17
                    end if
                  if getcastrarlevel = 1 then
                
                       set loc of btn 51 to LocH of btn reddish - CastraDiffr , LocV of btn reddish - 17
                    end if
                     if getcastrarlevel = 2   then
                        set loc of btn 52 to LocH of btn reddish + CastraDiffr, LocV of btn reddish - 17
                    end if
                   if getcastrarlevel = 3 then
                           set loc of btn 53 to LocH of btn reddish - (CastraDiffr * 2) , LocV of btn reddish - 17
                       end if
                     if getcastrarlevel = 4 then
                      set loc of btn 54 to LocH of btn reddish + (CastraDiffr * 2), LocV of btn reddish - 17
                      end if
            else
                    if getcastrarlevel = 5 then
                       set loc of btn 55 to LocH of btn reddish, LocV of btn reddish - 50
                   end if
                    if getcastrarlevel = 6 then
                
                        set loc of btn 56 to LocH of btn reddish - CastraDiffr, LocV of btn reddish - 50
                      end if
                    if getcastrarlevel = 7   then
                         set loc of btn 57 to LocH of btn reddish + CastraDiffr, LocV of btn reddish - 50
                     end if
                    if getcastrarlevel = 8 then
                      set loc of btn 58 to LocH of btn reddish - CastraDiffr * 2 , LocV of btn reddish - 50
                     end if
                     if getcastrarlevel = 9 then
                       set loc of btn 59 to LocH of btn reddish + CastraDiffr * 2, LocV of btn reddish - 50
                     end if
            end if
 
      put getcastrarlevel + 1 into getcastrarlevel


end if
 
End getcastrar


On ReturnCastrar
          put 49 + getcastrarlevel + 1 into JustLeftPlateCastrar
           put 49 + getcastrarlevel  into LastDishCastrar
if CastraDivideLevelr = 1 and  getcastrarlevel = 1 then
     
   set loc of btn castra1 to  446, 286
   put getcastrarlevel - 1 into getcastrarlevel
end if

if CastraDivideLevelr > 1 and  getcastrarlevel - 1 >= 0 and  (getcastrarlevel is not CastraDivideLevelr) then
          set loc of btn %LastDishCastrar% to LocH of btn %JustLeftPlateCastrar% + CastraDiffr, LocV of btn  %JustLeftPlateCastrar%
          put  getcastrarlevel - 1 into getcastrarlevel 
        end if

 if CastraDivideLevelr > 1 and  getcastrarlevel - 1 >= 0 and  (getcastrarlevel is CastraDivideLevelr) then
          set loc of btn %LastDishCastrar% to xofLeftBTnr, yofLeftBTnr
          put  getcastrarlevel - 1 into getcastrarlevel 
        end if


End ReturnCastrar






---------------------










On Game_BunboBunsi

play click
hide btn speech41

----------------

If DishSuu = 2 then
showredbluedish
 put random(9)  into click41
 repeat  click41 times
  clickcastra
end repeat


 put random(9)  into click41r
 repeat  click41r times
  clickcastrar
end repeat




wait 3 seconds

put click41 + 1 into clickclick
if clickclick = 11 then 
put 1 into clickclick
end if

put random( clickclick ) into any41

put any41 MOD CastraDivideLevel into any41



put click41r + 1 into clickclickr
if clickclickr = 11 then 
put 1 into clickclickr
end if

put random( clickclickr ) into any41r

put any41r MOD CastraDivideLevelr into any41r


 repeat any41 times
   getcastrab
 end repeat


 repeat any41r times
   getcastrar
 end repeat



put any41/CastraDivideLevel into bluevalue
put any41r/CastraDivideLevelr into redvalue





put CastraDivideLevel * CastraDivideLevelr into bunboans
----------------
If bluevalue > redvalue then
put any41*CastraDivideLevelr - any41r * CastraDivideLevel into bunsians
 QuizDlg10 "The cake on the blue dish exceeds that on the red dish by __/__", bunboans, bunsians

else

put any41r * CastraDivideLevel - any41*CastraDivideLevelr into bunsians

 QuizDlg10 "The cake on the red dish exceeds that on the blue dish by __/__", bunboans,  bunsians
end if

------------------


      repeat while quiz_quit = 0
         wait 30 ticks
      end repeat
      put 0 into quiz_quit
  if math_answer is not 1 then
       if math_answer is  -1 then
          play  uhoh2


          show btn speech41
          exit Game_BunboBunsi
        else
              play jawharp
          showwitch_surprised
        end if

       else
           play good
           show_pengin_good
          put score + 1 into score



 

    end if

end if

          show btn speech41

End Game_BunboBunsi










----------------------------------------------------------------------


On Game_BunboBunsi5_2
 --put random(2) into Dishsuu
put 2  into Dishsuu

put 0 into score
Repeat 2 times

-----------



If DishSuu = 2 then
showredbluedish
 put random(9)  into click41
 repeat  click41 times
  clickcastra
end repeat


 put random(9)  into click41r
 repeat  click41r times
  clickcastrar
end repeat




wait 3 seconds

put click41 + 1 into clickclick
if clickclick = 11 then 
put 1 into clickclick
end if

put random( clickclick ) into any41

put any41 MOD CastraDivideLevel into any41



put click41r + 1 into clickclickr
if clickclickr = 11 then 
put 1 into clickclickr
end if

put random( clickclickr ) into any41r

put any41r MOD CastraDivideLevelr into any41r


 repeat any41 times
   getcastrab
 end repeat


 repeat any41r times
   getcastrar
 end repeat



put any41/CastraDivideLevel into bluevalue
put any41r/CastraDivideLevelr into redvalue





put CastraDivideLevel * CastraDivideLevelr into bunboans
----------------
If bluevalue > redvalue then
put any41*CastraDivideLevelr - any41r * CastraDivideLevel into bunsians
 QuizDlg10 "The cake on the blue dish exceeds that on the red dish by __/__", bunboans, bunsians

else

put any41r * CastraDivideLevel - any41*CastraDivideLevelr into bunsians

 QuizDlg10 "The cake on the red dish exceed that on the blue dish by __/__", bunboans,  bunsians
end if




---------



      repeat while quiz_quit = 0
         wait 30 ticks
      end repeat
      put 0 into quiz_quit
  if math_answer is not 1 then
       if math_answer is  -1 then
          play  uhoh2


          
        else
              play jawharp
          showwitch_surprised
        end if
        exit Game_BunboBunsi5_2
       else
           play good
           show_frog_good
          put score + 1 into score



 

    end if

end if



end repeat

if score = 5 then
    ok100
end if
if score = 4 then
    ok80
end if
if score = 3 then
    ok60
end if
lock screen
             if DishSuu = 1 then
                show btn 17
                show btn 38
                showyellowdish

              else
                show btn 43
                show btn 44
                show btn 40
                showredbluedish


              end if 
unlock screen     

End Game_BunboBunsi5_2















On Game_BunboBunsi5
put 2  into Dishsuu

put 0 into score
Repeat 5 times

----------------

If DishSuu = 2 then
showredbluedish
 put random(9)  into click41
 repeat  click41 times
  clickcastra
end repeat


 put random(9)  into click41r
 repeat  click41r times
  clickcastrar
end repeat




wait 3 seconds

put click41 + 1 into clickclick
if clickclick = 11 then 
put 1 into clickclick
end if

put random( clickclick ) into any41

put any41 MOD CastraDivideLevel into any41



put click41r + 1 into clickclickr
if clickclickr = 11 then 
put 1 into clickclickr
end if

put random( clickclickr ) into any41r

put any41r MOD CastraDivideLevelr into any41r


 repeat any41 times
   getcastrab
 end repeat


 repeat any41r times
   getcastrar
 end repeat



put any41/CastraDivideLevel into bluevalue
put any41r/CastraDivideLevelr into redvalue





put CastraDivideLevel * CastraDivideLevelr into bunboans
----------------
If bluevalue > redvalue then
put any41*CastraDivideLevelr - any41r * CastraDivideLevel into bunsians
 QuizDlg10 "The cake on the blue dish exceeds that on the red dish by __/__", bunboans, bunsians

else

put any41r * CastraDivideLevel - any41*CastraDivideLevelr into bunsians

 QuizDlg10 "The cake on the red dish exceeds that on the blue dish by __/__", bunboans,  bunsians
end if

------------------



      repeat while quiz_quit = 0
         wait 30 ticks
      end repeat
      put 0 into quiz_quit
  if math_answer is not 1 then
       if math_answer is  -1 then
          play  uhoh2


          exit repeat
        else
              play jawharp
          showwitch_surprised
        end if

       else
           play good
           show_frog_good
          put score + 1 into score



 

    end if

end if



end repeat

if score = 5 then
    ok100
end if
if score = 4 then
    ok80
end if
if score = 3 then
    ok60
end if
lock screen
             if DishSuu = 1 then
                show btn 17
                show btn 38
                showyellowdish

              else
                show btn 43
                show btn 44
                show btn 40
                showredbluedish


              end if 
unlock screen     
End Game_BunboBunsi5


on show_pengin_good
repeat 2 times
set bitmap of btn pn_mth1 to pn_mth2
wait 1 ticks 
set bitmap of btn pn_mth1 to pn_mth3
wait 1 ticks 
set bitmap of btn pn_mth1 to pn_mth2
wait 1 ticks 
set bitmap of btn pn_mth1 to pn_mth1
wait 1 ticks 
if mouseclick() then
 exit repeat
end if
end repeat


end show_pengin_good


















--------- end card41 ------------
