Skip to content

Commit 9b375aa

Browse files
authored
Merge pull request #404 from the-hideout/prestige
Prestige
2 parents 1ab7026 + b68f23b commit 9b375aa

File tree

5 files changed

+171
-14
lines changed

5 files changed

+171
-14
lines changed

datasources/tasks.mjs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,21 @@ class TasksAPI extends WorkerKV {
144144
}
145145
return Promise.reject(new GraphQLError(`No achievement with id ${id} found`));
146146
}
147+
148+
async getPrestiges(context, info) {
149+
const { cache } = await this.getCache(context, info);
150+
return cache.Prestige;
151+
}
152+
153+
async getPrestige(context, info, id) {
154+
const prestiges = await this.getPrestiges(context, info);
155+
for (const prestige of prestiges) {
156+
if (prestige.id === id) {
157+
return prestige;
158+
}
159+
}
160+
return Promise.reject(new GraphQLError(`No prestiges with id ${id} found`));
161+
}
147162
}
148163

149164
export default TasksAPI;

http/package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

http/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
"dependencies": {
2020
"@graphql-tools/merge": "9.1.1",
2121
"@graphql-tools/schema": "10.0.25",
22-
"graphql-yoga": "^5.15.1",
22+
"graphql-yoga": "^5.16.0",
2323
"dotenv": "^16.4.5",
24-
"uuid": "^11.1.0"
24+
"uuid": "^13.0.0"
2525
},
2626
"nodemonConfig": {
2727
"watch": ["../", "*.mjs", ".env"],

resolvers/taskResolver.mjs

Lines changed: 80 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ export default {
33
achievements(obj, args, context, info) {
44
return context.util.paginate(context.data.worker.task.getAchievements(context, info), args);
55
},
6+
prestige(obj, args, context, info) {
7+
return context.util.paginate(context.data.worker.task.getPrestiges(context, info), args);
8+
},
69
async tasks(obj, args, context, info) {
710
let tasks = await context.data.worker.task.getList(context, info);
811
if (args.faction) {
@@ -40,6 +43,33 @@ export default {
4043
return context.data.worker.task.getLocale(data.rarity, context, info);
4144
},
4245
},
46+
CustomizationItem: {
47+
__resolveType(data, args, context) {
48+
return data.__typename;
49+
},
50+
},
51+
CustomizationItemBasic: {
52+
name(data, args, context, info) {
53+
return context.data.worker.task.getLocale(data.name, context, info);
54+
},
55+
customizationTypeName(data, args, context, info) {
56+
return context.data.worker.task.getLocale(data.customizationTypeName, context, info);
57+
},
58+
},
59+
CustomizationItems: {
60+
name(data, args, context, info) {
61+
return context.data.worker.task.getLocale(data.name, context, info);
62+
},
63+
customizationTypeName(data, args, context, info) {
64+
return context.data.worker.task.getLocale(data.customizationTypeName, context, info);
65+
},
66+
items(data, args, context, info) {
67+
if (!data.items?.length) {
68+
return [];
69+
}
70+
return data.items.map(id => context.data.worker.item.getItem(context, info, id));
71+
},
72+
},
4373
HealthEffect: {
4474
bodyParts(data, args, context, info) {
4575
if (data.bodyParts.length === 0) {
@@ -59,6 +89,24 @@ export default {
5989
return context.data.worker.map.get(context, info, data.map);
6090
},
6191
},
92+
Prestige: {
93+
name(data, args, context, info) {
94+
return context.data.worker.task.getLocale(data.name, context, info);
95+
},
96+
},
97+
PrestigeTransferSettings: {
98+
__resolveType(data, args, context) {
99+
if (data.gridWidth) {
100+
return 'PrestigeTransferSettingsStash';
101+
}
102+
return 'PrestigeTransferSettingsSkill';
103+
},
104+
},
105+
PrestigeTransferSettingsSkill: {
106+
name(data, args, context, info) {
107+
return context.data.worker.task.getLocale(data.name, context, info);
108+
},
109+
},
62110
SkillLevel: {
63111
skill(data, args, context, info) {
64112
return context.data.worker.handbook.getSkill(context, info, data.name);
@@ -77,7 +125,13 @@ export default {
77125
map(data, args, context, info) {
78126
if (data.location_id) return context.data.worker.map.get(context, info, data.location_id);
79127
return null;
80-
}
128+
},
129+
requiredPrestige(data, args, context, info) {
130+
if (!data.requiredPrestige) {
131+
return null;
132+
}
133+
return context.data.worker.task.getPrestige(context, info, data.requiredPrestige)
134+
},
81135
},
82136
TaskKey: {
83137
keys(data, args, context, info) {
@@ -95,12 +149,14 @@ export default {
95149
//return data.gql_type;
96150
if (data.type === 'findQuestItem' || data.type === 'giveQuestItem' || data.type === 'plantQuestItem') {
97151
return 'TaskObjectiveQuestItem';
98-
} else if (data.type === 'findItem' || data.type === 'giveItem' || data.type === 'plantItem' || data.type === 'sellItem') {
152+
} else if (data.type === 'findItem' || data.type === 'giveItem' || data.type === 'plantItem' || data.type === 'sellItem' || data.type === 'haveItem') {
99153
return 'TaskObjectiveItem';
100154
} else if (data.type === 'mark') {
101155
return 'TaskObjectiveMark';
102156
} else if (data.type === 'extract') {
103157
return 'TaskObjectiveExtract';
158+
} else if (data.type === 'hideoutStation') {
159+
return 'TaskObjectiveHideoutStation';
104160
} else if (data.type === 'skill') {
105161
return 'TaskObjectiveSkill';
106162
} else if (data.type === 'traderLevel') {
@@ -210,6 +266,14 @@ export default {
210266
return data.requiredKeys.map(keyIds => keyIds.map(keyId => context.data.worker.item.getItem(context, info, keyId)));
211267
},
212268
},
269+
TaskObjectiveHideoutStation: {
270+
hideoutStation(data, args, context, info) {
271+
return context.data.worker.hideout.getStation(context, info, data.station);
272+
},
273+
maps(data, args, context, info) {
274+
return [];
275+
}
276+
},
213277
TaskObjectiveItem: {
214278
item(data, args, context, info) {
215279
return context.data.worker.item.getItem(context, info, data.item);
@@ -449,7 +513,20 @@ export default {
449513
return true;
450514
});
451515
}).filter(Boolean);
452-
}
516+
},
517+
async achievement(data, args, context, info) {
518+
if (!data.achievement?.length) {
519+
return [];
520+
}
521+
const achievements = await context.data.worker.task.getAchievements(context, info);
522+
return data.achievement.map(id => {
523+
const achievement = achievements.find(a => a.id === id);
524+
if (!achievement) {
525+
return false;
526+
}
527+
return achievement;
528+
}).filter(Boolean);
529+
},
453530
},
454531
TaskStatusRequirement: {
455532
task(data, args, context, info) {

schema-static.mjs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,31 @@ type Craft {
161161
requirements: [PriceRequirement]! @deprecated(reason: "Use stationLevel instead.")
162162
}
163163
164+
interface CustomizationItem {
165+
id: ID!
166+
name: String!
167+
customizationType: String!
168+
customizationTypeName: String!
169+
imageLink: String
170+
}
171+
172+
type CustomizationItemBasic implements CustomizationItem {
173+
id: ID!
174+
name: String!
175+
customizationType: String!
176+
customizationTypeName: String!
177+
imageLink: String
178+
}
179+
180+
type CustomizationItems implements CustomizationItem {
181+
id: ID!
182+
name: String!
183+
customizationType: String!
184+
customizationTypeName: String!
185+
imageLink: String
186+
items: [Item]!
187+
}
188+
164189
type GameProperty {
165190
key: String!
166191
numericValue: Float
@@ -935,6 +960,31 @@ type PlayerLevel {
935960
levelBadgeImageLink: String
936961
}
937962
963+
type Prestige {
964+
id: ID!
965+
name: String
966+
prestigeLevel: Int
967+
imageLink: String
968+
iconLink: String
969+
conditions: [TaskObjective]
970+
rewards: TaskRewards
971+
transferSettings: [PrestigeTransferSettings]
972+
}
973+
974+
union PrestigeTransferSettings = PrestigeTransferSettingsStash | PrestigeTransferSettingsSkill
975+
976+
type PrestigeTransferSettingsStash {
977+
gridWidth: Int
978+
gridHeight: Int
979+
itemFilters: ItemFilters
980+
}
981+
982+
type PrestigeTransferSettingsSkill {
983+
name: String
984+
skillType: String
985+
transferRate: Float
986+
}
987+
938988
type PriceRequirement {
939989
type: RequirementType!
940990
value: Int
@@ -1084,6 +1134,7 @@ type Task {
10841134
failureOutcome: TaskRewards
10851135
restartable: Boolean
10861136
factionName: String
1137+
requiredPrestige: Prestige
10871138
neededKeys: [TaskKey] @deprecated(reason: "Use requiredKeys on objectives instead.")
10881139
kappaRequired: Boolean
10891140
lightkeeperRequired: Boolean
@@ -1158,6 +1209,17 @@ type TaskObjectiveExtract implements TaskObjective {
11581209
requiredKeys: [[Item]]
11591210
}
11601211
1212+
type TaskObjectiveHideoutStation implements TaskObjective {
1213+
id: ID
1214+
type: String!
1215+
description: String!
1216+
#locationNames: [String]!
1217+
maps: [Map]!
1218+
optional: Boolean!
1219+
hideoutStation: HideoutStation
1220+
stationLevel: Int
1221+
}
1222+
11611223
type TaskObjectiveItem implements TaskObjective {
11621224
id: ID
11631225
type: String!
@@ -1304,6 +1366,8 @@ type TaskRewards {
13041366
skillLevelReward: [SkillLevel]!
13051367
traderUnlock: [Trader]!
13061368
craftUnlock: [Craft]!
1369+
achievement: [Achievement]!
1370+
customization: [CustomizationItem]
13071371
}
13081372
13091373
type TaskStatusRequirement {
@@ -1452,6 +1516,7 @@ type Query {
14521516
fleaMarket(lang: LanguageCode, gameMode: GameMode): FleaMarket!
14531517
armorMaterials(lang: LanguageCode): [ArmorMaterial]!
14541518
playerLevels: [PlayerLevel]!
1519+
prestige(lang: LanguageCode, gameMode: GameMode): [Prestige]!
14551520
skills(lang: LanguageCode): [Skill]!
14561521
mastering(lang: LanguageCode): [Mastering]!
14571522
hideoutModules: [HideoutModule] @deprecated(reason: "Use hideoutStations instead.")

0 commit comments

Comments
 (0)