HE.lua 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. local ReceiverBase = require("core:erm.ReceiverBase")
  2. local HE = ReceiverBase:new()
  3. function HE:new(ERM, p1, p2, p3)
  4. assert(p1 ~= nil, "!!HE requires hero identifier")
  5. if p2 and p3 then
  6. --by coordinates
  7. error("!!HEx/y/l: form is not implemented")
  8. else
  9. -- assume p1 is identifier
  10. local hero = GAME:getHeroWithSubid(p1)
  11. if not hero then
  12. logError("Hero with id ".. tostring(p1) .. " not found")
  13. end
  14. return ReceiverBase.new(self,
  15. {
  16. id=p1,
  17. ERM=ERM,
  18. hero=hero
  19. })
  20. end
  21. end
  22. function HE:A(x, ...)
  23. --artifacts
  24. logError("!!HE:A is not implemented")
  25. end
  26. HE:p1Dispatcher("B")
  27. function HE:B0(x, ...)
  28. --name
  29. logError("!!HE:B is not implemented")
  30. end
  31. function HE:B1(x, ...)
  32. --bio
  33. logError("!!HE:B is not implemented")
  34. end
  35. function HE:B2(x, ...)
  36. --class
  37. logError("!!HE:B is not implemented")
  38. end
  39. function HE:B3(x, _)
  40. --get default bio
  41. logError("!!HE:B is not implemented")
  42. end
  43. function HE:C(x, ...)
  44. local argc = select("#", ...)
  45. if argc == 14 then
  46. return self:C14(x, ...)
  47. elseif argc == 4 then
  48. local N = select(1, ...)
  49. return nil, self["C"..tostring(N)](self, x, select(2, ...))
  50. else
  51. logError("!!HE:C extended form is not implemented")
  52. end
  53. end
  54. function HE:C0(x, slot, typ, count)
  55. --change creatures by slot
  56. if typ~=nil or count ~=nil then
  57. logError("!!HE:C0 set is not implemented")
  58. return
  59. end
  60. local stack = self.hero:getStack(slot)
  61. if not stack then
  62. return nil, -1, 0
  63. else
  64. return nil, stack:getType():getIndex(), stack:getCount()
  65. end
  66. end
  67. function HE:C1(x, ...)
  68. --change creatures by type
  69. end
  70. function HE:C05(x, ...)
  71. --change creatures by slot adv
  72. end
  73. function HE:C15(x, ...)
  74. --change creatures by type adv
  75. end
  76. function HE:C2(x, ...)
  77. --add creatures
  78. end
  79. function HE:C14(x, ...)
  80. -- change creatures with Query
  81. end
  82. function HE:D(x, ...)
  83. logError("!!HE:D not implemented")
  84. end
  85. function HE:E(x, ...)
  86. logError("!!HE:E is not implemented")
  87. end
  88. function HE:F(x, ...)
  89. logError("!!HE:F is not implemented")
  90. end
  91. function HE:G(x, ...)
  92. logError("!!HE:G is not implemented")
  93. end
  94. function HE:H(x, ...)
  95. logError("!!HE:H is not implemented")
  96. end
  97. function HE:I(x, ...)
  98. logError("!!HE:I is not implemented")
  99. end
  100. function HE:K(x, ...)
  101. logError("!!HE:K is not implemented")
  102. end
  103. function HE:L(x, ...)
  104. logError("!!HE:L is not implemented")
  105. end
  106. function HE:M(x, ...)
  107. logError("!!HE:M is not implemented")
  108. end
  109. function HE:N(x, ...)
  110. logError("!!HE:N is not implemented")
  111. end
  112. function HE:O(x, owner)
  113. if owner~=nil then
  114. logError("!!HE:O set is not implemented")
  115. return
  116. else
  117. if not self.hero then
  118. return 255
  119. end
  120. return self.hero:getOwner()
  121. end
  122. end
  123. function HE:P(x, ...)
  124. logError("!!HE:P is not implemented")
  125. end
  126. function HE:R(x, ...)
  127. logError("!!HE:R is not implemented")
  128. end
  129. function HE:S(x, ...)
  130. logError("!!HE:S is not implemented")
  131. end
  132. function HE:T(x, ...)
  133. logError("!!HE:T is not implemented")
  134. end
  135. function HE:U(x, ...)
  136. logError("!!HE:U is not implemented")
  137. end
  138. function HE:V(x, ...)
  139. logError("!!HE:V is not implemented")
  140. end
  141. function HE:W(x, ...)
  142. logError("!!HE:A is not implemented")
  143. end
  144. function HE:X(x, ...)
  145. logError("!!HE:X is not implemented")
  146. end
  147. function HE:Y(x, ...)
  148. logError("!!HE:Y is ot implemented")
  149. end
  150. return HE