OW.lua 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. local ReceiverBase = require("core:erm.ReceiverBase")
  2. local GAME = GAME
  3. local SetResources = require("netpacks.SetResources")
  4. local SERVER = SERVER
  5. local OW = ReceiverBase:new()
  6. function OW:new(ERM)
  7. return ReceiverBase.new(self,{ERM = ERM})
  8. end
  9. function OW:A(x, ...)
  10. logError("!!OW:A is not implemented")
  11. end
  12. function OW:C(x, p)
  13. if p1 == nil then
  14. return GAME:getCurrentPlayer()
  15. else
  16. error("Setting current player in not allowed")
  17. end
  18. end
  19. function OW:D(x, ...)
  20. logError("!!OW:D is not implemented")
  21. end
  22. function OW:G(x, ...)
  23. logError("!!OW:G is not implemented")
  24. end
  25. function OW:H(x, ...)
  26. logError("!!OW:H is not implemented")
  27. end
  28. function OW:I(x, ...)
  29. logError("!!OW:I is not implemented")
  30. end
  31. function OW:K(x, ...)
  32. logError("!!OW:K is not implemented")
  33. end
  34. function OW:N(x, ...)
  35. logError("!!OW:N is not implemented")
  36. end
  37. function OW:O(x, ...)
  38. logError("!!OW:O is not implemented")
  39. end
  40. function OW:R(x, player, typ, quantity)
  41. local p = GAME:getPlayer(player)
  42. assert(p, "Player ".. tostring(player).." not accessible")
  43. if quantity == nil then
  44. return nil, nil, p:getResourceAmount(typ)
  45. elseif type(quantity) == "table" then
  46. local hasD = false
  47. local s = ''
  48. local v
  49. for n, k in ipairs(quantity) do
  50. if k == "d" then
  51. hasD = true
  52. else
  53. v = k
  54. end
  55. end
  56. if not hasD then
  57. error ("OW:R Special variable expected ".. v .." found")
  58. end
  59. if type(v) ~= "number" then
  60. error ("OW:R Numeric quantity expected".. tostring(v) .." found")
  61. end
  62. quantity = v
  63. local pack = SetResources.new()
  64. pack:setPlayer(player)
  65. pack:setAbs(false)
  66. pack:setAmount(typ, quantity)
  67. SERVER:commitPackage(pack)
  68. else
  69. local pack = SetResources.new()
  70. pack:setPlayer(player)
  71. pack:setAbs(true)
  72. pack:setAmount(typ, quantity)
  73. SERVER:commitPackage(pack)
  74. end
  75. end
  76. function OW:S(x, ...)
  77. logError("!!OW:S is not implemented")
  78. end
  79. function OW:T(x, ...)
  80. logError("!!OW:T is not implemented")
  81. end
  82. function OW:V(x, ...)
  83. logError("!!OW:V is not implemented")
  84. end
  85. function OW:W(x, ...)
  86. logError("!!OW:W is not implemented")
  87. end
  88. return OW