home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / CheckersSparse.dxr / 00003.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  3.0 KB  |  119 lines

  1. on calcScore
  2.   global playerTMoves, playerTCaptures, playerTLosses, levelScore
  3.   sBit1 = (50 - playerTMoves) * 20
  4.   if sBit1 < 0 then
  5.     sBit1 = 0
  6.   end if
  7.   sBit2 = playerTCaptures * 200
  8.   sBit3 = playerTLosses * -100
  9.   levelScore = sBit1 + sBit2 + sBit3
  10.   if levelScore < 0 then
  11.     levelScore = 0
  12.   end if
  13.   member("Level Score").text = string(levelScore)
  14. end
  15.  
  16. on playSound whichSound, whichSlot
  17.   global lastClear
  18.   if whichSlot = 2 then
  19.     sound(2).stop()
  20.     sound(2).queue([#member: member(whichSound)])
  21.     sound(2).play()
  22.   else
  23.     sound(1).stop()
  24.     sound(1).queue([#member: member(whichSound)])
  25.     sound(1).play()
  26.   end if
  27. end
  28.  
  29. on returnPiece testLoc
  30.   global boardData
  31.   pRank = #Na
  32.   pSide = #Na
  33.   if (testLoc[1] >= 1) and (testLoc[2] >= 1) and (testLoc[1] <= count(boardData[1])) and (testLoc[2] <= count(boardData)) then
  34.     pieceType = boardData[testLoc[2]][testLoc[1]]
  35.   else
  36.     pieceType = #Na
  37.   end if
  38.   case pieceType of
  39.     #Rp:
  40.       pRank = 1
  41.       pSide = 1
  42.     #Bp:
  43.       pRank = 1
  44.       pSide = 2
  45.     #Rk:
  46.       pRank = 2
  47.       pSide = 1
  48.     #Bk:
  49.       pRank = 2
  50.       pSide = 2
  51.     otherwise:
  52.       pRank = 0
  53.       pSide = 0
  54.   end case
  55.   return [pRank, pSide]
  56. end
  57.  
  58. on testJumps testLoc, jumpPiece
  59.   global boardData, moveTestResults, moveTestPositions
  60.   jumpMode = #International
  61.   jumpMode = #Traditional
  62.   if jumpPiece = VOID then
  63.     bData = returnPiece(testLoc)
  64.   else
  65.     bData = jumpPiece
  66.   end if
  67.   pStartRank = bData[1]
  68.   pStartSide = bData[2]
  69.   case jumpMode of
  70.     #Traditional:
  71.       if pStartRank = 2 then
  72.         moveTest = [1, 1, 1, 1]
  73.       else
  74.         if pStartRank = 1 then
  75.           if pStartSide = 1 then
  76.             moveTest = [0, 0, 1, 1]
  77.           else
  78.             if pStartSide = 2 then
  79.               moveTest = [1, 1, 0, 0]
  80.             else
  81.               moveTest = [1, 1, 1, 1]
  82.             end if
  83.           end if
  84.         else
  85.           moveTest = [0, 0, 0, 0]
  86.         end if
  87.       end if
  88.       testVectors = [point(-1, -1), point(1, -1), point(-1, 1), point(1, 1)]
  89.       moveTestResults = [0, 0, 0, 0]
  90.       moveTestPositions = [0, 0, 0, 0]
  91.       repeat with whichV = 1 to 4
  92.         if moveTest[whichV] = 1 then
  93.           pathlength = pathlength + 1
  94.           pathLoc1 = testLoc + (testVectors[whichV] * 1)
  95.           pathLoc2 = testLoc + (testVectors[whichV] * 2)
  96.           obstacleDat1 = returnPiece(pathLoc1)
  97.           obstacleDat2 = returnPiece(pathLoc2)
  98.           squareTiles = count(boardData) + 1
  99.           playRect = rect(1, 1, squareTiles, squareTiles)
  100.           if (obstacleDat1[1] = 0) and inside(pathLoc1, playRect) then
  101.             action = #move
  102.             pPosition = pathLoc1
  103.           else
  104.             if (obstacleDat1[2] <> pStartSide) and (obstacleDat2[1] = 0) and inside(pathLoc2, playRect) then
  105.               action = #Attack
  106.               pPosition = pathLoc2
  107.             else
  108.               action = #Blocked
  109.               pPosition = 0
  110.             end if
  111.           end if
  112.           moveTestResults[whichV] = action
  113.           moveTestPositions[whichV] = pPosition
  114.         end if
  115.       end repeat
  116.     #International:
  117.   end case
  118. end
  119.