Merge pull request #3 from holmityd/mission-reward
items data from package
This commit is contained in:
commit
c2b9629859
@ -1,18 +1,24 @@
|
||||
import { RequestHandler } from "express";
|
||||
import { missionInventoryUpdate } from "@/src/services/inventoryService";
|
||||
import { MissionInventoryUpdate, MissionInventoryUpdateRewardInfo } from "@/src/types/missionInventoryUpdateType";
|
||||
import {
|
||||
MissionInventoryUpdate,
|
||||
MissionInventoryUpdateRewardInfo,
|
||||
MissionRewardResponse,
|
||||
Reward
|
||||
} from "@/src/types/missionInventoryUpdateType";
|
||||
import { RawUpgrade } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||
|
||||
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";
|
||||
import { RawUpgrade } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||
import {
|
||||
modNames,
|
||||
relicNames,
|
||||
skinNames,
|
||||
miscNames,
|
||||
resourceNames,
|
||||
gearNames,
|
||||
arcaneNames,
|
||||
craftNames
|
||||
} from "@/static/data/items";
|
||||
|
||||
/*
|
||||
**** INPUT ****
|
||||
@ -118,9 +124,6 @@ const missionInventoryUpdateController: RequestHandler = async (req, res) => {
|
||||
- [x] FusionPoints
|
||||
*/
|
||||
|
||||
interface StringDictionary {
|
||||
[key: string]: string;
|
||||
}
|
||||
const getRewards = (
|
||||
rewardInfo: MissionInventoryUpdateRewardInfo | undefined
|
||||
): { InventoryChanges: MissionInventoryUpdate; MissionRewards: MissionRewardResponse[] } => {
|
||||
@ -144,8 +147,7 @@ const getRewards = (
|
||||
// "rewardSeed": -5604904486637266000
|
||||
// },
|
||||
|
||||
const missionName = (missionNames as StringDictionary)[rewardInfo.node];
|
||||
const rewards = missionsDropTable.find(i => i.mission === missionName)?.rewards;
|
||||
const rewards = (missionsDropTable as { [key: string]: Reward[] })[rewardInfo.node];
|
||||
|
||||
if (!rewards) return { InventoryChanges: {}, MissionRewards: [] };
|
||||
|
||||
@ -165,11 +167,6 @@ const getRewards = (
|
||||
return formatRewardsToInventoryType(guaranteedDrops);
|
||||
};
|
||||
|
||||
interface Reward {
|
||||
name: string;
|
||||
chance: number;
|
||||
rotation?: string;
|
||||
}
|
||||
const getRandomRewardByChance = (data: Reward[] | undefined): Reward | undefined => {
|
||||
if (!data || data.length == 0) return;
|
||||
|
||||
@ -187,33 +184,22 @@ const getRandomRewardByChance = (data: Reward[] | undefined): Reward | undefined
|
||||
return;
|
||||
};
|
||||
|
||||
interface MissionRewardResponse {
|
||||
StoreItem?: string;
|
||||
TypeName: string;
|
||||
UpgradeLevel: number;
|
||||
ItemCount: number;
|
||||
TweetText: string;
|
||||
ProductCategory: string;
|
||||
}
|
||||
const formatRewardsToInventoryType = (
|
||||
rewards: Reward[]
|
||||
): { InventoryChanges: MissionInventoryUpdate; MissionRewards: MissionRewardResponse[] } => {
|
||||
const InventoryChanges: MissionInventoryUpdate = {};
|
||||
const MissionRewards: MissionRewardResponse[] = [];
|
||||
rewards.forEach(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 mod = modNames[i.name];
|
||||
const skin = skinNames[i.name];
|
||||
const gear = gearNames[i.name];
|
||||
const arcane = arcaneNames[i.name];
|
||||
const craft = craftNames[i.name];
|
||||
const misc = miscNames[i.name] || miscNames[i.name.replace(/\d+X\s*/, "")];
|
||||
const resource = resourceNames[i.name] || resourceNames[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")];
|
||||
relicNames[i.name.replace("Relic", "Exceptional")] ||
|
||||
relicNames[i.name.replace("Relic (Radiant)", "Radiant")];
|
||||
|
||||
if (mod) {
|
||||
if (!InventoryChanges.RawUpgrades) InventoryChanges.RawUpgrades = [];
|
||||
@ -250,4 +236,38 @@ const formatRewardsToInventoryType = (
|
||||
return { InventoryChanges, MissionRewards };
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const _missionRewardsCheckAllNamings = () => {
|
||||
let tempRewards: Reward[] = [];
|
||||
Object.values(missionsDropTable as { [key: string]: Reward[] }).forEach(i => {
|
||||
i.forEach(j => {
|
||||
tempRewards.push(j);
|
||||
});
|
||||
});
|
||||
tempRewards = tempRewards
|
||||
.filter(i => !modNames[i.name])
|
||||
|
||||
.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 => {
|
||||
// return true;
|
||||
// return !relicNames[i.name.replace("Relic", "Exceptional")];
|
||||
// console.log(i.name.replace("Relic", "Exceptional"));
|
||||
return (
|
||||
!relicNames[i.name.replace("Relic", "Exceptional")] &&
|
||||
!relicNames[i.name.replace("Relic (Radiant)", "Radiant")]
|
||||
);
|
||||
})
|
||||
.filter(i => !i.name.includes(" Endo"))
|
||||
.filter(i => !i.name.includes(" Credits Cache") && !i.name.includes("Return: "));
|
||||
console.log(tempRewards);
|
||||
};
|
||||
// _missionRewardsCheckAllNamings();
|
||||
|
||||
export { missionInventoryUpdateController };
|
||||
|
@ -73,3 +73,18 @@ export interface MissionInventoryUpdate {
|
||||
RewardInfo?: MissionInventoryUpdateRewardInfo;
|
||||
FusionPoints?: number;
|
||||
}
|
||||
|
||||
export interface MissionRewardResponse {
|
||||
StoreItem?: string;
|
||||
TypeName: string;
|
||||
UpgradeLevel: number;
|
||||
ItemCount: number;
|
||||
TweetText: string;
|
||||
ProductCategory: string;
|
||||
}
|
||||
|
||||
export interface Reward {
|
||||
name: string;
|
||||
chance: number;
|
||||
rotation?: string;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Items, { Item, Weapon } from "warframe-items";
|
||||
import Items, { Category, Item, Warframe, Weapon } from "warframe-items";
|
||||
|
||||
type MinWeapon = Omit<Weapon, "patchlogs">;
|
||||
type MinItem = Omit<Item, "patchlogs">;
|
||||
@ -16,3 +16,39 @@ export const items: MinItem[] = new Items({ category: ["All"] }).map(item => {
|
||||
delete next.patchlogs;
|
||||
return next;
|
||||
});
|
||||
|
||||
const getNamesObj = (category: Category) =>
|
||||
new Items({ category: [category] }).reduce((acc, i) => {
|
||||
acc[i.name!] = category !== "Mods" ? i.uniqueName! : i.uniqueName!.replace("'S", "'s");
|
||||
return acc;
|
||||
}, {} as ImportAssertions);
|
||||
|
||||
export const modNames = getNamesObj("Mods");
|
||||
export const resourceNames = getNamesObj("Resources");
|
||||
export const miscNames = getNamesObj("Misc");
|
||||
export const relicNames = getNamesObj("Relics");
|
||||
export const skinNames = getNamesObj("Skins");
|
||||
export const arcaneNames = getNamesObj("Arcanes");
|
||||
export const gearNames = getNamesObj("Gear");
|
||||
|
||||
export const craftNames: ImportAssertions = Object.fromEntries(
|
||||
(
|
||||
new Items({
|
||||
category: [
|
||||
"Warframes",
|
||||
"Gear",
|
||||
"Melee",
|
||||
"Primary",
|
||||
"Secondary",
|
||||
"Sentinels",
|
||||
"Misc",
|
||||
"Arch-Gun",
|
||||
"Arch-Melee"
|
||||
]
|
||||
}) as Warframe[]
|
||||
)
|
||||
.flatMap(j => j.components || [])
|
||||
.filter(i => i.drops && i.drops[0])
|
||||
.map(i => [i.drops![0].type, i.uniqueName])
|
||||
);
|
||||
craftNames["Forma Blueprint"] = "/Lotus/StoreItems/Types/Items/MiscItems/Forma";
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,31 +0,0 @@
|
||||
/* 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);
|
@ -1,89 +0,0 @@
|
||||
/* 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');
|
||||
});
|
@ -1,20 +0,0 @@
|
||||
/* 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');
|
||||
});
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user