home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / hypercar / game / hypersha.sit / HyperShanghai / stack.txt < prev   
Encoding:
Text File  |  1991-05-30  |  9.9 KB  |  359 lines

  1. -- stack: in
  2. -- format: 8 (HyperCard 1)
  3. -- flags: 0x1000 (none)
  4. -- protect password hash: 0
  5. -- maximum user level: 5 (scripting)
  6. -- window: Rect(x1=0, y1=0, x2=0, y2=0)
  7. -- screen: Rect(x1=0, y1=0, x2=0, y2=0)
  8. -- card dimensions: w=0 h=0
  9. -- scroll: x=0 y=0
  10. -- background count: 3
  11. -- first background id: 2740
  12. -- card count: 17
  13. -- first card id: 4426
  14. -- list block id: 2365
  15. -- print block id: 2185
  16. -- font table block id: 0
  17. -- style table block id: 0
  18. -- free block count: 5
  19. -- free size: 32064 bytes
  20. -- total size: 124928 bytes
  21. -- stack block size: 9216 bytes
  22. -- created by hypercard version: 0x01228000
  23. -- compacted by hypercard version: 0x01228000
  24. -- modified by hypercard version: 0x01228000
  25. -- opened by hypercard version: 0x01258000
  26. -- patterns[0]: 0x0000000000000000
  27. -- patterns[1]: 0x8000000008000000
  28. -- patterns[2]: 0x8800220088002200
  29. -- patterns[3]: 0x8888222288882222
  30. -- patterns[4]: 0x88AA22AA88AA22AA
  31. -- patterns[5]: 0xCCAA33AACCAA33AA
  32. -- patterns[6]: 0xEEAABBAAEEAABBAA
  33. -- patterns[7]: 0xEEBBBBEEEEBBBBEE
  34. -- patterns[8]: 0xFFBBFFEEFFBBFFEE
  35. -- patterns[9]: 0xFFBBFFFFFFBBFFFF
  36. -- patterns[10]: 0x8010022001084004
  37. -- patterns[11]: 0xFFFFFFFFFFFFFFFF
  38. -- patterns[12]: 0x8822882288228822
  39. -- patterns[13]: 0x1122448811224488
  40. -- patterns[14]: 0xC4800C6843023026
  41. -- patterns[15]: 0xB130031BD8C00C8D
  42. -- patterns[16]: 0xAA00AA00AA00AA00
  43. -- patterns[17]: 0x8822552288225522
  44. -- patterns[18]: 0x8855225588552255
  45. -- patterns[19]: 0x77DD77DD77DD77DD
  46. -- patterns[20]: 0x8000000000000000
  47. -- patterns[21]: 0xAA55AA55AA55AA55
  48. -- patterns[22]: 0x038448300C020101
  49. -- patterns[23]: 0x8244394482010101
  50. -- patterns[24]: 0x8814224188412214
  51. -- patterns[25]: 0x8080413E080814E3
  52. -- patterns[26]: 0x22048C7422179810
  53. -- patterns[27]: 0xBE808808EB088880
  54. -- patterns[28]: 0x25C8328964244C92
  55. -- patterns[29]: 0xA29C41BE2AC914EB
  56. -- patterns[30]: 0x40A00000040A0000
  57. -- patterns[31]: 0x8040200002040800
  58. -- patterns[32]: 0xAA00800088008000
  59. -- patterns[33]: 0xFF80808080808080
  60. -- patterns[34]: 0x081C22C180010204
  61. -- patterns[35]: 0xFF808080FF080808
  62. -- patterns[36]: 0xF87422478F172271
  63. -- patterns[37]: 0xBF00BFBFB0B0B0B0
  64. -- patterns[38]: 0xFF7FBE5DA2418000
  65. -- patterns[39]: 0xFAF5FAF5A050A050
  66. -- checksum: 0x0
  67. ----- HyperTalk script -----
  68. on openStack
  69.   global tileOne
  70.   global tileTwo
  71.   global ShangMenu
  72.   global peekFlag
  73.   hide menubar
  74.   put NewMenu("HyperShanghai"," New Deal"," Restart", " Symbols"," Peek"," Open Game"," Save Game") into ShangMenu
  75.   put empty into tileOne
  76.   put empty into tileTwo
  77.   put false into peekFlag
  78. end openStack
  79.  
  80. on closestack
  81.   global peekFlag
  82.   global ShangMenu
  83.   put DeleteMenu(ShangMenu) into ShangMenu
  84.   if peekFlag then send mouseUp to btn "done" of cd game
  85. end closestack
  86.  
  87. function shuffle icon
  88. put cd fld ("icons," & icon) of cd info into theTiles
  89. repeat with x = 1 to 144
  90.   set the cursor to busy
  91.   put random(144) into theRand
  92.   put line theRand of theTiles into theLine
  93.   put return & line x of theTiles after line theRand of theTiles
  94.   delete line theRand of theTiles
  95.   delete line x of theTiles
  96.   put theLine & return before line x of theTiles
  97. end repeat
  98. return theTiles
  99. end shuffle
  100.  
  101. on deal
  102.   set cursor to watch
  103.   repeat with x = 1 to 144
  104.     go cd game
  105.     set the icon of btn (line x of cd fld buttons of cd info) to (line x of cd fld Tiles of cd info)
  106.   end repeat
  107. end deal
  108.  
  109. on resetOpen
  110.   set cursor to watch
  111.   go cd game
  112.   repeat with x = 1 to 144
  113.     show btn (line x of cd fld buttons of cd info)
  114.     set the icon of btn (line x of cd fld buttons of cd info) to 0
  115.   end repeat
  116.   repeat with x = 1 to 56
  117.     show fld x
  118.   end repeat
  119.   put "144" into cd fld left
  120. end resetOpen
  121.  
  122. on subRestart
  123.   go cd game
  124.   repeat with x = 1 to 144
  125.     show btn (line x of cd fld buttons of cd info)
  126.   end repeat
  127.   repeat with x = 1 to 56
  128.     show fld x
  129.   end repeat
  130.   put "144" into cd fld left
  131. end subRestart
  132.  
  133. on Restart
  134.   answer "Are you sure you want to restart this hand?" with "Restart!" or "Cancel"
  135.   if it is "Restart!" then
  136.     set cursor to watch
  137.     put empty into cd fld "Undo"
  138.     lock screen
  139.     subRestart
  140.     put "Pick an open tile." into cd fld window
  141.     symbolReset
  142.     unlock screen with visual dissolve slowly
  143.   end if
  144. end Restart
  145.  
  146. on newDeal
  147.   answer "Are you sure you want a new deal?" with "Deal um!" or "Cancel"
  148.   if it is "Deal um!" then
  149.     set cursor to watch
  150.     put empty into cd fld "Undo"
  151.     lock screen
  152.     put shuffle("Music") into cd fld tiles of cd info
  153.     go cd game
  154.     deal
  155.     subRestart
  156.     put "Pick an open tile." into cd fld window
  157.     symbolReset
  158.     unlock screen with visual dissolve slowly
  159.   end if
  160. end newDeal
  161.  
  162. on Peek
  163.   global peekFlag
  164.   global shangMenu
  165.   set cursor to watch
  166.   lock screen
  167.   go cd game
  168.   hide btn help
  169.   enableMenu shangMenu,4,False
  170.   set the icon of btn "level1" to 0
  171.   set the icon of btn "level2" to 0
  172.   set the icon of btn "level3" to 0
  173.   set the icon of btn "level4" to 0
  174.   put true into peekFlag
  175.   repeat with x = 185 to 190
  176.     show btn x
  177.   end repeat
  178.   show cd fld "Peek"
  179.   unlock screen with visual dissolve
  180. end Peek
  181.  
  182. on saveGame
  183.   global tileOne
  184.   global tileTwo
  185.   put FileSave() into fName
  186.   if fName is not empty then
  187.     lock screen
  188.     if tileOne is not empty then
  189.       set the highlite of btn tileOne to false
  190.       put empty into tileOne
  191.     end if
  192.     if tileTwo is not empty then
  193.       set the highlite of btn tileTwo to false
  194.       put empty into tileTwo
  195.     end if
  196.     open file fName
  197.     put empty into saveRecord
  198.     put cd fld left & return into saveRecord
  199.     repeat with x = 1 to the number of lines of cd fld buttons of cd info
  200.       set the cursor to busy
  201.       get line x of cd fld buttons of cd info
  202.       put the visible of btn it into theVis
  203.       put the icon of btn it into theIcon
  204.       put (theVis & "," & theIcon & return) after saveRecord
  205.     end repeat
  206.     repeat with x = 1 to 36
  207.       set the cursor to busy
  208.       put (cd fld x of cd symbols & return) after saveRecord
  209.     end repeat
  210.     put return after saveRecord
  211.     write saveRecord to file fName
  212.     close file fName
  213.     unlock screen with visual dissolve
  214.   end if
  215. end saveGame
  216.  
  217. on openGame
  218.   global tileOne
  219.   global tileTwo
  220.   put FileName("TEXT") into fName
  221.   if fName is not empty then
  222.     lock screen
  223.     open file fName
  224.     if tileOne is not empty then
  225.       set the highlite of btn tileOne to false
  226.       put empty into tileOne
  227.     end if
  228.     if tileTwo is not empty then
  229.       set the highlite of btn tileTwo to false
  230.       put empty into tileTwo
  231.     end if
  232.     read from file fName until return
  233.     put it into cd fld left
  234.     repeat with x = 1 to the number of lines of cd fld buttons of cd info
  235.       set the cursor to busy
  236.       put line x of cd fld buttons of cd info into theBtn
  237.       read from file fName until return
  238.       set the visible of btn theBtn to item 1 of it
  239.       set the icon of btn theBtn to item 2 of it
  240.       if theBtn > 102 then
  241.         if item 1 of it then
  242.           show fld ("x" & theBtn)
  243.         else
  244.           hide fld ("x" & theBtn)
  245.         end if
  246.       end if
  247.     end repeat
  248.     repeat with x = 1 to 36
  249.       set the cursor to busy
  250.       read from file fName until return
  251.       put it into cd fld x of cd symbols
  252.     end repeat
  253.     close file fName
  254.     put "Pick and open tile." into cd fld window
  255.     unlock screen with visual dissolve
  256.   end if
  257. end openGame
  258.  
  259. function tileOpen theNum
  260. if theNum is 54 then
  261.   put (the visible of btn 38 of cd game) and (the visible of btn 55 of cd game) into theOpen
  262. else
  263.   if theNum is 65 then
  264.     put (the visible of btn 64 of cd game) and (the visible of btn 51 of cd game) into theOpen
  265.   else
  266.     if (theNum > 174) and (theNum < 183) then
  267.       put (the visible of btn (theNum - 1) of cd game) and (the visible of btn (theNum + 1)of cd game) into theOpen
  268.       put theOpen or (the visible of btn 183 of cd game) into theOpen
  269.     else
  270.       put (the visible of btn (theNum - 1 )of cd game) and (the visible of btn (theNum + 1) of cd game) into theOpen
  271.     end if
  272.   end if
  273. end if
  274. put not theOpen into theOpen
  275. return theOpen
  276. end tileOpen
  277.  
  278. on symbolReset
  279.   repeat with x = 1 to 36
  280.     put 4 into cd fld x of cd symbols
  281.   end repeat
  282. end symbolReset
  283.  
  284. on doMenu which
  285.   global tileOne
  286.   global tileTwo
  287.   if first char of which is " " then
  288.     put which into Com
  289.     delete char 1 of Com
  290.     if Com is "New Deal" then
  291.       go cd game
  292.       NewDeal
  293.     end if
  294.     if Com is "Restart" then
  295.       go cd game
  296.       Restart
  297.     end if
  298.     if Com is "Symbols" then
  299.       lock screen
  300.       hide menubar
  301.       go cd Symbols
  302.       unlock screen with visual wipe left slowly
  303.     end if
  304.     if Com is "Peek" then
  305.       Peek
  306.     end if
  307.     if Com is "Open Game" then
  308.       openGame
  309.     end if
  310.     if Com is "Save Game" then
  311.       saveGame
  312.     end if
  313.     --  else
  314.     --    if which is "Undo" then
  315.     --      if cd fld "Undo" is empty then
  316.     --        answer "Can't Undo!" with "Sorry"
  317.     --     else
  318.     --       if tileOne is not empty then
  319.     --         set the hilight of btn tileOne to false
  320.     --         put empty into tileOne
  321.     --       end if
  322.     --      if tileTwo is not empty then
  323.     --         set the hilight of btn tileTwo to false
  324.     --         put empty into tileTwo
  325.     --        end if
  326.     --       put item 1 of line 1 of cd fld "Undo" into firstTile
  327.     --        put item 2 of line 1 of cd fld "Undo" into secondTile
  328.     --        show btn firstTile
  329.     --        show btn secondTile
  330.     --        add 2 to cd fld left
  331.     --        if firstTile > 102 then
  332.     --          show bg fld ("x" & firstTile)
  333.     --        end if
  334.     --        if secondTile > 102 then
  335.     --          show bg fld ("x" & secondTile)
  336.     --        end if
  337.     --        put the icon of btn firstTile into theIcon
  338.     --        subtract 10000 from theIcon
  339.     --        add 2 to cd fld theIcon of cd symbols
  340.     --       put empty into cd fld "Undo"
  341.     --       put "Pick an open tile." into cd fld window
  342.     --        hide bg btn "Remove Tiles"
  343.     --      end if
  344.   else
  345.     pass doMenu
  346.     -- end if
  347.   end if
  348. end doMenu
  349.  
  350. on idle
  351.   global ShangMenu,lastTick, sessionStart, prevGame
  352.   if (the ticks-lastTick)>120 then
  353.     put the ticks into lastTick
  354.     showMenu(ShangMenu)
  355.   end if
  356. end idle
  357.  
  358.  
  359.