Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/npm-dependencies-2bf…
Browse files Browse the repository at this point in the history
…8de9f20
  • Loading branch information
Razzmatazzz authored Jan 21, 2025
2 parents c3bd481 + fc256b4 commit 6086b8f
Show file tree
Hide file tree
Showing 11 changed files with 172 additions and 140 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/branch-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: github/branch-deploy@v9
- uses: github/branch-deploy@v10
id: branch-deploy
with:
admins: the-hideout/core-contributors
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ jobs:
runs-on: ubuntu-latest
outputs: # set outputs for use in downstream jobs
continue: ${{ steps.deployment-check.outputs.continue }}
sha: ${{ steps.deployment-check.outputs.sha }}

steps:
# https://github.com/github/branch-deploy/blob/d3c24bd92505e623615b75ffdfac5ed5259adbdb/docs/merge-commit-strategy.md
- name: deployment check
uses: github/branch-deploy@v9
uses: github/branch-deploy@v10
id: deployment-check
with:
merge_deploy_mode: "true"
Expand All @@ -32,6 +33,8 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@v4
with:
ref: ${{ needs.deployment-check.outputs.sha }}

- name: setup node
uses: actions/setup-node@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unlock-on-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

steps:
- name: unlock on merge
uses: github/branch-deploy@v9
uses: github/branch-deploy@v10
id: unlock-on-merge
with:
unlock_on_merge_mode: "true" # <-- indicates that this is the "Unlock on Merge Mode" workflow
Expand Down
100 changes: 100 additions & 0 deletions datasources/handbook.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import WorkerKV from '../utils/worker-kv.mjs';

class HandbookAPI extends WorkerKV {
constructor(dataSource) {
super('handbook_data', dataSource);
//this.gameModes.push('pve');
}

async getCategory(context, info, id) {
const { cache } = await this.getCache(context, info);
return cache.ItemCategory[id] || cache.HandbookCategory[id];
}

async getTopCategory(context, info, id) {
const cat = await this.getCategory(context, info, id);
if (cat && cat.parent_id) return this.getTopCategory(context, info, cat.parent_id);
return cat;
}

async getCategories(context, info) {
const { cache } = await this.getCache(context, info);
if (!cache) {
return Promise.reject(new Error('Item cache is empty'));
}
const categories = [];
for (const id in cache.ItemCategory) {
categories.push(cache.ItemCategory[id]);
}
return categories;
}

async getCategoriesEnum(context, info) {
const cats = await this.getCategories(context, info);
const map = {};
for (const id in cats) {
map[cats[id].enumName] = cats[id];
}
return map;
}

async getHandbookCategory(context, info, id) {
const { cache } = await this.getCache(context, info);
return cache.HandbookCategory[id];
}

async getHandbookCategories(context, info) {
const { cache } = await this.getCache(context, info);
if (!cache) {
return Promise.reject(new Error('Item cache is empty'));
}
return Object.values(cache.HandbookCategory);
}

async getArmorMaterials(context, info) {
const { cache } = await this.getCache(context, info);
return Object.values(cache.ArmorMaterial).sort();
}

async getArmorMaterial(context, info, matKey) {
const { cache } = await this.getCache(context, info);
return cache.ArmorMaterial[matKey];
}

async getMasterings(context, info) {
const { cache } = await this.getCache(context, info);
return cache.Mastering;
}

async getMastering(context, info, mastId) {
const { cache } = await this.getCache(context, info);
return cache.Mastering.find(m => m.id === mastId);
}

async getSkills(context, info) {
const { cache } = await this.getCache(context, info);
return cache.Skill;
}

async getSkill(context, info, skillId) {
const { cache } = await this.getCache(context, info);
return cache.Skill.find(s => s.id === skillId);
}

async getPlayerLevels(context, info) {
const { cache } = await this.getCache(context, info);
return cache.PlayerLevel;
}

async getAllItemProperties(context, info) {
const { cache } = await this.getCache(context, info);
return cache.ItemProperties;
}

async getItemProperties(context, info, itemId) {
const { cache } = await this.getCache(context, info);
return cache.ItemProperties[itemId];
}
}

export default HandbookAPI;
2 changes: 2 additions & 0 deletions datasources/index.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import BartersAPI from './barters.mjs';
import CraftsAPI from './crafts.mjs';
import HandbookAPI from './handbook.mjs';
import HideoutAPI from './hideout.mjs';
import HistoricalPricesAPI from './historical-prices.mjs';
import ArchivedPricesAPI from './archived-prices.mjs';
Expand All @@ -23,6 +24,7 @@ class DataSource {
this.worker = {
barter: new BartersAPI(this),
craft: new CraftsAPI(this),
handbook: new HandbookAPI(this),
hideout: new HideoutAPI(this),
historicalPrice: new HistoricalPricesAPI(this),
archivedPrice: new ArchivedPricesAPI(this),
Expand Down
92 changes: 4 additions & 88 deletions datasources/items.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class ItemsAPI extends WorkerKV {
if (!items) {
items = Object.values(cache.Item);
}
const categories = (await this.getCategories(context, info)).filter(cat => names.includes(cat.enumName));
const categories = (await context.data.worker.handbook.getCategories(context, info)).filter(cat => names.includes(cat.enumName));
return items.filter((item) => {
return item.categories.some(catId => categories.some(cat => cat.id === catId));
});
Expand All @@ -181,7 +181,7 @@ class ItemsAPI extends WorkerKV {
if (!items) {
items = Object.values(cache.Item);
}
const categories = (await this.getHandbookCategories(context, info)).filter(cat => names.includes(cat.enumName));
const categories = (await context.data.worker.handbook.getHandbookCategories(context, info)).filter(cat => names.includes(cat.enumName));
return items.filter((item) => {
return item.handbookCategories.some(catId => categories.some(cat => cat.id === catId));
});
Expand Down Expand Up @@ -216,108 +216,24 @@ class ItemsAPI extends WorkerKV {
});
}

async getCategory(context, info, id) {
const { cache } = await this.getCache(context, info);
return cache.ItemCategory[id] || cache.HandbookCategory[id];
}

async getTopCategory(context, info, id) {
const cat = await this.getCategory(context, info, id);
if (cat && cat.parent_id) return this.getTopCategory(context, info, cat.parent_id);
return cat;
}

async getCategories(context, info) {
const { cache } = await this.getCache(context, info);
if (!cache) {
return Promise.reject(new Error('Item cache is empty'));
}
const categories = [];
for (const id in cache.ItemCategory) {
categories.push(cache.ItemCategory[id]);
}
return categories;
}

async getCategoriesEnum(context, info) {
const cats = await this.getCategories(context, info);
const map = {};
for (const id in cats) {
map[cats[id].enumName] = cats[id];
}
return map;
}

async getHandbookCategory(context, info, id) {
const { cache } = await this.getCache(context, info);
return cache.HandbookCategory[id];
}

async getHandbookCategories(context, info) {
const { cache } = await this.getCache(context, info);
if (!cache) {
return Promise.reject(new Error('Item cache is empty'));
}
return Object.values(cache.HandbookCategory);
}

async getFleaMarket(context, info) {
const { cache } = await this.getCache(context, info);
return cache.FleaMarket;
}

async getArmorMaterials(context, info) {
const { cache } = await this.getCache(context, info);
return Object.values(cache.ArmorMaterial).sort();
}

async getArmorMaterial(context, info, matKey) {
const { cache } = await this.getCache(context, info);
return cache.ArmorMaterial[matKey];
}

async getMasterings(context, info) {
const { cache } = await this.getCache(context, info);
return cache.Mastering;
}

async getMastering(context, info, mastId) {
const { cache } = await this.getCache(context, info);
return cache.Mastering.find(m => m.id === mastId);
}

async getSkills(context, info) {
const { cache } = await this.getCache(context, info);
return cache.Skill;
}

async getSkill(context, info, skillId) {
const { cache } = await this.getCache(context, info);
return cache.Skill.find(s => s.id === skillId);
}

async getAmmoList(context, info) {
const allAmmo = await this.getItemsByBsgCategoryId(context, info, '5485a8684bdc2da71d8b4567').then(ammoItems => {
// ignore bb
return ammoItems.filter(item => item.id !== '6241c316234b593b5676b637');
});
const itemProperties = await context.data.worker.handbook.getAllItemProperties(context, info);
return allAmmo.map(item => {
return {
...item,
...item.properties
...itemProperties[item.id],
};
});
}

async getPlayerLevels(context, info) {
const { cache } = await this.getCache(context, info);
return cache.PlayerLevel;
}

async getTypes(context, info) {
const { cache } = await this.getCache(context, info);
return cache.ItemType;
}
}

export default ItemsAPI;
2 changes: 1 addition & 1 deletion resolvers/hideoutResolver.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default {
return context.data.worker.hideout.getLocale(data.name, context, info);
},
skill(data, args, context, info) {
return context.data.worker.item.getSkill(context, info, data.name);
return context.data.worker.handbook.getSkill(context, info, data.name);
},
},
HideoutModule: {
Expand Down
Loading

0 comments on commit 6086b8f

Please sign in to comment.