ARKShopItemAPI.ts 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. import {Item} from "./ConfigFile";
  2. import {DeleteDataByPath, GetDataByPath, PostDataByPath, PutDataByPath, ResponseData} from "./api";
  3. export class ShopData {
  4. Description: string
  5. Price: number
  6. Type: string
  7. constructor(Description: string, Price: number, Type: string) {
  8. this.Description = Description;
  9. this.Price = Price;
  10. this.Type = Type;
  11. }
  12. }
  13. export class ShopItem extends ShopData {
  14. Items: Item[]
  15. static Create(): ShopItem {
  16. return new ShopItem("item", "", 0, []);
  17. }
  18. constructor(Type: string, Description: string, Price: number, Items: Item[]) {
  19. super(Description, Price, Type);
  20. this.Items = Items;
  21. }
  22. }
  23. export class ShopDino extends ShopData {
  24. Level: number
  25. MinLevel: number
  26. MaxLevel: number
  27. Neutered: boolean
  28. Gender: string
  29. SaddleBlueprint: string
  30. Blueprint: string
  31. static Create(): ShopDino {
  32. return new ShopDino("", 0, "dino", 0, 0, 0, false, "", "", "");
  33. }
  34. constructor(Description: string, Price: number, Type: string, Level: number, MinLevel: number, MaxLevel: number, Neutered: boolean, Gender: string, SaddleBlueprint: string, Blueprint: string) {
  35. super(Description, Price, Type);
  36. this.Level = Level;
  37. this.MinLevel = MinLevel;
  38. this.MaxLevel = MaxLevel;
  39. this.Neutered = Neutered;
  40. this.Gender = Gender;
  41. this.SaddleBlueprint = SaddleBlueprint;
  42. this.Blueprint = Blueprint;
  43. }
  44. }
  45. export class ShopBeacon extends ShopData {
  46. ClassName: string
  47. static Create(): ShopBeacon {
  48. return new ShopBeacon("", 0, "beacon", "");
  49. }
  50. constructor(Description: string, Price: number, Type: string, ClassName: string) {
  51. super(Description, Price, Type);
  52. this.ClassName = ClassName;
  53. }
  54. }
  55. //ShopExperience
  56. export class ShopExperience extends ShopData {
  57. Amount: number
  58. GiveToDino: boolean
  59. static Create(): ShopExperience {
  60. return new ShopExperience("", 0, "experience", 0, false);
  61. }
  62. constructor(Description: string, Price: number, Type: string, Amount: number, GiveToDino: boolean) {
  63. super(Description, Price, Type);
  64. this.Amount = Amount;
  65. this.GiveToDino = GiveToDino;
  66. }
  67. }
  68. //ShopUnlockengram
  69. export class ShopUnlockengram extends ShopData {
  70. Items: ShopUnlockengramItem[]
  71. static Create(): ShopUnlockengram {
  72. return new ShopUnlockengram("", 0, "unlockengram", []);
  73. }
  74. constructor(Description: string, Price: number, Type: string, Items: ShopUnlockengramItem[]) {
  75. super(Description, Price, Type);
  76. this.Items = Items;
  77. }
  78. }
  79. export class ShopUnlockengramItem {
  80. Blueprint: string
  81. static Create(): ShopUnlockengramItem {
  82. return new ShopUnlockengramItem("");
  83. }
  84. constructor(Blueprint: string) {
  85. this.Blueprint = Blueprint;
  86. }
  87. }
  88. export class ShopCommand extends ShopData {
  89. Items: ShopCommandItem[]
  90. static Create(): ShopCommand {
  91. return new ShopCommand("", 0, "command", []);
  92. }
  93. constructor(Description: string, Price: number, Type: string, Items: ShopCommandItem[]) {
  94. super(Description, Price, Type);
  95. this.Items = Items;
  96. }
  97. }
  98. export class ShopCommandItem {
  99. Command: string
  100. DisplayAs: string
  101. constructor(Command: string, DisplayAs: string) {
  102. this.Command = Command;
  103. this.DisplayAs = DisplayAs;
  104. }
  105. }
  106. export function GetShopItems(type: string) {
  107. return GetDataByPath("/ark/shopItem?type=" + type, {}, true) as Promise<ResponseData<ShopData[]>>;
  108. }
  109. export function SaveShopItem(shopItem: ShopData, name: string, shopType: string) {
  110. return PostDataByPath("/ark/shopItem",
  111. {shopItem: shopItem, shopItemName: name, shopType: shopType},
  112. true)
  113. }
  114. export function UpdateShopItem(newShopItem: ShopData, name: string, shopType: string) {
  115. return PutDataByPath("/ark/shopItem", {
  116. newShopItem: newShopItem,
  117. shopItemName: name, shopType: shopType
  118. }, true)
  119. }
  120. export function DeleteShopItem(shopItemName: string) {
  121. return DeleteDataByPath("/ark/shopItem", {shopItemName: shopItemName}, true)
  122. }