home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0" encoding="utf-8" ?>
- <!DOCTYPE background PUBLIC "-//Apple, Inc.//DTD background V 2.0//EN" "" >
- <background>
- <id>2788</id>
- <filler1>0</filler1>
- <bitmap>BMAP_3694.pbm</bitmap>
- <cantDelete> <true /> </cantDelete>
- <showPict> <true /> </showPict>
- <dontSearch> <false /> </dontSearch>
- <link rel="stylesheet" type="text/css" href="stylesheet_3183.css" />
- <part>
- <id>1</id>
- <type>field</type>
- <visible> <true /> </visible>
- <dontWrap> <false /> </dontWrap>
- <dontSearch> <false /> </dontSearch>
- <sharedText> <false /> </sharedText>
- <fixedLineHeight> <true /> </fixedLineHeight>
- <autoTab> <false /> </autoTab>
- <lockText> <true /> </lockText>
- <rect>
- <left>11</left>
- <top>9</top>
- <right>317</right>
- <bottom>309</bottom>
- </rect>
- <style>transparent</style>
- <autoSelect> <false /> </autoSelect>
- <showLines> <false /> </showLines>
- <wideMargins> <false /> </wideMargins>
- <multipleLines> <false /> </multipleLines>
- <reservedFamily> 0 </reservedFamily>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>left</textAlign>
- <font>Monaco</font>
- <textSize>16</textSize>
- <textStyle>plain</textStyle>
- <textHeight>30</textHeight>
- <name>Ours</name>
- <script></script>
- </part>
- <part>
- <id>2</id>
- <type>field</type>
- <visible> <true /> </visible>
- <dontWrap> <false /> </dontWrap>
- <dontSearch> <true /> </dontSearch>
- <sharedText> <false /> </sharedText>
- <fixedLineHeight> <true /> </fixedLineHeight>
- <autoTab> <false /> </autoTab>
- <lockText> <true /> </lockText>
- <rect>
- <left>11</left>
- <top>329</top>
- <right>318</right>
- <bottom>630</bottom>
- </rect>
- <style>transparent</style>
- <autoSelect> <false /> </autoSelect>
- <showLines> <false /> </showLines>
- <wideMargins> <false /> </wideMargins>
- <multipleLines> <false /> </multipleLines>
- <reservedFamily> 0 </reservedFamily>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>left</textAlign>
- <font>Monaco</font>
- <textSize>16</textSize>
- <textStyle>plain</textStyle>
- <textHeight>30</textHeight>
- <name>Enemy</name>
- <script>-----------------------------------------------------------------------
- --
- -- STACK: HyperBattleship 2.1 7/25/91
- -- © Copyright 1991 by Claris Corporation, All Rights Reserved
- -- By The HyperCard Development Team
- --
- -- HANDLERS USED IN THIS SCRIPT:
- -- mouseUp
- --
- -- LEGEND:
- -- "--Γêå" indicates strings which would need localization
- -----------------------------------------------------------------------
-
- on mouseUp
- -- If it is our turn to make a move, fire a shot at our opponent.
- -- Note: A shot is fired by sending the ΓÇ£hbsMoveΓÇ¥ message to our
- -- opponent with AppleEvents.
- put hbsStatus() into curStatus
-
- if curStatus is "Ready" then
- put gridItem(the clickLoc,rect of me) into gridClick
-
- -- Compute the row and column for this grid.
- put gridCharLocation(gridClick) into RowColumn
- --
- -- Verify that we have not already selected this grid item.
- put char item 1 of RowColumn of line item 2 of RowColumn of me ¬
- into CurChar
- if CurChar Γëá " " and CurChar Γëá numToChar(215) then
- beep
- status "This square has already been played." --Γêå
- pass mouseUp
- end if
-
- -- Fire shot - put temporary marker.
- play "ShellIncoming"
- put numToChar(215) into ¬
- char item 1 of RowColumn of line item 2 of RowColumn of me
- put myID() into SaveID
- --
- status "Shot fired. Waiting for reconnaissance." --Γêå
- send "hbsMove " ¬
- & quote & gridClick & quote & ", " ¬
- & quote & challengerID() & quote ¬
- & "" to program challenger()
- put the result into sendResult
- --
- -- In case we went somewhere, go back to where we were.
- showOpponentMap
- --
- -- Respond to all possible results.
- if sendResult is "Hit" ¬
- or sendResult is "Sunk" then
- animateHit gridClick, empty, "Enemy"
- put numToChar(165) into ¬
- char item 1 of RowColumn of line item 2 of RowColumn of me
- if sendResult is "Sunk" then
- repeat for 30 -- Play a sunk sound.
- play (any item of "Sunk 1,Sunk 2,Sunk 3")¬
- (any item of "rt,rt,g2s,c3t,g3x")
- end repeat
- status "You have sunk a ship." --Γêå
- else
- status "You have hit a ship." --Γêå
- end if
- if the address Γëá challenger() then
- status "Waiting for opponent to move.", "Status" --Γêå
- end if
-
- else if sendResult is "Miss" then
- animateMiss gridClick, "Enemy"
- put numToChar(219) into ¬
- char item 1 of RowColumn of line item 2 of RowColumn of me
- status "You have missed." --Γêå
- if the address Γëá challenger() then
- status "Waiting for opponent to move.", "Status" --Γêå
- end if
-
- else if sendResult is "End" then
- animateHit gridClick, empty, "Enemy"
- put numToChar(165) into ¬
- char item 1 of RowColumn of line item 2 of RowColumn of me
- repeat for 30 -- Play a sunk sound.
- play (any item of "Sunk 1,Sunk 2,Sunk 3") ¬
- (any item of "rt,rt,s,t,x")
- end repeat
- status "End of game.", "Status" --Γêå
- status "You have sunk all your opponent's ships!" --Γêå
- play flute tempo 190 "Bb3h D4q F Gq. De Gh Bbh C5q F4q" && ¬
- "Bbw G4h Bbq G F G A Bb4 D5e. Bb4s Fe Bb C5e. A4s Fe A Bbw"
- answer line random(9) of bg fld "Win"
- send "hbsMove " ¬
- & quote & "End" & quote & ", " ¬
- & quote & challengerID() & quote & ", " ¬
- & quote & shipLoc() & quote ¬
- & "" to program challenger()
- put the result into sendResult
-
- else -- We have a problem otherwise.
- put " " into ¬
- char item 1 of RowColumn of line item 2 of RowColumn of me
- if sendResult is "Busy" then
- status "Opponent is not ready. They might still be placing their" ¬
- && "ships. Try again." --Γêå
- else --if sendResult is "Timeout" then
- status "The opponent did not respond. They might have quit" && ¬
- "without telling you. Try again or quit and start over." --Γêå
- end if
- pass mouseUp
- end if
-
- else if curStatus is "Waiting" then
- status "Message: It is not your turn." --Γêå
- play "Ping"
- else if curStatus is "End" then
- status "The game is over." & " " ¬
- & "Click the ΓÇ£QuitΓÇ¥ button game options." --Γêå
- end if
- pass mouseUp
- end mouseUp
-
- </script>
- </part>
- <part>
- <id>3</id>
- <type>field</type>
- <visible> <true /> </visible>
- <dontWrap> <false /> </dontWrap>
- <dontSearch> <false /> </dontSearch>
- <sharedText> <false /> </sharedText>
- <fixedLineHeight> <false /> </fixedLineHeight>
- <autoTab> <false /> </autoTab>
- <lockText> <true /> </lockText>
- <rect>
- <left>339</left>
- <top>28</top>
- <right>492</right>
- <bottom>126</bottom>
- </rect>
- <style>rectangle</style>
- <autoSelect> <false /> </autoSelect>
- <showLines> <false /> </showLines>
- <wideMargins> <false /> </wideMargins>
- <multipleLines> <false /> </multipleLines>
- <reservedFamily> 0 </reservedFamily>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>left</textAlign>
- <font>Geneva</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <textHeight>16</textHeight>
- <name>Status</name>
- <script></script>
- </part>
- <part>
- <id>4</id>
- <type>button</type>
- <visible> <true /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>334</left>
- <top>279</top>
- <right>365</right>
- <bottom>310</bottom>
- </rect>
- <style>transparent</style>
- <showName> <false /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <true /> </autoHighlight>
- <sharedHighlight> <false /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>2335</icon>
- <textAlign>center</textAlign>
- <font>Chicago</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <name>Down</name>
- <script>on mouseUp
- showOpponentMap
- end mouseUp</script>
- </part>
- <part>
- <id>7</id>
- <type>button</type>
- <visible> <false /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>134</left>
- <top>249</top>
- <right>164</right>
- <bottom>279</bottom>
- </rect>
- <style>transparent</style>
- <showName> <false /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <false /> </autoHighlight>
- <sharedHighlight> <true /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>5018</icon>
- <textAlign>center</textAlign>
- <font>Chicago</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <name>Carrier 1 H</name>
- <script>on mouseDown
- dragShip 1, "7,9,10,11,12", topleft of bg btn id 7 & "," ¬
- & bottomRight of bg btn id 12
- pass mouseDown
- end mouseDown</script>
- </part>
- <part>
- <id>9</id>
- <type>button</type>
- <visible> <false /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>164</left>
- <top>249</top>
- <right>194</right>
- <bottom>279</bottom>
- </rect>
- <style>transparent</style>
- <showName> <false /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <false /> </autoHighlight>
- <sharedHighlight> <true /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>5019</icon>
- <textAlign>center</textAlign>
- <font>Chicago</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <name>Carrier 2</name>
- <script>on mouseDown
- dragShip 1, "7,9,10,11,12", topleft of bg btn id 7 & "," ¬
- & bottomRight of bg btn id 12
- pass mouseDown
- end mouseDown</script>
- </part>
- <part>
- <id>10</id>
- <type>button</type>
- <visible> <false /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>194</left>
- <top>249</top>
- <right>224</right>
- <bottom>279</bottom>
- </rect>
- <style>transparent</style>
- <showName> <false /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <false /> </autoHighlight>
- <sharedHighlight> <true /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>5020</icon>
- <textAlign>center</textAlign>
- <font>Chicago</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <name>Carrier 3</name>
- <script>on mouseDown
- dragShip 1, "7,9,10,11,12", topleft of bg btn id 7 & "," ¬
- & bottomRight of bg btn id 12
- pass mouseDown
- end mouseDown</script>
- </part>
- <part>
- <id>11</id>
- <type>button</type>
- <visible> <false /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>224</left>
- <top>249</top>
- <right>254</right>
- <bottom>279</bottom>
- </rect>
- <style>transparent</style>
- <showName> <false /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <false /> </autoHighlight>
- <sharedHighlight> <true /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>5021</icon>
- <textAlign>center</textAlign>
- <font>Chicago</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <name>Carrier 4</name>
- <script>on mouseDown
- dragShip 1, "7,9,10,11,12", topleft of bg btn id 7 & "," ¬
- & bottomRight of bg btn id 12
- pass mouseDown
- end mouseDown</script>
- </part>
- <part>
- <id>12</id>
- <type>button</type>
- <visible> <false /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>254</left>
- <top>249</top>
- <right>284</right>
- <bottom>279</bottom>
- </rect>
- <style>transparent</style>
- <showName> <false /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <false /> </autoHighlight>
- <sharedHighlight> <true /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>5022</icon>
- <textAlign>center</textAlign>
- <font>Chicago</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <name>Carrier 5</name>
- <script>on mouseDown
- dragShip 1, "7,9,10,11,12", topleft of bg btn id 7 & "," ¬
- & bottomRight of bg btn id 12
- pass mouseDown
- end mouseDown</script>
- </part>
- <part>
- <id>13</id>
- <type>button</type>
- <visible> <false /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>44</left>
- <top>159</top>
- <right>74</right>
- <bottom>189</bottom>
- </rect>
- <style>transparent</style>
- <showName> <false /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <false /> </autoHighlight>
- <sharedHighlight> <true /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>5023</icon>
- <textAlign>center</textAlign>
- <font>Chicago</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <name>Battleship 1 H</name>
- <script>on mouseDown
- dragShip 2, "13,14,15,16", topleft of bg btn id 13 & "," ¬
- & bottomRight of bg btn id 16
- pass mouseDown
- end mouseDown</script>
- </part>
- <part>
- <id>14</id>
- <type>button</type>
- <visible> <false /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>74</left>
- <top>159</top>
- <right>104</right>
- <bottom>189</bottom>
- </rect>
- <style>transparent</style>
- <showName> <false /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <false /> </autoHighlight>
- <sharedHighlight> <true /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>5024</icon>
- <textAlign>center</textAlign>
- <font>Chicago</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <name>Battleship 2</name>
- <script>on mouseDown
- dragShip 2, "13,14,15,16", topleft of bg btn id 13 & "," ¬
- & bottomRight of bg btn id 16
- pass mouseDown
- end mouseDown</script>
- </part>
- <part>
- <id>15</id>
- <type>button</type>
- <visible> <false /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>104</left>
- <top>159</top>
- <right>134</right>
- <bottom>189</bottom>
- </rect>
- <style>transparent</style>
- <showName> <false /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <false /> </autoHighlight>
- <sharedHighlight> <true /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>5025</icon>
- <textAlign>center</textAlign>
- <font>Chicago</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <name>Battleship 3</name>
- <script>on mouseDown
- dragShip 2, "13,14,15,16", topleft of bg btn id 13 & "," ¬
- & bottomRight of bg btn id 16
- pass mouseDown
- end mouseDown</script>
- </part>
- <part>
- <id>16</id>
- <type>button</type>
- <visible> <false /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>134</left>
- <top>159</top>
- <right>164</right>
- <bottom>189</bottom>
- </rect>
- <style>transparent</style>
- <showName> <false /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <false /> </autoHighlight>
- <sharedHighlight> <true /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>5026</icon>
- <textAlign>center</textAlign>
- <font>Chicago</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <name>Battleship 4</name>
- <script>on mouseDown
- dragShip 2, "13,14,15,16", topleft of bg btn id 13 & "," ¬
- & bottomRight of bg btn id 16
- pass mouseDown
- end mouseDown</script>
- </part>
- <part>
- <id>17</id>
- <type>button</type>
- <visible> <false /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>194</left>
- <top>159</top>
- <right>224</right>
- <bottom>189</bottom>
- </rect>
- <style>transparent</style>
- <showName> <false /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <false /> </autoHighlight>
- <sharedHighlight> <true /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>5027</icon>
- <textAlign>center</textAlign>
- <font>Chicago</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <name>Destroyer 1 H</name>
- <script>on mouseDown
- dragShip 3, "17,19,20", topleft of bg btn id 17 & "," ¬
- & bottomRight of bg btn id 20
- pass mouseDown
- end mouseDown</script>
- </part>
- <part>
- <id>19</id>
- <type>button</type>
- <visible> <false /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>224</left>
- <top>159</top>
- <right>254</right>
- <bottom>189</bottom>
- </rect>
- <style>transparent</style>
- <showName> <false /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <false /> </autoHighlight>
- <sharedHighlight> <true /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>5028</icon>
- <textAlign>center</textAlign>
- <font>Chicago</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <name>Destroyer 2</name>
- <script>on mouseDown
- dragShip 3, "17,19,20", topleft of bg btn id 17 & "," ¬
- & bottomRight of bg btn id 20
- pass mouseDown
- end mouseDown</script>
- </part>
- <part>
- <id>20</id>
- <type>button</type>
- <visible> <false /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>254</left>
- <top>159</top>
- <right>284</right>
- <bottom>189</bottom>
- </rect>
- <style>transparent</style>
- <showName> <false /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <false /> </autoHighlight>
- <sharedHighlight> <true /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>5029</icon>
- <textAlign>center</textAlign>
- <font>Chicago</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <name>Destroyer 3</name>
- <script>on mouseDown
- dragShip 3, "17,19,20", topleft of bg btn id 17 & "," ¬
- & bottomRight of bg btn id 20
- pass mouseDown
- end mouseDown</script>
- </part>
- <part>
- <id>21</id>
- <type>button</type>
- <visible> <false /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>194</left>
- <top>99</top>
- <right>224</right>
- <bottom>129</bottom>
- </rect>
- <style>transparent</style>
- <showName> <false /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <false /> </autoHighlight>
- <sharedHighlight> <true /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>5030</icon>
- <textAlign>center</textAlign>
- <font>Chicago</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <name>Submarine 1 H</name>
- <script>on mouseDown
- dragShip 4, "21,22,23", topleft of bg btn id 21 & "," ¬
- & bottomRight of bg btn id 23
- pass mouseDown
- end mouseDown</script>
- </part>
- <part>
- <id>22</id>
- <type>button</type>
- <visible> <false /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>224</left>
- <top>99</top>
- <right>254</right>
- <bottom>129</bottom>
- </rect>
- <style>transparent</style>
- <showName> <false /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <false /> </autoHighlight>
- <sharedHighlight> <true /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>5031</icon>
- <textAlign>center</textAlign>
- <font>Chicago</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <name>Submarine 2</name>
- <script>on mouseDown
- dragShip 4, "21,22,23", topleft of bg btn id 21 & "," ¬
- & bottomRight of bg btn id 23
- pass mouseDown
- end mouseDown</script>
- </part>
- <part>
- <id>23</id>
- <type>button</type>
- <visible> <false /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>254</left>
- <top>99</top>
- <right>284</right>
- <bottom>129</bottom>
- </rect>
- <style>transparent</style>
- <showName> <false /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <false /> </autoHighlight>
- <sharedHighlight> <true /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>5032</icon>
- <textAlign>center</textAlign>
- <font>Chicago</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <name>Submarine 3</name>
- <script>on mouseDown
- dragShip 4, "21,22,23", topleft of bg btn id 21 & "," ¬
- & bottomRight of bg btn id 23
- pass mouseDown
- end mouseDown</script>
- </part>
- <part>
- <id>26</id>
- <type>button</type>
- <visible> <false /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>134</left>
- <top>69</top>
- <right>164</right>
- <bottom>99</bottom>
- </rect>
- <style>transparent</style>
- <showName> <false /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <false /> </autoHighlight>
- <sharedHighlight> <true /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>5033</icon>
- <textAlign>center</textAlign>
- <font>Chicago</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <name>Patrol 1 H</name>
- <script>on mouseDown
- dragShip 5, "26,27", topleft of bg btn id 26 & "," ¬
- & bottomRight of bg btn id 27
- pass mouseDown
- end mouseDown</script>
- </part>
- <part>
- <id>27</id>
- <type>button</type>
- <visible> <false /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>164</left>
- <top>69</top>
- <right>194</right>
- <bottom>99</bottom>
- </rect>
- <style>transparent</style>
- <showName> <false /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <false /> </autoHighlight>
- <sharedHighlight> <true /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>5034</icon>
- <textAlign>center</textAlign>
- <font>Chicago</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <name>Patrol 2</name>
- <script>on mouseDown
- dragShip 5, "26,27", topleft of bg btn id 26 & "," ¬
- & bottomRight of bg btn id 27
- pass mouseDown
- end mouseDown</script>
- </part>
- <part>
- <id>28</id>
- <type>field</type>
- <visible> <true /> </visible>
- <dontWrap> <false /> </dontWrap>
- <dontSearch> <true /> </dontSearch>
- <sharedText> <false /> </sharedText>
- <fixedLineHeight> <false /> </fixedLineHeight>
- <autoTab> <false /> </autoTab>
- <lockText> <true /> </lockText>
- <rect>
- <left>339</left>
- <top>547</top>
- <right>492</right>
- <bottom>597</bottom>
- </rect>
- <style>rectangle</style>
- <autoSelect> <false /> </autoSelect>
- <showLines> <false /> </showLines>
- <wideMargins> <false /> </wideMargins>
- <multipleLines> <false /> </multipleLines>
- <reservedFamily> 0 </reservedFamily>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>left</textAlign>
- <font>Geneva</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <textHeight>16</textHeight>
- <name>Challenger</name>
- <script>
- </script>
- </part>
- <part>
- <id>29</id>
- <type>field</type>
- <visible> <false /> </visible>
- <dontWrap> <false /> </dontWrap>
- <dontSearch> <false /> </dontSearch>
- <sharedText> <false /> </sharedText>
- <fixedLineHeight> <false /> </fixedLineHeight>
- <autoTab> <false /> </autoTab>
- <lockText> <true /> </lockText>
- <rect>
- <left>467</left>
- <top>635</top>
- <right>512</right>
- <bottom>640</bottom>
- </rect>
- <style>transparent</style>
- <autoSelect> <false /> </autoSelect>
- <showLines> <false /> </showLines>
- <wideMargins> <false /> </wideMargins>
- <multipleLines> <false /> </multipleLines>
- <reservedFamily> 0 </reservedFamily>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>left</textAlign>
- <font>Geneva</font>
- <textSize>4</textSize>
- <textStyle>plain</textStyle>
- <textHeight>5</textHeight>
- <name>Challenger ID</name>
- <script></script>
- </part>
- <part>
- <id>30</id>
- <type>field</type>
- <visible> <true /> </visible>
- <dontWrap> <false /> </dontWrap>
- <dontSearch> <true /> </dontSearch>
- <sharedText> <false /> </sharedText>
- <fixedLineHeight> <false /> </fixedLineHeight>
- <autoTab> <false /> </autoTab>
- <lockText> <true /> </lockText>
- <rect>
- <left>339</left>
- <top>348</top>
- <right>492</right>
- <bottom>446</bottom>
- </rect>
- <style>rectangle</style>
- <autoSelect> <false /> </autoSelect>
- <showLines> <false /> </showLines>
- <wideMargins> <false /> </wideMargins>
- <multipleLines> <false /> </multipleLines>
- <reservedFamily> 0 </reservedFamily>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>left</textAlign>
- <font>Geneva</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <textHeight>16</textHeight>
- <name>Status 2</name>
- <script></script>
- </part>
- <part>
- <id>31</id>
- <type>field</type>
- <visible> <false /> </visible>
- <dontWrap> <false /> </dontWrap>
- <dontSearch> <false /> </dontSearch>
- <sharedText> <false /> </sharedText>
- <fixedLineHeight> <false /> </fixedLineHeight>
- <autoTab> <false /> </autoTab>
- <lockText> <true /> </lockText>
- <rect>
- <left>447</left>
- <top>0</top>
- <right>512</right>
- <bottom>5</bottom>
- </rect>
- <style>transparent</style>
- <autoSelect> <false /> </autoSelect>
- <showLines> <false /> </showLines>
- <wideMargins> <false /> </wideMargins>
- <multipleLines> <false /> </multipleLines>
- <reservedFamily> 0 </reservedFamily>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>right</textAlign>
- <font>Geneva</font>
- <textSize>4</textSize>
- <textStyle>plain</textStyle>
- <textHeight>5</textHeight>
- <name>Date</name>
- <script></script>
- </part>
- <part>
- <id>33</id>
- <type>button</type>
- <visible> <false /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>164</left>
- <top>479</top>
- <right>194</right>
- <bottom>509</bottom>
- </rect>
- <style>transparent</style>
- <showName> <false /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <false /> </autoHighlight>
- <sharedHighlight> <false /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>7004</icon>
- <textAlign>center</textAlign>
- <font>Chicago</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <name>Animation</name>
- <script></script>
- </part>
- <part>
- <id>34</id>
- <type>button</type>
- <visible> <true /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>339</left>
- <top>159</top>
- <right>493</right>
- <bottom>181</bottom>
- </rect>
- <style>shadow</style>
- <showName> <true /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <true /> </autoHighlight>
- <sharedHighlight> <false /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>center</textAlign>
- <font>Chicago</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <name>Choose Opponent</name>
- <script>on mouseUp
- chooseOpponent
- end mouseUp</script>
- </part>
- <part>
- <id>35</id>
- <type>field</type>
- <visible> <true /> </visible>
- <dontWrap> <false /> </dontWrap>
- <dontSearch> <false /> </dontSearch>
- <sharedText> <true /> </sharedText>
- <fixedLineHeight> <false /> </fixedLineHeight>
- <autoTab> <false /> </autoTab>
- <lockText> <true /> </lockText>
- <rect>
- <left>335</left>
- <top>11</top>
- <right>409</right>
- <bottom>26</bottom>
- </rect>
- <style>transparent</style>
- <autoSelect> <false /> </autoSelect>
- <showLines> <false /> </showLines>
- <wideMargins> <false /> </wideMargins>
- <multipleLines> <false /> </multipleLines>
- <reservedFamily> 0 </reservedFamily>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>left</textAlign>
- <font>Chicago</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <textHeight>16</textHeight>
- <name>Status Title</name>
- <script></script>
- </part>
- <part>
- <id>36</id>
- <type>field</type>
- <visible> <true /> </visible>
- <dontWrap> <false /> </dontWrap>
- <dontSearch> <false /> </dontSearch>
- <sharedText> <true /> </sharedText>
- <fixedLineHeight> <false /> </fixedLineHeight>
- <autoTab> <false /> </autoTab>
- <lockText> <true /> </lockText>
- <rect>
- <left>354</left>
- <top>236</top>
- <right>470</right>
- <bottom>256</bottom>
- </rect>
- <style>opaque</style>
- <autoSelect> <false /> </autoSelect>
- <showLines> <false /> </showLines>
- <wideMargins> <false /> </wideMargins>
- <multipleLines> <false /> </multipleLines>
- <reservedFamily> 0 </reservedFamily>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>left</textAlign>
- <font>Times</font>
- <textSize>18</textSize>
- <textStyle>italic</textStyle>
- <textStyle>bold</textStyle>
- <textHeight>24</textHeight>
- <name>Our Screen Title</name>
- <script></script>
- </part>
- <part>
- <id>37</id>
- <type>button</type>
- <visible> <true /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>466</left>
- <top>279</top>
- <right>496</right>
- <bottom>311</bottom>
- </rect>
- <style>opaque</style>
- <showName> <false /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <true /> </autoHighlight>
- <sharedHighlight> <true /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>17264</icon>
- <textAlign>center</textAlign>
- <font>Chicago</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <name>Help!</name>
- <script>on mouseUp
- help
- end mouseUp</script>
- </part>
- <part>
- <id>38</id>
- <type>button</type>
- <visible> <false /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>339</left>
- <top>186</top>
- <right>493</right>
- <bottom>208</bottom>
- </rect>
- <style>shadow</style>
- <showName> <true /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <true /> </autoHighlight>
- <sharedHighlight> <false /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>center</textAlign>
- <font>Chicago</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <name>Place Ships</name>
- <script>on mouseUp
- placeShips
- end mouseUp</script>
- </part>
- <part>
- <id>40</id>
- <type>button</type>
- <visible> <true /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>333</left>
- <top>598</top>
- <right>366</right>
- <bottom>630</bottom>
- </rect>
- <style>transparent</style>
- <showName> <false /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <true /> </autoHighlight>
- <sharedHighlight> <true /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>32488</icon>
- <textAlign>center</textAlign>
- <font>Chicago</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <name>Up</name>
- <script>on mouseUp
- showYourMap
- pass mouseUp
- end mouseUp</script>
- </part>
- <part>
- <id>41</id>
- <type>button</type>
- <visible> <true /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>465</left>
- <top>598</top>
- <right>495</right>
- <bottom>629</bottom>
- </rect>
- <style>opaque</style>
- <showName> <false /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <true /> </autoHighlight>
- <sharedHighlight> <true /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>17264</icon>
- <textAlign>center</textAlign>
- <font>Chicago</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <name>Help!</name>
- <script>on mouseUp
- help
- end mouseUp</script>
- </part>
- <part>
- <id>32</id>
- <type>button</type>
- <visible> <false /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>335</left>
- <top>282</top>
- <right>496</right>
- <bottom>311</bottom>
- </rect>
- <style>shadow</style>
- <showName> <true /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <true /> </autoHighlight>
- <sharedHighlight> <true /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>center</textAlign>
- <font>Geneva</font>
- <textSize>18</textSize>
- <textStyle>condense</textStyle>
- <textStyle>bold</textStyle>
- <name>Ready!</name>
- <script>-----------------------------------------------------------------------
- --
- -- STACK: HyperBattleship 2.1 7/25/91
- -- © Copyright 1991 by Claris Corporation, All Rights Reserved
- -- By The HyperCard Development Team
- --
- -- HANDLERS USED IN THIS SCRIPT:
- -- mouseUp, saveLocations
- --
- -- LEGEND:
- -- "--Γêå" indicates strings which would need localization
- -----------------------------------------------------------------------
-
- on mouseUp
- -- If all the ships are placed upon the board.
- -- save their locations to be compared later.
- if there is a window "Your Ships" then hide window "Your Ships"
- --
- saveLocations -- Attempt to save the ship locations.
- if the result is empty then -- We have successfully saved locations.
- hide bg btn "Place Ships"
- hide me
- status "Ships placed correctly." --Γêå
- setStatus
- disable menuItem 1 of menu "HyperBattleship!"
- disable menuItem 2 of menu "HyperBattleship!"
- if there is a window "Your Ships"
- then
- close window "Your Ships"
- end if
- else
- if there is a window "Your Ships" then show window "Your Ships"
- end if
- pass mouseUp
- end mouseUp
-
- on saveLocations
- -- Save all the ship locations so that we can play a game.
- -- Notes: The format of the SaveList is:
- -- "«Grid Loc» «Btn ID» «Btn TopLeft» «Btn Icon ID» «Btn ID List» ;"
- -- This list is current stored in line 11 of the bg fld "Ours".
- --
- put empty into SaveList -- Reset current values.
- --
- put rect of bg fld "Ours" into BoardRect -- Get the current board rect.
- --
- -- Step through the list of ships and save all the ship information.
- repeat with ShipNum = 1 to 5
- -- Get the list of all ships and save their locations.
- do "put ship" & ShipNum & "() into ShipList"
- repeat with ShipPart = 1 to number of items in ShipList
- set cursor to busy
- put "bg btn id " & item ShipPart of ShipList into CurrentShip
- put loc of CurrentShip into CurShipLoc
- --
- -- Verify that the ship is placed correctly.
- if CurShipLoc is not within BoardRect ¬
- or not visible of CurrentShip then
- status "Place all ships completely within game board before continuing.", "Alert" --Γêå
- return "Ship not placed."
- end if
- put gridItem(CurShipLoc, BoardRect) into CurItem
- if offset(CurItem & " ",SaveList) Γëá 0 then
- status "Ships can not be placed on top of other ships.", "Alert" --Γêå
- return "Ship incorrectly placed."
- end if
- -- Save the formatted list of ship information.
- put CurItem && short id of CurrentShip && topLeft of CurrentShip ¬
- && icon of CurrentShip && ShipList & " ;" after SaveList
- end repeat
- end repeat
- -- Save these lists into the currently defined location.
- put SaveList into line 11 of bg fld "Ours"
- end saveLocations
- </script>
- </part>
- <part>
- <id>43</id>
- <type>field</type>
- <visible> <true /> </visible>
- <dontWrap> <false /> </dontWrap>
- <dontSearch> <false /> </dontSearch>
- <sharedText> <true /> </sharedText>
- <fixedLineHeight> <false /> </fixedLineHeight>
- <autoTab> <false /> </autoTab>
- <lockText> <true /> </lockText>
- <rect>
- <left>334</left>
- <top>530</top>
- <right>455</right>
- <bottom>547</bottom>
- </rect>
- <style>transparent</style>
- <autoSelect> <false /> </autoSelect>
- <showLines> <false /> </showLines>
- <wideMargins> <false /> </wideMargins>
- <multipleLines> <false /> </multipleLines>
- <reservedFamily> 0 </reservedFamily>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>left</textAlign>
- <font>Chicago</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <textHeight>16</textHeight>
- <name></name>
- <script></script>
- </part>
- <part>
- <id>44</id>
- <type>field</type>
- <visible> <true /> </visible>
- <dontWrap> <false /> </dontWrap>
- <dontSearch> <true /> </dontSearch>
- <sharedText> <true /> </sharedText>
- <fixedLineHeight> <false /> </fixedLineHeight>
- <autoTab> <false /> </autoTab>
- <lockText> <true /> </lockText>
- <rect>
- <left>335</left>
- <top>331</top>
- <right>409</right>
- <bottom>346</bottom>
- </rect>
- <style>transparent</style>
- <autoSelect> <false /> </autoSelect>
- <showLines> <false /> </showLines>
- <wideMargins> <false /> </wideMargins>
- <multipleLines> <false /> </multipleLines>
- <reservedFamily> 0 </reservedFamily>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>left</textAlign>
- <font>Chicago</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <textHeight>16</textHeight>
- <name>Status Title</name>
- <script></script>
- </part>
- <part>
- <id>45</id>
- <type>field</type>
- <visible> <false /> </visible>
- <dontWrap> <true /> </dontWrap>
- <dontSearch> <false /> </dontSearch>
- <sharedText> <false /> </sharedText>
- <fixedLineHeight> <false /> </fixedLineHeight>
- <autoTab> <false /> </autoTab>
- <lockText> <true /> </lockText>
- <rect>
- <left>52</left>
- <top>32</top>
- <right>276</right>
- <bottom>149</bottom>
- </rect>
- <style>scrolling</style>
- <autoSelect> <false /> </autoSelect>
- <showLines> <false /> </showLines>
- <wideMargins> <false /> </wideMargins>
- <multipleLines> <false /> </multipleLines>
- <reservedFamily> 0 </reservedFamily>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>left</textAlign>
- <font>Geneva</font>
- <textSize>9</textSize>
- <textStyle>plain</textStyle>
- <textHeight>12</textHeight>
- <name>win</name>
- <script></script>
- </part>
- <part>
- <id>46</id>
- <type>field</type>
- <visible> <false /> </visible>
- <dontWrap> <true /> </dontWrap>
- <dontSearch> <false /> </dontSearch>
- <sharedText> <false /> </sharedText>
- <fixedLineHeight> <false /> </fixedLineHeight>
- <autoTab> <false /> </autoTab>
- <lockText> <true /> </lockText>
- <rect>
- <left>51</left>
- <top>172</top>
- <right>275</right>
- <bottom>285</bottom>
- </rect>
- <style>scrolling</style>
- <autoSelect> <false /> </autoSelect>
- <showLines> <false /> </showLines>
- <wideMargins> <false /> </wideMargins>
- <multipleLines> <false /> </multipleLines>
- <reservedFamily> 0 </reservedFamily>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>left</textAlign>
- <font>Geneva</font>
- <textSize>9</textSize>
- <textStyle>plain</textStyle>
- <textHeight>12</textHeight>
- <name>lose</name>
- <script></script>
- </part>
- <part>
- <id>47</id>
- <type>button</type>
- <visible> <true /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>339</left>
- <top>452</top>
- <right>493</right>
- <bottom>474</bottom>
- </rect>
- <style>shadow</style>
- <showName> <true /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <true /> </autoHighlight>
- <sharedHighlight> <false /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>center</textAlign>
- <font>Chicago</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <name>Quit</name>
- <script>on mouseUp
- quitGame
- end mouseUp</script>
- </part>
- <part>
- <id>48</id>
- <type>button</type>
- <visible> <true /> </visible>
- <reserved5> 0 </reserved5>
- <reserved4> 0 </reserved4>
- <reserved3> 0 </reserved3>
- <reserved2> 0 </reserved2>
- <reserved1> 0 </reserved1>
- <enabled> <true /> </enabled>
- <rect>
- <left>339</left>
- <top>132</top>
- <right>493</right>
- <bottom>154</bottom>
- </rect>
- <style>shadow</style>
- <showName> <true /> </showName>
- <highlight> <false /> </highlight>
- <autoHighlight> <true /> </autoHighlight>
- <sharedHighlight> <false /> </sharedHighlight>
- <family>0</family>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>center</textAlign>
- <font>Chicago</font>
- <textSize>12</textSize>
- <textStyle>plain</textStyle>
- <name>Quit</name>
- <script>on mouseUp
- quitGame
- end mouseUp</script>
- </part>
- <part>
- <id>49</id>
- <type>field</type>
- <visible> <true /> </visible>
- <dontWrap> <false /> </dontWrap>
- <dontSearch> <true /> </dontSearch>
- <sharedText> <true /> </sharedText>
- <fixedLineHeight> <false /> </fixedLineHeight>
- <autoTab> <false /> </autoTab>
- <lockText> <true /> </lockText>
- <rect>
- <left>333</left>
- <top>497</top>
- <right>492</right>
- <bottom>517</bottom>
- </rect>
- <style>opaque</style>
- <autoSelect> <false /> </autoSelect>
- <showLines> <false /> </showLines>
- <wideMargins> <false /> </wideMargins>
- <multipleLines> <false /> </multipleLines>
- <reservedFamily> 0 </reservedFamily>
- <titleWidth>0</titleWidth>
- <icon>0</icon>
- <textAlign>left</textAlign>
- <font>Times</font>
- <textSize>18</textSize>
- <textStyle>italic</textStyle>
- <textStyle>bold</textStyle>
- <textHeight>24</textHeight>
- <name>Our Screen Title</name>
- <script></script>
- </part>
- <content>
- <layer>background</layer>
- <id>35</id>
- <text>Status:</text>
- </content>
- <content>
- <layer>background</layer>
- <id>36</id>
- <text>Your Screen</text>
- </content>
- <content>
- <layer>background</layer>
- <id>49</id>
- <text>Opponent Screen</text>
- </content>
- <content>
- <layer>background</layer>
- <id>44</id>
- <text>Status:</text>
- </content>
- <content>
- <layer>background</layer>
- <id>43</id>
- <text>Opponent:</text>
- </content>
- <name>Battleship</name>
- <script>--------------------------------------------------------------------------------
- --
- -- STACK: HyperBattleship 2.1 7/28/91
- -- © Copyright 1991 by Claris Corporation, All Rights Reserved
- -- By The HyperCard Development Team
- --
- -- HANDLERS USED IN THIS SCRIPT:
- -- acceptIncoming, animateHit, animateMiss, appleEvent, challenger(),
- -- challengerID(), chooseOpponent, closeShip, closeShips, closeStack,
- -- continueChoose, dragAShip, dragShip, hbsCleanup, hbsInit, hbsMessage,
- -- hbsMove, hbsRequest, hbsSetup, hbsStatus(), help, idle, moveShip,
- -- moveWindow, myID(), offsetRect(), openCard, openStack, playerPause,
- -- playerUnPause, quitGame, resume, resumeStack, sendMessage, setStatus,
- -- setWindowSize, shipCondition(), shipLoc(), shipLocations(),
- -- shipOrient, showLocations, sizeWindow, status, suspend, suspendStack,
- --
- -- LEGEND:
- -- "--Γêå" indicates strings which would need localization
- --------------------------------------------------------------------------------
-
- --------------------------------------------------------------------------------
- -- System Message Handlers
- --------------------------------------------------------------------------------
-
- on openStack
- -- Check for Apple® Event support.
- check4aeSupport
- if the result is not "OK" then
- if the enabled of menuItem "Close Stack" of menu "File" then
- doMenu "Close Stack"
- else
- go Home
- end if
- exit to HyperCard
- end if
- -- Resize this stack
- set width of card window to 512
- set height of card window to 320
- -- get rid of the scroll window
- hide window scroll
- -- If it's a standard Mac screen position the stack window correctly
- if the screenRect = "0,0,512,342"
- then set the rect of card window to 0,20,512,340
- createMenu
- playerUnPause
- pass openStack
- end openStack
-
- on closeStack
- removeMenu
- if ((char 1 to 3 of the version) >= 2.1 ¬
- and value("the systemVersion") >= 7 )
- then playerPause
- pass closeStack
- end closeStack
-
- on resume
- createMenu
- playerUnPause
- pass resume
- end resume
-
- on suspend
- removeMenu
- playerPause
- pass suspend
- end suspend
-
- on resumeStack
- createMenu
- playerUnPause
- pass resumeStack
- end resumeStack
-
- on suspendStack
- removeMenu
- playerPause
- pass suspendStack
- end suspendStack
-
- on openCard
- setCheckMark
- pass openCard
- end openCard
-
- on help
- -- Show the help information.
- global gBeforeHelpCard, gBeforeHelpScroll
- if item 2 of the scroll of cd window < 170 then
- put "0,0" into gBeforeHelpScroll
- else put "0,320" into gBeforeHelpScroll
- put the long name of this cd into gBeforeHelpCard
- set scroll of cd window to "0,320"
- go cd "Stack Help"
- -- Update the menu.
- checkMarkChange 7
- end help
-
- on quit
- put hbsStatus() into CurStatus
- -- If the game is not completed, ask if we should quit this game.
- if CurStatus is not in "Choose,End" then
- answer "Save current game before quitting?" with "Yes" or "No"
- if it is "Yes" then pass quit
- else if it is "No" then
- lock screen
- hbsInit
- end if
- end if
- pass quit
- end quit
-
- --------------------------------------------------------------------------------
- -- Standard HyperBattleship Handlers
- --------------------------------------------------------------------------------
-
- on appleEvent Class, EventID
- -- Allow only ΓÇ£hbsΓÇ¥ events to occur while we are playing the game.
- -- Note: This is a simple method to prevent another application
- -- from sending just any Apple event.
- if Class = "misc" and (EventID = "dosc" or EventID = "eval") then
- request AppleEvent data
- put it into EventData
- if number of lines in EventData > 1 ¬
- or char 1 to 3 of EventData ≠ "hbs" ¬
- then reply error "Event not accepted."
- end if
- pass appleEvent
- end appleEvent
-
- on hbsRequest
- -- Allow the requested opponent to respond to invitation to play.
- --
- -- Make sure that we are not asking applications on the same machine
- -- to play. If we did we might never get a response because one
- -- application may not continue while the other is waiting.
- global gChoosing
- request appleEvent sender
- put it into AESender
- put the itemDelimiter into SaveDelim
- set the itemDelimiter to ":"
- put (item 1 to 2 of AESender is item 1 to 2 of the address) into IsLocal
- set the itemDelimiter to SaveDelim
- if IsLocal then
- put "Play" into GameAnswer -- Same machine, automatically approve.
- else
- if hbsStatus() is in "Place,Waiting,Ready" then
- return "Busy"
- else
- answer AESender & " asks, “Do you want to play HyperBattleship?”" ¬
- with "No" or "Play"
- put it into GameAnswer
- if GameAnswer is "Play" ¬
- and gChoosing is not empty then
- status "Canceling your game selection in order to play a game " ¬
- & "with " & AESender --Γêå
- put empty into gChoosing
- end if
- if GameAnswer is "Play" then hbsInit
- end if
- end if
- --
- return GameAnswer
- end hbsRequest
-
- on hbsInit
- -- Create a new game of HyperBattleship.
- -- Note: Init provides a parameterless initialization.
- if hbsStatus() is not in "Choose,End,Setup" then
- -- Let the other player know that we are going away.
- sendMessage "Your opponent has quit this game." --Γêå
- send "hbsMove " ¬
- & quote & "End" & quote & ", " ¬
- & quote & challengerID() & quote & ", " ¬
- & quote & shipLoc() & quote ¬
- & "" to program challenger() without reply
- end if
- hbsCleanup myID()
- end hbsInit
-
- on hbsSetup NewPlayer, NewPlayerID, OurID
- -- Create a HyperBattleship with the specified parameters.
- --
- if OurID is empty then
- go to last card in this bg -- There should be only one card.
- put myID() into OurID
- end if
- --
- -- Since we asked to play, let challenger know our id.
- if NewPlayer is not empty ¬
- and NewPlayerID is not empty then
- send "hbsMove " ¬
- & quote & "Challenger ID" & quote & ", " ¬
- & quote & NewPlayerID & quote & ", " ¬
- & quote & OurID & quote ¬
- to program NewPlayer
- put the result into SendResult
- if SendResult is not in "Setup,Busy" then
- if SendResult is not "Cancel" then status SendResult
- exit hbsSetup
- end if
- go to card id OurID
- end if
- --
- -- Set all the parameters that we have, and wait for any other
- -- parameters to be returned from the challenger.
- put NewPlayer into bg fld "Challenger" of card id OurID
- put NewPlayerID into bg fld "Challenger ID" of card id OurID
- put the date && the time into bg fld "Date" of card id OurID
- --
- setStatus
- status ""
- end hbsSetup
-
- on hbsCleanup OurGameID
- -- Remove everything from the current game.
- if (short id of this card) ≠ OurGameID ¬
- and OurGameID is not empty then
- hide bg btn "Ready!"
- push this card
- go to card id OurGameID
- send "hbsCleanup" && OurGameID to this card
- pop card
- else
- -- Clean up this game.
- lock screen
- if short name of this stack is "Home" then pass hbsCleanup
- set cursor to busy
- put empty into bg fld "Status"
- set cursor to busy
- put empty into bg fld "Status 2"
- set cursor to busy
- put fieldEmptyData() into bg fld "Ours"
- set cursor to busy
- put fieldEmptyData() into bg fld "Enemy"
- set cursor to busy
- put empty into bg fld "Challenger"
- set cursor to busy
- put empty into bg fld "Date"
- set cursor to busy
- put empty into bg fld "Challenger ID"
- set cursor to busy
- closeShips
- set cursor to busy
- status "Waiting to be configured.", "Status" --Γêå
- setStatus
- set cursor to busy
- showYourMap
- unlock screen with visual dissolve fast
- end if
- end hbsCleanup
-
- on hbsMessage Message
- -- Display a message from someone out on the network.
- request appleEvent sender
- put it into AESender
- status "ΓÇ£" & Message & "ΓÇ¥" && AESender, "Message"
- end hbsMessage
-
- on hbsMove MoveLocation, OurID, Value
- -- A game move has been made. Determine the type of
- -- move based upon our current status and any move information.
- --
- if OurID is empty then put short id of this card into OurID
- if OurID Γëá short id of this card then
- go to card id OurID
- end if
- --
- -- Verify this hbsMove.
- if MoveLocation is empty then exit hbsMove
- --
- -- Based upon the current game status, perform a move.
- put hbsStatus() into CurStatus
- if CurStatus = "End" ¬
- or MoveLocation = "End" then
- if Value is not empty then showLocations Value
- status "End of game. Opponent has quit.", "Status" --Γêå
- put empty into bg fld "Challenger" of card "Game"
- put empty into bg fld "Challenger ID" of card "Game"
- hide bg btn "Place Ships"
- hide bg btn "Ready!"
- menuStatus
- placeShipsCheck
- else if CurStatus = "Setup" then
- put Value into bg fld MoveLocation
- setStatus
- return "Setup"
- else if CurStatus = "Place" ¬
- or CurStatus = "Choose" then
- return "Busy"
- else
- -- If a shot has been fired at our ships, determine if
- -- there is a hit and respond accordingly.
- acceptIncoming MoveLocation
- return the result
- end if
- end hbsMove
-
- function hbsStatus
- -- Return the current status.
- put empty into returnValue
- -- Determine the current status of this game.
- if challenger() is empty then
- put "Choose" into returnValue -- A challenger has not been selected.
- else if challengerID() is empty then
- put "Setup" into returnValue -- Waiting for configuration information
- -- from the challenger.
- else if shipLocations() is empty then
- put "Place" into returnValue -- Ships have not yet been placed.
- else if word 1 of bg fld "Status" of card "Game" is "End" then
- put "End" into returnValue -- The game is over.
- else if word 1 of bg fld "Status" of card "Game" is "Waiting" then
- put "Waiting" into returnValue
- else
- put "Ready" into returnValue
- end if
- return returnValue
- end hbsStatus
-
- --------------------------------------------------------------------------------
- -- General HyperBattleship Handlers
- --------------------------------------------------------------------------------
-
- on quitGame
- -- Quit this game and be polite about letting everyone know.
- put hbsStatus() into CurStatus
- --
- -- If the game is not completed, verify that we really want
- -- to start over or go Home.
- if CurStatus is not "End" then
- answer "Clear everything and then exit to Home or start a new game?" ¬
- with "Cancel" or "Home" or "New Game"
- if it is "Cancel" then exit quitGame
- else if it is "Home" then
- lock screen
- hbsInit
- go home
- else if it is "New Game" then
- hbsInit
- end if
- else
- hbsInit
- end if
- end quitGame
-
- on chooseOpponent
- -- Get a challenger if we donΓÇÖt already have one.
- global gChoosing
- --
- go to cd "Game"
- put PlayerRequest() into NewChallenger
- set cursor to busy
- if NewChallenger is not empty then
- put NewChallenger into bg fld "Challenger"
- else -- Otherwise the user has selected cancel so exit.
- exit chooseOpponent
- end if
- set cursor to busy
- --
- -- Since choosing an opponent may take awhile, there is a strong
- -- possibility that the opponent is trying to choose us. Thus,
- -- before we go any further we should allow a pending AppleEvent
- -- to arrive. To make this happen we have to let one idle event
- -- occur before continuing the chooseOpponent process.
- --
- put "Wait" into gChoosing
- end chooseOpponent
-
- on idle
- global gChoosing
- if gChoosing is not empty then
- -- The first time through gChoosing is "Wait". We set the global
- -- to "Now" and let one idle to be trapped. Pending AppleEvents
- -- will occur at this point.
- set cursor to busy
- if gChoosing is "Wait"
- then put "Now" into gChoosing -- Allow one idle.
- else if gChoosing is "Now" then
- put empty into gChoosing
- continueChoose -- Continue with choosing opponent.
- end if
- exit idle
- end if
- pass idle
- end idle
-
- on continueChoose
- set cursor to busy
- -- Ask them if they want to play a game.
- -- We are about to send an event to the program, we must inform
- -- the user just before we send the event.
- status "Waiting for opponent to respond." --Γêå
- set cursor to busy
- put challenger() into TheChallenger
- send "hbsRequest" to program TheChallenger
- put the result into SendResult
- set cursor to busy
- if SendResult is not "Play" then
- -- They donΓÇÖt want to play, but describe the problem in detail.
- set cursor to busy
- if SendResult is "Timeout" then
- status "The application you selected is not responding." && ¬
- "Please try again and make sure you're selecting HyperCard" && ¬
- "2.1 or greater.","Alert" --Γêå
- else if SendResult is "Busy" then
- status "The selected opponent is already busy playing a game.", ¬
- "Alert" --Γêå
- else if SendResult is "No" then
- status "The selected opponent does not want to play a game.", ¬
- "Alert" --Γêå
- else if SendResult is "Can't understand " & quote & "hbsRequest" ¬
- & quote & "." then
- status "The selected opponent does not have HyperBattleship open.",¬
- "Alert" --Γêå
- else if SendResult is "Cancel" then exit continueChoose
- else
- status "Could not connect with chosen opponent." && ¬
- "Received error message:" && "“" & SendResult & ¬
- "ΓÇ¥. Please try again.","Alert" --Γêå
- end if
- exit continueChoose
- end if
- --
- -- We should now have a challenger name (and perhaps an ID)
- -- so let us start/setup a game.
- status "Making a game of HyperBattleship with " ¬
- & TheChallenger & ".", "Status" --Γêå
- set cursor to busy
- --
- -- Prepare the challenger to play the game!
- send "hbsSetup " ¬
- & quote & the address & quote & ", " ¬
- & quote & myID() & quote & ", " ¬
- & quote & challengerID() & quote ¬
- to program TheChallenger without reply
- put the result into SendResult
- set cursor to busy
- -- If the send to program command works correctly it will
- -- either return the empty or the name of the program.
- if SendResult is not TheChallenger ¬
- and SendResult is not empty then
- status SendResult -- We have a problem.
- exit continueChoose
- end if
- set cursor to busy
- --
- -- And, prepare ourselves to play this game.
- send "hbsSetup " ¬
- & quote & TheChallenger & quote & ", " ¬
- & quote & challengerID() & quote & ", " ¬
- & quote & myID() & quote & ", " ¬
- to this card
- set cursor to busy
- --
- setStatus
- end continueChoose
-
- on sendMessage TheMessage
- -- Send the message to an opponent.
- if TheMessage is empty then
- ask "Enter message to send to opponent." with return & return --Γêå
- put the Result into AskResult
- if AskResult is "Cancel" then exit sendMessage
- put it into TheMessage
- end if
- --
- send "hbsMessage " ¬
- & unValue(TheMessage) & ", " ¬
- to program challenger() without reply
- end sendMessage
-
- --------------------------------------------------------------------------------
- -- Other HyperBattleship specific handlers.
- --------------------------------------------------------------------------------
-
- on playerPause
- if hbsStatus() is in "Ready,Waiting,Place" then
- sendMessage "PAUSE: Your opponent has left this game temporarily." --Γêå
- end if
- placeShipsCheck FALSE
- end playerPause
-
- on playerUnPause
- if hbsStatus() is in "Ready,Waiting,Place" then
- sendMessage "Your opponent has returned to this game." --Γêå
- end if
- placeShipsCheck
- end playerUnPause
-
- on acceptIncoming MoveLocation
- -- Accept an incoming shot and display animation graphics.
- --
- -- Show the incoming shot.
- showYourMap
- -- Determine if we are hit.
- put shipLocations() into ShipList
- -- If the move location is in the shiplist, there is a hit.
- put offset(MoveLocation & " ", ShipList) into ShipLoc
- if ShipLoc Γëá 0 then
- -- Set the icon of my ship at specified location to hit.
- -- Specify the point of the hit and the ship button id.
- play "ShellIncoming"
- animateHit MoveLocation, ¬
- word 2 of char ShipLoc to (ShipLoc + 50) of ShipList
- --
- -- Check if the entire ship is.
- if shipCondition(word 5 of char ShipLoc to (ShipLoc + 50) of ShipList) ¬
- is "Sunk" then
- repeat for 30 -- Play a sunk sound.
- play (any item of "Sunk 1,Sunk 2,Sunk 3")¬
- (any item of "rt,rt,g2s,c3t,g3x")
- end repeat
- if shipCondition(allShips()) is "Sunk" then
- status "End of game.", "Status" --Γêå
- status "All your ships are sunk." --Γêå
- play flute tempo 160 "c4e a3 d4q a3h c4e a3 d4q a3h c4q f ee fs es " ¬
- & "dq c4e a3 d4q a3h"
- answer line random(9) of bg fld "Lose"
- return "End"
- end if
- status "Ready for your move.", "Status" --Γêå
- status "One of your ships sunk!" --Γêå
- showOpponentMap
- return "Sunk"
- else
- status "Ready for your move.", "Status" --Γêå
- status "Your ship has been hit!" --Γêå
- showOpponentMap
- return "Hit"
- end if
- else
- -- Set character in field to missed shot.
- play "ShellIncoming"
- animateMiss MoveLocation
- -- Put the miss character into our map.
- put gridCharLocation(MoveLocation) into RowColumn
- put numToChar(219) into ¬
- char item 1 of RowColumn of line item 2 of RowColumn ¬
- of bg fld "Ours"
- status "Ready for your move.", "Status" --Γêå
- status "Incoming shot missed!" --Γêå
- showOpponentMap
- return "Miss"
- end if
- end acceptIncoming
-
- on showLocations ShipList
- -- Show the location of all the opponent ships.
- showOpponentMap
- --
- -- Show all the locations of the unhit ships.
- repeat with PartNum = 1 to number of items in ShipList
- put item PartNum of ShipList into PartLocation
- put gridCharLocation(PartLocation) into RowColumn
- put char (item 1 of RowColumn) of line (item 2 of RowColumn) ¬
- of bg fld "Enemy" into CurChar
- if CurChar = " " or CurChar = numToChar(215) then
- put "+" into ¬
- char item 1 of RowColumn of line item 2 of RowColumn ¬
- of bg fld "Enemy"
- end if
- end repeat
- end showLocations
-
- on setStatus
- -- Configure possible actions based upon the current status.
- put challengerID() into CurChallenger
- --
- if CurChallenger is empty ¬
- and challenger() is empty then
- status "Choose an opponent.","Status" --Γêå
- show bg btn "Choose Opponent"
- set cursor to busy
- hide bg btn "Place Ships"
- set cursor to busy
- if there is a menu "HyperBattleship!" then
- enable menuItem 1 of menu "HyperBattleship!"
- disable menuItem 2 of menu "HyperBattleship!"
- end if
- set cursor to busy
- hide bg btn "Ready!"
- placeShipsCheck
- else if CurChallenger is empty then
- status "Waiting for opponent confirmation.", "Status" --Γêå
- enable menuItem 9 of menu "HyperBattleship!"
- else if shipLocations() is empty then
- hide bg btn "Choose Opponent"
- status "Place ships onto playing area.", "Status" --Γêå
- show bg btn "Place Ships"
- set cursor to busy
- disable menuItem 1 of menu "HyperBattleship!"
- enable menuItem 2 of menu "HyperBattleship!"
- enable menuItem 9 of menu "HyperBattleship!"
- placeShipsCheck
- set cursor to busy
- else
- hide bg btn "Place Ships"
- disable menuItem 1 of menu "HyperBattleship!"
- disable menuItem 2 of menu "HyperBattleship!"
- enable menuItem 9 of menu "HyperBattleship!"
- play "Ship's Alarm"
- play "Ship's Alarm"
- play "Ship's Alarm"
- play "All Hands"
- status "Ready to play game.","Status" --Γêå
- showOpponentMap
- set cursor to busy
- hide bg btn "Ready!"
- placeShipsCheck
- end if
- end setStatus
-
- function shipLoc
- -- Return a list of all ship grid locations.
- put empty into ReturnValue
- put shipLocations() into ShipList
- --
- -- Show all the locations of the unhit ships.
- put the itemDelimiter into SaveDelim
- set the itemDelimiter to ";"
- repeat with PartNum = 1 to number of items in ShipList
- put word 1 of item PartNum of ShipList & "," after ReturnValue
- end repeat
- delete last char of ReturnValue
- set the itemDelimiter to SaveDelim
- return ReturnValue
- end shipLoc
-
- on animateHit MoveLocation, ButtonID, FieldName
- -- Show the animation for a shot that hit our ship.
- if FieldName is empty then put "Ours" into FieldName
- -- Determine the location to show the animation.
- if MoveLocation is not empty then
- put gridItemLocation(MoveLocation, topLeft of bg fld FieldName) ¬
- into MovePoint
- if MovePoint is not empty
- then set topLeft of bg btn "Animation" to MovePoint
- end if
- -- Show the hidden animation button, do icon animation, and play sounds.
- set icon of bg btn "Animation" to 7001
- wait until the sound is "Done"
- show bg btn "Animation"
- play "Explosion"
- repeat with iconCnt = 7001 to 7004
- set icon of bg btn "Animation" to iconCnt
- wait 5
- end repeat
- -- Make a hole in our ship.
- if ButtonID is not empty
- then set icon of bg btn id ButtonID ¬
- to ("6" & char 2 to 4 of icon of bg btn id ButtonID)
- -- Hide the animation button.
- hide bg btn "Animation"
- end animateHit
-
- on animateMiss MoveLocation, FieldName
- -- Show the animation for a missed shot.
- if FieldName is empty then put "Ours" into FieldName
- -- Determine the location to show the animation.
- if MoveLocation is not empty then
- put gridItemLocation(MoveLocation, topLeft of bg fld FieldName) ¬
- into MovePoint
- if MovePoint is not empty
- then set topLeft of bg btn "Animation" to MovePoint
- end if
- -- Show the hidden animation button, do icon animation, and play sounds.
- set icon of bg btn "Animation" to "Miss 1"
- wait until the sound is "Done"
- play "Splash/Explosion"
- show bg btn "Animation"
- repeat with iconCnt = 8001 to 8012
- set icon of bg btn "Animation" to iconCnt
- wait 7
- end repeat
- hide bg btn "Animation"
- end animateMiss
-
- on setWindowSize
- -- Set the window size to a visually appealing size.
- put 320 into HalfHeight
- --
- put rect of card window into CurRect
- -- Our current size is smaller than the full size of this card.
- if height of card window < height of this card ¬
- and height of card window > HalfHeight then
- -- Show only a visually pleasing portion of this card.
- put (item 2 of curRect + HalfHeight) into item 4 of CurRect -- L,T,R,B
- set rect of card window to CurRect
- end if
- end setWindowSize
-
- --------------------------------------------------------------------------------
- -- System handlers specific to stack.
- --------------------------------------------------------------------------------
-
- on sizeWindow
- setWindowSize
- pass sizeWindow
- end sizeWindow
-
- on moveWindow
- setWindowSize
- pass moveWindow
- end moveWindow
-
- --------------------------------------------------------------------------------
- -- Ship Action Handlers.
- --------------------------------------------------------------------------------
-
- on dragShip ShipNum, ShipList, ShipRect
- -- Drag a ship from a current location on the game board.
- if hbsStatus() is not "Place" then exit dragShip
- --
- put DragRect(ShipRect) into MoveLoc
- set cursor to watch
- put round((item 1 of MoveLoc)/30) * 30 into item 1 of MoveLoc
- put round((item 2 of MoveLoc)/30) * 30 into item 2 of MoveLoc
- --
- if MoveLoc Γëá "0,0" then
- -- Compute the final mouse location (used to determine object placement).
- put the clickLoc into MovePoint
- put offsetRect(shipRect,item 1 of MoveLoc,item 2 of MoveLoc) into MoveRect
- -- If the point moved to is still within the rect of container continue.
- put rect of bg fld "Ours" into ContainerRect
- if item 1 to 2 of MoveRect is not within ContainerRect ¬
- or item 3 to 4 of MoveRect is not within ContainerRect then
- closeShip ShipNum, ShipList -- Close a specified ship.
- else
- moveShip ShipList, item 1 of MoveLoc, item 2 of MoveLoc
- end if
- end if
- end dragShip
-
- on moveShip ShipList, DeltaHorz, DeltaVert
- -- Move an entire ship.
- lock screen
- -- Move all the parts of this ship.
- repeat with PartNumber = 1 to (number of items in ShipList)
- set cursor to busy
- put item PartNumber of ShipList into TargetShip
- -- Move the ship.
- set loc of bg btn id TargetShip to ¬
- (item 1 of loc of bg btn id TargetShip + DeltaHorz & "," & ¬
- item 2 of loc of bg btn id TargetShip + DeltaVert)
- show bg btn id TargetShip
- end repeat
- end moveShip
-
- on closeShip ShipNum, ShipList
- -- Close a single ship.
- lock screen
- repeat with ItemNum = 1 to number of items in ShipList
- hide bg btn id (item ItemNum of ShipList)
- end repeat
- -- Update the palette.
- do "set the enabledButton_" & ShipNum & " of window " & quote & "your ships" ¬
- & quote & " to true"
- do "set the enabledButton_" & (ShipNum + 5) & " of window " & quote ¬
- & "your ships" ¬
- & quote & " to true"
- end closeShip
-
- on closeShips
- -- Hide all the ships.
- lock screen
- put allShips() into ShipList
- repeat with ShipNum = 1 to number of items in ShipList
- hide bg btn id (item ShipNum of ShipList)
- end repeat
- -- Update the palette.
- if there is a window "Your Ships" then
- close window "Your Ships"
- end if
- end closeShips
-
- function offsetRect currRect, XZero, YZero
- add XZero to item 1 of currRect
- add YZero to item 2 of currRect
- add XZero to item 3 of currRect
- add YZero to item 4 of currRect
- return currRect
- end offsetRect
-
- on dragAShip ShipRect, ShipNumber
- -- Drag an outline of the ship from a palette, and place the ship.
- --
- -- Grab the rect of the palette,
- put the rect of window "Your Ships" into PaletteRect
- -- and convert the rect of the button in the palette to global coordinates
- -- to pass to the XFCN
- put offsetRect(ShipRect, item 1 of PaletteRect, ¬
- item 2 of PaletteRect) into RectToDrag
- --
- -- Drag the outline around until the mouse button is released. This version
- -- of dragrect returns the offset from the start rect (delta X, delta Y).
- put dragRect(RectToDrag) into MoveLoc
- --
- set cursor to watch
- -- Compute the final mouse location (used to determine object placement).
- put item 1 to 2 of RectToDrag into MovePoint
- add item 1 of MoveLoc to item 1 of MovePoint
- add item 2 of MoveLoc to item 2 of MovePoint
- -- Get the bottom of the ship, so we can verify its location.
- put item 3 to 4 of RectToDrag into ExtentPoint
- add (item 1 of MoveLoc) - 5 to item 1 of ExtentPoint
- add (item 2 of MoveLoc) - 5 to item 2 of ExtentPoint
- --
- -- If the point moved to is still within the rect of container continue.
- put rect of bg fld "Ours" into ContainerRect
- if MovePoint is not within ContainerRect ¬
- or ExtentPoint is not within ContainerRect then
- -- Do nothing, they did not specify a location on the board
- beep 1
- status "Ships must be placed entirely within your game board boundries." --Γêå
- else
- -- Determine the orientation of the ship being dragged.
- put char 1 + ((ShipNumber - 1) div 5) of "VH" into Direction
- -- Determine the type of ship being placed.
- put (((ShipNumber - 1) mod 5) + 1) into ShipType
- --
- do "put ship" & ShipType & "() into ShipList"
- --
- put GridLocation(MovePoint,ContainerRect) into NewGrid
- shipOrient NewGrid, Direction, ShipList, ShipType
- end if
- -- Clean up the palette.
- set the hilitedButton of window "Your Ships" to 0
- end dragAShip
-
- on shipOrient Location, Direction, ShipList, ShipType
- -- Place all ship parts into their correct location.
- --
- lock screen
- -- Get name of ship.
- put (word 1 of short name of bg btn id (item 1 of ShipList)) into MainName
- --
- -- For each ship part set the location and icon.
- repeat with PartNumber = 1 to (number of items in ShipList)
- set cursor to busy
- put item PartNumber of ShipList into CurPart
- set icon of bg btn id CurPart to ¬
- (MainName && PartNumber && Direction && "OK")
- if Direction is "h" then
- set topLeft of bg btn id CurPart to ¬
- ((item 1 of Location + ((PartNumber - 1) * 30)) ¬
- & "," & item 2 of Location)
- else
- set topLeft of bg btn id CurPart to ¬
- (item 1 of Location & "," ¬
- & (item 2 of Location + ((PartNumber - 1) * 30)))
- end if
- show bg btn id CurPart
- end repeat
- --
- -- Update the palette.
- if there is a window "Your Ships" then
- do "set the enabledButton_" & ShipType & " of window " ¬
- & quote & "your ships" & quote & " to false"
- do "set the enabledButton_" & (ShipType + 5) & " of window " ¬
- & quote & "your ships" & quote & " to false"
- end if
- end shipOrient
-
- on status Message, Type
- -- Tell the player the current game status.
- if Type is "Status" then -- Information message from almost anywhere.
- put Message into line 1 of bg fld "Status"
- put Message into line 1 of bg fld "Status 2"
- else if Type is "Message" then -- Communications from other player.
- play "Ping"
- answer Message
- else if Type is "Alert" then -- A more important message.
- beep
- answer Message
- else
- put Message into line 2 of bg fld "Status"
- put Message into line 2 of bg fld "Status 2"
- end if
- end status
-
- --------------------------------------------------------------------------------
- -- HyperBattleship! information function handlers.
- --------------------------------------------------------------------------------
-
- function myID
- return short id of card "Game"
- end myID
-
- function challenger
- return bg fld "Challenger" of card "Game"
- end challenger
-
- function challengerID
- return bg fld "Challenger ID" of card "Game"
- end challengerID
-
- function shipLocations
- -- The placed ships locations are listed location format.
- -- Notes: The format of the ship location is:
- -- "«Grid Loc» «Btn ID» «Btn TopLeft» «Btn Icon ID» «Btn ID List» ;"
- return line 11 of bg fld "Ours" of card "Game"
- end shipLocations
-
- function shipCondition ShipList
- -- Determine if ship parts (buttons) in list are sunk.
- put "Sunk" into ReturnValue
- repeat with Index = 1 to number of items in ShipList
- if icon of bg btn id (item Index of ShipList) < 6000 ¬
- then return "OK"
- end repeat
- return ReturnValue
- end shipCondition
- </script>
- </background>
-