-----------card46----------
On opencard 46
if game_on is not 1 then
  play bokuwo

   put 5 into ntx
   naratoranimex
 end if
  put 0 into ColorCode
  put 71 into froglevel
  put 81 into ratlevel
  put 91 into kanilevel
  put 101 into rabitlevel
  put 111 into owllevel
  put 0 into effectiveselection
  put 0 into init40
  put 40 into presentcard
put 0 into num_frog
put 0 into num_rabit
put 0 into num_kani
put 0 into num_owl
put 0 into num_rat
put  127 into redbarbtnlevel
put 20 into Item 1 of barvalue
put 18 into Item 2 of barvalue
put 12 into Item 3 of barvalue
put  6 into Item 4 of barvalue
put  1 into Item 5 of barvalue
put 15 into Item 6 of barvalue
put  3 into Item 7 of barvalue
put 19 into Item 8 of barvalue
put  7 into Item 9 of barvalue
put  9 into Item 10 of barvalue
put 0 into Item 1 of usedflag
put 0 into Item 2 of usedflag
put 0 into Item 3 of usedflag
put 0 into Item 4 of usedflag
put 0 into Item 5 of usedflag
put 0 into Item 6 of usedflag
put 0 into Item 7 of usedflag
put 0 into Item 8 of usedflag
put 0 into Item 9 of usedflag
put 0 into Item 10 of usedflag

end opencard



On randomswap
put random(50) into n
put random(50) into m
put n + 11 - 1 into n
put m + 11 - 1 into m
put LocH of btn %n% into x0
put LocV of btn %n% into y0
put LocH of btn %m% into x1
put LocV of btn %m% into y1

set loc of btn %n% to x1, y1
set loc of btn %m% to x0, y0
End randomswap




On Scramble40
  put 0 into ColorCode
  put 71 into froglevel
  put 81 into ratlevel
  put 91 into kanilevel
  put 101 into rabitlevel
  put 111 into owllevel
  put 0 into effectiveselection
  put 0 into init40
  put 40 into presentcard
put 0 into num_frog
put 0 into num_rabit
put 0 into num_kani
put 0 into num_owl
put 0 into num_rat
lock screen
 repeat with i40 = 71 to 120
  if i40 < 81 then
   set bitmap of btn %i40% to red
  end if
  if i40 >=81 and i40 < 91 then
   set bitmap of btn %i40% to yellow
  end if
  if i40 >=91 and i40 < 101 then
   set bitmap of btn %i40% to green
  end if
  if i40 >=101 and i40 < 111 then
   set bitmap of btn %i40% to sky
  end if
  if i40 >=111 and i40 < 121 then
   set bitmap of btn %i40% to purple
  end if

 end repeat

unlock screen

put random(10) into num_owl
put random(10) into num_rat
put random(10) into num_kani
put random(10) into num_frog
put random(10) into num_rabit
lock screen
repeat 30 times
randomswap
end repeat
repeat with i = 1 to 10
 put 11 + i -1 into o
 if i <= num_owl then
 show btn %o%
 else
 hide btn %o%
end if
end repeat

repeat with i = 1 to 10
 put 21 + i -1 into r
if i <= num_rat then
 show btn %r%
else
 hide btn %r%
end if
end repeat


repeat with i = 1 to 10
 put 31 + i -1 into k
if i <= num_kani then
 show btn %k%
else
hide btn %k%
end if
end repeat

repeat with i = 1 to 10
 put 41 + i -1 into f
 if i <= num_frog then
   show btn %f%
 else
   hide btn %f%
 end if

end repeat


repeat with i = 1 to 10
 put 51 + i -1into rb
if i <= num_rabit then
 show btn %rb%
else
 hide btn %rb%
end if
end repeat


repeat 3 times
put random(5) into nn
put random(5) into mm
put nn + 60 into nn
put mm + 60 into mm
 put LocH of btn %nn% into nnx
 put LocH of btn %mm% into mmx
set loc of btn %nn% to mmx,357 
set loc of btn %mm% to nnx, 357
end repeat


show btn "Decide?"
show btn "Change?"
hide btn Question
unlock screen



show btn cover

End Scramble40


On hideallanimals
lock screen
repeat with i = 11 to 60
 hide btn %i%
end repeat
unlock screen
End hideallanimals


On resetanimals
hideallanimals
  put 0 into ColorCode
  put 71 into froglevel
  put 81 into ratlevel
  put 91 into kanilevel
  put 101 into rabitlevel
  put 111 into owllevel
  put 0 into effectiveselection
  put 0 into init40
  put 40 into presentcard
put 0 into num_frog
put 0 into num_rabit
put 0 into num_kani
put 0 into num_owl
put 0 into num_rat
lock screen
 repeat with i40 = 71 to 120
   hide btn %i40%
 end repeat
hide btn cover
hide btn "Change?"
hide btn "Decide?"
show btn Question
unlock screen
End resetanimals

On ColorDecideRed
put 1 into ColorCode
End ColorDecideRed


On ColorDecideYellow
put 2 into ColorCode
End ColorDecideYellow

On ColorDecideGreen
put 3 into ColorCode
End ColorDecideGreen


On ColorDecideSky
put 4 into ColorCode
End ColorDecideSky

On ColorDecideGreen
put 3 into ColorCode
End ColorDecideGreen


On ColorDecidePurple
put 5 into ColorCode
End ColorDecidePurple



On mkgraphfrog
if effectiveselection is not 1 then
         put 1 into effectiveselection
end if
if froglevel < 81  then
 set loc of btn %froglevel% to LocH of btn _frog, 320 - (froglevel - 71)* 23
   if colorcode = 1 then
    set bitmap of btn %froglevel% to red
    end if
   if colorcode = 2 then
    set bitmap of btn %froglevel% to yellow
    end if
   if colorcode = 3 then
    set bitmap of btn %froglevel% to green
    end if
   if colorcode = 4 then
    set bitmap of btn %froglevel% to sky
    end if
   if colorcode = 5 then
    set bitmap of btn %froglevel% to purple
    end if
 show btn %froglevel%
 put froglevel + 1 into froglevel
end if

  
End mkgraphfrog

On mkgraphrabit
if effectiveselection is not 2 then
         put 2 into effectiveselection
end if
if rabitlevel < 111  then
 set loc of btn %rabitlevel% to LocH of btn _rabbit, 320 - (rabitlevel - 101)* 23
   if colorcode = 1 then
    set bitmap of btn %rabitlevel% to red
    end if
   if colorcode = 2 then
    set bitmap of btn %rabitlevel% to yellow
    end if
   if colorcode = 3 then
    set bitmap of btn %rabitlevel% to green
    end if
   if colorcode = 4 then
    set bitmap of btn %rabitlevel% to sky
    end if
   if colorcode = 5 then
    set bitmap of btn %rabitlevel% to purple
    end if
 show btn %rabitlevel%
 put rabitlevel + 1 into rabitlevel
end if


End mkgraphrabit







On mkgraphkani
if effectiveselection is not 3 then
         put 3 into effectiveselection
end if
if kanilevel < 101  then
 set loc of btn %kanilevel% to LocH of btn  _crab, 320 - (kanilevel - 91)* 23
   if colorcode = 1 then
    set bitmap of btn %kanilevel% to red
    end if
   if colorcode = 2 then
    set bitmap of btn %kanilevel% to yellow
    end if
   if colorcode = 3 then
    set bitmap of btn %kanilevel% to green
    end if
   if colorcode = 4 then
    set bitmap of btn %kanilevel% to sky
    end if
   if colorcode = 5 then
    set bitmap of btn %kanilevel% to purple
    end if
 show btn %kanilevel%
 put kanilevel + 1 into kanilevel
end if


End mkgraphkani






On mkgraphowl
if effectiveselection is not 4 then
         put 4 into effectiveselection
end if
if owllevel < 121  then
 set loc of btn %owllevel% to LocH of btn _owl, 320 - (owllevel - 111)* 23
   if colorcode = 1 then
    set bitmap of btn %owllevel% to red
    end if
   if colorcode = 2 then
    set bitmap of btn %owllevel% to yellow
    end if
   if colorcode = 3 then
    set bitmap of btn %owllevel% to green
    end if
   if colorcode = 4 then
    set bitmap of btn %owllevel% to sky
    end if
   if colorcode = 5 then
    set bitmap of btn %owllevel% to purple
    end if
 show btn %owllevel%
   put owllevel + 1 into owllevel
end if


End mkgraphowl







On mkgraphrat
if effectiveselection is not 5 then
         put 5 into effectiveselection
end if
if ratlevel < 91  then
 set loc of btn %ratlevel% to LocH of btn _rat, 320 - (ratlevel - 81)* 23
   if colorcode = 1 then
    set bitmap of btn %ratlevel% to red
    end if
   if colorcode = 2 then
    set bitmap of btn %ratlevel% to yellow
    end if
   if colorcode = 3 then
    set bitmap of btn %ratlevel% to green
    end if
   if colorcode = 4 then
    set bitmap of btn %ratlevel% to sky
    end if
   if colorcode = 5 then
    set bitmap of btn %ratlevel% to purple
    end if
 show btn %ratlevel%
put ratlevel + 1 into ratlevel
end if


End mkgraphrat





On EraseGraph
   lock screen
if effectiveselection=5 then
    repeat with ll = 81 to 90
      hide btn %ll%
    end repeat
     put 81 into ratlevel
 end if
if effectiveselection=4 then
    repeat with ll = 111 to 120
      hide btn %ll%
    end repeat
   put 111 into owllevel
 end if
if effectiveselection=3 then
      repeat with ll = 91 to 100
      hide btn %ll%
    end repeat
    put 91 into kanilevel
 end if
if effectiveselection=2 then
    repeat with ll = 101 to 110
      hide btn %ll%
    end repeat
    put 101 into rabitlevel
 end if
if effectiveselection=1 then
    repeat with ll = 71 to 80
      hide btn %ll%
    end repeat
    put 71 into froglevel
 end if
unlock screen
End EraseGraph








On Areyouright
--scramble40
 put (owllevel-110 -1) into a
 put (ratlevel -80 - 1) into b
 put (kanilevel -90 - 1) into c
 put (froglevel -70 -1)  into d
 put (rabitlevel-100 - 1) into e
 if (num_owl= a) and (num_rat = b) and (num_kani = c ) and (num_frog =d) and (num_rabit=e) then
    put 1 into math_answer
   else
    put 0 into math_answer
  end if



  if math_answer is not 1 then
        if math_answer is  -1 then
          play  Uhoh2
        else
              play jawharp
          showwitch_surprised
         end if
  else
           play good
           show_frog_good
show btn t_writer
  message2 289, 31, 9, "Congratulations! You gave the correct answer."
hide btn t_writer
 end if




   put 0 into quiz_quit
  end Areyouright

---------  card40  another Quiz ------------




On quizbargraph
lock screen
show fld covercolor
--show fld 
--hide btn Question
unlock screen
put 0 into score40

repeat 5 times

lock screen
repeat with i = 1 to 10
 put 0 into Item i of usedflag
 put 127 + i -1 into btn_n
 hide btn %btn_n%
end repeat

getitem
put gottenitem +  127 -1 into  btn_n
set loc of btn %btn_n% to  LocH of btn _rat, 218
show btn %btn_n%
put Item gottenitem of barvalue into Item 1 of Comptable

getitem
put gottenitem +  127 -1 into  btn_n
set loc of btn %btn_n% to  LocH of btn _frog, 218
show btn %btn_n%
put Item gottenitem of barvalue into Item 2 of Comptable


getitem
put gottenitem +  127 -1 into  btn_n
set loc of btn %btn_n% to  LocH of btn _owl, 218
show btn %btn_n%
put Item gottenitem of barvalue into Item 3 of Comptable

getitem
put gottenitem +  127 -1 into  btn_n
set loc of btn %btn_n% to  LocH of btn _rabbit, 218
show btn %btn_n%
put Item gottenitem of barvalue into Item 4 of Comptable




getitem
put gottenitem +  127 -1 into  btn_n
set loc of btn %btn_n% to  LocH of btn _crab, 218
show btn %btn_n%
put Item gottenitem of barvalue into Item 5 of Comptable

unlock screen

put Item 1 of CompTable into min
put Item 1 of CompTable into max

repeat with i = 1 to 5
if Item i of comptable < Min then
  put Item i of comptable into min
end if
if Item i of comptable > Max then
  put Item i of comptable into Max
end if

end repeat

put max into min2
put min into max2
repeat with i = 1 to 5
if Item i of comptable < min2 and Item i of comptable is not min then
  put Item i of comptable into min2
end if
if Item i of comptable > max2 and Item i of comptable is not max  then
  put Item i of comptable into Max2
end if

end repeat


put max into min3
put min into max3
repeat with i = 1 to 5
if Item i of comptable < min3 and Item i of comptable is not min and  Item i of comptable is not min2 then
  put Item i of comptable into min3
end if
if Item i of comptable > max3 and Item i of comptable is not max and  Item i of comptable is not max2 then
  put Item i of comptable into Max3
end if

end repeat


put random(6) into t
if t = 1 then
          QuizDlg4 "Input the number of the most dominant animal", Max, left
end if

if t = 2 then
          QuizDlg4 "Input the number of the second most dominant animal", Max2, left
end if

if t = 3 then
          QuizDlg4 "Input the number of the third most dominant animal", Max3, left
end if



if t = 4 then
         QuizDlg4 "Input the number of the most scarce animal", Min, left
 end if

if t = 5 then
         QuizDlg4 "Input the number of the second most scarce animal", Min2, left
 end if

if t = 6 then
         QuizDlg4 "Input the number of the third most scarce animal", Min3, left
 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 score40 + 1 into score40
      end if
end repeat
lock screen
hide fld covercolor
--hide fld measurestick
repeat with i = 1 to 10
 put 0 into Item i of usedflag
 put 127 + i -1 into btn_n
 hide btn %btn_n%
end repeat
show btn "Question"
unlock screen
if score40 = 5 then
  ok100
end if
if score40 = 4 then
  ok80
end if

if score40 = 3 then
  ok60
end if


End quizbargraph


On getitem
put random(10) into itemx
 repeat with xxx = itemx to 10
if Item xxx of usedflag = 0 then
    put 1 into Item xxx of usedflag
    put xxx into gottenitem
    exit getitem
end if
end repeat
 repeat with xxx = 1 to itemx
if Item xxx of usedflag = 0 then
    put 1 into Item xxx of usedflag
    put xxx into gottenitem
    exit getitem
end if
end repeat
End getitem


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


On quizbargraph_2
lock screen
show fld covercolor
unlock screen
put 0 into score40

repeat 2 times

lock screen
repeat with i = 1 to 10
 put 0 into Item i of usedflag
 put 127 + i -1 into btn_n
 hide btn %btn_n%
end repeat

getitem
put gottenitem +  127 -1 into  btn_n
set loc of btn %btn_n% to  LocH of btn _rat, 218
show btn %btn_n%
put Item gottenitem of barvalue into Item 1 of Comptable

getitem
put gottenitem +  127 -1 into  btn_n
set loc of btn %btn_n% to  LocH of btn _frog, 218
show btn %btn_n%
put Item gottenitem of barvalue into Item 2 of Comptable


getitem
put gottenitem +  127 -1 into  btn_n
set loc of btn %btn_n% to  LocH of btn _owl, 218
show btn %btn_n%
put Item gottenitem of barvalue into Item 3 of Comptable

getitem
put gottenitem +  127 -1 into  btn_n
set loc of btn %btn_n% to  LocH of btn _rabbit, 218
show btn %btn_n%
put Item gottenitem of barvalue into Item 4 of Comptable




getitem
put gottenitem +  127 -1 into  btn_n
set loc of btn %btn_n% to  LocH of btn _crab, 218
show btn %btn_n%
put Item gottenitem of barvalue into Item 5 of Comptable

unlock screen

put Item 1 of CompTable into min
put Item 1 of CompTable into max

repeat with i = 1 to 5
if Item i of comptable < Min then
  put Item i of comptable into min
end if
if Item i of comptable > Max then
  put Item i of comptable into Max
end if

end repeat

put max into min2
put min into max2
repeat with i = 1 to 5
if Item i of comptable < min2 and Item i of comptable is not min then
  put Item i of comptable into min2
end if
if Item i of comptable > max2 and Item i of comptable is not max  then
  put Item i of comptable into Max2
end if

end repeat


put max into min3
put min into max3
repeat with i = 1 to 5
if Item i of comptable < min3 and Item i of comptable is not min and  Item i of comptable is not min2 then
  put Item i of comptable into min3
end if
if Item i of comptable > max3 and Item i of comptable is not max and  Item i of comptable is not max2 then
  put Item i of comptable into Max3
end if

end repeat




put random(6) into t
if t = 1 then
          QuizDlg4 "Input the number of the most dominant animal", Max, left
end if

if t = 2 then
          QuizDlg4 "Input the number of the second most dominant animal", Max2, left
end if

if t = 3 then
          QuizDlg4 "Input the number of the third most dominant animal", Max3, left
end if



if t = 4 then
         QuizDlg4 "Input the number of the most scarce animal", Min, left
 end if

if t = 5 then
         QuizDlg4 "Input the number of the second most scarce animal", Min2, left
 end if

if t = 6 then
         QuizDlg4 "Input the number of the third most scarce animal", Min3, left
 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
          exit repeat

          end if
       else
           play good
           show_frog_good
           put score40 + 1 into score40
      end if
end repeat
lock screen
hide fld covercolor
--hide fld measurestick
repeat with i = 1 to 10
 put 0 into Item i of usedflag
 put 127 + i -1 into btn_n
 hide btn %btn_n%
end repeat
show btn Question
unlock screen
if score40 = 5 then
  ok100
end if
if score40 = 4 then
  ok80
end if

if score40 = 3 then
  ok60
end if


End quizbargraph_2

