Skip to content

Commit ee5d30d

Browse files
authored
Merge pull request #88 from the-hideout/more-item-props
add more item properties
2 parents fc0db93 + 78923ea commit ee5d30d

File tree

4 files changed

+59
-15
lines changed

4 files changed

+59
-15
lines changed

index.js

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,31 @@ async function getSchema(data) {
4444
});
4545
}
4646
loadingSchema = true;
47-
return dynamicTypeDefs(data).then(dynamicTypeDefs => {
48-
schema = makeExecutableSchema({typeDefs: mergeTypeDefs([typeDefs, dynamicTypeDefs]), resolvers: resolvers});
49-
loadingSchema = false;
50-
return schema;
51-
}).catch(error => {
47+
return dynamicTypeDefs(data).catch(error => {
5248
loadingSchema = false;
49+
console.log('Error loading dynamic type definitions', error);
5350
return Promise.reject(error);
51+
}).then(dynamicTypeDefs => {
52+
let mergedDefs;
53+
try {
54+
mergedDefs = mergeTypeDefs([typeDefs, dynamicTypeDefs]);
55+
} catch (error) {
56+
console.log('Error merging type defs', error);
57+
return Promise.reject(error);
58+
}
59+
try {
60+
schema = makeExecutableSchema({typeDefs: mergedDefs, resolvers: resolvers});
61+
loadingSchema = false;
62+
return schema;
63+
} catch (error) {
64+
console.log('Error making schema executable');
65+
if (!error.message) {
66+
console.log('Check type names in resolvers');
67+
} else {
68+
console.log(error.message);
69+
}
70+
return Promise.reject(error);
71+
}
5472
});
5573
}
5674

resolvers/itemResolver.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,14 @@ module.exports = {
202202
return context.util.getLocale(data, 'zones', info);
203203
}
204204
},
205+
ItemPropertiesArmorAttachment: {
206+
material(data, args, context) {
207+
return context.data.item.getArmorMaterial(data.armor_material_id);
208+
},
209+
headZones(data, args, context, info) {
210+
return context.util.getLocale(data, 'headZones', info);
211+
}
212+
},
205213
ItemPropertiesChestRig: {
206214
material(data, args, context) {
207215
return context.data.item.getArmorMaterial(data.armor_material_id);

schema.js

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ type Ammo {
1414
ricochetChance: Float!
1515
penetrationChance: Float!
1616
penetrationPower: Int!
17-
accuracy: Int!
18-
recoil: Int
17+
accuracy: Int @deprecated(reason: "Use accuracyModifier instead.")
18+
accuracyModifier: Float
19+
recoil: Int @deprecated(reason: "Use recoilModifier instead.")
20+
recoilModifier: Float
1921
initialSpeed: Int!
2022
lightBleedModifier: Float!
2123
heavyBleedModifier: Float!
@@ -271,11 +273,15 @@ type ItemPropertiesAmmo {
271273
ricochetChance: Float
272274
penetrationChance: Float
273275
penetrationPower: Int
274-
accuracy: Int
275-
recoil: Float
276+
accuracy: Int @deprecated(reason: "Use accuracyModifier instead.")
277+
accuracyModifier: Float
278+
recoil: Float @deprecated(reason: "Use recoilModifier instead.")
279+
recoilModifier: Float
276280
initialSpeed: Int
277281
lightBleedModifier: Float
278282
heavyBleedModifier: Float
283+
durabilityBurnFactor: Float
284+
heatFactor: Float
279285
}
280286
281287
type ItemPropertiesArmor {
@@ -298,6 +304,7 @@ type ItemPropertiesArmorAttachment {
298304
ergoPenalty: Int
299305
headZones: [String]
300306
material: ArmorMaterial
307+
blindnessProtection: Float
301308
}
302309
303310
type ItemPropertiesBackpack {
@@ -367,7 +374,8 @@ type ItemPropertiesKey {
367374
368375
type ItemPropertiesMagazine {
369376
ergonomics: Float
370-
recoil: Float
377+
recoil: Float @deprecated(reason: "Use recoilModifier instead.")
378+
recoilModifier: Float
371379
capacity: Int
372380
loadModifier: Float
373381
ammoCheckModifier: Float
@@ -389,6 +397,12 @@ type ItemPropertiesMedKit {
389397
hpCostHeavyBleeding: Int
390398
}
391399
400+
type ItemPropertiesMelee {
401+
slashDamage: Int
402+
stabDamage: Int
403+
hitRadius: Float
404+
}
405+
392406
type ItemPropertiesNightVision {
393407
intensity: Float
394408
noiseIntensity: Float
@@ -414,7 +428,8 @@ type ItemPropertiesPreset {
414428
415429
type ItemPropertiesScope {
416430
ergonomics: Float
417-
recoil: Float
431+
recoil: Float @deprecated(reason: "Use recoilModifier instead.")
432+
recoilModifier: Float
418433
zoomLevels: [[Float]]
419434
}
420435
@@ -454,7 +469,9 @@ type ItemPropertiesWeapon {
454469
455470
type ItemPropertiesWeaponMod {
456471
ergonomics: Float
457-
recoil: Float
472+
recoil: Float @deprecated(reason: "Use recoilModifier instead.")
473+
recoilModifier: Float
474+
accuracyModifier: Float
458475
}
459476
460477
union ItemProperties =
@@ -471,6 +488,7 @@ union ItemProperties =
471488
ItemPropertiesKey |
472489
ItemPropertiesMagazine |
473490
ItemPropertiesMedicalItem |
491+
ItemPropertiesMelee |
474492
ItemPropertiesMedKit |
475493
ItemPropertiesNightVision |
476494
ItemPropertiesPainkiller |

schema_dynamic.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
module.exports = async (data) => {
22
const itemTypes = await data.item.getTypes();
33
const categories = await data.item.getCategories();
4-
const languageCodes = await data.item.getLanguageCodes();
4+
const languageCodes = await data.item.getLanguageCodes();
55
return `
66
enum ItemType {
7-
${itemTypes.join('\n ')}
7+
${itemTypes.join('\n ')}
88
}
99
enum ItemCategoryName {
10-
${categories.map(cat => cat.enumName).sort().join('\n ')}
10+
${categories.map(cat => cat.enumName).sort().join('\n ')}
1111
}
1212
enum LanguageCode {
1313
${languageCodes.join('\n ')}

0 commit comments

Comments
 (0)