Mission rewards - take 2
This commit is contained in:
parent
460d868715
commit
66a384088e
@ -1,8 +1,17 @@
|
||||
import { RequestHandler } from "express";
|
||||
import { missionInventoryUpdate } from "@/src/services/inventoryService";
|
||||
import { MissionInventoryUpdate, MissionInventoryUpdateRewardInfo } from "@/src/types/missionInventoryUpdateType";
|
||||
import missionNames from "@/static/data/mission-names.json";
|
||||
import missionReward from "@/static/data/mission-rewards.json";
|
||||
|
||||
import missionsDropTable from "@/static/json/missions-drop-table.json";
|
||||
import missionNames from "@/static/json/mission-names.json";
|
||||
import modNames from "@/static/json/mod-names.json";
|
||||
import relicNames from "@/static/json/relic-names.json";
|
||||
import skinNames from "@/static/json/skin-names.json";
|
||||
import miscNames from "@/static/json/misc-names.json";
|
||||
import resourceNames from "@/static/json/resource-names.json";
|
||||
import gearNames from "@/static/json/gear-names.json";
|
||||
import arcaneNames from "@/static/json/arcane-names.json";
|
||||
import craftNames from "@/static/json/craft-names.json";
|
||||
|
||||
/*
|
||||
**** INPUT ****
|
||||
@ -89,14 +98,14 @@ const missionInventoryUpdateController: RequestHandler = async (req, res) => {
|
||||
- [ ] FusionPoints int
|
||||
*/
|
||||
|
||||
interface MissionNames {
|
||||
interface StringDictionary {
|
||||
[key: string]: string;
|
||||
}
|
||||
const getRewards = (rewardInfo: MissionInventoryUpdateRewardInfo | undefined): Reward[] | undefined => {
|
||||
const getRewards = (rewardInfo: MissionInventoryUpdateRewardInfo | undefined) => {
|
||||
if (!rewardInfo) return;
|
||||
|
||||
const missionName = (missionNames as MissionNames)[rewardInfo.node];
|
||||
const rewards = missionReward.find(i => i.mission === missionName)?.rewards;
|
||||
const missionName = (missionNames as StringDictionary)[rewardInfo.node];
|
||||
const rewards = missionsDropTable.find(i => i.mission === missionName)?.rewards;
|
||||
|
||||
if (!rewards) return [];
|
||||
|
||||
@ -113,7 +122,7 @@ const getRewards = (rewardInfo: MissionInventoryUpdateRewardInfo | undefined): R
|
||||
const randomDrop = getRandomRewardByChance(chanceDrops);
|
||||
if (randomDrop) guaranteedDrops.push(randomDrop);
|
||||
|
||||
return guaranteedDrops;
|
||||
return formatRewardsToInventoryType(guaranteedDrops);
|
||||
};
|
||||
|
||||
interface Reward {
|
||||
@ -138,4 +147,48 @@ const getRandomRewardByChance = (data: Reward[] | undefined): Reward | undefined
|
||||
return;
|
||||
};
|
||||
|
||||
const formatRewardsToInventoryType = (rewards: Reward[]) => {
|
||||
return rewards.map(i => {
|
||||
const mod = (modNames as StringDictionary)[i.name];
|
||||
const skin = (skinNames as StringDictionary)[i.name];
|
||||
const gear = (gearNames as StringDictionary)[i.name];
|
||||
const arcane = (arcaneNames as StringDictionary)[i.name];
|
||||
const craft = (craftNames as StringDictionary)[i.name];
|
||||
const misc =
|
||||
(miscNames as StringDictionary)[i.name] || (miscNames as StringDictionary)[i.name.replace(/\d+X\s*/, "")];
|
||||
const resource =
|
||||
(resourceNames as StringDictionary)[i.name] ||
|
||||
(resourceNames as StringDictionary)[i.name.replace(/\d+X\s*/, "")];
|
||||
const relic =
|
||||
(relicNames as StringDictionary)[i.name.replace("Relic", "Exceptional")] ||
|
||||
(relicNames as StringDictionary)[i.name.replace("Relic (Radiant)", "Radiant")];
|
||||
|
||||
let ItemType: string = mod;
|
||||
const ItemCount = 1;
|
||||
|
||||
if (mod) {
|
||||
ItemType = mod;
|
||||
} else if (skin) {
|
||||
ItemType = skin;
|
||||
} else if (gear) {
|
||||
ItemType = gear;
|
||||
} else if (arcane) {
|
||||
ItemType = arcane;
|
||||
} else if (craft) {
|
||||
ItemType = craft;
|
||||
} else if (misc) {
|
||||
ItemType = misc;
|
||||
} else if (resource) {
|
||||
ItemType = resource;
|
||||
} else if (relic) {
|
||||
ItemType = relic;
|
||||
} else if (i.name.includes(" Endo")) {
|
||||
/* endo */
|
||||
} else if (i.name.includes(" Credits Cache") || i.name.includes("Return: ")) {
|
||||
/* credits */
|
||||
}
|
||||
return { ItemType, ItemCount };
|
||||
});
|
||||
};
|
||||
|
||||
export { missionInventoryUpdateController };
|
||||
|
@ -83,7 +83,7 @@ RawUpgrades.set("toJSON", {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
|
||||
returnedObject.ItemId = { $oid: returnedObject._id.toString() } satisfies Oid;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
|
||||
returnedObject.LastAdded = { $oid: returnedObject.__v.toString() } satisfies Oid;
|
||||
returnedObject.LastAdded = { $oid: returnedObject._id.toString() } satisfies Oid;
|
||||
delete returnedObject._id;
|
||||
delete returnedObject.__v;
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
1
static/json/arcane-names.json
Normal file
1
static/json/arcane-names.json
Normal file
File diff suppressed because one or more lines are too long
1
static/json/craft-names.json
Normal file
1
static/json/craft-names.json
Normal file
File diff suppressed because one or more lines are too long
1
static/json/gear-names.json
Normal file
1
static/json/gear-names.json
Normal file
File diff suppressed because one or more lines are too long
1
static/json/misc-names.json
Normal file
1
static/json/misc-names.json
Normal file
File diff suppressed because one or more lines are too long
1
static/json/missions-drop-table.json
Normal file
1
static/json/missions-drop-table.json
Normal file
File diff suppressed because one or more lines are too long
1
static/json/mod-names.json
Normal file
1
static/json/mod-names.json
Normal file
File diff suppressed because one or more lines are too long
1
static/json/relic-names.json
Normal file
1
static/json/relic-names.json
Normal file
File diff suppressed because one or more lines are too long
1
static/json/resource-names.json
Normal file
1
static/json/resource-names.json
Normal file
File diff suppressed because one or more lines are too long
31
static/json/scripts/check-rewards.js
Normal file
31
static/json/scripts/check-rewards.js
Normal file
@ -0,0 +1,31 @@
|
||||
/* eslint-disable */
|
||||
import missionsDropTable from '../missions-drop-table.json' assert { type: "json" };
|
||||
import modNames from '../mod-names.json' assert { type: "json" };
|
||||
import relicNames from '../relic-names.json' assert { type: "json" };
|
||||
import skinNames from '../skin-names.json' assert { type: "json" };
|
||||
import miscNames from '../misc-names.json' assert { type: "json" };
|
||||
import resourceNames from '../resource-names.json' assert { type: "json" };
|
||||
import gearNames from '../gear-names.json' assert { type: "json" };
|
||||
import arcaneNames from '../arcane-names.json' assert { type: "json" };
|
||||
import craftNames from '../craft-names.json' assert { type: "json" };
|
||||
|
||||
let tempRewards = [];
|
||||
missionsDropTable.forEach(i=>{
|
||||
i.rewards.forEach(j=>{
|
||||
tempRewards.push(j);
|
||||
});
|
||||
});
|
||||
tempRewards = tempRewards
|
||||
.filter(i=>!modNames[i.name])
|
||||
.filter(i=>!relicNames[i.name.replace('Relic','Exceptional')] && !relicNames[i.name.replace('Relic (Radiant)','Radiant')])
|
||||
.filter(i=>!skinNames[i.name])
|
||||
.filter(i=>!miscNames[i.name])
|
||||
.filter(i=>!miscNames[i.name.replace(/\d+X\s*/, '')])
|
||||
.filter(i=>!resourceNames[i.name])
|
||||
.filter(i=>!resourceNames[i.name.replace(/\d+X\s*/, '')])
|
||||
.filter(i=>!gearNames[i.name])
|
||||
.filter(i=>!arcaneNames[i.name])
|
||||
.filter(i=>!craftNames[i.name])
|
||||
.filter(i=>!i.name.includes(' Endo'))
|
||||
.filter(i=>!i.name.includes(' Credits Cache') && !i.name.includes('Return: '));
|
||||
console.log(tempRewards);
|
89
static/json/scripts/craft-names.js
Normal file
89
static/json/scripts/craft-names.js
Normal file
@ -0,0 +1,89 @@
|
||||
/* eslint-disable */
|
||||
import Warframes from './Warframes.json' assert { type: "json" };
|
||||
import Gear from './Gear.json' assert { type: "json" };
|
||||
import Melee from './Melee.json' assert { type: "json" };
|
||||
import Primary from './Primary.json' assert { type: "json" };
|
||||
import Secondary from './Secondary.json' assert { type: "json" };
|
||||
import Sentinels from './Sentinels.json' assert { type: "json" };
|
||||
import Misc from './Misc.json' assert { type: "json" };
|
||||
import ArchGun from './Arch-Gun.json' assert { type: "json" };
|
||||
import ArchMelee from './Arch-Melee.json' assert { type: "json" };
|
||||
import fs from 'fs';
|
||||
|
||||
const formated = {};
|
||||
Warframes.forEach(j=>{
|
||||
j.components?.forEach(i=>{
|
||||
if(i.drops && i.drops[0]){
|
||||
formated[i.drops[0].type] = i.uniqueName;
|
||||
}
|
||||
})
|
||||
});
|
||||
Gear.forEach(j=>{
|
||||
j.components?.forEach(i=>{
|
||||
if(i.drops && i.drops[0]){
|
||||
formated[i.drops[0].type] = i.uniqueName;
|
||||
}
|
||||
})
|
||||
});
|
||||
Melee.forEach(j=>{
|
||||
j.components?.forEach(i=>{
|
||||
if(i.drops && i.drops[0]){
|
||||
formated[i.drops[0].type] = i.uniqueName;
|
||||
}
|
||||
})
|
||||
});
|
||||
Primary.forEach(j=>{
|
||||
j.components?.forEach(i=>{
|
||||
if(i.drops && i.drops[0]){
|
||||
formated[i.drops[0].type] = i.uniqueName;
|
||||
}
|
||||
})
|
||||
});
|
||||
Secondary.forEach(j=>{
|
||||
j.components?.forEach(i=>{
|
||||
if(i.drops && i.drops[0]){
|
||||
formated[i.drops[0].type] = i.uniqueName;
|
||||
}
|
||||
})
|
||||
});
|
||||
Sentinels.forEach(j=>{
|
||||
j.components?.forEach(i=>{
|
||||
if(i.drops && i.drops[0]){
|
||||
formated[i.drops[0].type] = i.uniqueName;
|
||||
}
|
||||
})
|
||||
});
|
||||
Misc.forEach(j=>{
|
||||
j.components?.forEach(i=>{
|
||||
if(i.drops && i.drops[0]){
|
||||
formated[i.drops[0].type] = i.uniqueName;
|
||||
}
|
||||
})
|
||||
});
|
||||
ArchGun.forEach(j=>{
|
||||
j.components?.forEach(i=>{
|
||||
if(i.drops && i.drops[0]){
|
||||
formated[i.drops[0].type] = i.uniqueName;
|
||||
}
|
||||
})
|
||||
});
|
||||
ArchMelee.forEach(j=>{
|
||||
j.components?.forEach(i=>{
|
||||
if(i.drops && i.drops[0]){
|
||||
formated[i.drops[0].type] = i.uniqueName;
|
||||
}
|
||||
})
|
||||
});
|
||||
formated['Forma Blueprint'] = "/Lotus/StoreItems/Types/Items/MiscItems/Forma";
|
||||
console.log(formated);
|
||||
|
||||
const fileBody = JSON.stringify(formated);
|
||||
fs.writeFile("./craft-names.json", fileBody, err => {
|
||||
if (err) {
|
||||
console.log(err.message);
|
||||
|
||||
throw err;
|
||||
}
|
||||
|
||||
console.log('data written to file');
|
||||
});
|
20
static/json/scripts/get-names.js
Normal file
20
static/json/scripts/get-names.js
Normal file
@ -0,0 +1,20 @@
|
||||
/* eslint-disable */
|
||||
import mods from './Arch-Melee.json' assert { type: "json" };
|
||||
import fs from 'fs';
|
||||
|
||||
const formatedMods = {};
|
||||
for (let index = 0; index < mods.length; index++) {
|
||||
const {name, uniqueName} = mods[index];
|
||||
formatedMods[name] = uniqueName;
|
||||
}
|
||||
|
||||
const fileBody = JSON.stringify(formatedMods);
|
||||
fs.writeFile("./arch-melee-names.json", fileBody, err => {
|
||||
if (err) {
|
||||
console.log(err.message);
|
||||
|
||||
throw err;
|
||||
}
|
||||
|
||||
console.log('data written to file');
|
||||
});
|
@ -15,14 +15,14 @@
|
||||
const formatedMission = mission.substring(0, mission.indexOf(' ('))
|
||||
lastItem.mission = formatedMission;
|
||||
} else{
|
||||
rotation = element.children[0].textContent.replace('Rotation ');
|
||||
rotation = element.children[0].textContent.replace('Rotation ', '');
|
||||
}
|
||||
} else {
|
||||
if (!lastItem.rewards)
|
||||
lastItem.rewards = [];
|
||||
const name = element.children[0].textContent;
|
||||
const chance = parseFloat(element.children[1].textContent.match(/(\d+\.\d+)/)[0]);
|
||||
|
||||
|
||||
lastItem.rewards.push({ chance, name, ...(rotation !== undefined && { rotation }) });
|
||||
}
|
||||
});
|
1
static/json/skin-names.json
Normal file
1
static/json/skin-names.json
Normal file
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user