chore: improve typing of IFocusXp (#2182)
Any given focus school can be undefined in this object due to importing. Reviewed-on: #2182 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
This commit is contained in:
parent
145d21e30e
commit
1ead581780
@ -43,7 +43,7 @@ export const focusController: RequestHandler = async (req, res) => {
|
||||
inventory.FocusAbility ??= focusType;
|
||||
inventory.FocusUpgrades.push({ ItemType: focusType });
|
||||
if (inventory.FocusXP) {
|
||||
inventory.FocusXP[focusPolarity] -= cost;
|
||||
inventory.FocusXP[focusPolarity]! -= cost;
|
||||
}
|
||||
await inventory.save();
|
||||
res.json({
|
||||
@ -78,7 +78,7 @@ export const focusController: RequestHandler = async (req, res) => {
|
||||
cost += ExportFocusUpgrades[focusType].baseFocusPointCost;
|
||||
inventory.FocusUpgrades.push({ ItemType: focusType, Level: 0 });
|
||||
}
|
||||
inventory.FocusXP![focusPolarity] -= cost;
|
||||
inventory.FocusXP![focusPolarity]! -= cost;
|
||||
await inventory.save();
|
||||
res.json({
|
||||
FocusTypes: request.FocusTypes,
|
||||
@ -96,7 +96,7 @@ export const focusController: RequestHandler = async (req, res) => {
|
||||
const focusUpgradeDb = inventory.FocusUpgrades.find(entry => entry.ItemType == focusUpgrade.ItemType)!;
|
||||
focusUpgradeDb.Level = focusUpgrade.Level;
|
||||
}
|
||||
inventory.FocusXP![focusPolarity] -= cost;
|
||||
inventory.FocusXP![focusPolarity]! -= cost;
|
||||
await inventory.save();
|
||||
res.json({
|
||||
FocusInfos: request.FocusInfos,
|
||||
@ -123,7 +123,7 @@ export const focusController: RequestHandler = async (req, res) => {
|
||||
const request = JSON.parse(String(req.body)) as IUnbindUpgradeRequest;
|
||||
const focusPolarity = focusTypeToPolarity(request.FocusTypes[0]);
|
||||
const inventory = await getInventory(accountId);
|
||||
inventory.FocusXP![focusPolarity] -= 750_000 * request.FocusTypes.length;
|
||||
inventory.FocusXP![focusPolarity]! -= 750_000 * request.FocusTypes.length;
|
||||
addMiscItems(inventory, [
|
||||
{
|
||||
ItemType: "/Lotus/Types/Gameplay/Eidolon/Resources/SentientShards/SentientShardBrilliantItem",
|
||||
@ -168,8 +168,10 @@ export const focusController: RequestHandler = async (req, res) => {
|
||||
shard.ItemCount *= -1;
|
||||
}
|
||||
const inventory = await getInventory(accountId);
|
||||
inventory.FocusXP ??= { AP_POWER: 0, AP_TACTIC: 0, AP_DEFENSE: 0, AP_ATTACK: 0, AP_WARD: 0 };
|
||||
inventory.FocusXP[request.Polarity] += xp;
|
||||
const polarity = request.Polarity;
|
||||
inventory.FocusXP ??= {};
|
||||
inventory.FocusXP[polarity] ??= 0;
|
||||
inventory.FocusXP[polarity] += xp;
|
||||
addMiscItems(inventory, request.Shards);
|
||||
await inventory.save();
|
||||
break;
|
||||
|
@ -1731,12 +1731,27 @@ export const addFocusXpIncreases = (inventory: TInventoryDatabaseDocument, focus
|
||||
AP_ANY
|
||||
}
|
||||
|
||||
inventory.FocusXP ??= { AP_ATTACK: 0, AP_DEFENSE: 0, AP_TACTIC: 0, AP_POWER: 0, AP_WARD: 0 };
|
||||
inventory.FocusXP.AP_ATTACK += focusXpPlus[FocusType.AP_ATTACK];
|
||||
inventory.FocusXP.AP_DEFENSE += focusXpPlus[FocusType.AP_DEFENSE];
|
||||
inventory.FocusXP.AP_TACTIC += focusXpPlus[FocusType.AP_TACTIC];
|
||||
inventory.FocusXP.AP_POWER += focusXpPlus[FocusType.AP_POWER];
|
||||
inventory.FocusXP.AP_WARD += focusXpPlus[FocusType.AP_WARD];
|
||||
inventory.FocusXP ??= {};
|
||||
if (focusXpPlus[FocusType.AP_ATTACK]) {
|
||||
inventory.FocusXP.AP_ATTACK ??= 0;
|
||||
inventory.FocusXP.AP_ATTACK += focusXpPlus[FocusType.AP_ATTACK];
|
||||
}
|
||||
if (focusXpPlus[FocusType.AP_DEFENSE]) {
|
||||
inventory.FocusXP.AP_DEFENSE ??= 0;
|
||||
inventory.FocusXP.AP_DEFENSE += focusXpPlus[FocusType.AP_DEFENSE];
|
||||
}
|
||||
if (focusXpPlus[FocusType.AP_TACTIC]) {
|
||||
inventory.FocusXP.AP_TACTIC ??= 0;
|
||||
inventory.FocusXP.AP_TACTIC += focusXpPlus[FocusType.AP_TACTIC];
|
||||
}
|
||||
if (focusXpPlus[FocusType.AP_POWER]) {
|
||||
inventory.FocusXP.AP_POWER ??= 0;
|
||||
inventory.FocusXP.AP_POWER += focusXpPlus[FocusType.AP_POWER];
|
||||
}
|
||||
if (focusXpPlus[FocusType.AP_WARD]) {
|
||||
inventory.FocusXP.AP_WARD ??= 0;
|
||||
inventory.FocusXP.AP_WARD += focusXpPlus[FocusType.AP_WARD];
|
||||
}
|
||||
|
||||
if (!config.noDailyFocusLimit) {
|
||||
inventory.DailyFocus -= focusXpPlus.reduce((a, b) => a + b, 0);
|
||||
|
@ -641,11 +641,11 @@ export interface IFocusUpgrade {
|
||||
}
|
||||
|
||||
export interface IFocusXP {
|
||||
AP_POWER: number;
|
||||
AP_TACTIC: number;
|
||||
AP_DEFENSE: number;
|
||||
AP_ATTACK: number;
|
||||
AP_WARD: number;
|
||||
AP_POWER?: number;
|
||||
AP_TACTIC?: number;
|
||||
AP_DEFENSE?: number;
|
||||
AP_ATTACK?: number;
|
||||
AP_WARD?: number;
|
||||
}
|
||||
|
||||
export type TFocusPolarity = keyof IFocusXP;
|
||||
|
Loading…
x
Reference in New Issue
Block a user