ps99-api 1.2.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/.idea/runConfigurations/test.xml +11 -0
  2. package/.idea/runConfigurations/test_changing.xml +11 -0
  3. package/.idea/runConfigurations/test_snapshot.xml +11 -0
  4. package/.idea/runConfigurations/test_snapshot_changing.xml +12 -0
  5. package/.idea/webResources.xml +14 -0
  6. package/.releaserc +13 -0
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.js +1 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/ps99-api.d.ts +3 -3
  11. package/dist/ps99-api.js +2 -2
  12. package/dist/ps99-api.js.map +1 -1
  13. package/dist/responses/collection/achievement.d.ts +2 -9
  14. package/dist/responses/collection/boost.d.ts +2 -9
  15. package/dist/responses/collection/booth.d.ts +15 -22
  16. package/dist/responses/collection/box.d.ts +14 -21
  17. package/dist/responses/collection/buff.d.ts +2 -9
  18. package/dist/responses/collection/charm.d.ts +13 -20
  19. package/dist/responses/collection/collection-data.d.ts +9 -0
  20. package/dist/responses/collection/collection-data.js +3 -0
  21. package/dist/responses/collection/collection-data.js.map +1 -0
  22. package/dist/responses/collection/currency.d.ts +22 -29
  23. package/dist/responses/collection/egg.d.ts +25 -31
  24. package/dist/responses/collection/enchantment.d.ts +18 -25
  25. package/dist/responses/collection/fishing-rod.d.ts +9 -16
  26. package/dist/responses/collection/fruit.d.ts +15 -22
  27. package/dist/responses/collection/guild-battle.d.ts +6 -13
  28. package/dist/responses/collection/hoverboard.d.ts +27 -34
  29. package/dist/responses/collection/index.d.ts +7 -5
  30. package/dist/responses/collection/lootbox.d.ts +12 -19
  31. package/dist/responses/collection/mastery.d.ts +5 -12
  32. package/dist/responses/collection/merchant.d.ts +6 -13
  33. package/dist/responses/collection/misc-item.d.ts +10 -17
  34. package/dist/responses/collection/pet.d.ts +20 -27
  35. package/dist/responses/collection/potion.d.ts +17 -24
  36. package/dist/responses/collection/random-event.d.ts +9 -16
  37. package/dist/responses/collection/rank.d.ts +7 -22
  38. package/dist/responses/collection/rarity.d.ts +6 -13
  39. package/dist/responses/collection/rebirth.d.ts +4 -11
  40. package/dist/responses/collection/secret-room.d.ts +4 -41
  41. package/dist/responses/collection/seed.d.ts +47 -1
  42. package/dist/responses/collection/shovel.d.ts +4 -11
  43. package/dist/responses/collection/sprinkler.d.ts +14 -21
  44. package/dist/responses/collection/ultimate.d.ts +17 -23
  45. package/dist/responses/collection/upgrade.d.ts +26 -33
  46. package/dist/responses/collection/watering-can.d.ts +5 -12
  47. package/dist/responses/collection/world.d.ts +6 -13
  48. package/dist/responses/collection/zone-flag.d.ts +14 -21
  49. package/dist/responses/collection/zone.d.ts +25 -102
  50. package/dump-result.js +16 -3
  51. package/example-web/react2/package-lock.json +45 -8
  52. package/example-web/react2/package.json +4 -3
  53. package/example-web/react2/public/_redirects +1 -0
  54. package/example-web/react2/public/index.html +1 -1
  55. package/example-web/react2/public/service-worker.js +2 -1
  56. package/example-web/react2/src/App.tsx +26 -141
  57. package/example-web/react2/src/components/AchievementsComponent.tsx +34 -30
  58. package/example-web/react2/src/components/BoostsComponent.tsx +17 -31
  59. package/example-web/react2/src/components/BoothsComponent.tsx +25 -31
  60. package/example-web/react2/src/components/BoxesComponent.tsx +28 -31
  61. package/example-web/react2/src/components/BuffsComponent.tsx +19 -31
  62. package/example-web/react2/src/components/CharmsComponent.tsx +33 -38
  63. package/example-web/react2/src/components/CollectionConfigIndex.tsx +53 -0
  64. package/example-web/react2/src/components/CollectionsIndex.tsx +33 -0
  65. package/example-web/react2/src/components/CurrencyComponent.tsx +58 -31
  66. package/example-web/react2/src/components/DynamicCollectionConfigData.tsx +94 -0
  67. package/example-web/react2/src/components/EggsComponent.tsx +55 -32
  68. package/example-web/react2/src/components/EnchantsComponent.tsx +37 -40
  69. package/example-web/react2/src/components/FishingRodsComponent.tsx +35 -31
  70. package/example-web/react2/src/components/FruitsComponent.tsx +29 -37
  71. package/example-web/react2/src/components/GenericFetchComponent.tsx +53 -0
  72. package/example-web/react2/src/components/GuildBattlesComponent.tsx +70 -40
  73. package/example-web/react2/src/components/Header.tsx +27 -0
  74. package/example-web/react2/src/components/HomePage.tsx +14 -0
  75. package/example-web/react2/src/components/HoverboardsComponent.tsx +40 -31
  76. package/example-web/react2/src/components/ImageComponent.tsx +37 -19
  77. package/example-web/react2/src/components/LootboxesComponent.tsx +19 -31
  78. package/example-web/react2/src/components/MasteryComponent.tsx +48 -30
  79. package/example-web/react2/src/components/MerchantsComponent.tsx +39 -28
  80. package/example-web/react2/src/components/MiscItemsComponent.tsx +28 -46
  81. package/example-web/react2/src/components/PetsComponent.tsx +53 -34
  82. package/example-web/react2/src/components/PotionsComponent.tsx +42 -37
  83. package/example-web/react2/src/components/RandomEventsComponent.tsx +39 -32
  84. package/example-web/react2/src/components/RanksComponent.tsx +80 -29
  85. package/example-web/react2/src/components/RarityComponent.tsx +18 -27
  86. package/example-web/react2/src/components/RebirthsComponent.tsx +32 -29
  87. package/example-web/react2/src/components/SecretRoomsComponent.tsx +18 -28
  88. package/example-web/react2/src/components/SeedsComponent.tsx +66 -31
  89. package/example-web/react2/src/components/ShovelsComponent.tsx +22 -32
  90. package/example-web/react2/src/components/SprinklersComponent.tsx +23 -32
  91. package/example-web/react2/src/components/UltimatesComponent.tsx +29 -33
  92. package/example-web/react2/src/components/UpgradesComponent.tsx +68 -43
  93. package/example-web/react2/src/components/WateringCansComponent.tsx +25 -34
  94. package/example-web/react2/src/components/WorldsComponent.tsx +31 -29
  95. package/example-web/react2/src/components/ZoneFlagsComponent.tsx +27 -32
  96. package/example-web/react2/src/components/ZonesComponent.tsx +84 -29
  97. package/example-web/react2/src/index.tsx +4 -2
  98. package/example-web/react2/tsconfig.json +1 -1
  99. package/example-web/react2/webpack.config.js +2 -6
  100. package/package.json +5 -3
  101. package/src/__tests__/__snapshots__/ps99-api-changes.ts.snap +9852 -7851
  102. package/src/__tests__/__snapshots__/ps99-api-live.ts.snap +1313 -86
  103. package/src/__tests__/ps99-api-changes.ts +1 -1
  104. package/src/index.ts +1 -0
  105. package/src/ps99-api.ts +5 -5
  106. package/src/responses/collection/achievement.ts +12 -9
  107. package/src/responses/collection/boost.ts +9 -9
  108. package/src/responses/collection/booth.ts +17 -22
  109. package/src/responses/collection/box.ts +16 -21
  110. package/src/responses/collection/buff.ts +4 -9
  111. package/src/responses/collection/charm.ts +14 -20
  112. package/src/responses/collection/collection-data.ts +14 -0
  113. package/src/responses/collection/currency.ts +27 -29
  114. package/src/responses/collection/egg.ts +26 -31
  115. package/src/responses/collection/enchantment.ts +19 -25
  116. package/src/responses/collection/fishing-rod.ts +13 -16
  117. package/src/responses/collection/fruit.ts +16 -22
  118. package/src/responses/collection/guild-battle.ts +10 -13
  119. package/src/responses/collection/hoverboard.ts +31 -34
  120. package/src/responses/collection/index.ts +10 -6
  121. package/src/responses/collection/lootbox.ts +13 -19
  122. package/src/responses/collection/mastery.ts +6 -12
  123. package/src/responses/collection/merchant.ts +7 -13
  124. package/src/responses/collection/misc-item.ts +11 -17
  125. package/src/responses/collection/pet.ts +21 -27
  126. package/src/responses/collection/potion.ts +18 -24
  127. package/src/responses/collection/random-event.ts +13 -16
  128. package/src/responses/collection/rank.ts +8 -24
  129. package/src/responses/collection/rarity.ts +7 -13
  130. package/src/responses/collection/rebirth.ts +5 -11
  131. package/src/responses/collection/secret-room.ts +8 -44
  132. package/src/responses/collection/seed.ts +55 -0
  133. package/src/responses/collection/shovel.ts +5 -11
  134. package/src/responses/collection/sprinkler.ts +15 -21
  135. package/src/responses/collection/ultimate.ts +18 -23
  136. package/src/responses/collection/upgrade.ts +27 -33
  137. package/src/responses/collection/watering-can.ts +9 -12
  138. package/src/responses/collection/world.ts +7 -13
  139. package/src/responses/collection/zone-flag.ts +15 -21
  140. package/src/responses/collection/zone.ts +26 -119
  141. package/.release.rc +0 -8
@@ -1,42 +1,61 @@
1
- import React, { useEffect, useState } from "react";
2
- import { PetData, PetSimulator99API } from "ps99-api";
1
+ import React from "react";
2
+ import { CollectionConfigData } from "ps99-api";
3
+ import { GenericFetchComponent } from "./GenericFetchComponent";
3
4
  import ImageComponent from "./ImageComponent";
4
5
 
5
- const PetsComponent: React.FC = () => {
6
- const [pets, setPets] = useState<PetData[]>([]);
7
-
8
- useEffect(() => {
9
- const fetchPets = async () => {
10
- const api = new PetSimulator99API();
11
- const response = await api.getCollection("Pets");
12
- if (response.status === "ok") {
13
- setPets(response.data);
14
- }
15
- };
16
- fetchPets();
17
- }, []);
18
-
6
+ const PetsComponent: React.FC<{
7
+ configData?: CollectionConfigData<"Pets">;
8
+ }> = ({ configData }) => {
19
9
  return (
20
- <div>
21
- <h2>Pets</h2>
22
- <ul>
23
- {pets.map((pet, index) => (
24
- <li key={index}>
10
+ <GenericFetchComponent<CollectionConfigData<"Pets">>
11
+ collectionName="Pets"
12
+ configData={configData}
13
+ render={(data) => (
14
+ <div>
15
+ <h2>{data.name}</h2>
16
+ <ImageComponent src={data.thumbnail} alt={data.name} />
17
+ {data.goldenThumbnail && (
25
18
  <ImageComponent
26
- src={pet.configData.thumbnail}
27
- alt={pet.configData.name}
19
+ src={data.goldenThumbnail}
20
+ alt={`${data.name} (Golden)`}
28
21
  />
29
- <span>{pet.configData.name}</span>
30
- {pet.configData.goldenThumbnail && (
31
- <ImageComponent
32
- src={pet.configData.goldenThumbnail}
33
- alt={`Golden ${pet.configData.name}`}
34
- />
35
- )}
36
- </li>
37
- ))}
38
- </ul>
39
- </div>
22
+ )}
23
+ <p>From World Number: {data.fromWorldNumber}</p>
24
+ <p>From Zone Number: {data.fromZoneNumber}</p>
25
+ {data.indexObtainable && <p>Index Obtainable: Yes</p>}
26
+ {data.huge && <p>Huge: Yes</p>}
27
+ {data.fly && <p>Can Fly: Yes</p>}
28
+ {data.tradable && <p>Tradable: Yes</p>}
29
+ {data.secret && <p>Secret: Yes</p>}
30
+ {data.hidden && <p>Hidden: Yes</p>}
31
+ {data.cachedPower && (
32
+ <div>
33
+ <h3>Cached Power:</h3>
34
+ <ul>
35
+ {data.cachedPower.map((power, index) => (
36
+ <li key={index}>{power}</li>
37
+ ))}
38
+ </ul>
39
+ </div>
40
+ )}
41
+ {data.animations && (
42
+ <div>
43
+ <h3>Animations:</h3>
44
+ <ul>
45
+ {Object.entries(data.animations).map(([key, value], index) => (
46
+ <li key={index}>
47
+ {key}: {JSON.stringify(value)}
48
+ </li>
49
+ ))}
50
+ </ul>
51
+ </div>
52
+ )}
53
+ {data.indexDesc && <p>Description: {data.indexDesc}</p>}
54
+ {data.exclusiveLevel && <p>Exclusive Level: {data.exclusiveLevel}</p>}
55
+ {data.power && <p>Power: {data.power}</p>}
56
+ </div>
57
+ )}
58
+ />
40
59
  );
41
60
  };
42
61
 
@@ -1,43 +1,48 @@
1
- import React, { useEffect, useState } from "react";
2
- import { PetSimulator99API, PotionData } from "ps99-api";
1
+ import React from "react";
2
+ import { CollectionConfigData } from "ps99-api";
3
+ import { GenericFetchComponent } from "./GenericFetchComponent";
3
4
  import ImageComponent from "./ImageComponent";
4
5
 
5
- const PotionsComponent: React.FC = () => {
6
- const [potions, setPotions] = useState<PotionData[]>([]);
7
-
8
- useEffect(() => {
9
- const fetchPotions = async () => {
10
- const api = new PetSimulator99API();
11
- const response = await api.getCollection("Potions");
12
- if (response.status === "ok") {
13
- setPotions(response.data);
14
- }
15
- };
16
- fetchPotions();
17
- }, []);
18
-
6
+ const PotionsComponent: React.FC<{
7
+ configData?: CollectionConfigData<"Potions">;
8
+ }> = ({ configData }) => {
19
9
  return (
20
- <div>
21
- <h2>Potions</h2>
22
- <ul>
23
- {potions.map((potion, index) => (
24
- <li key={index}>
25
- <span>Base Tier: {potion.configData.BaseTier}</span>
26
- <span>Max Tier: {potion.configData.MaxTier}</span>
27
- {potion.configData.Tiers.map((tier, tierIndex) => (
28
- <div key={tierIndex}>
29
- <ImageComponent src={tier.Icon} alt={tier.DisplayName} />
30
- <span>Tier {tierIndex + 1}:</span>
31
- <span>{tier.DisplayName}</span>
32
- <span>Power: {tier.Power}</span>
33
- <span>Time: {tier.Time}</span>
34
- <span>Rarity: {tier.Rarity.DisplayName}</span>
35
- </div>
36
- ))}
37
- </li>
38
- ))}
39
- </ul>
40
- </div>
10
+ <GenericFetchComponent<CollectionConfigData<"Potions">>
11
+ collectionName="Potions"
12
+ configData={configData}
13
+ render={(data) => (
14
+ <div>
15
+ <h2>Potion: {data.Tiers[0].DisplayName}</h2>
16
+ <div>
17
+ <ImageComponent
18
+ src={data.Tiers[0].Icon}
19
+ alt={data.Tiers[0].DisplayName}
20
+ />
21
+ <p>Description: {data.Tiers[0].Desc}</p>
22
+ <p>Primary Color: {data.PrimaryColor}</p>
23
+ <p>Secondary Color: {data.SecondaryColor}</p>
24
+ <p>Base Tier: {data.BaseTier}</p>
25
+ <p>Max Tier: {data.MaxTier}</p>
26
+ </div>
27
+ <div>
28
+ <h3>Tiers:</h3>
29
+ <ul>
30
+ {data.Tiers.map((tier, index) => (
31
+ <li key={index}>
32
+ <p>Tier {index + 1}:</p>
33
+ <p>Display Name: {tier.DisplayName}</p>
34
+ <p>Description: {tier.Desc}</p>
35
+ <ImageComponent src={tier.Icon} alt={tier.DisplayName} />
36
+ <p>Power: {tier.Power}</p>
37
+ <p>Time: {tier.Time}</p>
38
+ <p>Rarity: {tier.Rarity.DisplayName}</p>
39
+ </li>
40
+ ))}
41
+ </ul>
42
+ </div>
43
+ </div>
44
+ )}
45
+ />
41
46
  );
42
47
  };
43
48
 
@@ -1,38 +1,45 @@
1
- import React, { useEffect, useState } from "react";
2
- import { PetSimulator99API, RandomEventData } from "ps99-api";
1
+ import React from "react";
2
+ import { CollectionConfigData } from "ps99-api";
3
+ import { GenericFetchComponent } from "./GenericFetchComponent";
3
4
  import ImageComponent from "./ImageComponent";
4
5
 
5
- const RandomEventsComponent: React.FC = () => {
6
- const [randomEvents, setRandomEvents] = useState<RandomEventData[]>([]);
7
-
8
- useEffect(() => {
9
- const fetchRandomEvents = async () => {
10
- const api = new PetSimulator99API();
11
- const response = await api.getCollection("RandomEvents");
12
- if (response.status === "ok") {
13
- setRandomEvents(response.data);
14
- }
15
- };
16
- fetchRandomEvents();
17
- }, []);
18
-
6
+ const RandomEventsComponent: React.FC<{
7
+ configData?: CollectionConfigData<"RandomEvents">;
8
+ }> = ({ configData }) => {
19
9
  return (
20
- <div>
21
- <h2>Random Events</h2>
22
- <ul>
23
- {randomEvents.map((event, index) => (
24
- <li key={index}>
25
- <ImageComponent
26
- src={event.configData.Icon}
27
- alt={event.configData.Name}
28
- />
29
- <span>{event.configData.Name}</span>
30
- <span>Duration: {event.configData.Duration}</span>
31
- <span>Chance: {event.configData.Chance}</span>
32
- </li>
33
- ))}
34
- </ul>
35
- </div>
10
+ <GenericFetchComponent<CollectionConfigData<"RandomEvents">>
11
+ collectionName="RandomEvents"
12
+ configData={configData}
13
+ render={(data) => (
14
+ <div>
15
+ <h2>Random Event: {data.Name}</h2>
16
+ <div>
17
+ <ImageComponent src={data.Icon} alt={data.Name} />
18
+ <p>Color: {data.Color}</p>
19
+ <p>Duration: {data.Duration} seconds</p>
20
+ <p>Breaking Requirement: {data.BreakingRequirement}</p>
21
+ <p>Playtime Requirement: {data.PlaytimeRequirement} minutes</p>
22
+ <p>Chance: {data.Chance}</p>
23
+ <p>Allow in Zones: {data.AllowInZones ? "Yes" : "No"}</p>
24
+ <p>Allow in Instances: {data.AllowInInstances ? "Yes" : "No"}</p>
25
+ <p>Allow Multiple: {data.AllowMultiple ? "Yes" : "No"}</p>
26
+ {data.MinimumZone && <p>Minimum Zone: {data.MinimumZone}</p>}
27
+ </div>
28
+ <div>
29
+ <h3>Area Whitelist:</h3>
30
+ <ul>
31
+ {Object.entries(data.AreaWhitelist).map(
32
+ ([area, allowed], index) => (
33
+ <li key={index}>
34
+ {area.replace("_", " ")}: {allowed ? "Yes" : "No"}
35
+ </li>
36
+ ),
37
+ )}
38
+ </ul>
39
+ </div>
40
+ </div>
41
+ )}
42
+ />
36
43
  );
37
44
  };
38
45
 
@@ -1,35 +1,86 @@
1
- import React, { useEffect, useState } from "react";
2
- import { PetSimulator99API, RankData } from "ps99-api";
1
+ import React from "react";
2
+ import { CollectionConfigData } from "ps99-api";
3
+ import { GenericFetchComponent } from "./GenericFetchComponent";
3
4
 
4
- const RanksComponent: React.FC = () => {
5
- const [ranks, setRanks] = useState<RankData[]>([]);
5
+ const RanksComponent: React.FC<{
6
+ configData?: CollectionConfigData<"Ranks">;
7
+ }> = ({ configData }) => {
8
+ return (
9
+ <GenericFetchComponent<CollectionConfigData<"Ranks">>
10
+ collectionName="Ranks"
11
+ configData={configData}
12
+ render={(data) => (
13
+ <div>
14
+ <h2>Rank: {data.Title}</h2>
15
+ <p>Rank Number: {data.RankNumber}</p>
16
+ <p>Max Enchants Equipped: {data.MaxEnchantsEquipped}</p>
17
+ <p>Maximum Active Goals: {data.MaximumActiveGoals}</p>
18
+ <p>Unlockable Egg Slots: {data.UnlockableEggSlots}</p>
19
+ <p>Unlockable Pet Slots: {data.UnlockablePetSlots}</p>
20
+ {data.RequiredRebirth && (
21
+ <p>Required Rebirth: {data.RequiredRebirth}</p>
22
+ )}
23
+ {data.RequiredZone && <p>Required Zone: {data.RequiredZone}</p>}
6
24
 
7
- useEffect(() => {
8
- const fetchRanks = async () => {
9
- const api = new PetSimulator99API();
10
- const response = await api.getCollection("Ranks");
11
- if (response.status === "ok") {
12
- setRanks(response.data);
13
- }
14
- };
15
- fetchRanks();
16
- }, []);
25
+ <div>
26
+ <h3>Goals:</h3>
27
+ {data.Goals.map((goalSet, index) => (
28
+ <div key={index}>
29
+ <h4>Goal Set {index + 1}</h4>
30
+ <ul>
31
+ {goalSet.map((goal, goalIndex) => (
32
+ <li key={goalIndex}>
33
+ <p>Type: {goal.Type}</p>
34
+ <p>Amount: {goal.Amount}</p>
35
+ <p>Weight: {goal.Weight}</p>
36
+ {goal.CurrencyID && <p>Currency ID: {goal.CurrencyID}</p>}
37
+ {goal.BreakableType && (
38
+ <p>Breakable Type: {goal.BreakableType}</p>
39
+ )}
40
+ {goal.PotionTier && <p>Potion Tier: {goal.PotionTier}</p>}
41
+ {goal.EnchantTier && (
42
+ <p>Enchant Tier: {goal.EnchantTier}</p>
43
+ )}
44
+ </li>
45
+ ))}
46
+ </ul>
47
+ </div>
48
+ ))}
49
+ </div>
17
50
 
18
- return (
19
- <div>
20
- <h2>Ranks</h2>
21
- <ul>
22
- {ranks.map((rank, index) => (
23
- <li key={index}>
24
- <span>{rank.configData.Title}</span>
25
- <span>Rank Number: {rank.configData.RankNumber}</span>
26
- <span>
27
- Max Enchants Equipped: {rank.configData.MaxEnchantsEquipped}
28
- </span>
29
- </li>
30
- ))}
31
- </ul>
32
- </div>
51
+ <div>
52
+ <h3>Rewards:</h3>
53
+ <ul>
54
+ {data.Rewards.map((reward, rewardIndex) => (
55
+ <li key={rewardIndex}>
56
+ <p>Stars Required: {reward.StarsRequired}</p>
57
+ <p>Reward Item ID: {reward.Item._data.id}</p>
58
+ {reward.Item._data._am && (
59
+ <p>Amount: {reward.Item._data._am}</p>
60
+ )}
61
+ {reward.Item._data.tn && <p>TN: {reward.Item._data.tn}</p>}
62
+ </li>
63
+ ))}
64
+ </ul>
65
+ </div>
66
+
67
+ {data.RankUpRewards && (
68
+ <div>
69
+ <h3>Rank Up Rewards:</h3>
70
+ <ul>
71
+ {data.RankUpRewards.map((reward, rewardIndex) => (
72
+ <li key={rewardIndex}>
73
+ <p>Reward Item ID: {reward._data.id}</p>
74
+ {reward._data._am && <p>Amount: {reward._data._am}</p>}
75
+ {reward._data.tn && <p>TN: {reward._data.tn}</p>}
76
+ </li>
77
+ ))}
78
+ </ul>
79
+ </div>
80
+ )}
81
+ </div>
82
+ )}
83
+ />
33
84
  );
34
85
  };
35
86
 
@@ -1,32 +1,23 @@
1
- import React, { useEffect, useState } from "react";
2
- import { PetSimulator99API, RarityData } from "ps99-api";
3
-
4
- const RarityComponent: React.FC = () => {
5
- const [rarityItems, setRarityItems] = useState<RarityData[]>([]);
6
-
7
- useEffect(() => {
8
- const fetchRarityItems = async () => {
9
- const api = new PetSimulator99API();
10
- const response = await api.getCollection("Rarity");
11
- if (response.status === "ok") {
12
- setRarityItems(response.data);
13
- }
14
- };
15
- fetchRarityItems();
16
- }, []);
1
+ import React from "react";
2
+ import { CollectionConfigData } from "ps99-api";
3
+ import { GenericFetchComponent } from "./GenericFetchComponent";
17
4
 
5
+ const RarityComponent: React.FC<{
6
+ configData?: CollectionConfigData<"Rarity">;
7
+ }> = ({ configData }) => {
18
8
  return (
19
- <div>
20
- <h2>Rarity</h2>
21
- <ul>
22
- {rarityItems.map((item, index) => (
23
- <li key={index}>
24
- <span>{item.configData.DisplayName}</span>
25
- <span>Rarity Number: {item.configData.RarityNumber}</span>
26
- </li>
27
- ))}
28
- </ul>
29
- </div>
9
+ <GenericFetchComponent<CollectionConfigData<"Rarity">>
10
+ collectionName="Rarity"
11
+ configData={configData}
12
+ render={(data) => (
13
+ <div>
14
+ <h2>Rarity: {data.DisplayName}</h2>
15
+ <p>Rarity Number: {data.RarityNumber}</p>
16
+ <p>Color: {data.Color}</p>
17
+ <p>Announce: {data.Announce ? "Yes" : "No"}</p>
18
+ </div>
19
+ )}
20
+ />
30
21
  );
31
22
  };
32
23
 
@@ -1,34 +1,37 @@
1
- import React, { useEffect, useState } from "react";
2
- import { PetSimulator99API, RebirthData } from "ps99-api";
3
-
4
- const RebirthsComponent: React.FC = () => {
5
- const [rebirths, setRebirths] = useState<RebirthData[]>([]);
6
-
7
- useEffect(() => {
8
- const fetchRebirths = async () => {
9
- const api = new PetSimulator99API();
10
- const response = await api.getCollection("Rebirths");
11
- if (response.status === "ok") {
12
- setRebirths(response.data);
13
- }
14
- };
15
- fetchRebirths();
16
- }, []);
1
+ import React from "react";
2
+ import { CollectionConfigData, RebirthUnlock } from "ps99-api";
3
+ import { GenericFetchComponent } from "./GenericFetchComponent";
4
+ import ImageComponent from "./ImageComponent";
17
5
 
6
+ const RebirthComponent: React.FC<{
7
+ configData?: CollectionConfigData<"Rebirths">;
8
+ }> = ({ configData }) => {
18
9
  return (
19
- <div>
20
- <h2>Rebirths</h2>
21
- <ul>
22
- {rebirths.map((rebirth, index) => (
23
- <li key={index}>
24
- <span>{rebirth.configData.DisplayName}</span>
25
- <span>Boost Description: {rebirth.configData.BoostDesc}</span>
26
- <span>Rebirth Number: {rebirth.configData.RebirthNumber}</span>
27
- </li>
28
- ))}
29
- </ul>
30
- </div>
10
+ <GenericFetchComponent<CollectionConfigData<"Rebirths">>
11
+ collectionName="Rebirths"
12
+ configData={configData}
13
+ render={(data) => (
14
+ <div>
15
+ <h2>Rebirth: {data.DisplayName}</h2>
16
+ <p>Rebirth Number: {data.RebirthNumber}</p>
17
+ <p>Zone Number Required: {data.ZoneNumberRequired}</p>
18
+ <p>Strength Power Boost: {data.StrengthPowerBoost}%</p>
19
+ <p>Boost Description: {data.BoostDesc}</p>
20
+ {data.ResetZone && <p>Reset Zone: {data.ResetZone}</p>}
21
+ <h3>Unlocks:</h3>
22
+ <ul>
23
+ {data.RebirthUnlocks.map((unlock: RebirthUnlock, index: number) => (
24
+ <li key={index}>
25
+ <ImageComponent src={unlock.Icon} alt={unlock.Title} />
26
+ <strong>{unlock.GuiTitle || unlock.Title}</strong>:{" "}
27
+ {unlock.Desc}
28
+ </li>
29
+ ))}
30
+ </ul>
31
+ </div>
32
+ )}
33
+ />
31
34
  );
32
35
  };
33
36
 
34
- export default RebirthsComponent;
37
+ export default RebirthComponent;
@@ -1,33 +1,23 @@
1
- import React, { useEffect, useState } from "react";
2
- import { PetSimulator99API, SecretRoomData } from "ps99-api";
3
-
4
- const SecretRoomsComponent: React.FC = () => {
5
- const [secretRooms, setSecretRooms] = useState<SecretRoomData[]>([]);
6
-
7
- useEffect(() => {
8
- const fetchSecretRooms = async () => {
9
- const api = new PetSimulator99API();
10
- const response = await api.getCollection("SecretRooms");
11
- if (response.status === "ok") {
12
- setSecretRooms(response.data);
13
- }
14
- };
15
- fetchSecretRooms();
16
- }, []);
1
+ import React from "react";
2
+ import { CollectionConfigData } from "ps99-api";
3
+ import { GenericFetchComponent } from "./GenericFetchComponent";
17
4
 
5
+ const SecretRoomComponent: React.FC<{
6
+ configData?: CollectionConfigData<"SecretRooms">;
7
+ }> = ({ configData }) => {
18
8
  return (
19
- <div>
20
- <h2>Secret Rooms</h2>
21
- <ul>
22
- {secretRooms.map((room, index) => (
23
- <li key={index}>
24
- <span>{room.configData.DisplayName}</span>
25
- <span>Required Zone: {room.configData.RequiredZone}</span>
26
- </li>
27
- ))}
28
- </ul>
29
- </div>
9
+ <GenericFetchComponent<CollectionConfigData<"SecretRooms">>
10
+ collectionName="SecretRooms"
11
+ configData={configData}
12
+ render={(data) => (
13
+ <div>
14
+ <h2>Secret Room: {data.DisplayName}</h2>
15
+ <p>Instance ID: {data.InstanceId}</p>
16
+ <p>Required Zone: {data.RequiredZone}</p>
17
+ </div>
18
+ )}
19
+ />
30
20
  );
31
21
  };
32
22
 
33
- export default SecretRoomsComponent;
23
+ export default SecretRoomComponent;
@@ -1,39 +1,74 @@
1
- import React, { useEffect, useState } from "react";
2
- import { PetSimulator99API, SeedData } from "ps99-api";
1
+ import React from "react";
2
+ import {
3
+ CollectionConfigData,
4
+ LootTableRoot,
5
+ LootTableEntry,
6
+ RawStackKey,
7
+ LootTableData,
8
+ } from "ps99-api";
9
+ import { GenericFetchComponent } from "./GenericFetchComponent";
3
10
  import ImageComponent from "./ImageComponent";
4
11
 
5
- const SeedsComponent: React.FC = () => {
6
- const [seeds, setSeeds] = useState<SeedData[]>([]);
12
+ const parseRawStackKey = (rawStackKey: RawStackKey): LootTableData => {
13
+ try {
14
+ return JSON.parse(rawStackKey);
15
+ } catch (error) {
16
+ console.error("Failed to parse RawStackKey:", rawStackKey, error);
17
+ return {} as LootTableData;
18
+ }
19
+ };
7
20
 
8
- useEffect(() => {
9
- const fetchSeeds = async () => {
10
- const api = new PetSimulator99API();
11
- const response = await api.getCollection("Seeds");
12
- if (response.status === "ok") {
13
- setSeeds(response.data);
14
- }
15
- };
16
- fetchSeeds();
17
- }, []);
21
+ const renderLootTable = (lootTable: LootTableRoot | LootTableRoot[]) => {
22
+ const lootTableArray = Array.isArray(lootTable) ? lootTable : [lootTable];
23
+ return lootTableArray.map((table, index) => (
24
+ <div key={index}>
25
+ {table.entries.map((entry: LootTableEntry, entryIndex: number) => {
26
+ const parsedStackKey = entry.Value._stackKey
27
+ ? parseRawStackKey(entry.Value._stackKey)
28
+ : null;
29
+ return (
30
+ <div key={entryIndex}>
31
+ <h4>Loot Entry {entryIndex + 1}</h4>
32
+ <p>Weight: {entry.Weight}</p>
33
+ {parsedStackKey && (
34
+ <>
35
+ <p>Item ID: {parsedStackKey.id}</p>
36
+ {parsedStackKey.tn && <p>Item TN: {parsedStackKey.tn}</p>}
37
+ {parsedStackKey._am && <p>Amount: {parsedStackKey._am}</p>}
38
+ </>
39
+ )}
40
+ </div>
41
+ );
42
+ })}
43
+ </div>
44
+ ));
45
+ };
18
46
 
47
+ const SeedComponent: React.FC<{
48
+ configData?: CollectionConfigData<"Seeds">;
49
+ }> = ({ configData }) => {
19
50
  return (
20
- <div>
21
- <h2>Seeds</h2>
22
- <ul>
23
- {seeds.map((seed, index) => (
24
- <li key={index}>
25
- <ImageComponent
26
- src={seed.configData.Icon}
27
- alt={seed.configData.DisplayName}
28
- />
29
- <span>{seed.configData.DisplayName}</span>
30
- <span>{seed.configData.Desc}</span>
31
- <span>Grow Time: {seed.configData.GrowTime}</span>
32
- </li>
33
- ))}
34
- </ul>
35
- </div>
51
+ <GenericFetchComponent<CollectionConfigData<"Seeds">>
52
+ collectionName="Seeds"
53
+ configData={configData}
54
+ render={(data) => (
55
+ <div>
56
+ <h2>Seed: {data.DisplayName}</h2>
57
+ <p>Description: {data.Desc}</p>
58
+ <p>Grow Time: {data.GrowTime} seconds</p>
59
+ <p>
60
+ Rarity: {data.Rarity.DisplayName} (Rarity Number:{" "}
61
+ {data.Rarity.RarityNumber})
62
+ </p>
63
+ <ImageComponent src={data.Icon} alt={data.DisplayName} />
64
+ <div>
65
+ <h3>Loot Table</h3>
66
+ {renderLootTable(data.LootTable)}
67
+ </div>
68
+ </div>
69
+ )}
70
+ />
36
71
  );
37
72
  };
38
73
 
39
- export default SeedsComponent;
74
+ export default SeedComponent;