Skip to content

Commit 6086b8f

Browse files
authored
Merge branch 'main' into dependabot/npm_and_yarn/npm-dependencies-2bf8de9f20
2 parents c3bd481 + fc256b4 commit 6086b8f

File tree

11 files changed

+172
-140
lines changed

11 files changed

+172
-140
lines changed

.github/workflows/branch-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
runs-on: ubuntu-latest
2020

2121
steps:
22-
- uses: github/branch-deploy@v9
22+
- uses: github/branch-deploy@v10
2323
id: branch-deploy
2424
with:
2525
admins: the-hideout/core-contributors

.github/workflows/deploy.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ jobs:
1313
runs-on: ubuntu-latest
1414
outputs: # set outputs for use in downstream jobs
1515
continue: ${{ steps.deployment-check.outputs.continue }}
16+
sha: ${{ steps.deployment-check.outputs.sha }}
1617

1718
steps:
1819
# https://github.com/github/branch-deploy/blob/d3c24bd92505e623615b75ffdfac5ed5259adbdb/docs/merge-commit-strategy.md
1920
- name: deployment check
20-
uses: github/branch-deploy@v9
21+
uses: github/branch-deploy@v10
2122
id: deployment-check
2223
with:
2324
merge_deploy_mode: "true"
@@ -32,6 +33,8 @@ jobs:
3233
steps:
3334
- name: checkout
3435
uses: actions/checkout@v4
36+
with:
37+
ref: ${{ needs.deployment-check.outputs.sha }}
3538

3639
- name: setup node
3740
uses: actions/setup-node@v4

.github/workflows/unlock-on-merge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616

1717
steps:
1818
- name: unlock on merge
19-
uses: github/branch-deploy@v9
19+
uses: github/branch-deploy@v10
2020
id: unlock-on-merge
2121
with:
2222
unlock_on_merge_mode: "true" # <-- indicates that this is the "Unlock on Merge Mode" workflow

datasources/handbook.mjs

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import WorkerKV from '../utils/worker-kv.mjs';
2+
3+
class HandbookAPI extends WorkerKV {
4+
constructor(dataSource) {
5+
super('handbook_data', dataSource);
6+
//this.gameModes.push('pve');
7+
}
8+
9+
async getCategory(context, info, id) {
10+
const { cache } = await this.getCache(context, info);
11+
return cache.ItemCategory[id] || cache.HandbookCategory[id];
12+
}
13+
14+
async getTopCategory(context, info, id) {
15+
const cat = await this.getCategory(context, info, id);
16+
if (cat && cat.parent_id) return this.getTopCategory(context, info, cat.parent_id);
17+
return cat;
18+
}
19+
20+
async getCategories(context, info) {
21+
const { cache } = await this.getCache(context, info);
22+
if (!cache) {
23+
return Promise.reject(new Error('Item cache is empty'));
24+
}
25+
const categories = [];
26+
for (const id in cache.ItemCategory) {
27+
categories.push(cache.ItemCategory[id]);
28+
}
29+
return categories;
30+
}
31+
32+
async getCategoriesEnum(context, info) {
33+
const cats = await this.getCategories(context, info);
34+
const map = {};
35+
for (const id in cats) {
36+
map[cats[id].enumName] = cats[id];
37+
}
38+
return map;
39+
}
40+
41+
async getHandbookCategory(context, info, id) {
42+
const { cache } = await this.getCache(context, info);
43+
return cache.HandbookCategory[id];
44+
}
45+
46+
async getHandbookCategories(context, info) {
47+
const { cache } = await this.getCache(context, info);
48+
if (!cache) {
49+
return Promise.reject(new Error('Item cache is empty'));
50+
}
51+
return Object.values(cache.HandbookCategory);
52+
}
53+
54+
async getArmorMaterials(context, info) {
55+
const { cache } = await this.getCache(context, info);
56+
return Object.values(cache.ArmorMaterial).sort();
57+
}
58+
59+
async getArmorMaterial(context, info, matKey) {
60+
const { cache } = await this.getCache(context, info);
61+
return cache.ArmorMaterial[matKey];
62+
}
63+
64+
async getMasterings(context, info) {
65+
const { cache } = await this.getCache(context, info);
66+
return cache.Mastering;
67+
}
68+
69+
async getMastering(context, info, mastId) {
70+
const { cache } = await this.getCache(context, info);
71+
return cache.Mastering.find(m => m.id === mastId);
72+
}
73+
74+
async getSkills(context, info) {
75+
const { cache } = await this.getCache(context, info);
76+
return cache.Skill;
77+
}
78+
79+
async getSkill(context, info, skillId) {
80+
const { cache } = await this.getCache(context, info);
81+
return cache.Skill.find(s => s.id === skillId);
82+
}
83+
84+
async getPlayerLevels(context, info) {
85+
const { cache } = await this.getCache(context, info);
86+
return cache.PlayerLevel;
87+
}
88+
89+
async getAllItemProperties(context, info) {
90+
const { cache } = await this.getCache(context, info);
91+
return cache.ItemProperties;
92+
}
93+
94+
async getItemProperties(context, info, itemId) {
95+
const { cache } = await this.getCache(context, info);
96+
return cache.ItemProperties[itemId];
97+
}
98+
}
99+
100+
export default HandbookAPI;

datasources/index.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import BartersAPI from './barters.mjs';
22
import CraftsAPI from './crafts.mjs';
3+
import HandbookAPI from './handbook.mjs';
34
import HideoutAPI from './hideout.mjs';
45
import HistoricalPricesAPI from './historical-prices.mjs';
56
import ArchivedPricesAPI from './archived-prices.mjs';
@@ -23,6 +24,7 @@ class DataSource {
2324
this.worker = {
2425
barter: new BartersAPI(this),
2526
craft: new CraftsAPI(this),
27+
handbook: new HandbookAPI(this),
2628
hideout: new HideoutAPI(this),
2729
historicalPrice: new HistoricalPricesAPI(this),
2830
archivedPrice: new ArchivedPricesAPI(this),

datasources/items.mjs

Lines changed: 4 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ class ItemsAPI extends WorkerKV {
170170
if (!items) {
171171
items = Object.values(cache.Item);
172172
}
173-
const categories = (await this.getCategories(context, info)).filter(cat => names.includes(cat.enumName));
173+
const categories = (await context.data.worker.handbook.getCategories(context, info)).filter(cat => names.includes(cat.enumName));
174174
return items.filter((item) => {
175175
return item.categories.some(catId => categories.some(cat => cat.id === catId));
176176
});
@@ -181,7 +181,7 @@ class ItemsAPI extends WorkerKV {
181181
if (!items) {
182182
items = Object.values(cache.Item);
183183
}
184-
const categories = (await this.getHandbookCategories(context, info)).filter(cat => names.includes(cat.enumName));
184+
const categories = (await context.data.worker.handbook.getHandbookCategories(context, info)).filter(cat => names.includes(cat.enumName));
185185
return items.filter((item) => {
186186
return item.handbookCategories.some(catId => categories.some(cat => cat.id === catId));
187187
});
@@ -216,108 +216,24 @@ class ItemsAPI extends WorkerKV {
216216
});
217217
}
218218

219-
async getCategory(context, info, id) {
220-
const { cache } = await this.getCache(context, info);
221-
return cache.ItemCategory[id] || cache.HandbookCategory[id];
222-
}
223-
224-
async getTopCategory(context, info, id) {
225-
const cat = await this.getCategory(context, info, id);
226-
if (cat && cat.parent_id) return this.getTopCategory(context, info, cat.parent_id);
227-
return cat;
228-
}
229-
230-
async getCategories(context, info) {
231-
const { cache } = await this.getCache(context, info);
232-
if (!cache) {
233-
return Promise.reject(new Error('Item cache is empty'));
234-
}
235-
const categories = [];
236-
for (const id in cache.ItemCategory) {
237-
categories.push(cache.ItemCategory[id]);
238-
}
239-
return categories;
240-
}
241-
242-
async getCategoriesEnum(context, info) {
243-
const cats = await this.getCategories(context, info);
244-
const map = {};
245-
for (const id in cats) {
246-
map[cats[id].enumName] = cats[id];
247-
}
248-
return map;
249-
}
250-
251-
async getHandbookCategory(context, info, id) {
252-
const { cache } = await this.getCache(context, info);
253-
return cache.HandbookCategory[id];
254-
}
255-
256-
async getHandbookCategories(context, info) {
257-
const { cache } = await this.getCache(context, info);
258-
if (!cache) {
259-
return Promise.reject(new Error('Item cache is empty'));
260-
}
261-
return Object.values(cache.HandbookCategory);
262-
}
263-
264219
async getFleaMarket(context, info) {
265220
const { cache } = await this.getCache(context, info);
266221
return cache.FleaMarket;
267222
}
268223

269-
async getArmorMaterials(context, info) {
270-
const { cache } = await this.getCache(context, info);
271-
return Object.values(cache.ArmorMaterial).sort();
272-
}
273-
274-
async getArmorMaterial(context, info, matKey) {
275-
const { cache } = await this.getCache(context, info);
276-
return cache.ArmorMaterial[matKey];
277-
}
278-
279-
async getMasterings(context, info) {
280-
const { cache } = await this.getCache(context, info);
281-
return cache.Mastering;
282-
}
283-
284-
async getMastering(context, info, mastId) {
285-
const { cache } = await this.getCache(context, info);
286-
return cache.Mastering.find(m => m.id === mastId);
287-
}
288-
289-
async getSkills(context, info) {
290-
const { cache } = await this.getCache(context, info);
291-
return cache.Skill;
292-
}
293-
294-
async getSkill(context, info, skillId) {
295-
const { cache } = await this.getCache(context, info);
296-
return cache.Skill.find(s => s.id === skillId);
297-
}
298-
299224
async getAmmoList(context, info) {
300225
const allAmmo = await this.getItemsByBsgCategoryId(context, info, '5485a8684bdc2da71d8b4567').then(ammoItems => {
301226
// ignore bb
302227
return ammoItems.filter(item => item.id !== '6241c316234b593b5676b637');
303228
});
229+
const itemProperties = await context.data.worker.handbook.getAllItemProperties(context, info);
304230
return allAmmo.map(item => {
305231
return {
306232
...item,
307-
...item.properties
233+
...itemProperties[item.id],
308234
};
309235
});
310236
}
311-
312-
async getPlayerLevels(context, info) {
313-
const { cache } = await this.getCache(context, info);
314-
return cache.PlayerLevel;
315-
}
316-
317-
async getTypes(context, info) {
318-
const { cache } = await this.getCache(context, info);
319-
return cache.ItemType;
320-
}
321237
}
322238

323239
export default ItemsAPI;

resolvers/hideoutResolver.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export default {
5050
return context.data.worker.hideout.getLocale(data.name, context, info);
5151
},
5252
skill(data, args, context, info) {
53-
return context.data.worker.item.getSkill(context, info, data.name);
53+
return context.data.worker.handbook.getSkill(context, info, data.name);
5454
},
5555
},
5656
HideoutModule: {

0 commit comments

Comments
 (0)