From ab088b9db8500e9577ef19db1718a4f95e329e41 Mon Sep 17 00:00:00 2001 From: Razzmatazz Date: Sun, 28 Jan 2024 16:41:33 -0600 Subject: [PATCH 1/4] Add achievements --- datasources/tasks.js | 16 ++++++++++++++++ resolvers/taskResolver.js | 11 +++++++++++ schema.js | 10 ++++++++++ 3 files changed, 37 insertions(+) diff --git a/datasources/tasks.js b/datasources/tasks.js index 8e972a35..70fcb583 100644 --- a/datasources/tasks.js +++ b/datasources/tasks.js @@ -130,6 +130,22 @@ class TasksAPI extends WorkerKV { await this.init(context); return this.cache.QuestItem[id]; } + + async getAchievements(context) { + await this.init(context); + return this.cache.Achievement; + } + + async getAchievement(context, id) { + await this.init(context); + const achievements = await this.getAchievements(context); + for (const achievement of achievements) { + if (achievement.id === id) { + return achievement; + } + } + return Promise.reject(new Error(`No achievement with id ${id} found`)); + } } module.exports = TasksAPI; diff --git a/resolvers/taskResolver.js b/resolvers/taskResolver.js index 41e6def2..3550445b 100644 --- a/resolvers/taskResolver.js +++ b/resolvers/taskResolver.js @@ -1,5 +1,8 @@ module.exports = { Query: { + achievements(obj, args, context) { + return context.util.paginate(context.data.task.getAchievements(context), args); + }, async tasks(obj, args, context, info) { let tasks = await context.data.task.getList(context); if (args.faction) { @@ -22,6 +25,14 @@ module.exports = { return context.data.task.getQuestItems(context); } }, + Achievement: { + name(data, args, context, info) { + return context.data.task.getLocale(data.name, context, info); + }, + description(data, args, context, info) { + return context.data.task.getLocale(data.description, context, info); + }, + }, HealthEffect: { bodyParts(data, args, context, info) { if (data.bodyParts.length === 0) { diff --git a/schema.js b/schema.js index 6ba839d1..3b3bc6ef 100644 --- a/schema.js +++ b/schema.js @@ -1,4 +1,12 @@ module.exports = ` +type Achievement { + id: ID! + name: String! + description: String + hidden: Boolean! + playersCompletedPercent: Float! +} + type Ammo { item: Item! weight: Float! @@ -385,6 +393,7 @@ type ItemPropertiesArmorAttachment { ergoPenalty: Int headZones: [String] material: ArmorMaterial + armorType: String blindnessProtection: Float bluntThroughput: Float slots: [ItemSlot] @@ -1306,6 +1315,7 @@ interface Vendor { #union Vendor = TraderOffer | FleaMarket type Query { + achievements(lang: LanguageCode, limit: Int, offset: Int): [Achievement]! ammo(lang: LanguageCode, limit: Int, offset: Int): [Ammo] #archivedItemPrices(id: ID!, limit: Int, offset: Int): [historicalPricePoint]! barters(lang: LanguageCode, limit: Int, offset: Int): [Barter] From dc9ff924bcfb9b982df10c8739066366c9266524 Mon Sep 17 00:00:00 2001 From: Razzmatazz Date: Wed, 31 Jan 2024 06:11:58 -0600 Subject: [PATCH 2/4] add penetrationPowerDeviation --- schema.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/schema.js b/schema.js index 3b3bc6ef..712aaa91 100644 --- a/schema.js +++ b/schema.js @@ -22,6 +22,7 @@ type Ammo { ricochetChance: Float! penetrationChance: Float! penetrationPower: Int! + penetrationPowerDeviation: Float accuracy: Int @deprecated(reason: "Use accuracyModifier instead.") accuracyModifier: Float recoil: Int @deprecated(reason: "Use recoilModifier instead.") @@ -355,6 +356,7 @@ type ItemPropertiesAmmo { ricochetChance: Float penetrationChance: Float penetrationPower: Int + penetrationPowerDeviation: Float accuracy: Int @deprecated(reason: "Use accuracyModifier instead.") accuracyModifier: Float recoil: Float @deprecated(reason: "Use recoilModifier instead.") From bd3c4aab4cf16ece2e3edbe86153c171df8be5ad Mon Sep 17 00:00:00 2001 From: Razzmatazz Date: Wed, 31 Jan 2024 06:39:06 -0600 Subject: [PATCH 3/4] split historical prices kv --- datasources/historical-prices.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/datasources/historical-prices.js b/datasources/historical-prices.js index 0cf011f9..fdb46003 100644 --- a/datasources/historical-prices.js +++ b/datasources/historical-prices.js @@ -1,6 +1,6 @@ -const WorkerKV = require('../utils/worker-kv'); +const WorkerKVSplit = require('../utils/worker-kv-split'); -class historicalPricesAPI extends WorkerKV { +class historicalPricesAPI extends WorkerKVSplit { constructor(dataSource) { super('historical_price_data', dataSource); this.defaultDays = 7; @@ -9,8 +9,9 @@ class historicalPricesAPI extends WorkerKV { } async getByItemId(context, itemId, days = this.defaultDays, halfResults = false) { - await this.init(context); - if (!this.cache) { + await this.init(context, itemId); + const data = await this.getKVData(context, itemId); + if (!data) { return Promise.reject(new Error('Historical prices cache is empty')); } @@ -22,7 +23,7 @@ class historicalPricesAPI extends WorkerKV { } } - let prices = this.cache.historicalPricePoint[itemId]; + let prices = data.historicalPricePoint[itemId]; if (!prices) { return []; } From a48839696469f08422b9414a121210cb77c4161f Mon Sep 17 00:00:00 2001 From: Razzmatazz Date: Wed, 31 Jan 2024 14:52:20 -0600 Subject: [PATCH 4/4] allow multiple types of task items --- resolvers/taskResolver.js | 3 +++ schema.js | 1 + 2 files changed, 4 insertions(+) diff --git a/resolvers/taskResolver.js b/resolvers/taskResolver.js index 3550445b..1594d4fe 100644 --- a/resolvers/taskResolver.js +++ b/resolvers/taskResolver.js @@ -204,6 +204,9 @@ module.exports = { item(data, args, context) { return context.data.item.getItem(context, data.item); }, + items(data, args, context) { + return data.items.map(id => context.data.item.getItem(context, id)); + }, maps(data, args, context) { return data.map_ids.map(id => { return context.data.map.get(context, id); diff --git a/schema.js b/schema.js index 712aaa91..f4252295 100644 --- a/schema.js +++ b/schema.js @@ -1061,6 +1061,7 @@ type TaskObjectiveItem implements TaskObjective { maps: [Map]! optional: Boolean! item: Item! + items: [Item]! count: Int! foundInRaid: Boolean! dogTagLevel: Int