spellBook.qsrc 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. #spellBook
  2. ! Make a table of Spells to Cast from a given list. the list is in the form of the lists as done in the spellList file.
  3. !
  4. ! $ARGS[0] = Type of List: cast, learn, list
  5. ! This determines the info to be displayed as wel las the HTML formatting
  6. ! $ARGS[1] = the name of the array to use for the spell list.
  7. ! $ARGS[2] = (optional) return Action Code - a dynamic piece of code to run instead of generic return.
  8. ! $ARGS[3] = (optional) Additional code to put in spell link (all spells)
  9. !
  10. $spellBookVar['Type'] = $ARGS[0]
  11. $spellBookVar['Array'] = $ARGS[1]
  12. $spellBookVar['ActionCode'] = $ARGS[2]
  13. $spellBookVar['CodeAfterSpell'] = $ARGS[3]
  14. ! Make sure opptional variables have defaults
  15. if $spellBookVar['ActionCode'] = '':
  16. $spellBookVar['ActionCode'] = 'gt $loc, $metka'
  17. end
  18. if $spellBookVar['CodeAfterSpell'] = '':
  19. $spellBookVar['CodeAfterSpell'] = 'gt $loc, $metka'
  20. end
  21. ! lets the user back out if they don''t want ot cast.
  22. act 'Never mind':dynamic spellBookVar['ActionCode']
  23. ! This just makes sure the current spellLists are loaded
  24. gs 'spellList'
  25. !-----------------------------------------------------------------------------------------------
  26. ! Choose the type of spell list to determine what info will be displayed and the HTML formatting
  27. ! 1) 'TableText' = The header for the table. The header row
  28. ! 2) 'RowCode' = The code used inside the loop to build the HTML text for that Row.
  29. !! 'learn' type is for displaying which seplls the user is currently learning.
  30. if $spellBookVar['Type'] = 'learn':
  31. $spellBookVar['TableText'] = "
  32. <center>
  33. <table CELLPADDING = '5'>
  34. <tr>
  35. <th align='left'>Spell</th>
  36. <th align='left'>Percent Learned</th>
  37. </tr>"
  38. $spellBookVar['RowCode'] = {
  39. if spellLearn[$ThisSpellName] > 0 and spellKnown[$ThisSpellName] ! 1:
  40. $result = "
  41. <tr>
  42. <td align='left'><<$spellName[$ThisSpellName]>></td>
  43. <td align='right'><<spellLearn[$ThisSpellName]>></td>
  44. </tr>"
  45. spellBookVar['Counter'] += 1
  46. else
  47. $result = ''
  48. end
  49. }
  50. !! 'list' type is list of castable spells. This makes a table of spells for the user to cast.
  51. elseif $spellBookVar['Type'] = 'cast':
  52. $spellBookVar['TableText'] = "
  53. <center>
  54. <table CELLPADDING = '5'>
  55. <tr>
  56. <th align='left'>Spell</th>
  57. <th align='left'>Mana</th>
  58. <th align='left'>Description</th>
  59. </tr>"
  60. $spellBookVar['RowCode'] = {
  61. if spellKnown[$ThisSpellName] = 1:
  62. if $spellOptDesc[$ThisSpellName] = '':
  63. ! If the spell has no Options, we jsut list it out for casting
  64. $tmpHTMLCode = "
  65. <tr>
  66. <td align='left'><a href=""EXEC: gs 'castSpell', '<<$ThisSpellName>>'& <<$spellBookVar['CodeAfterSpell']>>""><<$spellName[$ThisSpellName]>></a></td>
  67. <td align='right'><<spellMana[$ThisSpellName]>></td>
  68. <td align='left'><<$spellDesc[$ThisSpellName]>></td>
  69. </tr>"
  70. else
  71. ! If the spell does have options, we make a row for spell info, and loop through additional rows
  72. ! with options for the user to pick
  73. $tmpHTMLCode = "
  74. <tr>
  75. <td align='left'><<$spellName[$ThisSpellName]>></td>
  76. <td align='right'><<spellMana[$ThisSpellName]>></td>
  77. <td align='left'><<$spellDesc[$ThisSpellName]>></td>
  78. </tr>"
  79. n=0
  80. :RowCodeLoop98
  81. if n < arrsize('<<$spellOptDesc[$ThisSpellName]>>'):
  82. $spellBookVar['tmpVal'] = dyneval('$result = <<$spellOptVal[$ThisSpellName]>>[<<n>>]')
  83. $spellBookVar['tmpName']= dyneval('$result = <<$spellOptDesc[$ThisSpellName]>>[<<n>>]')
  84. $tmpHTMLCode += "
  85. <tr>
  86. <td align='left'></td>
  87. <td align='left'><a href=""EXEC: gs 'castSpell', '<<$ThisSpellName>>', '<<$spellBookVar['tmpVal']>>' & <<$spellBookVar['CodeAfterSpell']>>""><<$spellBookVar['tmpName']>></a></td>
  88. <td align='left'></td>
  89. </tr>"
  90. n += 1
  91. jump 'RowCodeLoop98'
  92. end
  93. end
  94. $result = $tmpHTMLCode
  95. spellBookVar['Counter'] += 1
  96. killvar '$tmpHTMLCode'
  97. killvar 'n'
  98. else
  99. $result = ''
  100. end
  101. }
  102. !! Default is a list of spells with descriptio nand mana cost listed.
  103. else
  104. $spellBookVar['TableText'] = "
  105. <center>
  106. <table CELLPADDING = '5'>
  107. <tr>
  108. <th align='left'>Spell</th>
  109. <th align='left'>Mana</th>
  110. <th align='left'>Description</th>
  111. </tr>"
  112. $spellBookVar['RowCode'] = {
  113. if spellKnown[$ThisSpellName] = 1:
  114. if $spellOptDesc[$ThisSpellName] = '':
  115. ! If the spell has no Options, we jsut list it out for casting
  116. $tmpHTMLCode = "
  117. <tr>
  118. <td align='left'><<$spellName[$ThisSpellName]>></td>
  119. <td align='right'><<spellMana[$ThisSpellName]>></td>
  120. <td align='left'><<$spellDesc[$ThisSpellName]>></td>
  121. </tr>"
  122. else
  123. ! If the spell does have options, we make a row for spell info, and loop through additional rows
  124. ! with options for the user to pick
  125. $tmpHTMLCode = "
  126. <tr>
  127. <td align='left'><<$spellName[$ThisSpellName]>></td>
  128. <td align='right'><<spellMana[$ThisSpellName]>></td>
  129. <td align='left'><<$spellDesc[$ThisSpellName]>></td>
  130. </tr>"
  131. n=0
  132. :RowCodeLoop99
  133. if n < arrsize('<<$spellOptDesc[$ThisSpellName]>>'):
  134. $spellBookVar['tmpVal'] = dyneval('$result = <<$spellOptVal[$ThisSpellName]>>[<<n>>]')
  135. $spellBookVar['tmpName']= dyneval('$result = <<$spellOptDesc[$ThisSpellName]>>[<<n>>]')
  136. $tmpHTMLCode += "
  137. <tr>
  138. <td align='left'></td>
  139. <td align='left'><<$spellBookVar['tmpName']>></td>
  140. <td align='left'></td>
  141. </tr>"
  142. n += 1
  143. jump 'RowCodeLoop99'
  144. end
  145. end
  146. $result = $tmpHTMLCode
  147. spellBookVar['Counter'] += 1
  148. killvar '$tmpHTMLCode'
  149. killvar 'n'
  150. else
  151. $result = ''
  152. end
  153. }
  154. end
  155. i = 0
  156. spellBookVar['ArraySize'] = dyneval("result = arrsize('<<$spellBookVar['Array']>>')")
  157. spellBookVar['Counter'] = 0
  158. :SpellListLoop
  159. $ThisSpellName = dyneval("$result = <<$spellBookVar['Array']>>[<<i>>]")
  160. if i < spellBookVar['ArraySize']:
  161. !$spellBookVar['RowCode']
  162. $spellBookVar['TableText'] += dyneval($spellBookVar['RowCode'])
  163. i += 1
  164. jump 'SpellListLoop'
  165. end
  166. $spellBookVar['TableText'] += "
  167. </table>
  168. </center>"
  169. if spellBookVar['Counter'] = 0:
  170. $spellBookVar['TableText'] = "<center>You have no spells in this list.</center>"
  171. end
  172. $result = func('cleanHTML',$spellBookVar['TableText'])
  173. killvar 'i'
  174. killvar '$ThisSpellName'
  175. killvar '$spellBookVar'
  176. killvar 'spellBookVar'
  177. --- spellBook ---------------------------------