Mission reward - rotation logic
This commit is contained in:
parent
2ad2c6d675
commit
9d2ebe018c
@ -65,8 +65,6 @@ const missionInventoryUpdateController: RequestHandler = async (req, res) => {
|
|||||||
const [data] = String(req.body).split("\n");
|
const [data] = String(req.body).split("\n");
|
||||||
const id = req.query.accountId as string;
|
const id = req.query.accountId as string;
|
||||||
|
|
||||||
// TODO - salt check
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const parsedData = JSON.parse(data) as IMissionInventoryUpdate;
|
const parsedData = JSON.parse(data) as IMissionInventoryUpdate;
|
||||||
if (typeof parsedData !== "object" || parsedData === null) throw new Error("Invalid data format");
|
if (typeof parsedData !== "object" || parsedData === null) throw new Error("Invalid data format");
|
||||||
@ -124,37 +122,25 @@ const missionInventoryUpdateController: RequestHandler = async (req, res) => {
|
|||||||
- [x] FusionPoints
|
- [x] FusionPoints
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// need reverse engineer rewardSeed, otherwise ingame displayed rotation loot will be different than added to db
|
||||||
const getRewards = (
|
const getRewards = (
|
||||||
rewardInfo: IMissionInventoryUpdateRewardInfo | undefined
|
rewardInfo: IMissionInventoryUpdateRewardInfo | undefined
|
||||||
): { InventoryChanges: IMissionInventoryUpdate; MissionRewards: IMissionRewardResponse[] } => {
|
): { InventoryChanges: IMissionInventoryUpdate; MissionRewards: IMissionRewardResponse[] } => {
|
||||||
if (!rewardInfo) return { InventoryChanges: {}, MissionRewards: [] };
|
if (!rewardInfo) return { InventoryChanges: {}, MissionRewards: [] };
|
||||||
|
|
||||||
// TODO - add Rotation logic
|
|
||||||
// no data for rotation, need reverse engineer rewardSeed, otherwise ingame displayed rotation loot will be different than added to db
|
|
||||||
|
|
||||||
// "RewardInfo": {
|
|
||||||
// "node": "SolNode39",
|
|
||||||
// "rewardTier": 1,
|
|
||||||
// "nightmareMode": false,
|
|
||||||
// "useVaultManifest": false,
|
|
||||||
// "EnemyCachesFound": 0,
|
|
||||||
// "toxinOk": true,
|
|
||||||
// "lostTargetWave": 0,
|
|
||||||
// "defenseTargetCount": 1,
|
|
||||||
// "EOM_AFK": 0,
|
|
||||||
// "rewardQualifications": "11",
|
|
||||||
// "PurgatoryRewardQualifications": "",
|
|
||||||
// "rewardSeed": -5604904486637266000
|
|
||||||
// },
|
|
||||||
|
|
||||||
const rewards = (missionsDropTable as { [key: string]: IReward[] })[rewardInfo.node];
|
const rewards = (missionsDropTable as { [key: string]: IReward[] })[rewardInfo.node];
|
||||||
|
|
||||||
if (!rewards) return { InventoryChanges: {}, MissionRewards: [] };
|
if (!rewards) return { InventoryChanges: {}, MissionRewards: [] };
|
||||||
|
|
||||||
|
const rotationCount = rewardInfo.rewardQualifications?.length || 0;
|
||||||
|
const rotations = getRotations(rotationCount);
|
||||||
|
const drops: IReward[] = [];
|
||||||
|
for (const rotation of rotations) {
|
||||||
|
const rotationRewards = rewards.filter(i => i.rotation === rotation);
|
||||||
|
|
||||||
// Separate guaranteed and chance drops
|
// Separate guaranteed and chance drops
|
||||||
const guaranteedDrops: IReward[] = [];
|
const guaranteedDrops: IReward[] = [];
|
||||||
const chanceDrops: IReward[] = [];
|
const chanceDrops: IReward[] = [];
|
||||||
for (const reward of rewards) {
|
for (const reward of rotationRewards) {
|
||||||
if (reward.chance === 100) guaranteedDrops.push(reward);
|
if (reward.chance === 100) guaranteedDrops.push(reward);
|
||||||
else chanceDrops.push(reward);
|
else chanceDrops.push(reward);
|
||||||
}
|
}
|
||||||
@ -162,9 +148,27 @@ const getRewards = (
|
|||||||
const randomDrop = getRandomRewardByChance(chanceDrops);
|
const randomDrop = getRandomRewardByChance(chanceDrops);
|
||||||
if (randomDrop) guaranteedDrops.push(randomDrop);
|
if (randomDrop) guaranteedDrops.push(randomDrop);
|
||||||
|
|
||||||
console.log("Mission rewards:", guaranteedDrops);
|
drops.push(...guaranteedDrops);
|
||||||
|
}
|
||||||
|
|
||||||
return formatRewardsToInventoryType(guaranteedDrops);
|
console.log("Mission rewards:", drops);
|
||||||
|
|
||||||
|
return formatRewardsToInventoryType(drops);
|
||||||
|
};
|
||||||
|
|
||||||
|
const getRotations = (rotationCount: number): (string | undefined)[] => {
|
||||||
|
if (rotationCount === 0) return [undefined];
|
||||||
|
|
||||||
|
const rotations = ["A", "B", "C"];
|
||||||
|
let rotationIndex = 0;
|
||||||
|
const rotatedValues = [];
|
||||||
|
|
||||||
|
for (let i = 1; i <= rotationCount; i++) {
|
||||||
|
rotatedValues.push(rotations[rotationIndex]);
|
||||||
|
rotationIndex = (rotationIndex + 1) % 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rotatedValues;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getRandomRewardByChance = (data: IReward[] | undefined): IReward | undefined => {
|
const getRandomRewardByChance = (data: IReward[] | undefined): IReward | undefined => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user