Skip to content

Commit

Permalink
feat: add universalPolarityEverywhere (#368)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sainan authored Jun 22, 2024
1 parent b4fedb7 commit fda7b5f
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 38 deletions.
1 change: 1 addition & 0 deletions config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
"unlockAllShipDecorations": true,
"unlockAllFlavourItems": true,
"unlockAllSkins": true,
"universalPolarityEverywhere": true,
"spoofMasteryRank": -1
}
20 changes: 19 additions & 1 deletion src/controllers/api/inventoryController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
import { config } from "@/src/services/configService";
import allMissions from "@/static/fixed_responses/allMissions.json";
import { ILoadoutDatabase } from "@/src/types/saveLoadoutTypes";
import { IShipInventory } from "@/src/types/inventoryTypes/inventoryTypes";
import { IShipInventory, equipmentKeys } from "@/src/types/inventoryTypes/inventoryTypes";
import { IPolarity, ArtifactPolarity } from "@/src/types/inventoryTypes/commonInventoryTypes";
import { ExportCustoms, ExportFlavour, ExportKeys, ExportResources } from "warframe-public-export-plus";

// eslint-disable-next-line @typescript-eslint/no-misused-promises
Expand Down Expand Up @@ -118,6 +119,23 @@ const inventoryController: RequestHandler = async (request, response) => {
}
}

if (config.universalPolarityEverywhere) {
const Polarity: IPolarity[] = [];
for (let i = 0; i != 10; ++i) {
Polarity.push({
Slot: i,
Value: ArtifactPolarity.Any
});
}
for (const key of equipmentKeys) {
if (key in inventoryResponse) {
for (const equipment of inventoryResponse[key]) {
equipment.Polarity = Polarity;
}
}
}
}

response.json(inventoryResponse);
};

Expand Down
8 changes: 6 additions & 2 deletions src/controllers/api/upgradesController.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { RequestHandler } from "express";
import { IUpgradesRequest } from "@/src/types/requestTypes";
import { FocusSchool, IEquipmentDatabase, EquipmentFeatures } from "@/src/types/inventoryTypes/commonInventoryTypes";
import {
ArtifactPolarity,
IEquipmentDatabase,
EquipmentFeatures
} from "@/src/types/inventoryTypes/commonInventoryTypes";
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { addMiscItems, getInventory, updateCurrency } from "@/src/services/inventoryService";
Expand Down Expand Up @@ -133,7 +137,7 @@ export const upgradesController: RequestHandler = async (req, res) => {
res.json({ InventoryChanges });
};

const setSlotPolarity = (item: IEquipmentDatabase, slot: number, polarity: FocusSchool): void => {
const setSlotPolarity = (item: IEquipmentDatabase, slot: number, polarity: ArtifactPolarity): void => {
item.Polarity ??= [];
const entry = item.Polarity.find(entry => entry.Slot == slot);
if (entry) {
Expand Down
1 change: 1 addition & 0 deletions src/services/configService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ interface IConfig {
unlockAllShipDecorations?: boolean;
unlockAllFlavourItems?: boolean;
unlockAllSkins?: boolean;
universalPolarityEverywhere?: boolean;
spoofMasteryRank?: number;
}

Expand Down
22 changes: 11 additions & 11 deletions src/types/inventoryTypes/commonInventoryTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import { Types } from "mongoose";

export interface IPolarity {
Slot: number;
Value: FocusSchool;
Value: ArtifactPolarity;
}

export enum FocusSchool {
ApAny = "AP_ANY",
ApAttack = "AP_ATTACK",
ApDefense = "AP_DEFENSE",
ApPower = "AP_POWER",
ApPrecept = "AP_PRECEPT",
ApTactic = "AP_TACTIC",
ApUmbra = "AP_UMBRA",
ApUniversal = "AP_UNIVERSAL",
ApWard = "AP_WARD"
export enum ArtifactPolarity {
Any = "AP_ANY",
Attack = "AP_ATTACK",
Defense = "AP_DEFENSE",
Power = "AP_POWER",
Precept = "AP_PRECEPT",
Tactic = "AP_TACTIC",
Umbra = "AP_UMBRA",
Universal = "AP_UNIVERSAL",
Ward = "AP_WARD"
}

export interface IColor {
Expand Down
36 changes: 25 additions & 11 deletions src/types/inventoryTypes/inventoryTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import { Document, Types } from "mongoose";
import { IOid, IMongoDate } from "../commonTypes";
import {
ArtifactPolarity,
IColor,
FocusSchool,
IItemConfig,
IOperatorConfigClient,
IEquipmentSelection,
Expand Down Expand Up @@ -61,15 +61,21 @@ export interface ITypeCount {
ItemCount: number;
}

export type TEquipmentKey =
| "Suits"
| "LongGuns"
| "Pistols"
| "Melee"
| "SpecialItems"
| "Sentinels"
| "SentinelWeapons"
| "SpaceGuns";
export const equipmentKeys = [
"Suits",
"LongGuns",
"Pistols",
"Melee",
"SpecialItems",
"Sentinels",
"SentinelWeapons",
"SpaceSuits",
"SpaceGuns",
"SpaceMelee",
"Hoverboards"
] as const;

export type TEquipmentKey = (typeof equipmentKeys)[number];

export interface IDuviriInfo {
Seed: number;
Expand Down Expand Up @@ -599,6 +605,14 @@ export interface ILoadOutPresets {
OPERATOR_ADULT: ILoadoutConfigClient[];
}

export enum FocusSchool {
Attack = "AP_ATTACK",
Defense = "AP_DEFENSE",
Power = "AP_POWER",
Tactic = "AP_TACTIC",
Ward = "AP_WARD"
}

export interface ILoadoutConfigClient {
FocusSchool?: FocusSchool;
PresetIcon?: string;
Expand Down Expand Up @@ -707,7 +721,7 @@ export interface IUpgradeFingerprint {
compat: string;
lim: number;
lvlReq: number;
pol: FocusSchool;
pol: ArtifactPolarity;
buffs: IBuff[];
curses: IBuff[];
}
Expand Down
4 changes: 2 additions & 2 deletions src/types/requestTypes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IOid } from "./commonTypes";
import { IPolarity, FocusSchool, IEquipmentClient } from "@/src/types/inventoryTypes/commonInventoryTypes";
import { ArtifactPolarity, IPolarity, IEquipmentClient } from "@/src/types/inventoryTypes/commonInventoryTypes";
import {
IBooster,
IChallengeProgress,
Expand Down Expand Up @@ -98,6 +98,6 @@ export interface IUpgradeOperation {
OperationType: string;
UpgradeRequirement: string; // uniqueName of item being consumed
PolarizeSlot: number;
PolarizeValue: FocusSchool;
PolarizeValue: ArtifactPolarity;
PolarityRemap: IPolarity[];
}
30 changes: 19 additions & 11 deletions static/webui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -231,32 +231,40 @@ <h5 class="card-header">Mods</h5>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="infiniteResources" />
<label class="form-check-label" for="infiniteResources"
>Infinite Credits and Platinum</label
>
<label class="form-check-label" for="infiniteResources">
Infinite Credits and Platinum
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="unlockAllShipFeatures" />
<label class="form-check-label" for="unlockAllShipFeatures">Unlock All Ship Features</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="unlockAllShipDecorations" />
<label class="form-check-label" for="unlockAllShipDecorations"
>Unlock All Ship Decorations</label
>
<label class="form-check-label" for="unlockAllShipDecorations">
Unlock All Ship Decorations
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="unlockAllFlavourItems" />
<label class="form-check-label" for="unlockAllFlavourItems">Unlock All Accessories</label>
<label class="form-check-label" for="unlockAllFlavourItems">
Unlock All Flavor Items (Glyphs & co.)
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="unlockAllSkins" />
<label class="form-check-label" for="unlockAllSkins">Unlock All Skins</label>
</div>
<div class="form-group">
<label class="form-label" for="spoofMasteryRank"
>Spoofed Mastery Rank (-1 to disable)</label
>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="universalPolarityEverywhere" />
<label class="form-check-label" for="universalPolarityEverywhere">
Universal Polarity Everywhere
</label>
</div>
<div class="form-group mt-2 mb-2">
<label class="form-label" for="spoofMasteryRank">
Spoofed Mastery Rank (-1 to disable)
</label>
<input class="form-control" id="spoofMasteryRank" type="number" min="-1" />
</div>
<button class="btn btn-primary mt-3" type="submit">Save Settings</button>
Expand Down

0 comments on commit fda7b5f

Please sign in to comment.