1
0

spellBook.qsrc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 thespellList file.
  3. !
  4. ! $ARGS[0] = Type of List: cast, learn
  5. ! $ARGS[1] = the name of the array to use for the spell list.
  6. ! $ARGS[2] = (optional) return Action Code - a dynamic piece of code to run instead of generic return.
  7. ! $ARGS[3] = (optional) Additional code to put in spell link (all spells)
  8. !
  9. $spellBookVar['Type'] = $ARGS[0]
  10. $spellBookVar['Array'] = $ARGS[1]
  11. $spellBookVar['ActionCode'] = $ARGS[2]
  12. $spellBookVar['CodeAfterSpell'] = $ARGS[3]
  13. ! Make sure opptional variables have defaults
  14. if $spellBookVar['ActionCode'] = '':
  15. $spellBookVar['ActionCode'] = "gt '<<$loc>>', '<<$metka>>'"
  16. end
  17. if $spellBookVar['CodeAfterSpell'] = '':
  18. $spellBookVar['CodeAfterSpell'] = "gt '<<$loc>>', '<<$metka>>'"
  19. end
  20. ! lets the user back out if they don''t want ot cast.
  21. act 'Never mind':dynamic spellBookVar['ActionCode']
  22. ! This just makes sure the current spellLists are loaded
  23. if spellMana['fog'] = 0:
  24. gs 'spellList'
  25. end
  26. ! Build the table - Choose Header for Type
  27. if $spellBookVar['Type'] = 'learn':
  28. $spellBookVar['TableText'] = "
  29. <center>
  30. <table CELLPADDING = '5'>
  31. <tr>
  32. <th align='left'>Spell</th>
  33. <th align='left'>Percent Learned</th>
  34. </tr>"
  35. $spellBookVar['RowCode'] = {
  36. if spellLearn[$ThisSpellName] > 0 and spellKnown[$ThisSpellName] ! 1:
  37. $result = "
  38. <tr>
  39. <td align='left'><<$spellName[$ThisSpellName]>></td>
  40. <td align='right'><<spellLearn[$ThisSpellName]>></td>
  41. </tr>"
  42. spellBookVar['Counter'] += 1
  43. else
  44. $result = ''
  45. end
  46. }
  47. else
  48. ! Default is list of castable spells.
  49. $spellBookVar['TableText'] = "
  50. <center>
  51. <table CELLPADDING = '5'>
  52. <tr>
  53. <th align='left'>Spell</th>
  54. <th align='left'>Mana</th>
  55. <th align='left'>Description</th>
  56. </tr>"
  57. $spellBookVar['RowCode'] = {
  58. if spellKnown[$ThisSpellName] = 1:
  59. if $spellOptDesc[$ThisSpellName] = '':
  60. $tmpHTMLCode = "
  61. <tr>
  62. <td align='left'><a href=""EXEC: gs 'castSpell', '<<$ThisSpellName>>'& <<$spellBookVar['CodeAfterSpell']>>""><<$spellName[$ThisSpellName]>></a></td>
  63. <td align='right'><<spellMana[$ThisSpellName]>></td>
  64. <td align='left'><<$spellDesc[$ThisSpellName]>></td>
  65. </tr>"
  66. else
  67. $tmpHTMLCode = "
  68. <tr>
  69. <td align='left'><<$spellName[$ThisSpellName]>></td>
  70. <td align='right'><<spellMana[$ThisSpellName]>></td>
  71. <td align='left'><<$spellDesc[$ThisSpellName]>></td>
  72. </tr>"
  73. n=0
  74. :RowCodeLoop99
  75. if n < arrsize('<<$spellOptDesc[$ThisSpellName]>>'):
  76. $spellBookVar['tmpVal'] = dyneval('$result = <<$spellOptVal[$ThisSpellName]>>[<<n>>]')
  77. $spellBookVar['tmpName']= dyneval('$result = <<$spellOptDesc[$ThisSpellName]>>[<<n>>]')
  78. $tmpHTMLCode += "
  79. <tr>
  80. <td align='left'></td>
  81. <td align='left'><a href=""EXEC: gs 'castSpell', '<<$ThisSpellName>>', '<<$spellBookVar['tmpVal']>>' & <<$spellBookVar['CodeAfterSpell']>>""><<$spellBookVar['tmpName']>></a></td>
  82. <td align='left'></td>
  83. </tr>"
  84. n += 1
  85. jump 'RowCodeLoop99'
  86. end
  87. end
  88. $result = $tmpHTMLCode
  89. spellBookVar['Counter'] += 1
  90. killvar '$tmpHTMLCode'
  91. killvar 'n'
  92. else
  93. $result = ''
  94. end
  95. }
  96. end
  97. i = 0
  98. spellBookVar['ArraySize'] = dyneval("result = arrsize('<<$spellBookVar['Array']>>')")
  99. spellBookVar['Counter'] = 0
  100. :SpellListLoop
  101. $ThisSpellName = dyneval("$result = <<$spellBookVar['Array']>>[<<i>>]")
  102. if i < spellBookVar['ArraySize']:
  103. !$spellBookVar['RowCode']
  104. $spellBookVar['TableText'] += dyneval($spellBookVar['RowCode'])
  105. i += 1
  106. jump 'SpellListLoop'
  107. end
  108. $spellBookVar['TableText'] += "
  109. </table>
  110. </center>"
  111. if spellBookVar['Counter'] = 0:
  112. $spellBookVar['TableText'] = "<center>You have no spells in this list.</center>"
  113. end
  114. $result = func('cleanHTML',$spellBookVar['TableText'])
  115. killvar 'i'
  116. killvar '$ThisSpellName'
  117. killvar '$spellBookVar'
  118. killvar 'spellBookVar'
  119. --- spellBook ---------------------------------