spellBook.qsrc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. $result = "
  60. <tr>
  61. <td align='left'><a href=""EXEC: gs 'castSpell', '<<$ThisSpellName>>'& <<$spellBookVar['CodeAfterSpell']>>""><<$spellName[$ThisSpellName]>></a></td>
  62. <td align='right'><<spellMana[$ThisSpellName]>></td>
  63. <td align='left'><<$spellDesc[$ThisSpellName]>></td>
  64. </tr>"
  65. spellBookVar['Counter'] += 1
  66. else
  67. $result = ''
  68. end
  69. }
  70. end
  71. i = 0
  72. spellBookVar['ArraySize'] = dyneval("result = arrsize('<<$spellBookVar['Array']>>')")
  73. spellBookVar['Counter'] = 0
  74. :SpellListLoop
  75. $ThisSpellName = dyneval("$result = <<$spellBookVar['Array']>>[<<i>>]")
  76. if i < spellBookVar['ArraySize']:
  77. !$spellBookVar['RowCode']
  78. $spellBookVar['TableText'] += dyneval($spellBookVar['RowCode'])
  79. i += 1
  80. jump 'SpellListLoop'
  81. end
  82. $spellBookVar['TableText'] += "
  83. </table>
  84. </center>"
  85. if spellBookVar['Counter'] = 0:
  86. $spellBookVar['TableText'] = "<center>You have no spells in this list.</center>"
  87. end
  88. $result = func('cleanHTML',$spellBookVar['TableText'])
  89. killvar 'i'
  90. killvar '$ThisSpellName'
  91. killvar '$spellBookVar'
  92. killvar 'spellBookVar'
  93. --- spellBook ---------------------------------