MissionInventoryUpdate(not completed), Mod upgrade, Booster purchase #49

Merged
holmityd merged 40 commits from interface-names into main 2023-09-06 03:02:54 -07:00
5 changed files with 80 additions and 252 deletions
Showing only changes of commit 460d868715 - Show all commits

View File

@ -1,6 +1,9 @@
import { RequestHandler } from "express";
import { missionInventoryUpdate } from "@/src/services/inventoryService";
import { MissionInventoryUpdate } from "@/src/types/missionInventoryUpdateType";
import { MissionInventoryUpdate, MissionInventoryUpdateRewardInfo } from "@/src/types/missionInventoryUpdateType";
import missionNames from "@/static/data/mission-names.json";
import missionReward from "@/static/data/mission-rewards.json";
/*
**** INPUT ****
- [ ] crossPlaySetting
@ -62,7 +65,7 @@ const missionInventoryUpdateController: RequestHandler = async (req, res) => {
const CreditsBonus = [creditsBonus, creditsBonus]; // mission reward
const TotalCredits = [totalCredits, totalCredits];
// TODO - get missions reward table
console.log(getRewards(parsedData.RewardInfo));
res.json({
// InventoryJson, // this part will reset game data and missions will be locked
@ -86,4 +89,53 @@ const missionInventoryUpdateController: RequestHandler = async (req, res) => {
- [ ] FusionPoints int
*/
interface MissionNames {
[key: string]: string;
}
const getRewards = (rewardInfo: MissionInventoryUpdateRewardInfo | undefined): Reward[] | undefined => {
if (!rewardInfo) return;
const missionName = (missionNames as MissionNames)[rewardInfo.node];
const rewards = missionReward.find(i => i.mission === missionName)?.rewards;
if (!rewards) return [];
// TODO - add Rotation logic
// Separate guaranteed and chance drops
const guaranteedDrops: Reward[] = [];
const chanceDrops: Reward[] = [];
for (const reward of rewards) {
if (reward.chance === 100) guaranteedDrops.push(reward);
else chanceDrops.push(reward);
}
const randomDrop = getRandomRewardByChance(chanceDrops);
if (randomDrop) guaranteedDrops.push(randomDrop);
return guaranteedDrops;
};
interface Reward {
name: string;
chance: number;
rotation?: string;
}
const getRandomRewardByChance = (data: Reward[] | undefined): Reward | undefined => {
if (!data || data.length == 0) return;
const totalChance = data.reduce((sum, item) => sum + item.chance, 0);
const randomValue = Math.random() * totalChance;
let cumulativeChance = 0;
for (const item of data) {
cumulativeChance += item.chance;
if (randomValue <= cumulativeChance) {
return item;
}
}
return;
};
export { missionInventoryUpdateController };

View File

@ -50,6 +50,21 @@ interface MissionInventoryUpdateChallange {
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
Completed: any[];
}
export interface MissionInventoryUpdateRewardInfo {
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
node: string;
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
rewardTier?: number;
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
nightmareMode?: boolean;
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
useVaultManifest?: boolean;
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
EnemyCachesFound?: number;
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
toxinOk?: boolean;
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
lostTargetWave?: number;
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
defenseTargetCount?: number;
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
EOM_AFK?: number;
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
rewardQualifications?: string;
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
PurgatoryRewardQualifications?: string;
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
rewardSeed?: number;
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
}
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
export interface MissionInventoryUpdate {
rewardsMultiplier?: number;
ActiveBoosters?: any[];
@ -61,4 +76,5 @@ export interface MissionInventoryUpdate {
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
MiscItems?: MissionInventoryUpdateItem[];
RegularCredits?: number;
ChallengeProgress?: MissionInventoryUpdateChallange[];
RewardInfo?: MissionInventoryUpdateRewardInfo;
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
}

File diff suppressed because one or more lines are too long

View File

@ -11,14 +11,18 @@
rotation = undefined;
} else if (element.children[0].getAttribute('colspan') == 2) {
if (!lastItem.mission) {
lastItem.mission = element.children[0].textContent;
} else
rotation = element.children[0].textContent;
const mission = element.children[0].textContent;
const formatedMission = mission.substring(0, mission.indexOf(' ('))
lastItem.mission = formatedMission;
} else{
rotation = element.children[0].textContent.replace('Rotation ');
}
} else {
if (!lastItem.rewards)
lastItem.rewards = [];
const name = element.children[0].textContent;
const chance = element.children[1].textContent;
const chance = parseFloat(element.children[1].textContent.match(/(\d+\.\d+)/)[0]);
lastItem.rewards.push({ chance, name, ...(rotation !== undefined && { rotation }) });
}
});

File diff suppressed because one or more lines are too long