Compare commits
	
		
			1 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 9c5164a989 | 
@ -3,6 +3,3 @@
 | 
			
		||||
Dockerfile*
 | 
			
		||||
.*
 | 
			
		||||
docker-data/
 | 
			
		||||
node_modules/
 | 
			
		||||
static/data/
 | 
			
		||||
logs/
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										38
									
								
								.eslintrc
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								.eslintrc
									
									
									
									
									
								
							@ -1,48 +1,36 @@
 | 
			
		||||
{
 | 
			
		||||
    "plugins": ["@typescript-eslint", "prettier", "import"],
 | 
			
		||||
    "extends": [
 | 
			
		||||
        "eslint:recommended",
 | 
			
		||||
        "plugin:@typescript-eslint/recommended",
 | 
			
		||||
        "plugin:@typescript-eslint/recommended-requiring-type-checking",
 | 
			
		||||
        "plugin:import/recommended",
 | 
			
		||||
        "plugin:import/typescript"
 | 
			
		||||
        "plugin:@typescript-eslint/recommended-requiring-type-checking"
 | 
			
		||||
    ],
 | 
			
		||||
    "plugins": ["@typescript-eslint", "prettier"],
 | 
			
		||||
    "env": {
 | 
			
		||||
        "browser": true,
 | 
			
		||||
        "es6": true,
 | 
			
		||||
        "node": true
 | 
			
		||||
    },
 | 
			
		||||
    "rules": {
 | 
			
		||||
        "@typescript-eslint/consistent-type-imports": "error",
 | 
			
		||||
        "@typescript-eslint/explicit-function-return-type": "error",
 | 
			
		||||
        "@typescript-eslint/restrict-template-expressions": "error",
 | 
			
		||||
        "@typescript-eslint/restrict-plus-operands": "error",
 | 
			
		||||
        "@typescript-eslint/no-unsafe-member-access": "error",
 | 
			
		||||
        "@typescript-eslint/explicit-function-return-type": "warn",
 | 
			
		||||
        "@typescript-eslint/restrict-template-expressions": "warn",
 | 
			
		||||
        "@typescript-eslint/restrict-plus-operands": "warn",
 | 
			
		||||
        "@typescript-eslint/no-unsafe-member-access": "warn",
 | 
			
		||||
        "@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_", "caughtErrors": "none" }],
 | 
			
		||||
        "@typescript-eslint/no-unsafe-argument": "error",
 | 
			
		||||
        "@typescript-eslint/no-unsafe-call": "error",
 | 
			
		||||
        "@typescript-eslint/no-unsafe-assignment": "error",
 | 
			
		||||
        "@typescript-eslint/no-explicit-any": "off",
 | 
			
		||||
        "no-loss-of-precision": "error",
 | 
			
		||||
        "@typescript-eslint/no-unnecessary-condition": "error",
 | 
			
		||||
        "@typescript-eslint/no-unsafe-call": "warn",
 | 
			
		||||
        "@typescript-eslint/no-unsafe-assignment": "warn",
 | 
			
		||||
        "@typescript-eslint/no-explicit-any": "warn",
 | 
			
		||||
        "no-loss-of-precision": "warn",
 | 
			
		||||
        "@typescript-eslint/no-unnecessary-condition": "warn",
 | 
			
		||||
        "@typescript-eslint/no-base-to-string": "off",
 | 
			
		||||
        "no-case-declarations": "error",
 | 
			
		||||
        "prettier/prettier": "error",
 | 
			
		||||
        "no-mixed-spaces-and-tabs": "error",
 | 
			
		||||
        "@typescript-eslint/require-await": "error",
 | 
			
		||||
        "import/no-named-as-default-member": "off",
 | 
			
		||||
        "import/no-cycle": "warn",
 | 
			
		||||
        "@typescript-eslint/no-deprecated": "warn"
 | 
			
		||||
        "require-await": "off",
 | 
			
		||||
        "@typescript-eslint/require-await": "error"
 | 
			
		||||
    },
 | 
			
		||||
    "parser": "@typescript-eslint/parser",
 | 
			
		||||
    "parserOptions": {
 | 
			
		||||
        "project": "./tsconfig.json"
 | 
			
		||||
    },
 | 
			
		||||
    "settings": {
 | 
			
		||||
        "import/extensions": [ ".ts" ],
 | 
			
		||||
        "import/resolver": {
 | 
			
		||||
            "typescript": true,
 | 
			
		||||
            "node": true
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										7
									
								
								.github/workflows/build.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								.github/workflows/build.yml
									
									
									
									
										vendored
									
									
								
							@ -1,7 +1,6 @@
 | 
			
		||||
name: Build
 | 
			
		||||
on:
 | 
			
		||||
    push:
 | 
			
		||||
        branches: ["main"]
 | 
			
		||||
    push: {}
 | 
			
		||||
    pull_request: {}
 | 
			
		||||
jobs:
 | 
			
		||||
    build:
 | 
			
		||||
@ -12,9 +11,9 @@ jobs:
 | 
			
		||||
            - name: Setup Node.js environment
 | 
			
		||||
              uses: actions/setup-node@v4.0.2
 | 
			
		||||
              with:
 | 
			
		||||
                  node-version: ">=20.18.1"
 | 
			
		||||
                  node-version: ">=20.6.0"
 | 
			
		||||
            - run: npm ci
 | 
			
		||||
            - run: cp config-vanilla.json config.json
 | 
			
		||||
            - run: cp config.json.example config.json
 | 
			
		||||
            - run: npm run verify
 | 
			
		||||
            - run: npm run lint:ci
 | 
			
		||||
            - run: npm run prettier
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										4
									
								
								.github/workflows/docker.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.github/workflows/docker.yml
									
									
									
									
										vendored
									
									
								
							@ -18,10 +18,8 @@ jobs:
 | 
			
		||||
            - name: Build and push
 | 
			
		||||
              uses: docker/build-push-action@v6
 | 
			
		||||
              with:
 | 
			
		||||
                  platforms: linux/arm64,linux/amd64
 | 
			
		||||
                  platforms: linux/amd64,linux/arm64
 | 
			
		||||
                  push: true
 | 
			
		||||
                  tags: |
 | 
			
		||||
                      openwf/spaceninjaserver:latest
 | 
			
		||||
                      openwf/spaceninjaserver:latest-arm64
 | 
			
		||||
                      openwf/spaceninjaserver:${{ github.sha }}
 | 
			
		||||
                      openwf/spaceninjaserver:${{ github.sha }}-arm64
 | 
			
		||||
 | 
			
		||||
@ -2,4 +2,3 @@ src/routes/api.ts
 | 
			
		||||
static/webui/libs/
 | 
			
		||||
*.html
 | 
			
		||||
*.md
 | 
			
		||||
config-vanilla.json
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										3
									
								
								.vscode/launch.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.vscode/launch.json
									
									
									
									
										vendored
									
									
								
							@ -8,7 +8,8 @@
 | 
			
		||||
      "type": "node",
 | 
			
		||||
      "request": "launch",
 | 
			
		||||
      "name": "Debug and Watch",
 | 
			
		||||
      "args": ["${workspaceFolder}/scripts/dev.js"],
 | 
			
		||||
      "runtimeArgs": ["-r", "tsconfig-paths/register", "-r", "ts-node/register", "--watch-path", "src"],
 | 
			
		||||
      "args": ["${workspaceFolder}/src/index.ts"],
 | 
			
		||||
      "console": "integratedTerminal"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										3
									
								
								.vscode/settings.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.vscode/settings.json
									
									
									
									
										vendored
									
									
								
							@ -1,3 +0,0 @@
 | 
			
		||||
{
 | 
			
		||||
  "typescript.preferences.preferTypeOnlyAutoImports": true
 | 
			
		||||
}
 | 
			
		||||
@ -1,19 +0,0 @@
 | 
			
		||||
## In General
 | 
			
		||||
 | 
			
		||||
### Prerequisites
 | 
			
		||||
 | 
			
		||||
Use `npm i` or `npm ci` to install all dependencies, including dev dependencies.
 | 
			
		||||
 | 
			
		||||
## Development Process
 | 
			
		||||
 | 
			
		||||
Auto reloading is supported for server and WebUI development. Simply use `npm run dev` or `npm run dev:bun` to start the server and edit away.
 | 
			
		||||
 | 
			
		||||
### Testing
 | 
			
		||||
 | 
			
		||||
Before submitting a PR:
 | 
			
		||||
- Use `npm run verify` to verify that the code is type-safe.
 | 
			
		||||
- Use `npm run fix` to fix formatting issues as well as be informed of any unfixable issues. Avoid introducing new warnings.
 | 
			
		||||
 | 
			
		||||
## WebUI Specific
 | 
			
		||||
 | 
			
		||||
The translation system is designed around additions being made to `static/webui/translations/en.js`. They are copied over for translation via `npm run update-translations`. DO NOT provide translations generated by AI or other automated tools.
 | 
			
		||||
							
								
								
									
										52
									
								
								Dockerfile
									
									
									
									
									
								
							
							
						
						
									
										52
									
								
								Dockerfile
									
									
									
									
									
								
							@ -1,11 +1,53 @@
 | 
			
		||||
FROM node:24-alpine3.21
 | 
			
		||||
FROM node:18-alpine3.19
 | 
			
		||||
 | 
			
		||||
RUN apk add --no-cache bash jq
 | 
			
		||||
ENV APP_MONGODB_URL=mongodb://mongodb:27017/openWF
 | 
			
		||||
ENV APP_MY_ADDRESS=localhost
 | 
			
		||||
ENV APP_HTTP_PORT=80
 | 
			
		||||
ENV APP_HTTPS_PORT=443
 | 
			
		||||
ENV APP_AUTO_CREATE_ACCOUNT=true
 | 
			
		||||
ENV APP_SKIP_TUTORIAL=false
 | 
			
		||||
ENV APP_SKIP_ALL_DIALOGUE=false
 | 
			
		||||
ENV APP_UNLOCK_ALL_SCANS=false
 | 
			
		||||
ENV APP_UNLOCK_ALL_MISSIONS=false
 | 
			
		||||
ENV APP_INFINITE_CREDITS=false
 | 
			
		||||
ENV APP_INFINITE_PLATINUM=false
 | 
			
		||||
ENV APP_INFINITE_ENDO=false
 | 
			
		||||
ENV APP_INFINITE_REGAL_AYA=false
 | 
			
		||||
ENV APP_INFINITE_HELMINTH_MATERIALS=false
 | 
			
		||||
ENV APP_CLAIMING_BLUEPRINT_REFUNDS_INGREDIENTS=false
 | 
			
		||||
ENV APP_DONT_SUBTRACT_VOIDTRACES=false
 | 
			
		||||
ENV APP_DONT_SUBTRACT_CONSUMABLES=false
 | 
			
		||||
ENV APP_UNLOCK_ALL_SHIP_FEATURES=false
 | 
			
		||||
ENV APP_UNLOCK_ALL_SHIP_DECORATIONS=false
 | 
			
		||||
ENV APP_UNLOCK_ALL_FLAVOUR_ITEMS=false
 | 
			
		||||
ENV APP_UNLOCK_ALL_SKINS=false
 | 
			
		||||
ENV APP_UNLOCK_ALL_CAPTURA_SCENES=false
 | 
			
		||||
ENV APP_UNIVERSAL_POLARITY_EVERYWHERE=false
 | 
			
		||||
ENV APP_UNLOCK_DOUBLE_CAPACITY_POTATOES_EVERYWHERE=false
 | 
			
		||||
ENV APP_UNLOCK_EXILUS_EVERYWHERE=false
 | 
			
		||||
ENV APP_UNLOCK_ARCANES_EVERYWHERE=false
 | 
			
		||||
ENV APP_NO_DAILY_FOCUS_LIMIT=false
 | 
			
		||||
ENV APP_NO_ARGON_CRYSTAL_DECAY=false
 | 
			
		||||
ENV APP_NO_MASTERY_RANK_UP_COOLDOWN=false
 | 
			
		||||
ENV APP_NO_VENDOR_PURCHASE_LIMITS=true
 | 
			
		||||
ENV APP_NO_DEATH_MARKS=false
 | 
			
		||||
ENV APP_NO_KIM_COOLDOWNS=false
 | 
			
		||||
ENV APP_SYNDICATE_MISSIONS_REPEATABLE=false
 | 
			
		||||
ENV APP_INSTANT_FINISH_RIVEN_CHALLENGE=false
 | 
			
		||||
ENV APP_INSTANT_RESOURCE_EXTRACTOR_DRONES=false
 | 
			
		||||
ENV APP_NO_RESOURCE_EXTRACTOR_DRONES_DAMAGE=false
 | 
			
		||||
ENV APP_SKIP_CLAN_KEY_CRAFTING=false
 | 
			
		||||
ENV APP_NO_DOJO_ROOM_BUILD_STAGE=false
 | 
			
		||||
ENV APP_NO_DECO_BUILD_STAGE=false
 | 
			
		||||
ENV APP_FAST_DOJO_ROOM_DESTRUCTION=false
 | 
			
		||||
ENV APP_NO_DOJO_RESEARCH_COSTS=false
 | 
			
		||||
ENV APP_NO_DOJO_RESEARCH_TIME=false
 | 
			
		||||
ENV APP_FAST_CLAN_ASCENSION=false
 | 
			
		||||
ENV APP_SPOOF_MASTERY_RANK=-1
 | 
			
		||||
 | 
			
		||||
RUN apk add --no-cache bash sed wget jq
 | 
			
		||||
 | 
			
		||||
COPY . /app
 | 
			
		||||
WORKDIR /app
 | 
			
		||||
 | 
			
		||||
RUN npm i --omit=dev --omit=optional
 | 
			
		||||
RUN date '+%d %B %Y' > BUILD_DATE
 | 
			
		||||
 | 
			
		||||
ENTRYPOINT ["/app/docker-entrypoint.sh"]
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										12
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								README.md
									
									
									
									
									
								
							@ -6,21 +6,17 @@ More information for the moment here: [https://discord.gg/PNNZ3asUuY](https://di
 | 
			
		||||
 | 
			
		||||
This project is in active development at <https://onlyg.it/OpenWF/SpaceNinjaServer>.
 | 
			
		||||
 | 
			
		||||
To get an idea of what functionality you can expect to be missing [have a look through the issues](https://onlyg.it/OpenWF/SpaceNinjaServer/issues). However, many things have been implemented and *should* work as expected. Please open an issue for anything where that's not the case and/or the server is reporting errors.
 | 
			
		||||
To get an idea of what functionality you can expect to be missing [have a look through the issues](https://onlyg.it/OpenWF/SpaceNinjaServer/issues?q=&type=all&state=open&labels=-4%2C-10&milestone=0&assignee=0&poster=). However, many things have been implemented and *should* work as expected. Please open an issue for anything where that's not the case and/or the server is reporting errors.
 | 
			
		||||
 | 
			
		||||
## config.json
 | 
			
		||||
 | 
			
		||||
SpaceNinjaServer requires a `config.json`. To set it up, you can copy the [config-vanilla.json](config-vanilla.json), which has most cheats disabled.
 | 
			
		||||
SpaceNinjaServer requires a `config.json`. To set it up, you can copy the [config.json.example](config.json.example), which has most cheats disabled.
 | 
			
		||||
 | 
			
		||||
- `skipTutorial` affects only newly created accounts, so you may wish to change it before logging in for the first time.
 | 
			
		||||
- `logger.level` can be `fatal`, `error`, `warn`, `info`, `http`, `debug`, or `trace`.
 | 
			
		||||
- `ircExecutable` can be provided with a relative path to an EXE which will be ran as a child process of SpaceNinjaServer.
 | 
			
		||||
- `ircAddress`, `hubAddress`, and `nrsAddress` can be provided if these secondary servers are on a different machine.
 | 
			
		||||
- `myIrcAddresses` can be used to point to an IRC server. If not provided, defaults to `[ myAddress ]`.
 | 
			
		||||
- `worldState.eidolonOverride` can be set to `day` or `night` to lock the time to day/fass and night/vome on Plains of Eidolon/Cambion Drift.
 | 
			
		||||
- `worldState.vallisOverride` can be set to `warm` or `cold` to lock the temperature on Orb Vallis.
 | 
			
		||||
- `worldState.duviriOverride` can be set to `joy`, `anger`, `envy`, `sorrow`, or `fear` to lock the Duviri spiral.
 | 
			
		||||
- `worldState.nightwaveOverride` will lock the nightwave season, assuming the client is new enough for it. Valid values:
 | 
			
		||||
  - `RadioLegionIntermission14Syndicate` for Nora's Mix: Dreams of the Dead
 | 
			
		||||
  - `RadioLegionIntermission13Syndicate` for Nora's Mix Vol. 9
 | 
			
		||||
  - `RadioLegionIntermission12Syndicate` for Nora's Mix Vol. 8
 | 
			
		||||
  - `RadioLegionIntermission11Syndicate` for Nora's Mix Vol. 7
 | 
			
		||||
@ -37,5 +33,3 @@ SpaceNinjaServer requires a `config.json`. To set it up, you can copy the [confi
 | 
			
		||||
  - `RadioLegion2Syndicate` for The Emissary
 | 
			
		||||
  - `RadioLegionIntermissionSyndicate` for Intermission I
 | 
			
		||||
  - `RadioLegionSyndicate` for The Wolf of Saturn Six
 | 
			
		||||
- `worldState.allTheFissures` can be set to `normal` or `hard` to enable all fissures either in normal or steel path, respectively.
 | 
			
		||||
- `worldState.circuitGameModes` can be set to an array of game modes which will override the otherwise-random pattern in The Circuit. Valid element values are `Survival`, `VoidFlood`, `Excavation`, `Defense`, `Exterminate`, `Assassination`, and `Alchemy`.
 | 
			
		||||
 | 
			
		||||
@ -2,32 +2,24 @@
 | 
			
		||||
 | 
			
		||||
echo Updating SpaceNinjaServer...
 | 
			
		||||
git fetch --prune
 | 
			
		||||
if %errorlevel% == 0 (
 | 
			
		||||
	git stash
 | 
			
		||||
	git checkout -f origin/main
 | 
			
		||||
git stash
 | 
			
		||||
git checkout -f origin/main
 | 
			
		||||
 | 
			
		||||
	if exist static\data\0\ (
 | 
			
		||||
		echo Updating stripped assets...
 | 
			
		||||
		cd static\data\0\
 | 
			
		||||
		git pull
 | 
			
		||||
		cd ..\..\..\
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	echo Updating dependencies...
 | 
			
		||||
	node scripts/raw-precheck.js > NUL
 | 
			
		||||
	if %errorlevel% == 0 (
 | 
			
		||||
		call npm i --omit=dev --omit=optional
 | 
			
		||||
		call npm run raw
 | 
			
		||||
	) else (
 | 
			
		||||
		call npm i --omit=dev
 | 
			
		||||
		call npm run build
 | 
			
		||||
		if %errorlevel% == 0 (
 | 
			
		||||
			call npm run start
 | 
			
		||||
		)
 | 
			
		||||
	)
 | 
			
		||||
	echo SpaceNinjaServer seems to have crashed.
 | 
			
		||||
if exist static\data\0\ (
 | 
			
		||||
	echo Updating stripped assets...
 | 
			
		||||
	cd static\data\0\
 | 
			
		||||
	git pull
 | 
			
		||||
	cd ..\..\..\
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
echo Updating dependencies...
 | 
			
		||||
call npm i --omit=dev
 | 
			
		||||
 | 
			
		||||
call npm run build
 | 
			
		||||
if %errorlevel% == 0 (
 | 
			
		||||
	call npm run start
 | 
			
		||||
	echo SpaceNinjaServer seems to have crashed.
 | 
			
		||||
)
 | 
			
		||||
:a
 | 
			
		||||
pause > nul
 | 
			
		||||
goto a
 | 
			
		||||
 | 
			
		||||
@ -2,28 +2,22 @@
 | 
			
		||||
 | 
			
		||||
echo "Updating SpaceNinjaServer..."
 | 
			
		||||
git fetch --prune
 | 
			
		||||
git stash
 | 
			
		||||
git checkout -f origin/main
 | 
			
		||||
 | 
			
		||||
if [ -d "static/data/0/" ]; then
 | 
			
		||||
    echo "Updating stripped assets..."
 | 
			
		||||
    cd static/data/0/
 | 
			
		||||
    git pull
 | 
			
		||||
    cd ../../../
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
echo "Updating dependencies..."
 | 
			
		||||
npm i --omit=dev
 | 
			
		||||
 | 
			
		||||
npm run build
 | 
			
		||||
if [ $? -eq 0 ]; then
 | 
			
		||||
    git stash
 | 
			
		||||
    git checkout -f origin/main
 | 
			
		||||
 | 
			
		||||
    if [ -d "static/data/0/" ]; then
 | 
			
		||||
        echo "Updating stripped assets..."
 | 
			
		||||
        cd static/data/0/
 | 
			
		||||
        git pull
 | 
			
		||||
        cd ../../../
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
    echo "Updating dependencies..."
 | 
			
		||||
    node scripts/raw-precheck.js > /dev/null
 | 
			
		||||
    if [ $? -eq 0 ]; then
 | 
			
		||||
        npm i --omit=dev --omit=optional
 | 
			
		||||
        npm run raw
 | 
			
		||||
    else
 | 
			
		||||
        npm i --omit=dev
 | 
			
		||||
        npm run build
 | 
			
		||||
        if [ $? -eq 0 ]; then
 | 
			
		||||
            npm run start
 | 
			
		||||
        fi
 | 
			
		||||
    fi
 | 
			
		||||
    npm run start
 | 
			
		||||
    echo "SpaceNinjaServer seems to have crashed."
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,74 +0,0 @@
 | 
			
		||||
{
 | 
			
		||||
  "mongodbUrl": "mongodb://127.0.0.1:27017/openWF",
 | 
			
		||||
  "logger": {
 | 
			
		||||
    "files": true,
 | 
			
		||||
    "level": "trace"
 | 
			
		||||
  },
 | 
			
		||||
  "myAddress": "localhost",
 | 
			
		||||
  "bindAddress": "0.0.0.0",
 | 
			
		||||
  "httpPort": 80,
 | 
			
		||||
  "httpsPort": 443,
 | 
			
		||||
  "ircExecutable": null,
 | 
			
		||||
  "ircAddress": null,
 | 
			
		||||
  "hubAddress": null,
 | 
			
		||||
  "nrsAddress": null,
 | 
			
		||||
  "administratorNames": [],
 | 
			
		||||
  "autoCreateAccount": true,
 | 
			
		||||
  "skipTutorial": false,
 | 
			
		||||
  "unlockAllSkins": false,
 | 
			
		||||
  "fullyStockedVendors": false,
 | 
			
		||||
  "skipClanKeyCrafting": false,
 | 
			
		||||
  "unfaithfulBugFixes": {
 | 
			
		||||
    "ignore1999LastRegionPlayed": false,
 | 
			
		||||
    "fixXtraCheeseTimer": false,
 | 
			
		||||
    "useAnniversaryTagForOldGoals": true
 | 
			
		||||
  },
 | 
			
		||||
  "worldState": {
 | 
			
		||||
    "creditBoost": false,
 | 
			
		||||
    "affinityBoost": false,
 | 
			
		||||
    "resourceBoost": false,
 | 
			
		||||
    "tennoLiveRelay": false,
 | 
			
		||||
    "baroTennoConRelay": false,
 | 
			
		||||
    "baroAlwaysAvailable": false,
 | 
			
		||||
    "baroFullyStocked": false,
 | 
			
		||||
    "varziaFullyStocked": false,
 | 
			
		||||
    "wolfHunt": null,
 | 
			
		||||
    "orphixVenom": false,
 | 
			
		||||
    "longShadow": false,
 | 
			
		||||
    "hallowedFlame": false,
 | 
			
		||||
    "anniversary": null,
 | 
			
		||||
    "hallowedNightmares": false,
 | 
			
		||||
    "hallowedNightmaresRewardsOverride": 0,
 | 
			
		||||
    "naberusNightsOverride": null,
 | 
			
		||||
    "proxyRebellion": false,
 | 
			
		||||
    "proxyRebellionRewardsOverride": 0,
 | 
			
		||||
    "voidCorruption2025Week1": false,
 | 
			
		||||
    "voidCorruption2025Week2": false,
 | 
			
		||||
    "voidCorruption2025Week3": false,
 | 
			
		||||
    "voidCorruption2025Week4": false,
 | 
			
		||||
    "qtccAlerts": false,
 | 
			
		||||
    "galleonOfGhouls": 0,
 | 
			
		||||
    "ghoulEmergenceOverride": null,
 | 
			
		||||
    "plagueStarOverride": null,
 | 
			
		||||
    "starDaysOverride": null,
 | 
			
		||||
    "dogDaysOverride": null,
 | 
			
		||||
    "dogDaysRewardsOverride": null,
 | 
			
		||||
    "bellyOfTheBeast": false,
 | 
			
		||||
    "bellyOfTheBeastProgressOverride": 0,
 | 
			
		||||
    "eightClaw": false,
 | 
			
		||||
    "eightClawProgressOverride": 0,
 | 
			
		||||
    "thermiaFracturesOverride": null,
 | 
			
		||||
    "thermiaFracturesProgressOverride": 0,
 | 
			
		||||
    "eidolonOverride": "",
 | 
			
		||||
    "vallisOverride": "",
 | 
			
		||||
    "duviriOverride": "",
 | 
			
		||||
    "nightwaveOverride": "",
 | 
			
		||||
    "allTheFissures": "",
 | 
			
		||||
    "varziaOverride": "",
 | 
			
		||||
    "circuitGameModes": null,
 | 
			
		||||
    "darvoStockMultiplier": 1
 | 
			
		||||
  },
 | 
			
		||||
  "dev": {
 | 
			
		||||
    "keepVendorsExpired": false
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										62
									
								
								config.json.example
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								config.json.example
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,62 @@
 | 
			
		||||
{
 | 
			
		||||
  "mongodbUrl": "mongodb://127.0.0.1:27017/openWF",
 | 
			
		||||
  "logger": {
 | 
			
		||||
    "files": true,
 | 
			
		||||
    "level": "trace"
 | 
			
		||||
  },
 | 
			
		||||
  "myAddress": "localhost",
 | 
			
		||||
  "httpPort": 80,
 | 
			
		||||
  "httpsPort": 443,
 | 
			
		||||
  "NRS": ["localhost"],
 | 
			
		||||
  "administratorNames": [],
 | 
			
		||||
  "autoCreateAccount": true,
 | 
			
		||||
  "skipTutorial": false,
 | 
			
		||||
  "skipAllDialogue": false,
 | 
			
		||||
  "unlockAllScans": false,
 | 
			
		||||
  "unlockAllMissions": false,
 | 
			
		||||
  "infiniteCredits": false,
 | 
			
		||||
  "infinitePlatinum": false,
 | 
			
		||||
  "infiniteEndo": false,
 | 
			
		||||
  "infiniteRegalAya": false,
 | 
			
		||||
  "infiniteHelminthMaterials": false,
 | 
			
		||||
  "claimingBlueprintRefundsIngredients": false,
 | 
			
		||||
  "dontSubtractVoidTraces": false,
 | 
			
		||||
  "dontSubtractConsumables": false,
 | 
			
		||||
  "unlockAllShipFeatures": false,
 | 
			
		||||
  "unlockAllShipDecorations": false,
 | 
			
		||||
  "unlockAllFlavourItems": false,
 | 
			
		||||
  "unlockAllSkins": false,
 | 
			
		||||
  "unlockAllCapturaScenes": false,
 | 
			
		||||
  "universalPolarityEverywhere": false,
 | 
			
		||||
  "unlockDoubleCapacityPotatoesEverywhere": false,
 | 
			
		||||
  "unlockExilusEverywhere": false,
 | 
			
		||||
  "unlockArcanesEverywhere": false,
 | 
			
		||||
  "noDailyStandingLimits": false,
 | 
			
		||||
  "noDailyFocusLimit": false,
 | 
			
		||||
  "noArgonCrystalDecay": false,
 | 
			
		||||
  "noMasteryRankUpCooldown": false,
 | 
			
		||||
  "noVendorPurchaseLimits": true,
 | 
			
		||||
  "noDeathMarks": false,
 | 
			
		||||
  "noKimCooldowns": false,
 | 
			
		||||
  "syndicateMissionsRepeatable": false,
 | 
			
		||||
  "instantFinishRivenChallenge": false,
 | 
			
		||||
  "instantResourceExtractorDrones": false,
 | 
			
		||||
  "noResourceExtractorDronesDamage": false,
 | 
			
		||||
  "skipClanKeyCrafting": false,
 | 
			
		||||
  "noDojoRoomBuildStage": false,
 | 
			
		||||
  "noDecoBuildStage": false,
 | 
			
		||||
  "fastDojoRoomDestruction": false,
 | 
			
		||||
  "noDojoResearchCosts": false,
 | 
			
		||||
  "noDojoResearchTime": false,
 | 
			
		||||
  "fastClanAscension": false,
 | 
			
		||||
  "spoofMasteryRank": -1,
 | 
			
		||||
  "worldState": {
 | 
			
		||||
    "creditBoost": false,
 | 
			
		||||
    "affinityBoost": false,
 | 
			
		||||
    "resourceBoost": false,
 | 
			
		||||
    "starDays": true,
 | 
			
		||||
    "eidolonOverride": "",
 | 
			
		||||
    "vallisOverride": "",
 | 
			
		||||
    "nightwaveOverride": ""
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@ -1,23 +1,68 @@
 | 
			
		||||
services:
 | 
			
		||||
    spaceninjaserver:
 | 
			
		||||
        # build: .
 | 
			
		||||
        image: openwf/spaceninjaserver:latest
 | 
			
		||||
        environment:
 | 
			
		||||
            APP_MONGODB_URL: mongodb://openwfagent:spaceninjaserver@mongodb:27017/
 | 
			
		||||
 | 
			
		||||
            # Following environment variables are set to default image values.
 | 
			
		||||
            # Uncomment to edit.
 | 
			
		||||
 | 
			
		||||
            # APP_MY_ADDRESS: localhost
 | 
			
		||||
            # APP_HTTP_PORT: 80
 | 
			
		||||
            # APP_HTTPS_PORT: 443
 | 
			
		||||
            # APP_AUTO_CREATE_ACCOUNT: true
 | 
			
		||||
            # APP_SKIP_TUTORIAL: false
 | 
			
		||||
            # APP_SKIP_ALL_DIALOGUE: false
 | 
			
		||||
            # APP_UNLOCK_ALL_SCANS: false
 | 
			
		||||
            # APP_UNLOCK_ALL_MISSIONS: false
 | 
			
		||||
            # APP_INFINITE_CREDITS: false
 | 
			
		||||
            # APP_INFINITE_PLATINUM: false
 | 
			
		||||
            # APP_INFINITE_ENDO: false
 | 
			
		||||
            # APP_INFINITE_REGAL_AYA: false
 | 
			
		||||
            # APP_INFINITE_HELMINTH_MATERIALS: false
 | 
			
		||||
            # APP_CLAIMING_BLUEPRINT_REFUNDS_INGREDIENTS: false
 | 
			
		||||
            # APP_DONT_SUBTRACT_VOIDTRACES: false
 | 
			
		||||
            # APP_DONT_SUBTRACT_CONSUMABLES: false
 | 
			
		||||
            # APP_UNLOCK_ALL_SHIP_FEATURES: false
 | 
			
		||||
            # APP_UNLOCK_ALL_SHIP_DECORATIONS: false
 | 
			
		||||
            # APP_UNLOCK_ALL_FLAVOUR_ITEMS: false
 | 
			
		||||
            # APP_UNLOCK_ALL_SKINS: false
 | 
			
		||||
            # APP_UNLOCK_ALL_CAPTURA_SCENES: false
 | 
			
		||||
            # APP_UNIVERSAL_POLARITY_EVERYWHERE: false
 | 
			
		||||
            # APP_UNLOCK_DOUBLE_CAPACITY_POTATOES_EVERYWHERE: false
 | 
			
		||||
            # APP_UNLOCK_EXILUS_EVERYWHERE: false
 | 
			
		||||
            # APP_UNLOCK_ARCANES_EVERYWHERE: false
 | 
			
		||||
            # APP_NO_DAILY_FOCUS_LIMIT: false
 | 
			
		||||
            # APP_NO_ARGON_CRYSTAL_DECAY: false
 | 
			
		||||
            # APP_NO_MASTERY_RANK_UP_COOLDOWN: false
 | 
			
		||||
            # APP_NO_VENDOR_PURCHASE_LIMITS: true
 | 
			
		||||
            # APP_NO_DEATH_MARKS: false
 | 
			
		||||
            # APP_NO_KIM_COOLDOWNS: false
 | 
			
		||||
            # APP_SYNDICATE_MISSIONS_REPEATABLE: false
 | 
			
		||||
            # APP_INSTANT_FINISH_RIVEN_CHALLENGE: false
 | 
			
		||||
            # APP_INSTANT_RESOURCE_EXTRACTOR_DRONES: false
 | 
			
		||||
            # APP_NO_RESOURCE_EXTRACTOR_DRONES_DAMAGE: false
 | 
			
		||||
            # APP_SKIP_CLAN_KEY_CRAFTING: false
 | 
			
		||||
            # APP_NO_DOJO_ROOM_BUILD_STAGE: false
 | 
			
		||||
            # APP_NO_DECO_BUILD_STAGE: false
 | 
			
		||||
            # APP_FAST_DOJO_ROOM_DESTRUCTION: false
 | 
			
		||||
            # APP_NO_DOJO_RESEARCH_COSTS: false
 | 
			
		||||
            # APP_NO_DOJO_RESEARCH_TIME: false
 | 
			
		||||
            # APP_FAST_CLAN_ASCENSION: false
 | 
			
		||||
            # APP_SPOOF_MASTERY_RANK: -1
 | 
			
		||||
        volumes:
 | 
			
		||||
            - ./docker-data/conf:/app/conf
 | 
			
		||||
            - ./docker-data/static-data:/app/static/data
 | 
			
		||||
            - ./docker-data/static:/app/static/data
 | 
			
		||||
            - ./docker-data/logs:/app/logs
 | 
			
		||||
        ports:
 | 
			
		||||
            - 80:80
 | 
			
		||||
            - 443:443
 | 
			
		||||
 | 
			
		||||
        # Normally, the image is fetched from Docker Hub, but you can use the local Dockerfile by removing "image" above and adding this:
 | 
			
		||||
        #build: .
 | 
			
		||||
        # Works best when using `docker-compose up --force-recreate --build`.
 | 
			
		||||
 | 
			
		||||
        depends_on:
 | 
			
		||||
            - mongodb
 | 
			
		||||
    mongodb:
 | 
			
		||||
        image: docker.io/library/mongo:8.0.0-noble
 | 
			
		||||
        environment:
 | 
			
		||||
            MONGO_INITDB_ROOT_USERNAME: openwfagent
 | 
			
		||||
            MONGO_INITDB_ROOT_PASSWORD: spaceninjaserver
 | 
			
		||||
        volumes:
 | 
			
		||||
            - ./docker-data/database:/data/db
 | 
			
		||||
        command: mongod --quiet --logpath /dev/null
 | 
			
		||||
 | 
			
		||||
@ -1,8 +1,24 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
set -e
 | 
			
		||||
 | 
			
		||||
if [ ! -f conf/config.json ]; then
 | 
			
		||||
	jq --arg value "mongodb://mongodb:27017/openWF" '.mongodbUrl = $value' /app/config-vanilla.json > /app/conf/config.json
 | 
			
		||||
fi
 | 
			
		||||
# Set up the configuration file using environment variables.
 | 
			
		||||
echo '{
 | 
			
		||||
	"logger": {
 | 
			
		||||
	  "files": true,
 | 
			
		||||
	  "level": "trace",
 | 
			
		||||
	  "__valid_levels": "fatal, error, warn, info, http, debug, trace"
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
' > config.json
 | 
			
		||||
 | 
			
		||||
exec npm run raw -- --configPath conf/config.json
 | 
			
		||||
for config in $(env | grep "APP_")
 | 
			
		||||
do
 | 
			
		||||
  var=$(echo "${config}" | tr '[:upper:]' '[:lower:]' | sed 's/app_//g' | sed -E 's/_([a-z])/\U\1/g' | sed 's/=.*//g')
 | 
			
		||||
  val=$(echo "${config}" | sed 's/.*=//g')
 | 
			
		||||
  jq --arg variable "$var" --arg value "$val" '.[$variable] += try [$value|fromjson][] catch $value' config.json > config.tmp
 | 
			
		||||
  mv config.tmp config.json
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
npm i --omit=dev
 | 
			
		||||
npm run build
 | 
			
		||||
exec npm run start
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										3062
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										3062
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										47
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										47
									
								
								package.json
									
									
									
									
									
								
							@ -4,63 +4,40 @@
 | 
			
		||||
  "description": "WF Emulator",
 | 
			
		||||
  "main": "index.ts",
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "start": "node --enable-source-maps build/src/index.js",
 | 
			
		||||
    "build": "tsgo --inlineSourceMap && ncp static/webui build/static/webui",
 | 
			
		||||
    "build:tsc": "tsc --incremental --inlineSourceMap && ncp static/webui build/static/webui",
 | 
			
		||||
    "build:dev": "tsgo --inlineSourceMap",
 | 
			
		||||
    "build:dev:tsc": "tsc --incremental --inlineSourceMap",
 | 
			
		||||
    "build-and-start": "npm run build && npm run start",
 | 
			
		||||
    "dev": "node scripts/dev.cjs",
 | 
			
		||||
    "dev:bun": "bun scripts/dev.cjs",
 | 
			
		||||
    "start": "node --enable-source-maps --import ./build/src/pathman.js build/src/index.js",
 | 
			
		||||
    "dev": "ts-node-dev --openssl-legacy-provider -r tsconfig-paths/register src/index.ts ",
 | 
			
		||||
    "build": "tsc --incremental --sourceMap && ncp static/webui build/static/webui",
 | 
			
		||||
    "verify": "tsgo --noEmit",
 | 
			
		||||
    "verify:tsc": "tsc --noEmit",
 | 
			
		||||
    "raw": "node scripts/raw-precheck.js && node --experimental-transform-types src/index.ts",
 | 
			
		||||
    "raw:bun": "bun src/index.ts",
 | 
			
		||||
    "lint": "eslint --ext .ts .",
 | 
			
		||||
    "lint:ci": "eslint --ext .ts --rule \"prettier/prettier: off\" .",
 | 
			
		||||
    "lint:fix": "eslint --fix --ext .ts .",
 | 
			
		||||
    "prettier": "prettier --write .",
 | 
			
		||||
    "update-translations": "cd scripts && node update-translations.cjs",
 | 
			
		||||
    "fix": "npm run update-translations && npm run prettier"
 | 
			
		||||
    "update-translations": "cd scripts && node update-translations.js"
 | 
			
		||||
  },
 | 
			
		||||
  "license": "GNU",
 | 
			
		||||
  "type": "module",
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "body-parser": "^2.2.0",
 | 
			
		||||
    "chokidar": "^4.0.3",
 | 
			
		||||
    "@types/express": "^5",
 | 
			
		||||
    "@types/morgan": "^1.9.9",
 | 
			
		||||
    "crc-32": "^1.2.2",
 | 
			
		||||
    "express": "^5",
 | 
			
		||||
    "json-with-bigint": "^3.4.4",
 | 
			
		||||
    "mongoose": "^8.11.0",
 | 
			
		||||
    "morgan": "^1.10.0",
 | 
			
		||||
    "ncp": "^2.0.0",
 | 
			
		||||
    "undici": "^7.10.0",
 | 
			
		||||
    "warframe-public-export-plus": "^0.5.93",
 | 
			
		||||
    "typescript": "^5.5",
 | 
			
		||||
    "warframe-public-export-plus": "^0.5.66",
 | 
			
		||||
    "warframe-riven-info": "^0.1.2",
 | 
			
		||||
    "winston": "^3.17.0",
 | 
			
		||||
    "winston-daily-rotate-file": "^5.0.0",
 | 
			
		||||
    "ws": "^8.18.2"
 | 
			
		||||
  },
 | 
			
		||||
  "optionalDependencies": {
 | 
			
		||||
    "@types/body-parser": "^1.19.6",
 | 
			
		||||
    "@types/express": "^5",
 | 
			
		||||
    "@types/morgan": "^1.9.9",
 | 
			
		||||
    "@types/websocket": "^1.0.10",
 | 
			
		||||
    "@types/ws": "^8.18.1",
 | 
			
		||||
    "@typescript/native-preview": "^7.0.0-dev.20250625.1",
 | 
			
		||||
    "typescript": "^5.7"
 | 
			
		||||
    "winston-daily-rotate-file": "^5.0.0"
 | 
			
		||||
  },
 | 
			
		||||
  "devDependencies": {
 | 
			
		||||
    "@typescript-eslint/eslint-plugin": "^8.28.0",
 | 
			
		||||
    "@typescript-eslint/parser": "^8.28.0",
 | 
			
		||||
    "@typescript/native-preview": "^7.0.0-dev.20250523.1",
 | 
			
		||||
    "eslint": "^8",
 | 
			
		||||
    "eslint-import-resolver-typescript": "^4.4.4",
 | 
			
		||||
    "eslint-plugin-import": "^2.32.0",
 | 
			
		||||
    "eslint-plugin-prettier": "^5.2.5",
 | 
			
		||||
    "prettier": "^3.5.3",
 | 
			
		||||
    "tree-kill": "^1.2.2"
 | 
			
		||||
  },
 | 
			
		||||
  "engines": {
 | 
			
		||||
    "node": ">=20.18.1"
 | 
			
		||||
    "ts-node-dev": "^2.0.0",
 | 
			
		||||
    "tsconfig-paths": "^4.2.0"
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,81 +0,0 @@
 | 
			
		||||
/* eslint-disable */
 | 
			
		||||
const { spawn } = require("child_process");
 | 
			
		||||
const chokidar = require("chokidar");
 | 
			
		||||
const kill = require("tree-kill");
 | 
			
		||||
 | 
			
		||||
let secret = "";
 | 
			
		||||
for (let i = 0; i != 10; ++i) {
 | 
			
		||||
    secret += String.fromCharCode(Math.floor(Math.random() * 26) + 0x41);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const args = [...process.argv].splice(2);
 | 
			
		||||
args.push("--dev");
 | 
			
		||||
args.push("--secret");
 | 
			
		||||
args.push(secret);
 | 
			
		||||
 | 
			
		||||
const cangoraw = (() => {
 | 
			
		||||
    if (process.versions.bun) {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    const [major, minor] = process.versions.node.split(".").map(x => parseInt(x));
 | 
			
		||||
    if (major > 22 || (major == 22 && minor >= 7)) {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    return false;
 | 
			
		||||
})();
 | 
			
		||||
 | 
			
		||||
let buildproc, runproc;
 | 
			
		||||
const spawnopts = { stdio: "inherit", shell: true };
 | 
			
		||||
function run(changedFile) {
 | 
			
		||||
    if (changedFile) {
 | 
			
		||||
        console.log(`Change to ${changedFile} detected`);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (buildproc) {
 | 
			
		||||
        kill(buildproc.pid);
 | 
			
		||||
        buildproc = undefined;
 | 
			
		||||
    }
 | 
			
		||||
    if (runproc) {
 | 
			
		||||
        kill(runproc.pid);
 | 
			
		||||
        runproc = undefined;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const thisbuildproc = spawn(
 | 
			
		||||
        [process.versions.bun ? "bun" : "npm", "run", cangoraw ? "verify" : "build:dev"].join(" "),
 | 
			
		||||
        spawnopts
 | 
			
		||||
    );
 | 
			
		||||
    const thisbuildstart = Date.now();
 | 
			
		||||
    buildproc = thisbuildproc;
 | 
			
		||||
    buildproc.on("exit", code => {
 | 
			
		||||
        if (buildproc !== thisbuildproc) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        buildproc = undefined;
 | 
			
		||||
        if (code === 0) {
 | 
			
		||||
            console.log(`${cangoraw ? "Verified" : "Built"} in ${Date.now() - thisbuildstart} ms`);
 | 
			
		||||
            runproc = spawn(
 | 
			
		||||
                [
 | 
			
		||||
                    process.versions.bun ? "bun" : "npm",
 | 
			
		||||
                    "run",
 | 
			
		||||
                    cangoraw ? (process.versions.bun ? "raw:bun" : "raw") : "start",
 | 
			
		||||
                    "--",
 | 
			
		||||
                    ...args
 | 
			
		||||
                ].join(" "),
 | 
			
		||||
                spawnopts
 | 
			
		||||
            );
 | 
			
		||||
            runproc.on("exit", () => {
 | 
			
		||||
                runproc = undefined;
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
run();
 | 
			
		||||
chokidar.watch("src").on("change", run);
 | 
			
		||||
chokidar.watch("static/fixed_responses").on("change", run);
 | 
			
		||||
 | 
			
		||||
chokidar.watch("static/webui").on("change", async () => {
 | 
			
		||||
    try {
 | 
			
		||||
        await fetch("http://localhost/custom/webuiFileChangeDetected?secret=" + secret);
 | 
			
		||||
    } catch (e) {}
 | 
			
		||||
});
 | 
			
		||||
@ -1,9 +0,0 @@
 | 
			
		||||
const [major, minor] = process.versions.node.split(".").map(x => parseInt(x));
 | 
			
		||||
if (major > 22 || (major == 22 && minor >= 7)) {
 | 
			
		||||
    // ok
 | 
			
		||||
} else {
 | 
			
		||||
    console.log("Sorry, your Node version is a bit too old for this. You have 2 options:");
 | 
			
		||||
    console.log("- Update Node.js.");
 | 
			
		||||
    console.log("- Use 'npm run build && npm run start'. Optional libraries must be installed for this.");
 | 
			
		||||
    process.exit(1);
 | 
			
		||||
}
 | 
			
		||||
@ -1,7 +1,6 @@
 | 
			
		||||
// Based on https://onlyg.it/OpenWF/Translations/src/branch/main/update.php
 | 
			
		||||
// Converted via ChatGPT-4o
 | 
			
		||||
 | 
			
		||||
/* eslint-disable */
 | 
			
		||||
const fs = require("fs");
 | 
			
		||||
 | 
			
		||||
function extractStrings(content) {
 | 
			
		||||
@ -31,7 +30,7 @@ fs.readdirSync("../static/webui/translations").forEach(file => {
 | 
			
		||||
            const strings = extractStrings(line);
 | 
			
		||||
            if (Object.keys(strings).length > 0) {
 | 
			
		||||
                Object.entries(strings).forEach(([key, value]) => {
 | 
			
		||||
                    if (targetStrings.hasOwnProperty(key) && !targetStrings[key].startsWith("[UNTRANSLATED]")) {
 | 
			
		||||
                    if (targetStrings.hasOwnProperty(key)) {
 | 
			
		||||
                        fs.writeSync(fileHandle, `    ${key}: \`${targetStrings[key]}\`,\n`);
 | 
			
		||||
                    } else {
 | 
			
		||||
                        fs.writeSync(fileHandle, `    ${key}: \`[UNTRANSLATED] ${value}\`,\n`);
 | 
			
		||||
							
								
								
									
										22
									
								
								src/app.ts
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								src/app.ts
									
									
									
									
									
								
							@ -1,23 +1,23 @@
 | 
			
		||||
import express from "express";
 | 
			
		||||
 | 
			
		||||
import bodyParser from "body-parser";
 | 
			
		||||
import { unknownEndpointHandler } from "./middleware/middleware.ts";
 | 
			
		||||
import { requestLogger } from "./middleware/morgenMiddleware.ts";
 | 
			
		||||
import { errorHandler } from "./middleware/errorHandler.ts";
 | 
			
		||||
import { unknownEndpointHandler } from "@/src/middleware/middleware";
 | 
			
		||||
import { requestLogger } from "@/src/middleware/morgenMiddleware";
 | 
			
		||||
import { errorHandler } from "@/src/middleware/errorHandler";
 | 
			
		||||
 | 
			
		||||
import { apiRouter } from "./routes/api.ts";
 | 
			
		||||
import { cacheRouter } from "./routes/cache.ts";
 | 
			
		||||
import { customRouter } from "./routes/custom.ts";
 | 
			
		||||
import { dynamicController } from "./routes/dynamic.ts";
 | 
			
		||||
import { payRouter } from "./routes/pay.ts";
 | 
			
		||||
import { statsRouter } from "./routes/stats.ts";
 | 
			
		||||
import { webuiRouter } from "./routes/webui.ts";
 | 
			
		||||
import { apiRouter } from "@/src/routes/api";
 | 
			
		||||
import { cacheRouter } from "@/src/routes/cache";
 | 
			
		||||
import { customRouter } from "@/src/routes/custom";
 | 
			
		||||
import { dynamicController } from "@/src/routes/dynamic";
 | 
			
		||||
import { payRouter } from "@/src/routes/pay";
 | 
			
		||||
import { statsRouter } from "@/src/routes/stats";
 | 
			
		||||
import { webuiRouter } from "@/src/routes/webui";
 | 
			
		||||
 | 
			
		||||
const app = express();
 | 
			
		||||
 | 
			
		||||
app.use((req, _res, next) => {
 | 
			
		||||
    // 38.5.0 introduced "ezip" for encrypted body blobs and "e" for request verification only (encrypted body blobs with no application data).
 | 
			
		||||
    // The client patch is expected to decrypt it for us but having an unsupported Content-Encoding here would still be an issue for Express, so removing it.
 | 
			
		||||
    // The bootstrapper decrypts it for us but having an unsupported Content-Encoding here would still be an issue for Express, so removing it.
 | 
			
		||||
    if (req.headers["content-encoding"] == "ezip" || req.headers["content-encoding"] == "e") {
 | 
			
		||||
        req.headers["content-encoding"] = undefined;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,3 @@
 | 
			
		||||
export const EPOCH = 1734307200_000; // Monday, Dec 16, 2024 @ 00:00 UTC+0; should logically be the start of winter in 1999 iteration 0
 | 
			
		||||
 | 
			
		||||
const millisecondsPerSecond = 1000;
 | 
			
		||||
const secondsPerMinute = 60;
 | 
			
		||||
const minutesPerHour = 60;
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,6 @@
 | 
			
		||||
import { getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const abandonLibraryDailyTaskController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
 | 
			
		||||
@ -5,11 +5,11 @@ import {
 | 
			
		||||
    hasGuildPermission,
 | 
			
		||||
    removeDojoDeco,
 | 
			
		||||
    removeDojoRoom
 | 
			
		||||
} from "../../services/guildService.ts";
 | 
			
		||||
import { getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { GuildPermission } from "../../types/guildTypes.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
} from "@/src/services/guildService";
 | 
			
		||||
import { getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { GuildPermission } from "@/src/types/guildTypes";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const abortDojoComponentController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
@ -31,13 +31,12 @@ export const abortDojoComponentController: RequestHandler = async (req, res) =>
 | 
			
		||||
 | 
			
		||||
    if (request.DecoId) {
 | 
			
		||||
        removeDojoDeco(guild, request.ComponentId, request.DecoId);
 | 
			
		||||
        await guild.save();
 | 
			
		||||
        res.json(await getDojoClient(guild, 0, request.ComponentId));
 | 
			
		||||
    } else {
 | 
			
		||||
        await removeDojoRoom(guild, request.ComponentId);
 | 
			
		||||
        await guild.save();
 | 
			
		||||
        res.json(await getDojoClient(guild, 0));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    await guild.save();
 | 
			
		||||
    res.json(await getDojoClient(guild, 0, request.ComponentId));
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
interface IAbortDojoComponentRequest {
 | 
			
		||||
 | 
			
		||||
@ -1,13 +1,8 @@
 | 
			
		||||
import {
 | 
			
		||||
    getDojoClient,
 | 
			
		||||
    getGuildForRequestEx,
 | 
			
		||||
    hasAccessToDojo,
 | 
			
		||||
    hasGuildPermission
 | 
			
		||||
} from "../../services/guildService.ts";
 | 
			
		||||
import { getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { GuildPermission } from "../../types/guildTypes.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getDojoClient, getGuildForRequestEx, hasAccessToDojo, hasGuildPermission } from "@/src/services/guildService";
 | 
			
		||||
import { getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { GuildPermission } from "@/src/types/guildTypes";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const abortDojoComponentDestructionController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
 | 
			
		||||
@ -1,19 +1,20 @@
 | 
			
		||||
import { toOid } from "../../helpers/inventoryHelpers.ts";
 | 
			
		||||
import { toOid } from "@/src/helpers/inventoryHelpers";
 | 
			
		||||
import {
 | 
			
		||||
    createVeiledRivenFingerprint,
 | 
			
		||||
    createUnveiledRivenFingerprint,
 | 
			
		||||
    rivenRawToRealWeighted
 | 
			
		||||
} from "../../helpers/rivenHelper.ts";
 | 
			
		||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
			
		||||
import { addMods, getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { getRandomElement } from "../../services/rngService.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
} from "@/src/helpers/rivenHelper";
 | 
			
		||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { addMods, getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { getRandomElement } from "@/src/services/rngService";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { ExportUpgrades } from "warframe-public-export-plus";
 | 
			
		||||
import { config } from "@/src/services/configService";
 | 
			
		||||
 | 
			
		||||
export const activateRandomModController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
    const inventory = await getInventory(accountId, "RawUpgrades Upgrades instantFinishRivenChallenge");
 | 
			
		||||
    const inventory = await getInventory(accountId);
 | 
			
		||||
    const request = getJSONfromString<IActiveRandomModRequest>(String(req.body));
 | 
			
		||||
    addMods(inventory, [
 | 
			
		||||
        {
 | 
			
		||||
@ -22,7 +23,7 @@ export const activateRandomModController: RequestHandler = async (req, res) => {
 | 
			
		||||
        }
 | 
			
		||||
    ]);
 | 
			
		||||
    const rivenType = getRandomElement(rivenRawToRealWeighted[request.ItemType])!;
 | 
			
		||||
    const fingerprint = inventory.instantFinishRivenChallenge
 | 
			
		||||
    const fingerprint = config.instantFinishRivenChallenge
 | 
			
		||||
        ? createUnveiledRivenFingerprint(ExportUpgrades[rivenType])
 | 
			
		||||
        : createVeiledRivenFingerprint(ExportUpgrades[rivenType]);
 | 
			
		||||
    const upgradeIndex =
 | 
			
		||||
 | 
			
		||||
@ -1,10 +1,10 @@
 | 
			
		||||
import { toOid } from "../../helpers/inventoryHelpers.ts";
 | 
			
		||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
			
		||||
import { Friendship } from "../../models/friendModel.ts";
 | 
			
		||||
import { addAccountDataToFriendInfo, addInventoryDataToFriendInfo } from "../../services/friendService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import type { IFriendInfo } from "../../types/friendTypes.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { toOid } from "@/src/helpers/inventoryHelpers";
 | 
			
		||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { Friendship } from "@/src/models/friendModel";
 | 
			
		||||
import { addAccountDataToFriendInfo, addInventoryDataToFriendInfo } from "@/src/services/friendService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { IFriendInfo } from "@/src/types/friendTypes";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const addFriendController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { Inventory } from "../../models/inventoryModels/inventoryModel.ts";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
 | 
			
		||||
 | 
			
		||||
export const addFriendImageController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
 | 
			
		||||
@ -1,9 +1,9 @@
 | 
			
		||||
import { toOid } from "../../helpers/inventoryHelpers.ts";
 | 
			
		||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
			
		||||
import { Account, Ignore } from "../../models/loginModel.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import type { IFriendInfo } from "../../types/friendTypes.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { toOid } from "@/src/helpers/inventoryHelpers";
 | 
			
		||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { Account, Ignore } from "@/src/models/loginModel";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { IFriendInfo } from "@/src/types/friendTypes";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const addIgnoredUserController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
 | 
			
		||||
@ -1,12 +1,12 @@
 | 
			
		||||
import { toMongoDate, toOid } from "../../helpers/inventoryHelpers.ts";
 | 
			
		||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
			
		||||
import { Friendship } from "../../models/friendModel.ts";
 | 
			
		||||
import { Account } from "../../models/loginModel.ts";
 | 
			
		||||
import { addInventoryDataToFriendInfo, areFriendsOfFriends } from "../../services/friendService.ts";
 | 
			
		||||
import { getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import type { IFriendInfo } from "../../types/friendTypes.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { toMongoDate, toOid } from "@/src/helpers/inventoryHelpers";
 | 
			
		||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { Friendship } from "@/src/models/friendModel";
 | 
			
		||||
import { Account } from "@/src/models/loginModel";
 | 
			
		||||
import { addInventoryDataToFriendInfo, areFriendsOfFriends } from "@/src/services/friendService";
 | 
			
		||||
import { getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { IFriendInfo } from "@/src/types/friendTypes";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const addPendingFriendController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const payload = getJSONfromString<IAddPendingFriendRequest>(String(req.body));
 | 
			
		||||
 | 
			
		||||
@ -1,11 +1,11 @@
 | 
			
		||||
import { getJSONfromString, regexEscape } from "../../helpers/stringHelpers.ts";
 | 
			
		||||
import { Alliance, AllianceMember, Guild, GuildMember } from "../../models/guildModel.ts";
 | 
			
		||||
import { createMessage } from "../../services/inboxService.ts";
 | 
			
		||||
import { getEffectiveAvatarImageType, getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountForRequest, getSuffixedName } from "../../services/loginService.ts";
 | 
			
		||||
import { GuildPermission } from "../../types/guildTypes.ts";
 | 
			
		||||
import { logger } from "../../utils/logger.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getJSONfromString, regexEscape } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { Alliance, AllianceMember, Guild, GuildMember } from "@/src/models/guildModel";
 | 
			
		||||
import { createMessage } from "@/src/services/inboxService";
 | 
			
		||||
import { getEffectiveAvatarImageType, getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountForRequest, getSuffixedName } from "@/src/services/loginService";
 | 
			
		||||
import { GuildPermission } from "@/src/types/guildTypes";
 | 
			
		||||
import { logger } from "@/src/utils/logger";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { ExportFlavour } from "warframe-public-export-plus";
 | 
			
		||||
 | 
			
		||||
export const addToAllianceController: RequestHandler = async (req, res) => {
 | 
			
		||||
 | 
			
		||||
@ -1,16 +1,15 @@
 | 
			
		||||
import { toMongoDate } from "../../helpers/inventoryHelpers.ts";
 | 
			
		||||
import { Guild, GuildMember } from "../../models/guildModel.ts";
 | 
			
		||||
import { Account } from "../../models/loginModel.ts";
 | 
			
		||||
import { addInventoryDataToFriendInfo, areFriends } from "../../services/friendService.ts";
 | 
			
		||||
import { hasGuildPermission } from "../../services/guildService.ts";
 | 
			
		||||
import { createMessage } from "../../services/inboxService.ts";
 | 
			
		||||
import { getEffectiveAvatarImageType, getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountForRequest, getAccountIdForRequest, getSuffixedName } from "../../services/loginService.ts";
 | 
			
		||||
import type { IOid } from "../../types/commonTypes.ts";
 | 
			
		||||
import type { IGuildMemberClient } from "../../types/guildTypes.ts";
 | 
			
		||||
import { GuildPermission } from "../../types/guildTypes.ts";
 | 
			
		||||
import { logger } from "../../utils/logger.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { toMongoDate } from "@/src/helpers/inventoryHelpers";
 | 
			
		||||
import { Guild, GuildMember } from "@/src/models/guildModel";
 | 
			
		||||
import { Account } from "@/src/models/loginModel";
 | 
			
		||||
import { addInventoryDataToFriendInfo, areFriends } from "@/src/services/friendService";
 | 
			
		||||
import { hasGuildPermission } from "@/src/services/guildService";
 | 
			
		||||
import { createMessage } from "@/src/services/inboxService";
 | 
			
		||||
import { getEffectiveAvatarImageType, getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountForRequest, getAccountIdForRequest, getSuffixedName } from "@/src/services/loginService";
 | 
			
		||||
import { IOid } from "@/src/types/commonTypes";
 | 
			
		||||
import { GuildPermission, IGuildMemberClient } from "@/src/types/guildTypes";
 | 
			
		||||
import { logger } from "@/src/utils/logger";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { ExportFlavour } from "warframe-public-export-plus";
 | 
			
		||||
 | 
			
		||||
export const addToGuildController: RequestHandler = async (req, res) => {
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
			
		||||
import { getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const adoptPetController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
 | 
			
		||||
@ -1,22 +0,0 @@
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { getPersonalRooms } from "../../services/personalRoomsService.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const apartmentController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
    const personalRooms = await getPersonalRooms(accountId, "Apartment");
 | 
			
		||||
    const response: IApartmentResponse = {};
 | 
			
		||||
    if (req.query.backdrop !== undefined) {
 | 
			
		||||
        response.NewBackdropItem = personalRooms.Apartment.VideoWallBackdrop = req.query.backdrop as string;
 | 
			
		||||
    }
 | 
			
		||||
    if (req.query.soundscape !== undefined) {
 | 
			
		||||
        response.NewSoundscapeItem = personalRooms.Apartment.Soundscape = req.query.soundscape as string;
 | 
			
		||||
    }
 | 
			
		||||
    await personalRooms.save();
 | 
			
		||||
    res.json(response);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
interface IApartmentResponse {
 | 
			
		||||
    NewBackdropItem?: string;
 | 
			
		||||
    NewSoundscapeItem?: string;
 | 
			
		||||
}
 | 
			
		||||
@ -1,8 +1,8 @@
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { getInventory, addMods } from "../../services/inventoryService.ts";
 | 
			
		||||
import type { IOid } from "../../types/commonTypes.ts";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { getInventory, addMods } from "@/src/services/inventoryService";
 | 
			
		||||
import { IOid } from "@/src/types/commonTypes";
 | 
			
		||||
 | 
			
		||||
export const arcaneCommonController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
 | 
			
		||||
@ -1,8 +1,8 @@
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { addMiscItems, getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import type { IMiscItem } from "../../types/inventoryTypes/inventoryTypes.ts";
 | 
			
		||||
import { colorToShard, combineColors, shardToColor } from "../../helpers/shardHelper.ts";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { addMiscItems, getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
			
		||||
import { colorToShard, combineColors, shardToColor } from "@/src/helpers/shardHelper";
 | 
			
		||||
 | 
			
		||||
export const archonFusionController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
 | 
			
		||||
@ -1,12 +1,11 @@
 | 
			
		||||
import { fromOid, toOid } from "../../helpers/inventoryHelpers.ts";
 | 
			
		||||
import { createVeiledRivenFingerprint, rivenRawToRealWeighted } from "../../helpers/rivenHelper.ts";
 | 
			
		||||
import { addMiscItems, addMods, getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { getRandomElement, getRandomWeightedReward, getRandomWeightedRewardUc } from "../../services/rngService.ts";
 | 
			
		||||
import type { IUpgradeFromClient } from "../../types/inventoryTypes/inventoryTypes.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import type { TRarity } from "warframe-public-export-plus";
 | 
			
		||||
import { ExportBoosterPacks, ExportUpgrades } from "warframe-public-export-plus";
 | 
			
		||||
import { fromOid, toOid } from "@/src/helpers/inventoryHelpers";
 | 
			
		||||
import { createVeiledRivenFingerprint, rivenRawToRealWeighted } from "@/src/helpers/rivenHelper";
 | 
			
		||||
import { addMiscItems, addMods, getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { getRandomElement, getRandomWeightedReward, getRandomWeightedRewardUc } from "@/src/services/rngService";
 | 
			
		||||
import { IUpgradeFromClient } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { ExportBoosterPacks, ExportUpgrades, TRarity } from "warframe-public-export-plus";
 | 
			
		||||
 | 
			
		||||
export const artifactTransmutationController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
 | 
			
		||||
@ -1,9 +1,9 @@
 | 
			
		||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import type { IInventoryClient, IUpgradeClient } from "../../types/inventoryTypes/inventoryTypes.ts";
 | 
			
		||||
import { addMods, getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { broadcastInventoryUpdate } from "../../services/wsService.ts";
 | 
			
		||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { IInventoryClient, IUpgradeClient } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
			
		||||
import { addMods, getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { config } from "@/src/services/configService";
 | 
			
		||||
 | 
			
		||||
export const artifactsController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
@ -24,6 +24,7 @@ export const artifactsController: RequestHandler = async (req, res) => {
 | 
			
		||||
 | 
			
		||||
    if (itemIndex !== -1) {
 | 
			
		||||
        Upgrades[itemIndex].UpgradeFingerprint = stringifiedUpgradeFingerprint;
 | 
			
		||||
        inventory.markModified(`Upgrades.${itemIndex}.UpgradeFingerprint`);
 | 
			
		||||
    } else {
 | 
			
		||||
        itemIndex =
 | 
			
		||||
            Upgrades.push({
 | 
			
		||||
@ -34,10 +35,10 @@ export const artifactsController: RequestHandler = async (req, res) => {
 | 
			
		||||
        addMods(inventory, [{ ItemType, ItemCount: -1 }]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (!inventory.infiniteCredits) {
 | 
			
		||||
    if (!config.infiniteCredits) {
 | 
			
		||||
        inventory.RegularCredits -= Cost;
 | 
			
		||||
    }
 | 
			
		||||
    if (!inventory.infiniteEndo) {
 | 
			
		||||
    if (!config.infiniteEndo) {
 | 
			
		||||
        inventory.FusionPoints -= FusionPointCost;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -58,7 +59,6 @@ export const artifactsController: RequestHandler = async (req, res) => {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    res.send(itemId);
 | 
			
		||||
    broadcastInventoryUpdate(req);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
interface IArtifactsRequest {
 | 
			
		||||
 | 
			
		||||
@ -1,9 +1,9 @@
 | 
			
		||||
import { GuildAd } from "../../models/guildModel.ts";
 | 
			
		||||
import { getGuildForRequestEx, hasGuildPermission } from "../../services/guildService.ts";
 | 
			
		||||
import { getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { GuildPermission } from "../../types/guildTypes.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { GuildAd } from "@/src/models/guildModel";
 | 
			
		||||
import { getGuildForRequestEx, hasGuildPermission } from "@/src/services/guildService";
 | 
			
		||||
import { getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { GuildPermission } from "@/src/types/guildTypes";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const cancelGuildAdvertisementController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
 | 
			
		||||
@ -1,16 +1,10 @@
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import {
 | 
			
		||||
    getDojoClient,
 | 
			
		||||
    getGuildForRequestEx,
 | 
			
		||||
    hasAccessToDojo,
 | 
			
		||||
    hasGuildPermission
 | 
			
		||||
} from "../../services/guildService.ts";
 | 
			
		||||
import { logger } from "../../utils/logger.ts";
 | 
			
		||||
import type { IDojoComponentDatabase } from "../../types/guildTypes.ts";
 | 
			
		||||
import { GuildPermission } from "../../types/guildTypes.ts";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { getDojoClient, getGuildForRequestEx, hasAccessToDojo, hasGuildPermission } from "@/src/services/guildService";
 | 
			
		||||
import { logger } from "@/src/utils/logger";
 | 
			
		||||
import { GuildPermission, IDojoComponentDatabase } from "@/src/types/guildTypes";
 | 
			
		||||
import { Types } from "mongoose";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
 | 
			
		||||
export const changeDojoRootController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
 | 
			
		||||
@ -1,8 +1,8 @@
 | 
			
		||||
import { GuildMember } from "../../models/guildModel.ts";
 | 
			
		||||
import { getGuildForRequest, hasGuildPermissionEx } from "../../services/guildService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { GuildPermission } from "../../types/guildTypes.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { GuildMember } from "@/src/models/guildModel";
 | 
			
		||||
import { getGuildForRequest, hasGuildPermissionEx } from "@/src/services/guildService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { GuildPermission } from "@/src/types/guildTypes";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const changeGuildRankController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
 | 
			
		||||
@ -1,12 +1,16 @@
 | 
			
		||||
import { getAccountForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const checkDailyMissionBonusController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const account = await getAccountForRequest(req);
 | 
			
		||||
    const today = Math.trunc(Date.now() / 86400000) * 86400;
 | 
			
		||||
    if (account.DailyFirstWinDate != today) {
 | 
			
		||||
        res.send("DailyMissionBonus:1-DailyPVPWinBonus:1\n");
 | 
			
		||||
    } else {
 | 
			
		||||
        res.send("DailyMissionBonus:0-DailyPVPWinBonus:1\n");
 | 
			
		||||
    }
 | 
			
		||||
const checkDailyMissionBonusController: RequestHandler = (_req, res) => {
 | 
			
		||||
    const data = Buffer.from([
 | 
			
		||||
        0x44, 0x61, 0x69, 0x6c, 0x79, 0x4d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0x6f, 0x6e, 0x75, 0x73, 0x3a,
 | 
			
		||||
        0x31, 0x2d, 0x44, 0x61, 0x69, 0x6c, 0x79, 0x50, 0x56, 0x50, 0x57, 0x69, 0x6e, 0x42, 0x6f, 0x6e, 0x75, 0x73,
 | 
			
		||||
        0x3a, 0x31, 0x0a
 | 
			
		||||
    ]);
 | 
			
		||||
    res.writeHead(200, {
 | 
			
		||||
        "Content-Type": "text/html",
 | 
			
		||||
        "Content-Length": data.length
 | 
			
		||||
    });
 | 
			
		||||
    res.end(data);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export { checkDailyMissionBonusController };
 | 
			
		||||
 | 
			
		||||
@ -1,275 +1,145 @@
 | 
			
		||||
//this is a controller for the claimCompletedRecipe route
 | 
			
		||||
//it will claim a recipe for the user
 | 
			
		||||
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { logger } from "../../utils/logger.ts";
 | 
			
		||||
import { getRecipe } from "../../services/itemDataService.ts";
 | 
			
		||||
import type { IOidWithLegacySupport } from "../../types/commonTypes.ts";
 | 
			
		||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
			
		||||
import type { TAccountDocument } from "../../services/loginService.ts";
 | 
			
		||||
import { getAccountForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { logger } from "@/src/utils/logger";
 | 
			
		||||
import { getRecipe } from "@/src/services/itemDataService";
 | 
			
		||||
import { IOid, IOidWithLegacySupport } from "@/src/types/commonTypes";
 | 
			
		||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { getAccountForRequest } from "@/src/services/loginService";
 | 
			
		||||
import {
 | 
			
		||||
    getInventory,
 | 
			
		||||
    updateCurrency,
 | 
			
		||||
    addItem,
 | 
			
		||||
    addRecipes,
 | 
			
		||||
    occupySlot,
 | 
			
		||||
    combineInventoryChanges,
 | 
			
		||||
    addKubrowPetPrint,
 | 
			
		||||
    addPowerSuit,
 | 
			
		||||
    addEquipment
 | 
			
		||||
} from "../../services/inventoryService.ts";
 | 
			
		||||
import type { IInventoryChanges } from "../../types/purchaseTypes.ts";
 | 
			
		||||
import type { IPendingRecipeDatabase } from "../../types/inventoryTypes/inventoryTypes.ts";
 | 
			
		||||
import { InventorySlot } from "../../types/inventoryTypes/inventoryTypes.ts";
 | 
			
		||||
import { fromOid, toOid2 } from "../../helpers/inventoryHelpers.ts";
 | 
			
		||||
import type { TInventoryDatabaseDocument } from "../../models/inventoryModels/inventoryModel.ts";
 | 
			
		||||
import type { IRecipe } from "warframe-public-export-plus";
 | 
			
		||||
import type { IEquipmentClient } from "../../types/equipmentTypes.ts";
 | 
			
		||||
import { EquipmentFeatures, Status } from "../../types/equipmentTypes.ts";
 | 
			
		||||
    combineInventoryChanges
 | 
			
		||||
} from "@/src/services/inventoryService";
 | 
			
		||||
import { IInventoryChanges } from "@/src/types/purchaseTypes";
 | 
			
		||||
import { IEquipmentClient } from "@/src/types/inventoryTypes/commonInventoryTypes";
 | 
			
		||||
import { InventorySlot, IPendingRecipeDatabase, Status } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
			
		||||
import { toOid2 } from "@/src/helpers/inventoryHelpers";
 | 
			
		||||
import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel";
 | 
			
		||||
import { IRecipe } from "warframe-public-export-plus";
 | 
			
		||||
import { config } from "@/src/services/configService";
 | 
			
		||||
 | 
			
		||||
interface IClaimCompletedRecipeRequest {
 | 
			
		||||
    RecipeIds: IOidWithLegacySupport[];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface IClaimCompletedRecipeResponse {
 | 
			
		||||
    InventoryChanges: IInventoryChanges;
 | 
			
		||||
    BrandedSuits?: IOidWithLegacySupport[];
 | 
			
		||||
    RecipeIds: IOid[];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export const claimCompletedRecipeController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const claimCompletedRecipeRequest = getJSONfromString<IClaimCompletedRecipeRequest>(String(req.body));
 | 
			
		||||
    const account = await getAccountForRequest(req);
 | 
			
		||||
    const inventory = await getInventory(account._id.toString());
 | 
			
		||||
    const resp: IClaimCompletedRecipeResponse = {
 | 
			
		||||
        InventoryChanges: {}
 | 
			
		||||
    };
 | 
			
		||||
    for (const recipeId of claimCompletedRecipeRequest.RecipeIds) {
 | 
			
		||||
        const pendingRecipe = inventory.PendingRecipes.id(fromOid(recipeId));
 | 
			
		||||
        if (!pendingRecipe) {
 | 
			
		||||
            throw new Error(`no pending recipe found with id ${fromOid(recipeId)}`);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //check recipe is indeed ready to be completed
 | 
			
		||||
        // if (pendingRecipe.CompletionDate > new Date()) {
 | 
			
		||||
        //     throw new Error(`recipe ${pendingRecipe._id} is not ready to be completed`);
 | 
			
		||||
        // }
 | 
			
		||||
 | 
			
		||||
        inventory.PendingRecipes.pull(pendingRecipe._id);
 | 
			
		||||
 | 
			
		||||
        const recipe = getRecipe(pendingRecipe.ItemType);
 | 
			
		||||
        if (!recipe) {
 | 
			
		||||
            throw new Error(`no completed item found for recipe ${pendingRecipe._id.toString()}`);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (req.query.cancel) {
 | 
			
		||||
            const inventoryChanges: IInventoryChanges = {};
 | 
			
		||||
            await refundRecipeIngredients(inventory, inventoryChanges, recipe, pendingRecipe);
 | 
			
		||||
            await inventory.save();
 | 
			
		||||
            res.json(inventoryChanges); // Not a bug: In the specific case of cancelling a recipe, InventoryChanges are expected to be the root.
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        await claimCompletedRecipe(account, inventory, recipe, pendingRecipe, resp, req.query.rush);
 | 
			
		||||
    const pendingRecipe = inventory.PendingRecipes.id(claimCompletedRecipeRequest.RecipeIds[0].$oid);
 | 
			
		||||
    if (!pendingRecipe) {
 | 
			
		||||
        throw new Error(`no pending recipe found with id ${claimCompletedRecipeRequest.RecipeIds[0].$oid}`);
 | 
			
		||||
    }
 | 
			
		||||
    await inventory.save();
 | 
			
		||||
    res.json(resp);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const claimCompletedRecipe = async (
 | 
			
		||||
    account: TAccountDocument,
 | 
			
		||||
    inventory: TInventoryDatabaseDocument,
 | 
			
		||||
    recipe: IRecipe,
 | 
			
		||||
    pendingRecipe: IPendingRecipeDatabase,
 | 
			
		||||
    resp: IClaimCompletedRecipeResponse,
 | 
			
		||||
    rush: any
 | 
			
		||||
): Promise<void> => {
 | 
			
		||||
    logger.debug("Claiming Recipe", { recipe, pendingRecipe });
 | 
			
		||||
    //check recipe is indeed ready to be completed
 | 
			
		||||
    // if (pendingRecipe.CompletionDate > new Date()) {
 | 
			
		||||
    //     throw new Error(`recipe ${pendingRecipe._id} is not ready to be completed`);
 | 
			
		||||
    // }
 | 
			
		||||
 | 
			
		||||
    if (recipe.secretIngredientAction == "SIA_SPECTRE_LOADOUT_COPY") {
 | 
			
		||||
        inventory.PendingSpectreLoadouts ??= [];
 | 
			
		||||
        inventory.SpectreLoadouts ??= [];
 | 
			
		||||
    inventory.PendingRecipes.pull(pendingRecipe._id);
 | 
			
		||||
 | 
			
		||||
        const pendingLoadoutIndex = inventory.PendingSpectreLoadouts.findIndex(x => x.ItemType == recipe.resultType);
 | 
			
		||||
        if (pendingLoadoutIndex != -1) {
 | 
			
		||||
            const loadoutIndex = inventory.SpectreLoadouts.findIndex(x => x.ItemType == recipe.resultType);
 | 
			
		||||
            if (loadoutIndex != -1) {
 | 
			
		||||
                inventory.SpectreLoadouts.splice(loadoutIndex, 1);
 | 
			
		||||
            }
 | 
			
		||||
            logger.debug(
 | 
			
		||||
                "moving spectre loadout from pending to active",
 | 
			
		||||
                inventory.toJSON().PendingSpectreLoadouts![pendingLoadoutIndex]
 | 
			
		||||
    const recipe = getRecipe(pendingRecipe.ItemType);
 | 
			
		||||
    if (!recipe) {
 | 
			
		||||
        throw new Error(`no completed item found for recipe ${pendingRecipe._id.toString()}`);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (req.query.cancel) {
 | 
			
		||||
        const inventoryChanges: IInventoryChanges = {};
 | 
			
		||||
        await refundRecipeIngredients(inventory, inventoryChanges, recipe, pendingRecipe);
 | 
			
		||||
        await inventory.save();
 | 
			
		||||
        res.json(inventoryChanges); // Not a bug: In the specific case of cancelling a recipe, InventoryChanges are expected to be the root.
 | 
			
		||||
    } else {
 | 
			
		||||
        logger.debug("Claiming Recipe", { recipe, pendingRecipe });
 | 
			
		||||
 | 
			
		||||
        let BrandedSuits: undefined | IOidWithLegacySupport[];
 | 
			
		||||
        if (recipe.secretIngredientAction == "SIA_SPECTRE_LOADOUT_COPY") {
 | 
			
		||||
            inventory.PendingSpectreLoadouts ??= [];
 | 
			
		||||
            inventory.SpectreLoadouts ??= [];
 | 
			
		||||
 | 
			
		||||
            const pendingLoadoutIndex = inventory.PendingSpectreLoadouts.findIndex(
 | 
			
		||||
                x => x.ItemType == recipe.resultType
 | 
			
		||||
            );
 | 
			
		||||
            inventory.SpectreLoadouts.push(inventory.PendingSpectreLoadouts[pendingLoadoutIndex]);
 | 
			
		||||
            inventory.PendingSpectreLoadouts.splice(pendingLoadoutIndex, 1);
 | 
			
		||||
        }
 | 
			
		||||
    } else if (recipe.secretIngredientAction == "SIA_UNBRAND") {
 | 
			
		||||
        inventory.BrandedSuits!.splice(
 | 
			
		||||
            inventory.BrandedSuits!.findIndex(x => x.equals(pendingRecipe.SuitToUnbrand)),
 | 
			
		||||
            1
 | 
			
		||||
        );
 | 
			
		||||
        resp.BrandedSuits = [toOid2(pendingRecipe.SuitToUnbrand!, account.BuildLabel)];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (recipe.consumeOnUse) {
 | 
			
		||||
        addRecipes(inventory, [
 | 
			
		||||
            {
 | 
			
		||||
                ItemType: pendingRecipe.ItemType,
 | 
			
		||||
                ItemCount: -1
 | 
			
		||||
            if (pendingLoadoutIndex != -1) {
 | 
			
		||||
                const loadoutIndex = inventory.SpectreLoadouts.findIndex(x => x.ItemType == recipe.resultType);
 | 
			
		||||
                if (loadoutIndex != -1) {
 | 
			
		||||
                    inventory.SpectreLoadouts.splice(loadoutIndex, 1);
 | 
			
		||||
                }
 | 
			
		||||
                logger.debug(
 | 
			
		||||
                    "moving spectre loadout from pending to active",
 | 
			
		||||
                    inventory.toJSON().PendingSpectreLoadouts![pendingLoadoutIndex]
 | 
			
		||||
                );
 | 
			
		||||
                inventory.SpectreLoadouts.push(inventory.PendingSpectreLoadouts[pendingLoadoutIndex]);
 | 
			
		||||
                inventory.PendingSpectreLoadouts.splice(pendingLoadoutIndex, 1);
 | 
			
		||||
            }
 | 
			
		||||
        ]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (rush) {
 | 
			
		||||
        const end = Math.trunc(pendingRecipe.CompletionDate.getTime() / 1000);
 | 
			
		||||
        const start = end - recipe.buildTime;
 | 
			
		||||
        const secondsElapsed = Math.trunc(Date.now() / 1000) - start;
 | 
			
		||||
        const progress = secondsElapsed / recipe.buildTime;
 | 
			
		||||
        logger.debug(`rushing recipe at ${Math.trunc(progress * 100)}% completion`);
 | 
			
		||||
        const cost =
 | 
			
		||||
            progress > 0.5 ? Math.round(recipe.skipBuildTimePrice * (1 - (progress - 0.5))) : recipe.skipBuildTimePrice;
 | 
			
		||||
        combineInventoryChanges(resp.InventoryChanges, updateCurrency(inventory, cost, true));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (recipe.secretIngredientAction == "SIA_CREATE_KUBROW") {
 | 
			
		||||
        const pet = inventory.KubrowPets.id(pendingRecipe.KubrowPet!)!;
 | 
			
		||||
        if (pet.Details!.HatchDate!.getTime() > Date.now()) {
 | 
			
		||||
            pet.Details!.HatchDate = new Date();
 | 
			
		||||
        } else if (recipe.secretIngredientAction == "SIA_UNBRAND") {
 | 
			
		||||
            inventory.BrandedSuits!.splice(
 | 
			
		||||
                inventory.BrandedSuits!.findIndex(x => x.equals(pendingRecipe.SuitToUnbrand)),
 | 
			
		||||
                1
 | 
			
		||||
            );
 | 
			
		||||
            BrandedSuits = [toOid2(pendingRecipe.SuitToUnbrand!, account.BuildLabel)];
 | 
			
		||||
        }
 | 
			
		||||
        let canSetActive = true;
 | 
			
		||||
        for (const pet of inventory.KubrowPets) {
 | 
			
		||||
            if (pet.Details!.Status == Status.StatusAvailable) {
 | 
			
		||||
                canSetActive = false;
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        pet.Details!.Status = canSetActive ? Status.StatusAvailable : Status.StatusStasis;
 | 
			
		||||
    } else if (recipe.secretIngredientAction == "SIA_DISTILL_PRINT") {
 | 
			
		||||
        const pet = inventory.KubrowPets.id(pendingRecipe.KubrowPet!)!;
 | 
			
		||||
        addKubrowPetPrint(inventory, pet, resp.InventoryChanges);
 | 
			
		||||
    } else if (recipe.secretIngredientAction != "SIA_UNBRAND") {
 | 
			
		||||
        if (recipe.resultType == "/Lotus/Powersuits/Excalibur/ExcaliburUmbra") {
 | 
			
		||||
            // Quite the special case here...
 | 
			
		||||
            // We don't just get Umbra, but also Skiajati and Umbra Mods. Both items are max rank, potatoed, and with the mods are pre-installed.
 | 
			
		||||
            // Source: https://wiki.warframe.com/w/The_Sacrifice, https://wiki.warframe.com/w/Excalibur/Umbra, https://wiki.warframe.com/w/Skiajati
 | 
			
		||||
 | 
			
		||||
            const umbraModA = (
 | 
			
		||||
                await addItem(
 | 
			
		||||
                    inventory,
 | 
			
		||||
                    "/Lotus/Upgrades/Mods/Sets/Umbra/WarframeUmbraModA",
 | 
			
		||||
                    1,
 | 
			
		||||
                    false,
 | 
			
		||||
                    undefined,
 | 
			
		||||
                    `{"lvl":5}`
 | 
			
		||||
                )
 | 
			
		||||
            ).Upgrades![0];
 | 
			
		||||
            const umbraModB = (
 | 
			
		||||
                await addItem(
 | 
			
		||||
                    inventory,
 | 
			
		||||
                    "/Lotus/Upgrades/Mods/Sets/Umbra/WarframeUmbraModB",
 | 
			
		||||
                    1,
 | 
			
		||||
                    false,
 | 
			
		||||
                    undefined,
 | 
			
		||||
                    `{"lvl":5}`
 | 
			
		||||
                )
 | 
			
		||||
            ).Upgrades![0];
 | 
			
		||||
            const umbraModC = (
 | 
			
		||||
                await addItem(
 | 
			
		||||
                    inventory,
 | 
			
		||||
                    "/Lotus/Upgrades/Mods/Sets/Umbra/WarframeUmbraModC",
 | 
			
		||||
                    1,
 | 
			
		||||
                    false,
 | 
			
		||||
                    undefined,
 | 
			
		||||
                    `{"lvl":5}`
 | 
			
		||||
                )
 | 
			
		||||
            ).Upgrades![0];
 | 
			
		||||
            const sacrificeModA = (
 | 
			
		||||
                await addItem(
 | 
			
		||||
                    inventory,
 | 
			
		||||
                    "/Lotus/Upgrades/Mods/Sets/Sacrifice/MeleeSacrificeModA",
 | 
			
		||||
                    1,
 | 
			
		||||
                    false,
 | 
			
		||||
                    undefined,
 | 
			
		||||
                    `{"lvl":5}`
 | 
			
		||||
                )
 | 
			
		||||
            ).Upgrades![0];
 | 
			
		||||
            const sacrificeModB = (
 | 
			
		||||
                await addItem(
 | 
			
		||||
                    inventory,
 | 
			
		||||
                    "/Lotus/Upgrades/Mods/Sets/Sacrifice/MeleeSacrificeModB",
 | 
			
		||||
                    1,
 | 
			
		||||
                    false,
 | 
			
		||||
                    undefined,
 | 
			
		||||
                    `{"lvl":5}`
 | 
			
		||||
                )
 | 
			
		||||
            ).Upgrades![0];
 | 
			
		||||
            resp.InventoryChanges.Upgrades ??= [];
 | 
			
		||||
            resp.InventoryChanges.Upgrades.push(umbraModA, umbraModB, umbraModC, sacrificeModA, sacrificeModB);
 | 
			
		||||
 | 
			
		||||
            await addPowerSuit(
 | 
			
		||||
                inventory,
 | 
			
		||||
                "/Lotus/Powersuits/Excalibur/ExcaliburUmbra",
 | 
			
		||||
        let InventoryChanges: IInventoryChanges = {};
 | 
			
		||||
        if (recipe.consumeOnUse) {
 | 
			
		||||
            addRecipes(inventory, [
 | 
			
		||||
                {
 | 
			
		||||
                    Configs: [
 | 
			
		||||
                        {
 | 
			
		||||
                            Upgrades: [
 | 
			
		||||
                                "",
 | 
			
		||||
                                "",
 | 
			
		||||
                                "",
 | 
			
		||||
                                "",
 | 
			
		||||
                                "",
 | 
			
		||||
                                umbraModA.ItemId.$oid,
 | 
			
		||||
                                umbraModB.ItemId.$oid,
 | 
			
		||||
                                umbraModC.ItemId.$oid
 | 
			
		||||
                            ]
 | 
			
		||||
                        }
 | 
			
		||||
                    ],
 | 
			
		||||
                    XP: 900_000,
 | 
			
		||||
                    Features: EquipmentFeatures.DOUBLE_CAPACITY
 | 
			
		||||
                },
 | 
			
		||||
                resp.InventoryChanges
 | 
			
		||||
            );
 | 
			
		||||
            inventory.XPInfo.push({
 | 
			
		||||
                ItemType: "/Lotus/Powersuits/Excalibur/ExcaliburUmbra",
 | 
			
		||||
                XP: 900_000
 | 
			
		||||
            });
 | 
			
		||||
                    ItemType: pendingRecipe.ItemType,
 | 
			
		||||
                    ItemCount: -1
 | 
			
		||||
                }
 | 
			
		||||
            ]);
 | 
			
		||||
        }
 | 
			
		||||
        if (req.query.rush) {
 | 
			
		||||
            const end = Math.trunc(pendingRecipe.CompletionDate.getTime() / 1000);
 | 
			
		||||
            const start = end - recipe.buildTime;
 | 
			
		||||
            const secondsElapsed = Math.trunc(Date.now() / 1000) - start;
 | 
			
		||||
            const progress = secondsElapsed / recipe.buildTime;
 | 
			
		||||
            logger.debug(`rushing recipe at ${Math.trunc(progress * 100)}% completion`);
 | 
			
		||||
            const cost = Math.round(recipe.skipBuildTimePrice * (1 - (progress - 0.5)));
 | 
			
		||||
            InventoryChanges = {
 | 
			
		||||
                ...InventoryChanges,
 | 
			
		||||
                ...updateCurrency(inventory, cost, true)
 | 
			
		||||
            };
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
            addEquipment(
 | 
			
		||||
                inventory,
 | 
			
		||||
                "Melee",
 | 
			
		||||
                "/Lotus/Weapons/Tenno/Melee/Swords/UmbraKatana/UmbraKatana",
 | 
			
		||||
                {
 | 
			
		||||
                    Configs: [
 | 
			
		||||
                        { Upgrades: ["", "", "", "", "", "", sacrificeModA.ItemId.$oid, sacrificeModB.ItemId.$oid] }
 | 
			
		||||
                    ],
 | 
			
		||||
                    XP: 450_000,
 | 
			
		||||
                    Features: EquipmentFeatures.DOUBLE_CAPACITY
 | 
			
		||||
                },
 | 
			
		||||
                resp.InventoryChanges
 | 
			
		||||
            );
 | 
			
		||||
            inventory.XPInfo.push({
 | 
			
		||||
                ItemType: "/Lotus/Weapons/Tenno/Melee/Swords/UmbraKatana/UmbraKatana",
 | 
			
		||||
                XP: 450_000
 | 
			
		||||
            });
 | 
			
		||||
        } else {
 | 
			
		||||
            combineInventoryChanges(
 | 
			
		||||
                resp.InventoryChanges,
 | 
			
		||||
                await addItem(
 | 
			
		||||
        if (recipe.secretIngredientAction == "SIA_CREATE_KUBROW") {
 | 
			
		||||
            const pet = inventory.KubrowPets.id(pendingRecipe.KubrowPet!)!;
 | 
			
		||||
            if (pet.Details!.HatchDate!.getTime() > Date.now()) {
 | 
			
		||||
                pet.Details!.HatchDate = new Date();
 | 
			
		||||
            }
 | 
			
		||||
            let canSetActive = true;
 | 
			
		||||
            for (const pet of inventory.KubrowPets) {
 | 
			
		||||
                if (pet.Details!.Status == Status.StatusAvailable) {
 | 
			
		||||
                    canSetActive = false;
 | 
			
		||||
                    break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            pet.Details!.Status = canSetActive ? Status.StatusAvailable : Status.StatusStasis;
 | 
			
		||||
        } else if (recipe.secretIngredientAction != "SIA_UNBRAND") {
 | 
			
		||||
            InventoryChanges = {
 | 
			
		||||
                ...InventoryChanges,
 | 
			
		||||
                ...(await addItem(
 | 
			
		||||
                    inventory,
 | 
			
		||||
                    recipe.resultType,
 | 
			
		||||
                    recipe.num,
 | 
			
		||||
                    false,
 | 
			
		||||
                    undefined,
 | 
			
		||||
                    pendingRecipe.TargetFingerprint
 | 
			
		||||
                )
 | 
			
		||||
            );
 | 
			
		||||
                ))
 | 
			
		||||
            };
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    if (
 | 
			
		||||
        inventory.claimingBlueprintRefundsIngredients &&
 | 
			
		||||
        recipe.secretIngredientAction != "SIA_CREATE_KUBROW" // Can't refund the egg
 | 
			
		||||
    ) {
 | 
			
		||||
        await refundRecipeIngredients(inventory, resp.InventoryChanges, recipe, pendingRecipe);
 | 
			
		||||
        if (
 | 
			
		||||
            config.claimingBlueprintRefundsIngredients &&
 | 
			
		||||
            recipe.secretIngredientAction != "SIA_CREATE_KUBROW" // Can't refund the egg
 | 
			
		||||
        ) {
 | 
			
		||||
            await refundRecipeIngredients(inventory, InventoryChanges, recipe, pendingRecipe);
 | 
			
		||||
        }
 | 
			
		||||
        await inventory.save();
 | 
			
		||||
        res.json({ InventoryChanges, BrandedSuits });
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,35 +0,0 @@
 | 
			
		||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
			
		||||
import { combineInventoryChanges, getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { handleStoreItemAcquisition } from "../../services/purchaseService.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { ExportChallenges } from "warframe-public-export-plus";
 | 
			
		||||
 | 
			
		||||
export const claimJunctionChallengeRewardController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
    const inventory = await getInventory(accountId);
 | 
			
		||||
    const data = getJSONfromString<IClaimJunctionChallengeRewardRequest>(String(req.body));
 | 
			
		||||
    const challengeProgress = inventory.ChallengeProgress.find(x => x.Name == data.Challenge)!;
 | 
			
		||||
    if (challengeProgress.ReceivedJunctionReward) {
 | 
			
		||||
        throw new Error(`attempt to double-claim junction reward`);
 | 
			
		||||
    }
 | 
			
		||||
    challengeProgress.ReceivedJunctionReward = true;
 | 
			
		||||
    inventory.ClaimedJunctionChallengeRewards ??= [];
 | 
			
		||||
    inventory.ClaimedJunctionChallengeRewards.push(data.Challenge);
 | 
			
		||||
    const challengeMeta = Object.entries(ExportChallenges).find(arr => arr[0].endsWith("/" + data.Challenge))![1];
 | 
			
		||||
    const inventoryChanges = {};
 | 
			
		||||
    for (const reward of challengeMeta.countedRewards!) {
 | 
			
		||||
        combineInventoryChanges(
 | 
			
		||||
            inventoryChanges,
 | 
			
		||||
            (await handleStoreItemAcquisition(reward.StoreItem, inventory, reward.ItemCount)).InventoryChanges
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
    await inventory.save();
 | 
			
		||||
    res.json({
 | 
			
		||||
        inventoryChanges: inventoryChanges // Yeah, it's "inventoryChanges" in the response here.
 | 
			
		||||
    });
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
interface IClaimJunctionChallengeRewardRequest {
 | 
			
		||||
    Challenge: string;
 | 
			
		||||
}
 | 
			
		||||
@ -1,6 +1,6 @@
 | 
			
		||||
import { addFusionPoints, getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { addFusionPoints, getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const claimLibraryDailyTaskRewardController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,6 @@
 | 
			
		||||
import { getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const clearDialogueHistoryController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
// example req.body: {"NewEpisodeReward":true,"crossPlaySetting":"ENABLED"}
 | 
			
		||||
export const clearNewEpisodeRewardController: RequestHandler = (_req, res) => {
 | 
			
		||||
 | 
			
		||||
@ -1,9 +1,9 @@
 | 
			
		||||
import { checkCalendarAutoAdvance, getCalendarProgress, getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { handleStoreItemAcquisition } from "../../services/purchaseService.ts";
 | 
			
		||||
import { getWorldState } from "../../services/worldStateService.ts";
 | 
			
		||||
import type { IInventoryChanges } from "../../types/purchaseTypes.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getCalendarProgress, getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { handleStoreItemAcquisition } from "@/src/services/purchaseService";
 | 
			
		||||
import { getWorldState } from "@/src/services/worldStateService";
 | 
			
		||||
import { IInventoryChanges } from "@/src/types/purchaseTypes";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
// GET request; query parameters: CompletedEventIdx=0&Iteration=4&Version=19&Season=CST_SUMMER
 | 
			
		||||
export const completeCalendarEventController: RequestHandler = async (req, res) => {
 | 
			
		||||
@ -12,23 +12,27 @@ export const completeCalendarEventController: RequestHandler = async (req, res)
 | 
			
		||||
    const calendarProgress = getCalendarProgress(inventory);
 | 
			
		||||
    const currentSeason = getWorldState().KnownCalendarSeasons[0];
 | 
			
		||||
    let inventoryChanges: IInventoryChanges = {};
 | 
			
		||||
    const dayIndex = calendarProgress.SeasonProgress.LastCompletedDayIdx + 1;
 | 
			
		||||
    const day = currentSeason.Days[dayIndex];
 | 
			
		||||
    if (day.events.length != 0) {
 | 
			
		||||
        if (day.events[0].type == "CET_CHALLENGE") {
 | 
			
		||||
            throw new Error(`completeCalendarEvent should not be used for challenges`);
 | 
			
		||||
        }
 | 
			
		||||
        const selection = day.events[parseInt(req.query.CompletedEventIdx as string)];
 | 
			
		||||
        if (selection.type == "CET_REWARD") {
 | 
			
		||||
            inventoryChanges = (await handleStoreItemAcquisition(selection.reward!, inventory)).InventoryChanges;
 | 
			
		||||
        } else if (selection.type == "CET_UPGRADE") {
 | 
			
		||||
            calendarProgress.YearProgress.Upgrades.push(selection.upgrade!);
 | 
			
		||||
        } else if (selection.type != "CET_PLOT") {
 | 
			
		||||
            throw new Error(`unexpected selection type: ${selection.type}`);
 | 
			
		||||
    let dayIndex = 0;
 | 
			
		||||
    for (const day of currentSeason.Days) {
 | 
			
		||||
        if (day.events.length == 0 || day.events[0].type != "CET_CHALLENGE") {
 | 
			
		||||
            if (dayIndex == calendarProgress.SeasonProgress.LastCompletedDayIdx) {
 | 
			
		||||
                if (day.events.length != 0) {
 | 
			
		||||
                    const selection = day.events[parseInt(req.query.CompletedEventIdx as string)];
 | 
			
		||||
                    if (selection.type == "CET_REWARD") {
 | 
			
		||||
                        inventoryChanges = (await handleStoreItemAcquisition(selection.reward!, inventory))
 | 
			
		||||
                            .InventoryChanges;
 | 
			
		||||
                    } else if (selection.type == "CET_UPGRADE") {
 | 
			
		||||
                        calendarProgress.YearProgress.Upgrades.push(selection.upgrade!);
 | 
			
		||||
                    } else if (selection.type != "CET_PLOT") {
 | 
			
		||||
                        throw new Error(`unexpected selection type: ${selection.type}`);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
            ++dayIndex;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    calendarProgress.SeasonProgress.LastCompletedDayIdx = dayIndex;
 | 
			
		||||
    checkCalendarAutoAdvance(inventory, currentSeason);
 | 
			
		||||
    calendarProgress.SeasonProgress.LastCompletedDayIdx++;
 | 
			
		||||
    await inventory.save();
 | 
			
		||||
    res.json({
 | 
			
		||||
        InventoryChanges: inventoryChanges,
 | 
			
		||||
 | 
			
		||||
@ -1,10 +1,11 @@
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { addMiscItems, getInventory, updateCurrency } from "../../services/inventoryService.ts";
 | 
			
		||||
import type { IInventoryChanges } from "../../types/purchaseTypes.ts";
 | 
			
		||||
import type { IMiscItem } from "../../types/inventoryTypes/inventoryTypes.ts";
 | 
			
		||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
			
		||||
import type { IVeiledRivenFingerprint } from "../../helpers/rivenHelper.ts";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { addMiscItems, getInventory, updateCurrency } from "@/src/services/inventoryService";
 | 
			
		||||
import { IInventoryChanges } from "@/src/types/purchaseTypes";
 | 
			
		||||
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
			
		||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { createUnveiledRivenFingerprint } from "@/src/helpers/rivenHelper";
 | 
			
		||||
import { ExportUpgrades } from "warframe-public-export-plus";
 | 
			
		||||
 | 
			
		||||
export const completeRandomModChallengeController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
@ -26,11 +27,10 @@ export const completeRandomModChallengeController: RequestHandler = async (req,
 | 
			
		||||
        inventoryChanges.MiscItems = miscItemChanges;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Complete the riven challenge
 | 
			
		||||
    // Update riven fingerprint to a randomised unveiled state
 | 
			
		||||
    const upgrade = inventory.Upgrades.id(request.ItemId)!;
 | 
			
		||||
    const fp = JSON.parse(upgrade.UpgradeFingerprint!) as IVeiledRivenFingerprint;
 | 
			
		||||
    fp.challenge.Progress = fp.challenge.Required;
 | 
			
		||||
    upgrade.UpgradeFingerprint = JSON.stringify(fp);
 | 
			
		||||
    const meta = ExportUpgrades[upgrade.ItemType];
 | 
			
		||||
    upgrade.UpgradeFingerprint = JSON.stringify(createUnveiledRivenFingerprint(meta));
 | 
			
		||||
 | 
			
		||||
    await inventory.save();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
import { Alliance, AllianceMember, Guild, GuildMember } from "../../models/guildModel.ts";
 | 
			
		||||
import { getAllianceClient } from "../../services/guildService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { Alliance, AllianceMember, Guild, GuildMember } from "@/src/models/guildModel";
 | 
			
		||||
import { getAllianceClient } from "@/src/services/guildService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const confirmAllianceInvitationController: RequestHandler = async (req, res) => {
 | 
			
		||||
    // Check requester is a warlord in their guild
 | 
			
		||||
 | 
			
		||||
@ -1,18 +1,18 @@
 | 
			
		||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
			
		||||
import { Guild, GuildMember } from "../../models/guildModel.ts";
 | 
			
		||||
import { Account } from "../../models/loginModel.ts";
 | 
			
		||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { Guild, GuildMember } from "@/src/models/guildModel";
 | 
			
		||||
import { Account } from "@/src/models/loginModel";
 | 
			
		||||
import {
 | 
			
		||||
    deleteGuild,
 | 
			
		||||
    getGuildClient,
 | 
			
		||||
    giveClanKey,
 | 
			
		||||
    hasGuildPermission,
 | 
			
		||||
    removeDojoKeyItems
 | 
			
		||||
} from "../../services/guildService.ts";
 | 
			
		||||
import { getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountForRequest, getAccountIdForRequest, getSuffixedName } from "../../services/loginService.ts";
 | 
			
		||||
import { GuildPermission } from "../../types/guildTypes.ts";
 | 
			
		||||
import type { IInventoryChanges } from "../../types/purchaseTypes.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
} from "@/src/services/guildService";
 | 
			
		||||
import { getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountForRequest, getAccountIdForRequest, getSuffixedName } from "@/src/services/loginService";
 | 
			
		||||
import { GuildPermission } from "@/src/types/guildTypes";
 | 
			
		||||
import { IInventoryChanges } from "@/src/types/purchaseTypes";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { Types } from "mongoose";
 | 
			
		||||
 | 
			
		||||
// GET request: A player accepting an invite they got in their inbox.
 | 
			
		||||
 | 
			
		||||
@ -1,10 +1,10 @@
 | 
			
		||||
import { toMongoDate } from "../../helpers/inventoryHelpers.ts";
 | 
			
		||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
			
		||||
import { Guild } from "../../models/guildModel.ts";
 | 
			
		||||
import { checkClanAscensionHasRequiredContributors } from "../../services/guildService.ts";
 | 
			
		||||
import { addFusionPoints, getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { toMongoDate } from "@/src/helpers/inventoryHelpers";
 | 
			
		||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { Guild } from "@/src/models/guildModel";
 | 
			
		||||
import { checkClanAscensionHasRequiredContributors } from "@/src/services/guildService";
 | 
			
		||||
import { addFusionPoints, getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { Types } from "mongoose";
 | 
			
		||||
 | 
			
		||||
export const contributeGuildClassController: RequestHandler = async (req, res) => {
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,5 @@
 | 
			
		||||
import type { TGuildDatabaseDocument } from "../../models/guildModel.ts";
 | 
			
		||||
import { GuildMember } from "../../models/guildModel.ts";
 | 
			
		||||
import type { TInventoryDatabaseDocument } from "../../models/inventoryModels/inventoryModel.ts";
 | 
			
		||||
import { GuildMember, TGuildDatabaseDocument } from "@/src/models/guildModel";
 | 
			
		||||
import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel";
 | 
			
		||||
import {
 | 
			
		||||
    addGuildMemberMiscItemContribution,
 | 
			
		||||
    getDojoClient,
 | 
			
		||||
@ -9,15 +8,14 @@ import {
 | 
			
		||||
    processDojoBuildMaterialsGathered,
 | 
			
		||||
    scaleRequiredCount,
 | 
			
		||||
    setDojoRoomLogFunded
 | 
			
		||||
} from "../../services/guildService.ts";
 | 
			
		||||
import { addMiscItems, getInventory, updateCurrency } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import type { IDojoContributable, IGuildMemberDatabase } from "../../types/guildTypes.ts";
 | 
			
		||||
import type { IMiscItem } from "../../types/inventoryTypes/inventoryTypes.ts";
 | 
			
		||||
import type { IInventoryChanges } from "../../types/purchaseTypes.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import type { IDojoBuild } from "warframe-public-export-plus";
 | 
			
		||||
import { ExportDojoRecipes } from "warframe-public-export-plus";
 | 
			
		||||
} from "@/src/services/guildService";
 | 
			
		||||
import { addMiscItems, getInventory, updateCurrency } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { IDojoContributable, IGuildMemberDatabase } from "@/src/types/guildTypes";
 | 
			
		||||
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
			
		||||
import { IInventoryChanges } from "@/src/types/purchaseTypes";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { ExportDojoRecipes, IDojoBuild } from "warframe-public-export-plus";
 | 
			
		||||
 | 
			
		||||
interface IContributeToDojoComponentRequest {
 | 
			
		||||
    ComponentId: string;
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,10 @@
 | 
			
		||||
import type { TGuildDatabaseDocument, TGuildMemberDatabaseDocument } from "../../models/guildModel.ts";
 | 
			
		||||
import { Alliance, Guild, GuildMember } from "../../models/guildModel.ts";
 | 
			
		||||
import {
 | 
			
		||||
    Alliance,
 | 
			
		||||
    Guild,
 | 
			
		||||
    GuildMember,
 | 
			
		||||
    TGuildDatabaseDocument,
 | 
			
		||||
    TGuildMemberDatabaseDocument
 | 
			
		||||
} from "@/src/models/guildModel";
 | 
			
		||||
import {
 | 
			
		||||
    addGuildMemberMiscItemContribution,
 | 
			
		||||
    addGuildMemberShipDecoContribution,
 | 
			
		||||
@ -7,18 +12,17 @@ import {
 | 
			
		||||
    addVaultMiscItems,
 | 
			
		||||
    addVaultShipDecos,
 | 
			
		||||
    getGuildForRequestEx
 | 
			
		||||
} from "../../services/guildService.ts";
 | 
			
		||||
} from "@/src/services/guildService";
 | 
			
		||||
import {
 | 
			
		||||
    addFusionTreasures,
 | 
			
		||||
    addMiscItems,
 | 
			
		||||
    addShipDecorations,
 | 
			
		||||
    getInventory,
 | 
			
		||||
    updateCurrency
 | 
			
		||||
} from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import type { ITypeCount } from "../../types/commonTypes.ts";
 | 
			
		||||
import type { IFusionTreasure, IMiscItem } from "../../types/inventoryTypes/inventoryTypes.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
} from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { IFusionTreasure, IMiscItem, ITypeCount } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const contributeToVaultController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
 | 
			
		||||
@ -1,10 +1,10 @@
 | 
			
		||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
			
		||||
import { Alliance, AllianceMember, Guild, GuildMember } from "../../models/guildModel.ts";
 | 
			
		||||
import { getAllianceClient } from "../../services/guildService.ts";
 | 
			
		||||
import { getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { GuildPermission } from "../../types/guildTypes.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { Alliance, AllianceMember, Guild, GuildMember } from "@/src/models/guildModel";
 | 
			
		||||
import { getAllianceClient } from "@/src/services/guildService";
 | 
			
		||||
import { getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { GuildPermission } from "@/src/types/guildTypes";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const createAllianceController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
 | 
			
		||||
@ -1,27 +1,15 @@
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getAccountForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
			
		||||
import { Guild, GuildMember } from "../../models/guildModel.ts";
 | 
			
		||||
import { createUniqueClanName, getGuildClient, giveClanKey } from "../../services/guildService.ts";
 | 
			
		||||
import { getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import type { IInventoryChanges } from "../../types/purchaseTypes.ts";
 | 
			
		||||
import { sendWsBroadcastTo } from "../../services/wsService.ts";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { getAccountForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { Guild, GuildMember } from "@/src/models/guildModel";
 | 
			
		||||
import { createUniqueClanName, getGuildClient, giveClanKey } from "@/src/services/guildService";
 | 
			
		||||
import { getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { IInventoryChanges } from "@/src/types/purchaseTypes";
 | 
			
		||||
 | 
			
		||||
export const createGuildController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const account = await getAccountForRequest(req);
 | 
			
		||||
    const payload = getJSONfromString<ICreateGuildRequest>(String(req.body));
 | 
			
		||||
 | 
			
		||||
    const inventory = await getInventory(account._id.toString(), "GuildId LevelKeys Recipes");
 | 
			
		||||
    if (inventory.GuildId) {
 | 
			
		||||
        const guild = await Guild.findById(inventory.GuildId);
 | 
			
		||||
        if (guild) {
 | 
			
		||||
            res.json({
 | 
			
		||||
                ...(await getGuildClient(guild, account))
 | 
			
		||||
            });
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Remove pending applications for this account
 | 
			
		||||
    await GuildMember.deleteMany({ accountId: account._id, status: 1 });
 | 
			
		||||
 | 
			
		||||
@ -39,6 +27,7 @@ export const createGuildController: RequestHandler = async (req, res) => {
 | 
			
		||||
        rank: 0
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    const inventory = await getInventory(account._id.toString(), "GuildId LevelKeys Recipes");
 | 
			
		||||
    inventory.GuildId = guild._id;
 | 
			
		||||
    const inventoryChanges: IInventoryChanges = {};
 | 
			
		||||
    giveClanKey(inventory, inventoryChanges);
 | 
			
		||||
@ -48,7 +37,6 @@ export const createGuildController: RequestHandler = async (req, res) => {
 | 
			
		||||
        ...(await getGuildClient(guild, account)),
 | 
			
		||||
        InventoryChanges: inventoryChanges
 | 
			
		||||
    });
 | 
			
		||||
    sendWsBroadcastTo(account._id.toString(), { update_inventory: true });
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
interface ICreateGuildRequest {
 | 
			
		||||
 | 
			
		||||
@ -1,17 +1,12 @@
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { config } from "@/src/services/configService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
 | 
			
		||||
export const creditsController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const inventory = (
 | 
			
		||||
        await Promise.all([
 | 
			
		||||
            getAccountIdForRequest(req),
 | 
			
		||||
            getInventory(
 | 
			
		||||
                req.query.accountId as string,
 | 
			
		||||
                "RegularCredits TradesRemaining PremiumCreditsFree PremiumCredits infiniteCredits infinitePlatinum"
 | 
			
		||||
            )
 | 
			
		||||
        ])
 | 
			
		||||
    )[1];
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
 | 
			
		||||
    const inventory = await getInventory(accountId, "RegularCredits TradesRemaining PremiumCreditsFree PremiumCredits");
 | 
			
		||||
 | 
			
		||||
    const response = {
 | 
			
		||||
        RegularCredits: inventory.RegularCredits,
 | 
			
		||||
@ -20,10 +15,10 @@ export const creditsController: RequestHandler = async (req, res) => {
 | 
			
		||||
        PremiumCredits: inventory.PremiumCredits
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    if (inventory.infiniteCredits) {
 | 
			
		||||
    if (config.infiniteCredits) {
 | 
			
		||||
        response.RegularCredits = 999999999;
 | 
			
		||||
    }
 | 
			
		||||
    if (inventory.infinitePlatinum) {
 | 
			
		||||
    if (config.infinitePlatinum) {
 | 
			
		||||
        response.PremiumCreditsFree = 0;
 | 
			
		||||
        response.PremiumCredits = 999999999;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -1,9 +1,9 @@
 | 
			
		||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
			
		||||
import type { TInventoryDatabaseDocument } from "../../models/inventoryModels/inventoryModel.ts";
 | 
			
		||||
import { getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import type { ICrewMemberClient } from "../../types/inventoryTypes/inventoryTypes.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel";
 | 
			
		||||
import { getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { ICrewMemberClient } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { Types } from "mongoose";
 | 
			
		||||
 | 
			
		||||
export const crewMembersController: RequestHandler = async (req, res) => {
 | 
			
		||||
 | 
			
		||||
@ -1,107 +0,0 @@
 | 
			
		||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
			
		||||
import { addMiscItems, freeUpSlot, getInventory, updateCurrency } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import type { IOid } from "../../types/commonTypes.ts";
 | 
			
		||||
import type { ICrewShipComponentFingerprint } from "../../types/inventoryTypes/inventoryTypes.ts";
 | 
			
		||||
import { InventorySlot } from "../../types/inventoryTypes/inventoryTypes.ts";
 | 
			
		||||
import type { IInventoryChanges } from "../../types/purchaseTypes.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { ExportCustoms, ExportDojoRecipes } from "warframe-public-export-plus";
 | 
			
		||||
 | 
			
		||||
export const crewShipFusionController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
    const inventory = await getInventory(accountId);
 | 
			
		||||
    const payload = getJSONfromString<ICrewShipFusionRequest>(String(req.body));
 | 
			
		||||
 | 
			
		||||
    const isWeapon = inventory.CrewShipWeapons.id(payload.PartA.$oid);
 | 
			
		||||
    const itemA = isWeapon ?? inventory.CrewShipWeaponSkins.id(payload.PartA.$oid)!;
 | 
			
		||||
    const category = isWeapon ? "CrewShipWeapons" : "CrewShipWeaponSkins";
 | 
			
		||||
    const salvageCategory = isWeapon ? "CrewShipSalvagedWeapons" : "CrewShipSalvagedWeaponSkins";
 | 
			
		||||
    const itemB = inventory[payload.SourceRecipe ? salvageCategory : category].id(payload.PartB.$oid)!;
 | 
			
		||||
    const tierA = itemA.ItemType.charCodeAt(itemA.ItemType.length - 1) - 65;
 | 
			
		||||
    const tierB = itemB.ItemType.charCodeAt(itemB.ItemType.length - 1) - 65;
 | 
			
		||||
 | 
			
		||||
    const inventoryChanges: IInventoryChanges = {};
 | 
			
		||||
 | 
			
		||||
    // Charge partial repair cost if fusing with an identified but unrepaired part
 | 
			
		||||
    if (payload.SourceRecipe) {
 | 
			
		||||
        const recipe = ExportDojoRecipes.research[payload.SourceRecipe];
 | 
			
		||||
        updateCurrency(inventory, Math.round(recipe.price * 0.4), false, inventoryChanges);
 | 
			
		||||
        const miscItemChanges = recipe.ingredients.map(x => ({ ...x, ItemCount: Math.round(x.ItemCount * -0.4) }));
 | 
			
		||||
        addMiscItems(inventory, miscItemChanges);
 | 
			
		||||
        inventoryChanges.MiscItems = miscItemChanges;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Remove inferior item
 | 
			
		||||
    if (payload.SourceRecipe) {
 | 
			
		||||
        inventory[salvageCategory].pull({ _id: payload.PartB.$oid });
 | 
			
		||||
        inventoryChanges.RemovedIdItems = [{ ItemId: payload.PartB }];
 | 
			
		||||
    } else {
 | 
			
		||||
        const inferiorId = tierA < tierB ? payload.PartA : payload.PartB;
 | 
			
		||||
        inventory[category].pull({ _id: inferiorId.$oid });
 | 
			
		||||
        inventoryChanges.RemovedIdItems = [{ ItemId: inferiorId }];
 | 
			
		||||
        freeUpSlot(inventory, InventorySlot.RJ_COMPONENT_AND_ARMAMENTS);
 | 
			
		||||
        inventoryChanges[InventorySlot.RJ_COMPONENT_AND_ARMAMENTS] = { count: -1, platinum: 0, Slots: 1 };
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Upgrade superior item
 | 
			
		||||
    const superiorItem = tierA < tierB ? itemB : itemA;
 | 
			
		||||
    const inferiorItem = tierA < tierB ? itemA : itemB;
 | 
			
		||||
    const fingerprint: ICrewShipComponentFingerprint = JSON.parse(
 | 
			
		||||
        superiorItem.UpgradeFingerprint!
 | 
			
		||||
    ) as ICrewShipComponentFingerprint;
 | 
			
		||||
    const inferiorFingerprint: ICrewShipComponentFingerprint = inferiorItem.UpgradeFingerprint
 | 
			
		||||
        ? (JSON.parse(inferiorItem.UpgradeFingerprint) as ICrewShipComponentFingerprint)
 | 
			
		||||
        : { compat: "", buffs: [] };
 | 
			
		||||
    if (isWeapon) {
 | 
			
		||||
        for (let i = 0; i != fingerprint.buffs.length; ++i) {
 | 
			
		||||
            const buffA = fingerprint.buffs[i];
 | 
			
		||||
            const buffB = i < inferiorFingerprint.buffs.length ? inferiorFingerprint.buffs[i] : undefined;
 | 
			
		||||
            const fvalA = buffA.Value / 0x3fffffff;
 | 
			
		||||
            const fvalB = (buffB?.Value ?? 0) / 0x3fffffff;
 | 
			
		||||
            const percA = 0.3 + fvalA * (0.6 - 0.3);
 | 
			
		||||
            const percB = 0.3 + fvalB * (0.6 - 0.3);
 | 
			
		||||
            const newPerc = Math.min(0.6, Math.max(percA, percB) * FUSE_MULTIPLIERS[Math.abs(tierA - tierB)]);
 | 
			
		||||
            const newFval = (newPerc - 0.3) / (0.6 - 0.3);
 | 
			
		||||
            buffA.Value = Math.trunc(newFval * 0x3fffffff);
 | 
			
		||||
        }
 | 
			
		||||
    } else {
 | 
			
		||||
        const superiorMeta = ExportCustoms[superiorItem.ItemType].randomisedUpgrades ?? [];
 | 
			
		||||
        const inferiorMeta = ExportCustoms[inferiorItem.ItemType].randomisedUpgrades ?? [];
 | 
			
		||||
        for (let i = 0; i != inferiorFingerprint.buffs.length; ++i) {
 | 
			
		||||
            const buffA = fingerprint.buffs[i];
 | 
			
		||||
            const buffB = inferiorFingerprint.buffs[i];
 | 
			
		||||
            const fvalA = buffA.Value / 0x3fffffff;
 | 
			
		||||
            const fvalB = buffB.Value / 0x3fffffff;
 | 
			
		||||
            const rangeA = superiorMeta[i].range;
 | 
			
		||||
            const rangeB = inferiorMeta[i].range;
 | 
			
		||||
            const percA = rangeA[0] + fvalA * (rangeA[1] - rangeA[0]);
 | 
			
		||||
            const percB = rangeB[0] + fvalB * (rangeB[1] - rangeB[0]);
 | 
			
		||||
            const newPerc = Math.min(rangeA[1], Math.max(percA, percB) * FUSE_MULTIPLIERS[Math.abs(tierA - tierB)]);
 | 
			
		||||
            const newFval = (newPerc - rangeA[0]) / (rangeA[1] - rangeA[0]);
 | 
			
		||||
            buffA.Value = Math.trunc(newFval * 0x3fffffff);
 | 
			
		||||
        }
 | 
			
		||||
        if (inferiorFingerprint.SubroutineIndex !== undefined) {
 | 
			
		||||
            const useSuperiorSubroutine = tierA < tierB ? !payload.UseSubroutineA : payload.UseSubroutineA;
 | 
			
		||||
            if (!useSuperiorSubroutine) {
 | 
			
		||||
                fingerprint.SubroutineIndex = inferiorFingerprint.SubroutineIndex;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    superiorItem.UpgradeFingerprint = JSON.stringify(fingerprint);
 | 
			
		||||
    inventoryChanges[category] = [superiorItem.toJSON() as any];
 | 
			
		||||
 | 
			
		||||
    await inventory.save();
 | 
			
		||||
    res.json({
 | 
			
		||||
        InventoryChanges: inventoryChanges
 | 
			
		||||
    });
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
interface ICrewShipFusionRequest {
 | 
			
		||||
    PartA: IOid;
 | 
			
		||||
    PartB: IOid;
 | 
			
		||||
    SourceRecipe: string;
 | 
			
		||||
    UseSubroutineA: boolean;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const FUSE_MULTIPLIERS = [1.1, 1.05, 1.02];
 | 
			
		||||
@ -3,19 +3,16 @@ import {
 | 
			
		||||
    addCrewShipRawSalvage,
 | 
			
		||||
    getInventory,
 | 
			
		||||
    addEquipment
 | 
			
		||||
} from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import type {
 | 
			
		||||
    ICrewShipComponentFingerprint,
 | 
			
		||||
    IInnateDamageFingerprint
 | 
			
		||||
} from "../../types/inventoryTypes/inventoryTypes.ts";
 | 
			
		||||
} from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { ICrewShipComponentFingerprint, IInnateDamageFingerprint } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
			
		||||
import { ExportCustoms, ExportRailjackWeapons, ExportUpgrades } from "warframe-public-export-plus";
 | 
			
		||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
			
		||||
import type { IInventoryChanges } from "../../types/purchaseTypes.ts";
 | 
			
		||||
import { getRandomInt } from "../../services/rngService.ts";
 | 
			
		||||
import type { IFingerprintStat } from "../../helpers/rivenHelper.ts";
 | 
			
		||||
import type { IEquipmentDatabase } from "../../types/equipmentTypes.ts";
 | 
			
		||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { IInventoryChanges } from "@/src/types/purchaseTypes";
 | 
			
		||||
import { getRandomInt } from "@/src/services/rngService";
 | 
			
		||||
import { IFingerprintStat } from "@/src/helpers/rivenHelper";
 | 
			
		||||
import { IEquipmentDatabase } from "@/src/types/inventoryTypes/commonInventoryTypes";
 | 
			
		||||
 | 
			
		||||
export const crewShipIdentifySalvageController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
 | 
			
		||||
@ -1,15 +1,12 @@
 | 
			
		||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
			
		||||
import { Guild } from "../../models/guildModel.ts";
 | 
			
		||||
import { hasAccessToDojo, hasGuildPermission } from "../../services/guildService.ts";
 | 
			
		||||
import { getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountForRequest, getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { GuildPermission } from "../../types/guildTypes.ts";
 | 
			
		||||
import { logger } from "../../utils/logger.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { Guild } from "@/src/models/guildModel";
 | 
			
		||||
import { getAccountForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { logger } from "@/src/utils/logger";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const customObstacleCourseLeaderboardController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const data = getJSONfromString<ICustomObstacleCourseLeaderboardRequest>(String(req.body));
 | 
			
		||||
    const guild = (await Guild.findById(data.g, "DojoComponents Ranks"))!;
 | 
			
		||||
    const guild = (await Guild.findById(data.g, "DojoComponents"))!;
 | 
			
		||||
    const component = guild.DojoComponents.id(data.c)!;
 | 
			
		||||
    if (req.query.act == "f") {
 | 
			
		||||
        res.json({
 | 
			
		||||
@ -37,19 +34,6 @@ export const customObstacleCourseLeaderboardController: RequestHandler = async (
 | 
			
		||||
            entry.r = ++r;
 | 
			
		||||
        }
 | 
			
		||||
        await guild.save();
 | 
			
		||||
        res.status(200).end();
 | 
			
		||||
    } else if (req.query.act == "c") {
 | 
			
		||||
        // TOVERIFY: What clan permission is actually needed for this?
 | 
			
		||||
        const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
        const inventory = await getInventory(accountId, "GuildId LevelKeys");
 | 
			
		||||
        if (!hasAccessToDojo(inventory) || !(await hasGuildPermission(guild, accountId, GuildPermission.Decorator))) {
 | 
			
		||||
            res.status(400).end();
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        component.Leaderboard = undefined;
 | 
			
		||||
        await guild.save();
 | 
			
		||||
 | 
			
		||||
        res.status(200).end();
 | 
			
		||||
    } else {
 | 
			
		||||
        logger.debug(`data provided to ${req.path}: ${String(req.body)}`);
 | 
			
		||||
 | 
			
		||||
@ -1,8 +1,7 @@
 | 
			
		||||
import { getGuildForRequest, hasGuildPermission } from "../../services/guildService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import type { IGuildRank } from "../../types/guildTypes.ts";
 | 
			
		||||
import { GuildPermission } from "../../types/guildTypes.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getGuildForRequest, hasGuildPermission } from "@/src/services/guildService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { GuildPermission, IGuildRank } from "@/src/types/guildTypes";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const customizeGuildRanksController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,6 @@
 | 
			
		||||
import { AllianceMember, GuildMember } from "../../models/guildModel.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { AllianceMember, GuildMember } from "@/src/models/guildModel";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const declineAllianceInviteController: RequestHandler = async (req, res) => {
 | 
			
		||||
    // Check requester is a warlord in their guild
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,6 @@
 | 
			
		||||
import { GuildMember } from "../../models/guildModel.ts";
 | 
			
		||||
import { getAccountForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { GuildMember } from "@/src/models/guildModel";
 | 
			
		||||
import { getAccountForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const declineGuildInviteController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountForRequest(req);
 | 
			
		||||
 | 
			
		||||
@ -1,17 +1,9 @@
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { deleteSession } from "../../managers/sessionManager.ts";
 | 
			
		||||
import { getAccountForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { version_compare } from "../../helpers/inventoryHelpers.ts";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { deleteSession } from "@/src/managers/sessionManager";
 | 
			
		||||
 | 
			
		||||
const deleteSessionController: RequestHandler = async (_req, res) => {
 | 
			
		||||
    const account = await getAccountForRequest(_req);
 | 
			
		||||
const deleteSessionController: RequestHandler = (_req, res) => {
 | 
			
		||||
    deleteSession(_req.query.sessionId as string);
 | 
			
		||||
    if (account.BuildLabel && version_compare(account.BuildLabel, "2016.07.08.16.56") < 0) {
 | 
			
		||||
        // Pre-Specters of the Rail
 | 
			
		||||
        res.send(_req.query.sessionId as string); // Unsure if this is correct, but the client is chill with it
 | 
			
		||||
    } else {
 | 
			
		||||
        res.sendStatus(200);
 | 
			
		||||
    }
 | 
			
		||||
    res.sendStatus(200);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export { deleteSessionController };
 | 
			
		||||
 | 
			
		||||
@ -3,14 +3,12 @@ import {
 | 
			
		||||
    getGuildForRequestEx,
 | 
			
		||||
    hasAccessToDojo,
 | 
			
		||||
    hasGuildPermission,
 | 
			
		||||
    refundDojoDeco,
 | 
			
		||||
    removeDojoDeco
 | 
			
		||||
} from "../../services/guildService.ts";
 | 
			
		||||
import { getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { GuildPermission } from "../../types/guildTypes.ts";
 | 
			
		||||
import { logger } from "../../utils/logger.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
} from "@/src/services/guildService";
 | 
			
		||||
import { getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { GuildPermission } from "@/src/types/guildTypes";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const destroyDojoDecoController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
@ -20,20 +18,9 @@ export const destroyDojoDecoController: RequestHandler = async (req, res) => {
 | 
			
		||||
        res.json({ DojoRequestStatus: -1 });
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
    const request = JSON.parse(String(req.body)) as IDestroyDojoDecoRequest | IClearObstacleCourseRequest;
 | 
			
		||||
    if ("DecoType" in request) {
 | 
			
		||||
        removeDojoDeco(guild, request.ComponentId, request.DecoId);
 | 
			
		||||
    } else if (request.Act == "cObst") {
 | 
			
		||||
        const component = guild.DojoComponents.id(request.ComponentId)!;
 | 
			
		||||
        if (component.Decos) {
 | 
			
		||||
            for (const deco of component.Decos) {
 | 
			
		||||
                refundDojoDeco(guild, component, deco);
 | 
			
		||||
            }
 | 
			
		||||
            component.Decos.splice(0, component.Decos.length);
 | 
			
		||||
        }
 | 
			
		||||
    } else {
 | 
			
		||||
        logger.error(`unhandled destroyDojoDeco request`, request);
 | 
			
		||||
    }
 | 
			
		||||
    const request = JSON.parse(String(req.body)) as IDestroyDojoDecoRequest;
 | 
			
		||||
 | 
			
		||||
    removeDojoDeco(guild, request.ComponentId, request.DecoId);
 | 
			
		||||
 | 
			
		||||
    await guild.save();
 | 
			
		||||
    res.json(await getDojoClient(guild, 0, request.ComponentId));
 | 
			
		||||
@ -44,8 +31,3 @@ interface IDestroyDojoDecoRequest {
 | 
			
		||||
    ComponentId: string;
 | 
			
		||||
    DecoId: string;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface IClearObstacleCourseRequest {
 | 
			
		||||
    ComponentId: string;
 | 
			
		||||
    Act: "cObst" | "maybesomethingelsewedontknowabout";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,9 +1,9 @@
 | 
			
		||||
import { Alliance, AllianceMember, Guild, GuildMember } from "../../models/guildModel.ts";
 | 
			
		||||
import { getAccountForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { GuildPermission } from "../../types/guildTypes.ts";
 | 
			
		||||
import { parallelForeach } from "../../utils/async-utils.ts";
 | 
			
		||||
import { logger } from "../../utils/logger.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { Alliance, AllianceMember, Guild, GuildMember } from "@/src/models/guildModel";
 | 
			
		||||
import { getAccountForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { GuildPermission } from "@/src/types/guildTypes";
 | 
			
		||||
import { parallelForeach } from "@/src/utils/async-utils";
 | 
			
		||||
import { logger } from "@/src/utils/logger";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const divvyAllianceVaultController: RequestHandler = async (req, res) => {
 | 
			
		||||
    // Afaict, there's no way to put anything other than credits in the alliance vault (anymore?), so just no-op if this is not a request to divvy credits.
 | 
			
		||||
 | 
			
		||||
@ -1,17 +1,10 @@
 | 
			
		||||
import type { TGuildDatabaseDocument } from "../../models/guildModel.ts";
 | 
			
		||||
import { GuildMember } from "../../models/guildModel.ts";
 | 
			
		||||
import {
 | 
			
		||||
    getDojoClient,
 | 
			
		||||
    getGuildForRequestEx,
 | 
			
		||||
    hasAccessToDojo,
 | 
			
		||||
    scaleRequiredCount
 | 
			
		||||
} from "../../services/guildService.ts";
 | 
			
		||||
import { getInventory, updateCurrency } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import type { IDojoContributable } from "../../types/guildTypes.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import type { IDojoBuild } from "warframe-public-export-plus";
 | 
			
		||||
import { ExportDojoRecipes } from "warframe-public-export-plus";
 | 
			
		||||
import { GuildMember, TGuildDatabaseDocument } from "@/src/models/guildModel";
 | 
			
		||||
import { getDojoClient, getGuildForRequestEx, hasAccessToDojo, scaleRequiredCount } from "@/src/services/guildService";
 | 
			
		||||
import { getInventory, updateCurrency } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { IDojoContributable } from "@/src/types/guildTypes";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { ExportDojoRecipes, IDojoBuild } from "warframe-public-export-plus";
 | 
			
		||||
 | 
			
		||||
interface IDojoComponentRushRequest {
 | 
			
		||||
    DecoType?: string;
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
// Arbiter Dojo endpoints, not really used by us as we don't provide a ContentURL.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,12 +1,13 @@
 | 
			
		||||
import { toMongoDate, toOid } from "../../helpers/inventoryHelpers.ts";
 | 
			
		||||
import { addMiscItems, getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { fromStoreItem } from "../../services/itemDataService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { getRandomInt, getRandomWeightedRewardUc } from "../../services/rngService.ts";
 | 
			
		||||
import type { IMongoDate, IOid } from "../../types/commonTypes.ts";
 | 
			
		||||
import type { IDroneClient } from "../../types/inventoryTypes/inventoryTypes.ts";
 | 
			
		||||
import type { IInventoryChanges } from "../../types/purchaseTypes.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { toMongoDate, toOid } from "@/src/helpers/inventoryHelpers";
 | 
			
		||||
import { config } from "@/src/services/configService";
 | 
			
		||||
import { addMiscItems, getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { fromStoreItem } from "@/src/services/itemDataService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { getRandomInt, getRandomWeightedRewardUc } from "@/src/services/rngService";
 | 
			
		||||
import { IMongoDate, IOid } from "@/src/types/commonTypes";
 | 
			
		||||
import { IDroneClient } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
			
		||||
import { IInventoryChanges } from "@/src/types/purchaseTypes";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { ExportDrones, ExportResources, ExportSystems } from "warframe-public-export-plus";
 | 
			
		||||
 | 
			
		||||
export const dronesController: RequestHandler = async (req, res) => {
 | 
			
		||||
@ -38,13 +39,10 @@ export const dronesController: RequestHandler = async (req, res) => {
 | 
			
		||||
            ActiveDrones: activeDrones
 | 
			
		||||
        });
 | 
			
		||||
    } else if ("droneId" in req.query && "systemIndex" in req.query) {
 | 
			
		||||
        const inventory = await getInventory(
 | 
			
		||||
            accountId,
 | 
			
		||||
            "Drones instantResourceExtractorDrones noResourceExtractorDronesDamage"
 | 
			
		||||
        );
 | 
			
		||||
        const inventory = await getInventory(accountId, "Drones");
 | 
			
		||||
        const drone = inventory.Drones.id(req.query.droneId as string)!;
 | 
			
		||||
        const droneMeta = ExportDrones[drone.ItemType];
 | 
			
		||||
        drone.DeployTime = inventory.instantResourceExtractorDrones ? new Date(0) : new Date();
 | 
			
		||||
        drone.DeployTime = config.instantResourceExtractorDrones ? new Date(0) : new Date();
 | 
			
		||||
        if (drone.RepairStart) {
 | 
			
		||||
            const repairMinutes = (Date.now() - drone.RepairStart.getTime()) / 60_000;
 | 
			
		||||
            const hpPerMinute = droneMeta.repairRate / 60;
 | 
			
		||||
@ -53,11 +51,11 @@ export const dronesController: RequestHandler = async (req, res) => {
 | 
			
		||||
        }
 | 
			
		||||
        drone.System = parseInt(req.query.systemIndex as string);
 | 
			
		||||
        const system = ExportSystems[drone.System - 1];
 | 
			
		||||
        drone.DamageTime = inventory.instantResourceExtractorDrones
 | 
			
		||||
        drone.DamageTime = config.instantResourceExtractorDrones
 | 
			
		||||
            ? new Date()
 | 
			
		||||
            : new Date(Date.now() + getRandomInt(3 * 3600 * 1000, 4 * 3600 * 1000));
 | 
			
		||||
        drone.PendingDamage =
 | 
			
		||||
            !inventory.noResourceExtractorDronesDamage && Math.random() < system.damageChance
 | 
			
		||||
            !config.noResourceExtractorDronesDamage && Math.random() < system.damageChance
 | 
			
		||||
                ? getRandomInt(system.droneDamage.minValue, system.droneDamage.maxValue)
 | 
			
		||||
                : 0;
 | 
			
		||||
        const resource = getRandomWeightedRewardUc(system.resources, droneMeta.probabilities)!;
 | 
			
		||||
@ -74,7 +72,7 @@ export const dronesController: RequestHandler = async (req, res) => {
 | 
			
		||||
                );
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            drone.ResourceCount = droneMeta.binCapacity * droneMeta.capacityMultipliers[resource.Rarity];
 | 
			
		||||
            drone.ResourceCount = 1;
 | 
			
		||||
        }
 | 
			
		||||
        await inventory.save();
 | 
			
		||||
        res.json({});
 | 
			
		||||
 | 
			
		||||
@ -1,18 +1,13 @@
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { combineInventoryChanges, getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
			
		||||
import type {
 | 
			
		||||
    IEndlessXpReward,
 | 
			
		||||
    IInventoryClient,
 | 
			
		||||
    TEndlessXpCategory
 | 
			
		||||
} from "../../types/inventoryTypes/inventoryTypes.ts";
 | 
			
		||||
import { logger } from "../../utils/logger.ts";
 | 
			
		||||
import type { ICountedStoreItem } from "warframe-public-export-plus";
 | 
			
		||||
import { ExportRewards } from "warframe-public-export-plus";
 | 
			
		||||
import { getRandomElement } from "../../services/rngService.ts";
 | 
			
		||||
import { handleStoreItemAcquisition } from "../../services/purchaseService.ts";
 | 
			
		||||
import type { IInventoryChanges } from "../../types/purchaseTypes.ts";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { combineInventoryChanges, getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { IEndlessXpReward, IInventoryClient, TEndlessXpCategory } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
			
		||||
import { logger } from "@/src/utils/logger";
 | 
			
		||||
import { ExportRewards, ICountedStoreItem } from "warframe-public-export-plus";
 | 
			
		||||
import { getRandomElement } from "@/src/services/rngService";
 | 
			
		||||
import { handleStoreItemAcquisition } from "@/src/services/purchaseService";
 | 
			
		||||
import { IInventoryChanges } from "@/src/types/purchaseTypes";
 | 
			
		||||
 | 
			
		||||
export const endlessXpController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
 | 
			
		||||
@ -1,8 +1,8 @@
 | 
			
		||||
import { toMongoDate } from "../../helpers/inventoryHelpers.ts";
 | 
			
		||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
			
		||||
import { getInventory, updateEntratiVault } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { toMongoDate } from "@/src/helpers/inventoryHelpers";
 | 
			
		||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const entratiLabConquestModeController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
@ -11,7 +11,26 @@ export const entratiLabConquestModeController: RequestHandler = async (req, res)
 | 
			
		||||
        "EntratiVaultCountResetDate EntratiVaultCountLastPeriod EntratiLabConquestUnlocked EchoesHexConquestUnlocked EchoesHexConquestActiveFrameVariants EchoesHexConquestActiveStickers EntratiLabConquestActiveFrameVariants EntratiLabConquestCacheScoreMission EchoesHexConquestCacheScoreMission"
 | 
			
		||||
    );
 | 
			
		||||
    const body = getJSONfromString<IEntratiLabConquestModeRequest>(String(req.body));
 | 
			
		||||
    updateEntratiVault(inventory);
 | 
			
		||||
    if (!inventory.EntratiVaultCountResetDate || Date.now() >= inventory.EntratiVaultCountResetDate.getTime()) {
 | 
			
		||||
        const EPOCH = 1734307200 * 1000; // Mondays, amirite?
 | 
			
		||||
        const day = Math.trunc((Date.now() - EPOCH) / 86400000);
 | 
			
		||||
        const week = Math.trunc(day / 7);
 | 
			
		||||
        const weekStart = EPOCH + week * 604800000;
 | 
			
		||||
        const weekEnd = weekStart + 604800000;
 | 
			
		||||
        inventory.EntratiVaultCountLastPeriod = 0;
 | 
			
		||||
        inventory.EntratiVaultCountResetDate = new Date(weekEnd);
 | 
			
		||||
        if (inventory.EntratiLabConquestUnlocked) {
 | 
			
		||||
            inventory.EntratiLabConquestUnlocked = 0;
 | 
			
		||||
            inventory.EntratiLabConquestCacheScoreMission = 0;
 | 
			
		||||
            inventory.EntratiLabConquestActiveFrameVariants = [];
 | 
			
		||||
        }
 | 
			
		||||
        if (inventory.EchoesHexConquestUnlocked) {
 | 
			
		||||
            inventory.EchoesHexConquestUnlocked = 0;
 | 
			
		||||
            inventory.EchoesHexConquestCacheScoreMission = 0;
 | 
			
		||||
            inventory.EchoesHexConquestActiveFrameVariants = [];
 | 
			
		||||
            inventory.EchoesHexConquestActiveStickers = [];
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    if (body.BuyMode) {
 | 
			
		||||
        inventory.EntratiVaultCountLastPeriod! += 2;
 | 
			
		||||
        if (body.IsEchoesDeepArchemedea) {
 | 
			
		||||
@ -32,7 +51,7 @@ export const entratiLabConquestModeController: RequestHandler = async (req, res)
 | 
			
		||||
    }
 | 
			
		||||
    await inventory.save();
 | 
			
		||||
    res.json({
 | 
			
		||||
        EntratiVaultCountResetDate: toMongoDate(inventory.EntratiVaultCountResetDate!),
 | 
			
		||||
        EntratiVaultCountResetDate: toMongoDate(inventory.EntratiVaultCountResetDate),
 | 
			
		||||
        EntratiVaultCountLastPeriod: inventory.EntratiVaultCountLastPeriod,
 | 
			
		||||
        EntratiLabConquestUnlocked: inventory.EntratiLabConquestUnlocked,
 | 
			
		||||
        EntratiLabConquestCacheScoreMission: inventory.EntratiLabConquestCacheScoreMission,
 | 
			
		||||
 | 
			
		||||
@ -1,10 +1,9 @@
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { addMiscItems, getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
			
		||||
import type { WeaponTypeInternal } from "../../services/itemDataService.ts";
 | 
			
		||||
import { getRecipe } from "../../services/itemDataService.ts";
 | 
			
		||||
import { EquipmentFeatures } from "../../types/equipmentTypes.ts";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { addMiscItems, getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { getRecipe, WeaponTypeInternal } from "@/src/services/itemDataService";
 | 
			
		||||
import { EquipmentFeatures } from "@/src/types/inventoryTypes/commonInventoryTypes";
 | 
			
		||||
 | 
			
		||||
export const evolveWeaponController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
 | 
			
		||||
@ -1,62 +0,0 @@
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { addMiscItem, getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
			
		||||
import { logger } from "../../utils/logger.ts";
 | 
			
		||||
import type { IInventoryChanges } from "../../types/purchaseTypes.ts";
 | 
			
		||||
 | 
			
		||||
export const feedPrinceController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
    const inventory = await getInventory(accountId, "MiscItems NokkoColony NodeIntrosCompleted");
 | 
			
		||||
    const payload = getJSONfromString<IFeedPrinceRequest>(String(req.body));
 | 
			
		||||
 | 
			
		||||
    switch (payload.Mode) {
 | 
			
		||||
        case "r": {
 | 
			
		||||
            inventory.NokkoColony ??= {
 | 
			
		||||
                FeedLevel: 0,
 | 
			
		||||
                JournalEntries: []
 | 
			
		||||
            };
 | 
			
		||||
            const InventoryChanges: IInventoryChanges = {};
 | 
			
		||||
            inventory.NokkoColony.FeedLevel += payload.Amount;
 | 
			
		||||
            if (
 | 
			
		||||
                (!inventory.NodeIntrosCompleted.includes("CompletedVision1") && inventory.NokkoColony.FeedLevel > 20) ||
 | 
			
		||||
                (!inventory.NodeIntrosCompleted.includes("CompletedVision2") && inventory.NokkoColony.FeedLevel > 60)
 | 
			
		||||
            ) {
 | 
			
		||||
                res.json({
 | 
			
		||||
                    FeedSucceeded: false,
 | 
			
		||||
                    FeedLevel: inventory.NokkoColony.FeedLevel - payload.Amount,
 | 
			
		||||
                    InventoryChanges
 | 
			
		||||
                } satisfies IFeedPrinceResponse);
 | 
			
		||||
            } else {
 | 
			
		||||
                addMiscItem(
 | 
			
		||||
                    inventory,
 | 
			
		||||
                    "/Lotus/Types/Items/MiscItems/MushroomFood",
 | 
			
		||||
                    payload.Amount * -1,
 | 
			
		||||
                    InventoryChanges
 | 
			
		||||
                );
 | 
			
		||||
                await inventory.save();
 | 
			
		||||
                res.json({
 | 
			
		||||
                    FeedSucceeded: true,
 | 
			
		||||
                    FeedLevel: inventory.NokkoColony.FeedLevel,
 | 
			
		||||
                    InventoryChanges
 | 
			
		||||
                } satisfies IFeedPrinceResponse);
 | 
			
		||||
            }
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        default:
 | 
			
		||||
            logger.debug(`data provided to ${req.path}: ${String(req.body)}`);
 | 
			
		||||
            throw new Error(`unknown feedPrince mode: ${payload.Mode}`);
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
interface IFeedPrinceRequest {
 | 
			
		||||
    Mode: string; // r
 | 
			
		||||
    Amount: number;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface IFeedPrinceResponse {
 | 
			
		||||
    FeedSucceeded: boolean;
 | 
			
		||||
    FeedLevel: number;
 | 
			
		||||
    InventoryChanges: IInventoryChanges;
 | 
			
		||||
}
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getSession } from "../../managers/sessionManager.ts";
 | 
			
		||||
import { logger } from "../../utils/logger.ts";
 | 
			
		||||
import type { IFindSessionRequest } from "../../types/session.ts";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { getSession } from "@/src/managers/sessionManager";
 | 
			
		||||
import { logger } from "@/src/utils/logger";
 | 
			
		||||
import { IFindSessionRequest } from "@/src/types/session";
 | 
			
		||||
 | 
			
		||||
export const findSessionsController: RequestHandler = (_req, res) => {
 | 
			
		||||
    const req = JSON.parse(String(_req.body)) as IFindSessionRequest;
 | 
			
		||||
 | 
			
		||||
@ -1,8 +1,8 @@
 | 
			
		||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
			
		||||
import { addMiscItems, addStanding, getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import type { IMiscItem } from "../../types/inventoryTypes/inventoryTypes.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { addMiscItems, addStanding, getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { ExportResources } from "warframe-public-export-plus";
 | 
			
		||||
 | 
			
		||||
export const fishmongerController: RequestHandler = async (req, res) => {
 | 
			
		||||
@ -30,14 +30,15 @@ export const fishmongerController: RequestHandler = async (req, res) => {
 | 
			
		||||
        miscItemChanges.push({ ItemType: fish.ItemType, ItemCount: fish.ItemCount * -1 });
 | 
			
		||||
    }
 | 
			
		||||
    addMiscItems(inventory, miscItemChanges);
 | 
			
		||||
    if (gainedStanding && syndicateTag) addStanding(inventory, syndicateTag, gainedStanding);
 | 
			
		||||
    let affiliationMod;
 | 
			
		||||
    if (gainedStanding && syndicateTag) affiliationMod = addStanding(inventory, syndicateTag, gainedStanding);
 | 
			
		||||
    await inventory.save();
 | 
			
		||||
    res.json({
 | 
			
		||||
        InventoryChanges: {
 | 
			
		||||
            MiscItems: miscItemChanges
 | 
			
		||||
        },
 | 
			
		||||
        SyndicateTag: syndicateTag,
 | 
			
		||||
        StandingChange: gainedStanding
 | 
			
		||||
        StandingChange: affiliationMod?.Standing || 0
 | 
			
		||||
    });
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,91 +1,23 @@
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getAccountForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { getInventory, addMiscItems, addEquipment, occupySlot } from "../../services/inventoryService.ts";
 | 
			
		||||
import type { IMiscItem, TFocusPolarity, TEquipmentKey } from "../../types/inventoryTypes/inventoryTypes.ts";
 | 
			
		||||
import { InventorySlot } from "../../types/inventoryTypes/inventoryTypes.ts";
 | 
			
		||||
import { logger } from "../../utils/logger.ts";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { getInventory, addMiscItems, addEquipment, occupySlot } from "@/src/services/inventoryService";
 | 
			
		||||
import { IMiscItem, TFocusPolarity, TEquipmentKey, InventorySlot } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
			
		||||
import { logger } from "@/src/utils/logger";
 | 
			
		||||
import { ExportFocusUpgrades } from "warframe-public-export-plus";
 | 
			
		||||
import { Inventory } from "../../models/inventoryModels/inventoryModel.ts";
 | 
			
		||||
import { version_compare } from "../../helpers/inventoryHelpers.ts";
 | 
			
		||||
import { IEquipmentClient } from "@/src/types/inventoryTypes/commonInventoryTypes";
 | 
			
		||||
import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
 | 
			
		||||
 | 
			
		||||
export const focusController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const account = await getAccountForRequest(req);
 | 
			
		||||
 | 
			
		||||
    let op = req.query.op as string;
 | 
			
		||||
    const focus2 = account.BuildLabel && version_compare(account.BuildLabel, "2022.04.29.12.53") < 0;
 | 
			
		||||
    if (focus2) {
 | 
			
		||||
        // Focus 2.0
 | 
			
		||||
        switch (req.query.op) {
 | 
			
		||||
            case Focus2Operation.InstallLens:
 | 
			
		||||
                op = "InstallLens";
 | 
			
		||||
                break;
 | 
			
		||||
            case Focus2Operation.UnlockWay:
 | 
			
		||||
                op = "UnlockWay";
 | 
			
		||||
                break;
 | 
			
		||||
            case Focus2Operation.UnlockUpgrade:
 | 
			
		||||
                op = "UnlockUpgrade";
 | 
			
		||||
                break;
 | 
			
		||||
            case Focus2Operation.IncreasePool:
 | 
			
		||||
                op = "IncreasePool";
 | 
			
		||||
                break;
 | 
			
		||||
            case Focus2Operation.LevelUpUpgrade:
 | 
			
		||||
                op = "LevelUpUpgrade";
 | 
			
		||||
                break;
 | 
			
		||||
            case Focus2Operation.ActivateWay:
 | 
			
		||||
                op = "ActivateWay";
 | 
			
		||||
                break;
 | 
			
		||||
            case Focus2Operation.UpdateUpgrade:
 | 
			
		||||
                op = "UpdateUpgrade";
 | 
			
		||||
                break;
 | 
			
		||||
            case Focus2Operation.SentTrainingAmplifier:
 | 
			
		||||
                op = "SentTrainingAmplifier";
 | 
			
		||||
                break;
 | 
			
		||||
            case Focus2Operation.UnbindUpgrade:
 | 
			
		||||
                op = "UnbindUpgrade";
 | 
			
		||||
                break;
 | 
			
		||||
            case Focus2Operation.ConvertShard:
 | 
			
		||||
                op = "ConvertShard";
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
    } else {
 | 
			
		||||
        // Focus 3.0
 | 
			
		||||
        switch (req.query.op) {
 | 
			
		||||
            case Focus3Operation.InstallLens:
 | 
			
		||||
                op = "InstallLens";
 | 
			
		||||
                break;
 | 
			
		||||
            case Focus3Operation.UnlockWay:
 | 
			
		||||
                op = "UnlockWay";
 | 
			
		||||
                break;
 | 
			
		||||
            case Focus3Operation.UnlockUpgrade:
 | 
			
		||||
                op = "UnlockUpgrade";
 | 
			
		||||
                break;
 | 
			
		||||
            case Focus3Operation.LevelUpUpgrade:
 | 
			
		||||
                op = "LevelUpUpgrade";
 | 
			
		||||
                break;
 | 
			
		||||
            case Focus3Operation.ActivateWay:
 | 
			
		||||
                op = "ActivateWay";
 | 
			
		||||
                break;
 | 
			
		||||
            case Focus3Operation.SentTrainingAmplifier:
 | 
			
		||||
                op = "SentTrainingAmplifier";
 | 
			
		||||
                break;
 | 
			
		||||
            case Focus3Operation.UnbindUpgrade:
 | 
			
		||||
                op = "UnbindUpgrade";
 | 
			
		||||
                break;
 | 
			
		||||
            case Focus3Operation.ConvertShard:
 | 
			
		||||
                op = "ConvertShard";
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    switch (op) {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
    switch (req.query.op) {
 | 
			
		||||
        default:
 | 
			
		||||
            logger.error("Unhandled focus op type: " + String(req.query.op));
 | 
			
		||||
            logger.debug(String(req.body));
 | 
			
		||||
            res.end();
 | 
			
		||||
            break;
 | 
			
		||||
        case "InstallLens": {
 | 
			
		||||
        case FocusOperation.InstallLens: {
 | 
			
		||||
            const request = JSON.parse(String(req.body)) as ILensInstallRequest;
 | 
			
		||||
            const inventory = await getInventory(account._id.toString());
 | 
			
		||||
            const inventory = await getInventory(accountId);
 | 
			
		||||
            const item = inventory[request.Category].id(request.WeaponId);
 | 
			
		||||
            if (item) {
 | 
			
		||||
                item.FocusLens = request.LensType;
 | 
			
		||||
@ -103,15 +35,15 @@ export const focusController: RequestHandler = async (req, res) => {
 | 
			
		||||
            });
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        case "UnlockWay": {
 | 
			
		||||
        case FocusOperation.UnlockWay: {
 | 
			
		||||
            const focusType = (JSON.parse(String(req.body)) as IWayRequest).FocusType;
 | 
			
		||||
            const focusPolarity = focusTypeToPolarity(focusType);
 | 
			
		||||
            const inventory = await getInventory(account._id.toString(), "FocusAbility FocusUpgrades FocusXP");
 | 
			
		||||
            const inventory = await getInventory(accountId);
 | 
			
		||||
            const cost = inventory.FocusAbility ? 50_000 : 0;
 | 
			
		||||
            inventory.FocusAbility ??= focusType;
 | 
			
		||||
            inventory.FocusUpgrades.push({ ItemType: focusType });
 | 
			
		||||
            if (cost) {
 | 
			
		||||
                inventory.FocusXP![focusPolarity]! -= cost;
 | 
			
		||||
            if (inventory.FocusXP) {
 | 
			
		||||
                inventory.FocusXP[focusPolarity] -= cost;
 | 
			
		||||
            }
 | 
			
		||||
            await inventory.save();
 | 
			
		||||
            res.json({
 | 
			
		||||
@ -120,29 +52,12 @@ export const focusController: RequestHandler = async (req, res) => {
 | 
			
		||||
            });
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        case "IncreasePool": {
 | 
			
		||||
            const request = JSON.parse(String(req.body)) as IIncreasePoolRequest;
 | 
			
		||||
            const focusPolarity = focusTypeToPolarity(request.FocusType);
 | 
			
		||||
            const inventory = await getInventory(account._id.toString(), "FocusXP FocusCapacity");
 | 
			
		||||
            let cost = 0;
 | 
			
		||||
            for (let capacity = request.CurrentTotalCapacity; capacity != request.NewTotalCapacity; ++capacity) {
 | 
			
		||||
                cost += increasePoolCost[capacity - 5];
 | 
			
		||||
            }
 | 
			
		||||
            inventory.FocusXP![focusPolarity]! -= cost;
 | 
			
		||||
            inventory.FocusCapacity = request.NewTotalCapacity;
 | 
			
		||||
            await inventory.save();
 | 
			
		||||
            res.json({
 | 
			
		||||
                TotalCapacity: request.NewTotalCapacity,
 | 
			
		||||
                FocusPointCosts: { [focusPolarity]: cost }
 | 
			
		||||
            });
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        case "ActivateWay": {
 | 
			
		||||
        case FocusOperation.ActivateWay: {
 | 
			
		||||
            const focusType = (JSON.parse(String(req.body)) as IWayRequest).FocusType;
 | 
			
		||||
 | 
			
		||||
            await Inventory.updateOne(
 | 
			
		||||
                {
 | 
			
		||||
                    accountOwnerId: account._id.toString()
 | 
			
		||||
                    accountOwnerId: accountId
 | 
			
		||||
                },
 | 
			
		||||
                {
 | 
			
		||||
                    FocusAbility: focusType
 | 
			
		||||
@ -154,23 +69,16 @@ export const focusController: RequestHandler = async (req, res) => {
 | 
			
		||||
            });
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        case "UnlockUpgrade": {
 | 
			
		||||
        case FocusOperation.UnlockUpgrade: {
 | 
			
		||||
            const request = JSON.parse(String(req.body)) as IUnlockUpgradeRequest;
 | 
			
		||||
            const focusPolarity = focusTypeToPolarity(request.FocusTypes[0]);
 | 
			
		||||
            const inventory = await getInventory(account._id.toString());
 | 
			
		||||
            const inventory = await getInventory(accountId);
 | 
			
		||||
            let cost = 0;
 | 
			
		||||
            for (const focusType of request.FocusTypes) {
 | 
			
		||||
                if (focusType in ExportFocusUpgrades) {
 | 
			
		||||
                    cost += ExportFocusUpgrades[focusType].baseFocusPointCost;
 | 
			
		||||
                } else if (focusType == "/Lotus/Upgrades/Focus/Power/Residual/ChannelEfficiencyFocusUpgrade") {
 | 
			
		||||
                    // Zenurik's Inner Might (Focus 2.0)
 | 
			
		||||
                    cost += 50_000;
 | 
			
		||||
                } else {
 | 
			
		||||
                    logger.warn(`unknown focus upgrade ${focusType}, will unlock it for free`);
 | 
			
		||||
                }
 | 
			
		||||
                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,
 | 
			
		||||
@ -178,22 +86,17 @@ export const focusController: RequestHandler = async (req, res) => {
 | 
			
		||||
            });
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        case "LevelUpUpgrade":
 | 
			
		||||
        case "UpdateUpgrade": {
 | 
			
		||||
        case FocusOperation.LevelUpUpgrade: {
 | 
			
		||||
            const request = JSON.parse(String(req.body)) as ILevelUpUpgradeRequest;
 | 
			
		||||
            const focusPolarity = focusTypeToPolarity(request.FocusInfos[0].ItemType);
 | 
			
		||||
            const inventory = await getInventory(account._id.toString());
 | 
			
		||||
            const inventory = await getInventory(accountId);
 | 
			
		||||
            let cost = 0;
 | 
			
		||||
            for (const focusUpgrade of request.FocusInfos) {
 | 
			
		||||
                cost += focusUpgrade.FocusXpCost;
 | 
			
		||||
                const focusUpgradeDb = inventory.FocusUpgrades.find(entry => entry.ItemType == focusUpgrade.ItemType)!;
 | 
			
		||||
                if (op == "UpdateUpgrade") {
 | 
			
		||||
                    focusUpgradeDb.IsActive = focusUpgrade.IsActive;
 | 
			
		||||
                } else {
 | 
			
		||||
                    focusUpgradeDb.Level = focusUpgrade.Level;
 | 
			
		||||
                }
 | 
			
		||||
                focusUpgradeDb.Level = focusUpgrade.Level;
 | 
			
		||||
            }
 | 
			
		||||
            inventory.FocusXP![focusPolarity]! -= cost;
 | 
			
		||||
            inventory.FocusXP![focusPolarity] -= cost;
 | 
			
		||||
            await inventory.save();
 | 
			
		||||
            res.json({
 | 
			
		||||
                FocusInfos: request.FocusInfos,
 | 
			
		||||
@ -201,9 +104,9 @@ export const focusController: RequestHandler = async (req, res) => {
 | 
			
		||||
            });
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        case "SentTrainingAmplifier": {
 | 
			
		||||
        case FocusOperation.SentTrainingAmplifier: {
 | 
			
		||||
            const request = JSON.parse(String(req.body)) as ISentTrainingAmplifierRequest;
 | 
			
		||||
            const inventory = await getInventory(account._id.toString());
 | 
			
		||||
            const inventory = await getInventory(accountId);
 | 
			
		||||
            const inventoryChanges = addEquipment(inventory, "OperatorAmps", request.StartingWeaponType, {
 | 
			
		||||
                ModularParts: [
 | 
			
		||||
                    "/Lotus/Weapons/Sentients/OperatorAmplifiers/SentTrainingAmplifier/SentAmpTrainingGrip",
 | 
			
		||||
@ -213,14 +116,14 @@ export const focusController: RequestHandler = async (req, res) => {
 | 
			
		||||
            });
 | 
			
		||||
            occupySlot(inventory, InventorySlot.AMPS, false);
 | 
			
		||||
            await inventory.save();
 | 
			
		||||
            res.json(inventoryChanges.OperatorAmps![0]);
 | 
			
		||||
            res.json((inventoryChanges.OperatorAmps as IEquipmentClient[])[0]);
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        case "UnbindUpgrade": {
 | 
			
		||||
        case FocusOperation.UnbindUpgrade: {
 | 
			
		||||
            const request = JSON.parse(String(req.body)) as IUnbindUpgradeRequest;
 | 
			
		||||
            const focusPolarity = focusTypeToPolarity(request.FocusTypes[0]);
 | 
			
		||||
            const inventory = await getInventory(account._id.toString());
 | 
			
		||||
            inventory.FocusXP![focusPolarity]! -= 750_000 * request.FocusTypes.length;
 | 
			
		||||
            const inventory = await getInventory(accountId);
 | 
			
		||||
            inventory.FocusXP![focusPolarity] -= 750_000 * request.FocusTypes.length;
 | 
			
		||||
            addMiscItems(inventory, [
 | 
			
		||||
                {
 | 
			
		||||
                    ItemType: "/Lotus/Types/Gameplay/Eidolon/Resources/SentientShards/SentientShardBrilliantItem",
 | 
			
		||||
@ -246,7 +149,7 @@ export const focusController: RequestHandler = async (req, res) => {
 | 
			
		||||
            });
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        case "ConvertShard": {
 | 
			
		||||
        case FocusOperation.ConvertShard: {
 | 
			
		||||
            const request = JSON.parse(String(req.body)) as IConvertShardRequest;
 | 
			
		||||
            // Tally XP
 | 
			
		||||
            let xp = 0;
 | 
			
		||||
@ -264,11 +167,9 @@ export const focusController: RequestHandler = async (req, res) => {
 | 
			
		||||
            for (const shard of request.Shards) {
 | 
			
		||||
                shard.ItemCount *= -1;
 | 
			
		||||
            }
 | 
			
		||||
            const inventory = await getInventory(account._id.toString());
 | 
			
		||||
            const polarity = request.Polarity;
 | 
			
		||||
            inventory.FocusXP ??= {};
 | 
			
		||||
            inventory.FocusXP[polarity] ??= 0;
 | 
			
		||||
            inventory.FocusXP[polarity] += xp;
 | 
			
		||||
            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;
 | 
			
		||||
            addMiscItems(inventory, request.Shards);
 | 
			
		||||
            await inventory.save();
 | 
			
		||||
            break;
 | 
			
		||||
@ -276,8 +177,7 @@ export const focusController: RequestHandler = async (req, res) => {
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// Focus 3.0
 | 
			
		||||
enum Focus3Operation {
 | 
			
		||||
enum FocusOperation {
 | 
			
		||||
    InstallLens = "1",
 | 
			
		||||
    UnlockWay = "2",
 | 
			
		||||
    UnlockUpgrade = "3",
 | 
			
		||||
@ -288,20 +188,6 @@ enum Focus3Operation {
 | 
			
		||||
    ConvertShard = "9"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Focus 2.0
 | 
			
		||||
enum Focus2Operation {
 | 
			
		||||
    InstallLens = "1",
 | 
			
		||||
    UnlockWay = "2",
 | 
			
		||||
    UnlockUpgrade = "3",
 | 
			
		||||
    IncreasePool = "4",
 | 
			
		||||
    LevelUpUpgrade = "5",
 | 
			
		||||
    ActivateWay = "6",
 | 
			
		||||
    UpdateUpgrade = "7", // used to change the IsActive state, same format as ILevelUpUpgradeRequest
 | 
			
		||||
    SentTrainingAmplifier = "9",
 | 
			
		||||
    UnbindUpgrade = "10",
 | 
			
		||||
    ConvertShard = "11"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// For UnlockWay & ActivateWay
 | 
			
		||||
interface IWayRequest {
 | 
			
		||||
    FocusType: string;
 | 
			
		||||
@ -311,13 +197,6 @@ interface IUnlockUpgradeRequest {
 | 
			
		||||
    FocusTypes: string[];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Focus 2.0
 | 
			
		||||
interface IIncreasePoolRequest {
 | 
			
		||||
    FocusType: string;
 | 
			
		||||
    CurrentTotalCapacity: number;
 | 
			
		||||
    NewTotalCapacity: number;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface ILevelUpUpgradeRequest {
 | 
			
		||||
    FocusInfos: {
 | 
			
		||||
        ItemType: string;
 | 
			
		||||
@ -325,7 +204,6 @@ interface ILevelUpUpgradeRequest {
 | 
			
		||||
        IsUniversal: boolean;
 | 
			
		||||
        Level: number;
 | 
			
		||||
        IsActiveAbility: boolean;
 | 
			
		||||
        IsActive?: number; // Focus 2.0
 | 
			
		||||
    }[];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -351,7 +229,7 @@ interface ILensInstallRequest {
 | 
			
		||||
 | 
			
		||||
// Works for ways & upgrades
 | 
			
		||||
const focusTypeToPolarity = (type: string): TFocusPolarity => {
 | 
			
		||||
    return ("AP_" + type.substring(1).split("/")[3].toUpperCase()) as TFocusPolarity;
 | 
			
		||||
    return ("AP_" + type.substr(1).split("/")[3].toUpperCase()) as TFocusPolarity;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const shardValues = {
 | 
			
		||||
@ -360,19 +238,3 @@ const shardValues = {
 | 
			
		||||
    "/Lotus/Types/Gameplay/Eidolon/Resources/SentientShards/SentientShardBrilliantItem": 25_000,
 | 
			
		||||
    "/Lotus/Types/Gameplay/Eidolon/Resources/SentientShards/SentientShardBrilliantTierTwoItem": 40_000
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// Starting at a capacity of 5 (Source: https://wiki.warframe.com/w/Focus_2.0)
 | 
			
		||||
const increasePoolCost = [
 | 
			
		||||
    2576, 3099, 3638, 4190, 4755, 5331, 5918, 6514, 7120, 7734, 8357, 8988, 9626, 10271, 10923, 11582, 12247, 12918,
 | 
			
		||||
    13595, 14277, 14965, 15659, 16357, 17061, 17769, 18482, 19200, 19922, 20649, 21380, 22115, 22854, 23597, 24344,
 | 
			
		||||
    25095, 25850, 26609, 27371, 28136, 28905, 29678, 30454, 31233, 32015, 32801, 33590, 34382, 35176, 35974, 36775,
 | 
			
		||||
    37579, 38386, 39195, 40008, 40823, 41641, 42461, 43284, 44110, 44938, 45769, 46603, 47439, 48277, 49118, 49961,
 | 
			
		||||
    50807, 51655, 52505, 53357, 54212, 55069, 55929, 56790, 57654, 58520, 59388, 60258, 61130, 62005, 62881, 63759,
 | 
			
		||||
    64640, 65522, 66407, 67293, 68182, 69072, 69964, 70858, 71754, 72652, 73552, 74453, 75357, 76262, 77169, 78078,
 | 
			
		||||
    78988, 79900, 80814, 81730, 82648, 83567, 84488, 85410, 86334, 87260, 88188, 89117, 90047, 90980, 91914, 92849,
 | 
			
		||||
    93786, 94725, 95665, 96607, 97550, 98495, 99441, 100389, 101338, 102289, 103241, 104195, 105150, 106107, 107065,
 | 
			
		||||
    108024, 108985, 109948, 110911, 111877, 112843, 113811, 114780, 115751, 116723, 117696, 118671, 119647, 120624,
 | 
			
		||||
    121603, 122583, 123564, 124547, 125531, 126516, 127503, 128490, 129479, 130470, 131461, 132454, 133448, 134443,
 | 
			
		||||
    135440, 136438, 137437, 138437, 139438, 140441, 141444, 142449, 143455, 144463, 145471, 146481, 147492, 148503,
 | 
			
		||||
    149517
 | 
			
		||||
];
 | 
			
		||||
 | 
			
		||||
@ -1,27 +0,0 @@
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
			
		||||
import { getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import type { IInventoryChanges } from "../../types/purchaseTypes.ts";
 | 
			
		||||
 | 
			
		||||
export const forceRemoveItemController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
    const inventory = await getInventory(accountId, "MiscItems");
 | 
			
		||||
    const body = getJSONfromString<IForceRemoveItemRequest>(String(req.body));
 | 
			
		||||
    const inventoryChanges: IInventoryChanges = {};
 | 
			
		||||
    for (const item of body.items) {
 | 
			
		||||
        const index = inventory.MiscItems.findIndex(x => x.ItemType == item);
 | 
			
		||||
        if (index != -1) {
 | 
			
		||||
            inventoryChanges.MiscItems ??= [];
 | 
			
		||||
            inventoryChanges.MiscItems.push({ ItemType: item, ItemCount: inventory.MiscItems[index].ItemCount * -1 });
 | 
			
		||||
 | 
			
		||||
            inventory.MiscItems.splice(index, 1);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    await inventory.save();
 | 
			
		||||
    res.json({ InventoryChanges: inventoryChanges });
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
interface IForceRemoveItemRequest {
 | 
			
		||||
    items: string[];
 | 
			
		||||
}
 | 
			
		||||
@ -1,15 +1,23 @@
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { ExportResources } from "warframe-public-export-plus";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { addFusionTreasures, addMiscItems, getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import type { IMiscItem } from "../../types/inventoryTypes/inventoryTypes.ts";
 | 
			
		||||
import { parseFusionTreasure } from "../../helpers/inventoryHelpers.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { addFusionTreasures, addMiscItems, getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { IFusionTreasure, IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
			
		||||
 | 
			
		||||
interface IFusionTreasureRequest {
 | 
			
		||||
    oldTreasureName: string;
 | 
			
		||||
    newTreasureName: string;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const parseFusionTreasure = (name: string, count: number): IFusionTreasure => {
 | 
			
		||||
    const arr = name.split("_");
 | 
			
		||||
    return {
 | 
			
		||||
        ItemType: arr[0],
 | 
			
		||||
        Sockets: parseInt(arr[1], 16),
 | 
			
		||||
        ItemCount: count
 | 
			
		||||
    };
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const fusionTreasuresController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
    const inventory = await getInventory(accountId);
 | 
			
		||||
 | 
			
		||||
@ -1,14 +1,15 @@
 | 
			
		||||
import { toMongoDate } from "../../helpers/inventoryHelpers.ts";
 | 
			
		||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
			
		||||
import { addMiscItem, getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { toStoreItem } from "../../services/itemDataService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { createGarden, getPersonalRooms } from "../../services/personalRoomsService.ts";
 | 
			
		||||
import type { IMongoDate } from "../../types/commonTypes.ts";
 | 
			
		||||
import type { IMissionReward } from "../../types/missionTypes.ts";
 | 
			
		||||
import type { IGardeningClient, IPersonalRoomsClient } from "../../types/personalRoomsTypes.ts";
 | 
			
		||||
import type { IInventoryChanges } from "../../types/purchaseTypes.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { toMongoDate } from "@/src/helpers/inventoryHelpers";
 | 
			
		||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { addMiscItem, getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { toStoreItem } from "@/src/services/itemDataService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { createGarden, getPersonalRooms } from "@/src/services/personalRoomsService";
 | 
			
		||||
import { IMongoDate } from "@/src/types/commonTypes";
 | 
			
		||||
import { IMissionReward } from "@/src/types/missionTypes";
 | 
			
		||||
import { IPersonalRoomsClient } from "@/src/types/personalRoomsTypes";
 | 
			
		||||
import { IInventoryChanges } from "@/src/types/purchaseTypes";
 | 
			
		||||
import { IGardeningClient } from "@/src/types/shipTypes";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { dict_en, ExportResources } from "warframe-public-export-plus";
 | 
			
		||||
 | 
			
		||||
export const gardeningController: RequestHandler = async (req, res) => {
 | 
			
		||||
 | 
			
		||||
@ -1,8 +1,8 @@
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { updateGeneric } from "../../services/inventoryService.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
			
		||||
import type { IGenericUpdate } from "../../types/genericUpdate.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { updateGeneric } from "@/src/services/inventoryService";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { IGenericUpdate } from "@/src/types/genericUpdate";
 | 
			
		||||
 | 
			
		||||
// This endpoint used to be /api/genericUpdate.php, but sometime around the Jade Shadows update, it was changed to /api/updateNodeIntros.php.
 | 
			
		||||
// SpaceNinjaServer supports both endpoints right now.
 | 
			
		||||
 | 
			
		||||
@ -1,8 +1,8 @@
 | 
			
		||||
import { Alliance, Guild } from "../../models/guildModel.ts";
 | 
			
		||||
import { getAllianceClient } from "../../services/guildService.ts";
 | 
			
		||||
import { getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { Alliance, Guild } from "@/src/models/guildModel";
 | 
			
		||||
import { getAllianceClient } from "@/src/services/guildService";
 | 
			
		||||
import { getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const getAllianceController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
 | 
			
		||||
@ -1,10 +1,8 @@
 | 
			
		||||
import { DailyDeal } from "../../models/worldStateModel.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const getDailyDealStockLevelsController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const dailyDeal = (await DailyDeal.findOne({ StoreItem: req.query.productName }, "AmountSold"))!;
 | 
			
		||||
export const getDailyDealStockLevelsController: RequestHandler = (req, res) => {
 | 
			
		||||
    res.json({
 | 
			
		||||
        StoreItem: req.query.productName,
 | 
			
		||||
        AmountSold: dailyDeal.AmountSold
 | 
			
		||||
        AmountSold: 0
 | 
			
		||||
    });
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -1,9 +1,9 @@
 | 
			
		||||
import { toOid } from "../../helpers/inventoryHelpers.ts";
 | 
			
		||||
import { Friendship } from "../../models/friendModel.ts";
 | 
			
		||||
import { addAccountDataToFriendInfo, addInventoryDataToFriendInfo } from "../../services/friendService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import type { IFriendInfo } from "../../types/friendTypes.ts";
 | 
			
		||||
import type { Request, RequestHandler, Response } from "express";
 | 
			
		||||
import { toOid } from "@/src/helpers/inventoryHelpers";
 | 
			
		||||
import { Friendship } from "@/src/models/friendModel";
 | 
			
		||||
import { addAccountDataToFriendInfo, addInventoryDataToFriendInfo } from "@/src/services/friendService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { IFriendInfo } from "@/src/types/friendTypes";
 | 
			
		||||
import { Request, RequestHandler, Response } from "express";
 | 
			
		||||
 | 
			
		||||
// POST with {} instead of GET as of 38.5.0
 | 
			
		||||
export const getFriendsController: RequestHandler = async (req: Request, res: Response) => {
 | 
			
		||||
 | 
			
		||||
@ -1,8 +1,8 @@
 | 
			
		||||
import { GuildMember } from "../../models/guildModel.ts";
 | 
			
		||||
import { getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import type { IGuildMemberClient } from "../../types/guildTypes.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { GuildMember } from "@/src/models/guildModel";
 | 
			
		||||
import { getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { IGuildMemberClient } from "@/src/types/guildTypes";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const getGuildContributionsController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
 | 
			
		||||
@ -1,9 +1,9 @@
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { Guild } from "../../models/guildModel.ts";
 | 
			
		||||
import { getAccountForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { logger } from "../../utils/logger.ts";
 | 
			
		||||
import { getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { createUniqueClanName, getGuildClient } from "../../services/guildService.ts";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { Guild } from "@/src/models/guildModel";
 | 
			
		||||
import { getAccountForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { logger } from "@/src/utils/logger";
 | 
			
		||||
import { getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { createUniqueClanName, getGuildClient } from "@/src/services/guildService";
 | 
			
		||||
 | 
			
		||||
export const getGuildController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const account = await getAccountForRequest(req);
 | 
			
		||||
 | 
			
		||||
@ -1,8 +1,8 @@
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { Types } from "mongoose";
 | 
			
		||||
import { Guild } from "../../models/guildModel.ts";
 | 
			
		||||
import { getDojoClient } from "../../services/guildService.ts";
 | 
			
		||||
import { Account } from "../../models/loginModel.ts";
 | 
			
		||||
import { Guild } from "@/src/models/guildModel";
 | 
			
		||||
import { getDojoClient } from "@/src/services/guildService";
 | 
			
		||||
import { Account } from "@/src/models/loginModel";
 | 
			
		||||
 | 
			
		||||
export const getGuildDojoController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const guildId = req.query.guildId as string;
 | 
			
		||||
@ -19,7 +19,7 @@ export const getGuildDojoController: RequestHandler = async (req, res) => {
 | 
			
		||||
            _id: new Types.ObjectId(),
 | 
			
		||||
            pf: "/Lotus/Levels/ClanDojo/DojoHall.level",
 | 
			
		||||
            ppf: "",
 | 
			
		||||
            CompletionTime: new Date(Date.now() - 1000),
 | 
			
		||||
            CompletionTime: new Date(Date.now()),
 | 
			
		||||
            DecoCapacity: 600
 | 
			
		||||
        });
 | 
			
		||||
        await guild.save();
 | 
			
		||||
 | 
			
		||||
@ -1,26 +0,0 @@
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getAccountForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { Guild } from "../../models/guildModel.ts";
 | 
			
		||||
 | 
			
		||||
export const getGuildEventScoreController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const account = await getAccountForRequest(req);
 | 
			
		||||
    const inventory = await getInventory(account._id.toString(), "GuildId");
 | 
			
		||||
    const guild = await Guild.findById(inventory.GuildId);
 | 
			
		||||
    const goalId = req.query.goalId as string;
 | 
			
		||||
    if (guild && guild.GoalProgress && goalId) {
 | 
			
		||||
        const goal = guild.GoalProgress.find(x => x.goalId.toString() == goalId);
 | 
			
		||||
        if (goal) {
 | 
			
		||||
            res.json({
 | 
			
		||||
                Tier: guild.Tier,
 | 
			
		||||
                GoalProgress: {
 | 
			
		||||
                    Count: goal.Count,
 | 
			
		||||
                    Tag: goal.Tag,
 | 
			
		||||
                    _id: { $oid: goal.goalId }
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    res.json({});
 | 
			
		||||
};
 | 
			
		||||
@ -1,9 +1,9 @@
 | 
			
		||||
import { toMongoDate } from "../../helpers/inventoryHelpers.ts";
 | 
			
		||||
import { Guild } from "../../models/guildModel.ts";
 | 
			
		||||
import { getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import type { IMongoDate } from "../../types/commonTypes.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { toMongoDate } from "@/src/helpers/inventoryHelpers";
 | 
			
		||||
import { Guild } from "@/src/models/guildModel";
 | 
			
		||||
import { getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { IMongoDate } from "@/src/types/commonTypes";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const getGuildLogController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
 | 
			
		||||
@ -1,9 +1,9 @@
 | 
			
		||||
import { toOid } from "../../helpers/inventoryHelpers.ts";
 | 
			
		||||
import { Account, Ignore } from "../../models/loginModel.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import type { IFriendInfo } from "../../types/friendTypes.ts";
 | 
			
		||||
import { parallelForeach } from "../../utils/async-utils.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { toOid } from "@/src/helpers/inventoryHelpers";
 | 
			
		||||
import { Account, Ignore } from "@/src/models/loginModel";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { IFriendInfo } from "@/src/types/friendTypes";
 | 
			
		||||
import { parallelForeach } from "@/src/utils/async-utils";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const getIgnoredUsersController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
import { Inventory } from "../../models/inventoryModels/inventoryModel.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { generateRewardSeed } from "../../services/rngService.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
 | 
			
		||||
import { generateRewardSeed } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const getNewRewardSeedController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
 | 
			
		||||
@ -1,62 +0,0 @@
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getSeasonChallengePools, getWorldState, pushWeeklyActs } from "../../services/worldStateService.ts";
 | 
			
		||||
import { EPOCH, unixTimesInMs } from "../../constants/timeConstants.ts";
 | 
			
		||||
import type { ISeasonChallenge } from "../../types/worldStateTypes.ts";
 | 
			
		||||
import { ExportChallenges } from "warframe-public-export-plus";
 | 
			
		||||
 | 
			
		||||
export const getPastWeeklyChallengesController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
    const inventory = await getInventory(accountId, "SeasonChallengeHistory ChallengeProgress");
 | 
			
		||||
    const worldState = getWorldState(undefined);
 | 
			
		||||
 | 
			
		||||
    if (worldState.SeasonInfo) {
 | 
			
		||||
        const pools = getSeasonChallengePools(worldState.SeasonInfo.AffiliationTag);
 | 
			
		||||
        const nightwaveStartTimestamp = Number(worldState.SeasonInfo.Activation.$date.$numberLong);
 | 
			
		||||
        const nightwaveSeason = worldState.SeasonInfo.Season;
 | 
			
		||||
        const timeMs = worldState.Time * 1000;
 | 
			
		||||
        const completedChallengesIds = new Set<string>();
 | 
			
		||||
 | 
			
		||||
        inventory.SeasonChallengeHistory.forEach(challengeHistory => {
 | 
			
		||||
            const entryNightwaveSeason = parseInt(challengeHistory.id.slice(0, 4), 10) - 1;
 | 
			
		||||
            if (nightwaveSeason == entryNightwaveSeason) {
 | 
			
		||||
                const meta = Object.entries(ExportChallenges).find(
 | 
			
		||||
                    ([key]) => key.split("/").pop() === challengeHistory.challenge
 | 
			
		||||
                );
 | 
			
		||||
                if (meta) {
 | 
			
		||||
                    const [, challengeMeta] = meta;
 | 
			
		||||
                    const challengeProgress = inventory.ChallengeProgress.find(
 | 
			
		||||
                        c => c.Name === challengeHistory.challenge
 | 
			
		||||
                    );
 | 
			
		||||
 | 
			
		||||
                    if (challengeProgress && challengeProgress.Progress >= (challengeMeta.requiredCount ?? 1)) {
 | 
			
		||||
                        completedChallengesIds.add(challengeHistory.id);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        const PastWeeklyChallenges: ISeasonChallenge[] = [];
 | 
			
		||||
 | 
			
		||||
        let week = Math.trunc((timeMs - EPOCH) / unixTimesInMs.week) - 1;
 | 
			
		||||
 | 
			
		||||
        while (EPOCH + week * unixTimesInMs.week >= nightwaveStartTimestamp && PastWeeklyChallenges.length < 3) {
 | 
			
		||||
            const tempActs: ISeasonChallenge[] = [];
 | 
			
		||||
            pushWeeklyActs(tempActs, pools, week, nightwaveStartTimestamp, nightwaveSeason);
 | 
			
		||||
 | 
			
		||||
            for (const act of tempActs) {
 | 
			
		||||
                if (!completedChallengesIds.has(act._id.$oid) && PastWeeklyChallenges.length < 3) {
 | 
			
		||||
                    if (act.Challenge.startsWith("/Lotus/Types/Challenges/Seasons/Weekly/SeasonWeeklyPermanent")) {
 | 
			
		||||
                        act.Permanent = true;
 | 
			
		||||
                    }
 | 
			
		||||
                    PastWeeklyChallenges.push(act);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            week--;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        res.json({ PastWeeklyChallenges: PastWeeklyChallenges });
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
@ -1,9 +1,12 @@
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { createGarden, getPersonalRooms } from "../../services/personalRoomsService.ts";
 | 
			
		||||
import type { IGetShipResponse, IPersonalRoomsClient } from "../../types/personalRoomsTypes.ts";
 | 
			
		||||
import { getLoadout } from "../../services/loadoutService.ts";
 | 
			
		||||
import { toOid } from "../../helpers/inventoryHelpers.ts";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { config } from "@/src/services/configService";
 | 
			
		||||
import allShipFeatures from "@/static/fixed_responses/allShipFeatures.json";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { createGarden, getPersonalRooms } from "@/src/services/personalRoomsService";
 | 
			
		||||
import { toOid } from "@/src/helpers/inventoryHelpers";
 | 
			
		||||
import { IGetShipResponse } from "@/src/types/shipTypes";
 | 
			
		||||
import { IPersonalRoomsClient } from "@/src/types/personalRoomsTypes";
 | 
			
		||||
import { getLoadout } from "@/src/services/loadoutService";
 | 
			
		||||
 | 
			
		||||
export const getShipController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
@ -23,11 +26,23 @@ export const getShipController: RequestHandler = async (req, res) => {
 | 
			
		||||
        LoadOutInventory: { LoadOutPresets: loadout.toJSON() },
 | 
			
		||||
        Ship: {
 | 
			
		||||
            ...personalRooms.Ship,
 | 
			
		||||
            ShipId: toOid(personalRoomsDb.activeShipId)
 | 
			
		||||
            ShipId: toOid(personalRoomsDb.activeShipId),
 | 
			
		||||
            ShipInterior: {
 | 
			
		||||
                Colors: personalRooms.ShipInteriorColors,
 | 
			
		||||
                ShipAttachments: { HOOD_ORNAMENT: "" },
 | 
			
		||||
                SkinFlavourItem: ""
 | 
			
		||||
            },
 | 
			
		||||
            FavouriteLoadoutId: personalRooms.Ship.FavouriteLoadoutId
 | 
			
		||||
                ? toOid(personalRooms.Ship.FavouriteLoadoutId)
 | 
			
		||||
                : undefined
 | 
			
		||||
        },
 | 
			
		||||
        Apartment: personalRooms.Apartment,
 | 
			
		||||
        TailorShop: personalRooms.TailorShop
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    if (config.unlockAllShipFeatures) {
 | 
			
		||||
        getShipResponse.Ship.Features = allShipFeatures;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    res.json(getShipResponse);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -1,8 +1,7 @@
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { applyStandingToVendorManifest, getVendorManifestByTypeName } from "../../services/serversideVendorsService.ts";
 | 
			
		||||
import { getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { config } from "../../services/configService.ts";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { applyStandingToVendorManifest, getVendorManifestByTypeName } from "@/src/services/serversideVendorsService";
 | 
			
		||||
import { getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
 | 
			
		||||
export const getVendorInfoController: RequestHandler = async (req, res) => {
 | 
			
		||||
    let manifest = getVendorManifestByTypeName(req.query.vendor as string);
 | 
			
		||||
@ -15,14 +14,6 @@ export const getVendorInfoController: RequestHandler = async (req, res) => {
 | 
			
		||||
        const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
        const inventory = await getInventory(accountId);
 | 
			
		||||
        manifest = applyStandingToVendorManifest(inventory, manifest);
 | 
			
		||||
        if (config.dev?.keepVendorsExpired) {
 | 
			
		||||
            manifest = {
 | 
			
		||||
                VendorInfo: {
 | 
			
		||||
                    ...manifest.VendorInfo,
 | 
			
		||||
                    Expiry: { $date: { $numberLong: "0" } }
 | 
			
		||||
                }
 | 
			
		||||
            };
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    res.json(manifest);
 | 
			
		||||
 | 
			
		||||
@ -1,9 +1,9 @@
 | 
			
		||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
			
		||||
import { crackRelic } from "../../helpers/relicHelper.ts";
 | 
			
		||||
import { getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import type { IVoidTearParticipantInfo } from "../../types/requestTypes.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { crackRelic } from "@/src/helpers/relicHelper";
 | 
			
		||||
import { getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { IVoidTearParticipantInfo } from "@/src/types/requestTypes";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const getVoidProjectionRewardsController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
@ -11,11 +11,7 @@ export const getVoidProjectionRewardsController: RequestHandler = async (req, re
 | 
			
		||||
 | 
			
		||||
    if (data.ParticipantInfo.QualifiesForReward && !data.ParticipantInfo.HaveRewardResponse) {
 | 
			
		||||
        const inventory = await getInventory(accountId);
 | 
			
		||||
        const reward = await crackRelic(inventory, data.ParticipantInfo);
 | 
			
		||||
        if (!inventory.MissionRelicRewards || inventory.MissionRelicRewards.length >= data.CurrentWave) {
 | 
			
		||||
            inventory.MissionRelicRewards = [];
 | 
			
		||||
        }
 | 
			
		||||
        inventory.MissionRelicRewards.push({ ItemType: reward.type, ItemCount: reward.itemCount });
 | 
			
		||||
        await crackRelic(inventory, data.ParticipantInfo);
 | 
			
		||||
        await inventory.save();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,35 +1,23 @@
 | 
			
		||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
			
		||||
import { Account } from "../../models/loginModel.ts";
 | 
			
		||||
import { areFriends } from "../../services/friendService.ts";
 | 
			
		||||
import { createMessage } from "../../services/inboxService.ts";
 | 
			
		||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { Account } from "@/src/models/loginModel";
 | 
			
		||||
import { areFriends } from "@/src/services/friendService";
 | 
			
		||||
import { createMessage } from "@/src/services/inboxService";
 | 
			
		||||
import {
 | 
			
		||||
    combineInventoryChanges,
 | 
			
		||||
    getEffectiveAvatarImageType,
 | 
			
		||||
    getInventory,
 | 
			
		||||
    updateCurrency
 | 
			
		||||
} from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountForRequest, getSuffixedName } from "../../services/loginService.ts";
 | 
			
		||||
import { handleDailyDealPurchase, handleStoreItemAcquisition } from "../../services/purchaseService.ts";
 | 
			
		||||
import type { IOid } from "../../types/commonTypes.ts";
 | 
			
		||||
import type { IPurchaseParams, IPurchaseResponse } from "../../types/purchaseTypes.ts";
 | 
			
		||||
import { PurchaseSource } from "../../types/purchaseTypes.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
} from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountForRequest, getSuffixedName } from "@/src/services/loginService";
 | 
			
		||||
import { handleStoreItemAcquisition } from "@/src/services/purchaseService";
 | 
			
		||||
import { IOid } from "@/src/types/commonTypes";
 | 
			
		||||
import { IInventoryChanges, IPurchaseParams } from "@/src/types/purchaseTypes";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { ExportBundles, ExportFlavour } from "warframe-public-export-plus";
 | 
			
		||||
 | 
			
		||||
const checkPurchaseParams = (params: IPurchaseParams): boolean => {
 | 
			
		||||
    switch (params.Source) {
 | 
			
		||||
        case PurchaseSource.Market:
 | 
			
		||||
            return params.UsePremium;
 | 
			
		||||
 | 
			
		||||
        case PurchaseSource.DailyDeal:
 | 
			
		||||
            return true;
 | 
			
		||||
    }
 | 
			
		||||
    return false;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const giftingController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const data = getJSONfromString<IGiftingRequest>(String(req.body));
 | 
			
		||||
    if (!checkPurchaseParams(data.PurchaseParams)) {
 | 
			
		||||
    if (data.PurchaseParams.Source != 0 || !data.PurchaseParams.UsePremium) {
 | 
			
		||||
        throw new Error(`unexpected purchase params in gifting request: ${String(req.body)}`);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -70,19 +58,16 @@ export const giftingController: RequestHandler = async (req, res) => {
 | 
			
		||||
    }
 | 
			
		||||
    senderInventory.GiftsRemaining -= 1;
 | 
			
		||||
 | 
			
		||||
    const response: IPurchaseResponse = {
 | 
			
		||||
        InventoryChanges: {}
 | 
			
		||||
    };
 | 
			
		||||
    if (data.PurchaseParams.Source == PurchaseSource.DailyDeal) {
 | 
			
		||||
        await handleDailyDealPurchase(senderInventory, data.PurchaseParams, response);
 | 
			
		||||
    } else {
 | 
			
		||||
        updateCurrency(senderInventory, data.PurchaseParams.ExpectedPrice, true, response.InventoryChanges);
 | 
			
		||||
    }
 | 
			
		||||
    const inventoryChanges: IInventoryChanges = updateCurrency(
 | 
			
		||||
        senderInventory,
 | 
			
		||||
        data.PurchaseParams.ExpectedPrice,
 | 
			
		||||
        true
 | 
			
		||||
    );
 | 
			
		||||
    if (data.PurchaseParams.StoreItem in ExportBundles) {
 | 
			
		||||
        const bundle = ExportBundles[data.PurchaseParams.StoreItem];
 | 
			
		||||
        if (bundle.giftingBonus) {
 | 
			
		||||
            combineInventoryChanges(
 | 
			
		||||
                response.InventoryChanges,
 | 
			
		||||
                inventoryChanges,
 | 
			
		||||
                (await handleStoreItemAcquisition(bundle.giftingBonus, senderInventory)).InventoryChanges
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
@ -114,7 +99,9 @@ export const giftingController: RequestHandler = async (req, res) => {
 | 
			
		||||
        }
 | 
			
		||||
    ]);
 | 
			
		||||
 | 
			
		||||
    res.json(response);
 | 
			
		||||
    res.json({
 | 
			
		||||
        InventoryChanges: inventoryChanges
 | 
			
		||||
    });
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
interface IGiftingRequest {
 | 
			
		||||
 | 
			
		||||
@ -1,14 +1,11 @@
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { broadcastInventoryUpdate } from "../../services/wsService.ts";
 | 
			
		||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
			
		||||
import { addMiscItems, getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import type { TEquipmentKey } from "../../types/inventoryTypes/inventoryTypes.ts";
 | 
			
		||||
import type { ArtifactPolarity } from "../../types/inventoryTypes/commonInventoryTypes.ts";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { addMiscItems, getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
			
		||||
import { ArtifactPolarity, EquipmentFeatures, IEquipmentClient } from "@/src/types/inventoryTypes/commonInventoryTypes";
 | 
			
		||||
import { ExportRecipes } from "warframe-public-export-plus";
 | 
			
		||||
import type { IInventoryChanges } from "../../types/purchaseTypes.ts";
 | 
			
		||||
import type { IEquipmentClient } from "../../types/equipmentTypes.ts";
 | 
			
		||||
import { EquipmentFeatures } from "../../types/equipmentTypes.ts";
 | 
			
		||||
import { IInventoryChanges } from "@/src/types/purchaseTypes";
 | 
			
		||||
 | 
			
		||||
interface IGildWeaponRequest {
 | 
			
		||||
    ItemName: string;
 | 
			
		||||
@ -75,5 +72,4 @@ export const gildWeaponController: RequestHandler = async (req, res) => {
 | 
			
		||||
        InventoryChanges: inventoryChanges,
 | 
			
		||||
        AffiliationMods: affiliationMods
 | 
			
		||||
    });
 | 
			
		||||
    broadcastInventoryUpdate(req);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -1,17 +1,16 @@
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
 | 
			
		||||
import { getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { giveKeyChainItem } from "../../services/questService.ts";
 | 
			
		||||
import type { IKeyChainRequest } from "../../types/requestTypes.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { parseString } from "@/src/helpers/general";
 | 
			
		||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { giveKeyChainItem } from "@/src/services/questService";
 | 
			
		||||
import { IKeyChainRequest } from "@/src/types/requestTypes";
 | 
			
		||||
 | 
			
		||||
export const giveKeyChainTriggeredItemsController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
    const accountId = parseString(req.query.accountId);
 | 
			
		||||
    const keyChainInfo = getJSONfromString<IKeyChainRequest>((req.body as string).toString());
 | 
			
		||||
 | 
			
		||||
    const inventory = await getInventory(accountId);
 | 
			
		||||
    const questKey = inventory.QuestKeys.find(qk => qk.ItemType === keyChainInfo.KeyChain)!;
 | 
			
		||||
    const inventoryChanges = await giveKeyChainItem(inventory, keyChainInfo, questKey);
 | 
			
		||||
    const inventoryChanges = await giveKeyChainItem(inventory, keyChainInfo);
 | 
			
		||||
    await inventory.save();
 | 
			
		||||
 | 
			
		||||
    res.send(inventoryChanges);
 | 
			
		||||
 | 
			
		||||
@ -1,16 +1,15 @@
 | 
			
		||||
import { getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { giveKeyChainMessage } from "../../services/questService.ts";
 | 
			
		||||
import type { IKeyChainRequest } from "../../types/requestTypes.ts";
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { giveKeyChainMessage } from "@/src/services/questService";
 | 
			
		||||
import { IKeyChainRequest } from "@/src/types/requestTypes";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const giveKeyChainTriggeredMessageController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
    const keyChainInfo = JSON.parse((req.body as Buffer).toString()) as IKeyChainRequest;
 | 
			
		||||
 | 
			
		||||
    const inventory = await getInventory(accountId, "QuestKeys accountOwnerId");
 | 
			
		||||
    const questKey = inventory.QuestKeys.find(qk => qk.ItemType === keyChainInfo.KeyChain)!;
 | 
			
		||||
    await giveKeyChainMessage(inventory, keyChainInfo, questKey);
 | 
			
		||||
    const inventory = await getInventory(accountId, "QuestKeys");
 | 
			
		||||
    await giveKeyChainMessage(inventory, accountId, keyChainInfo);
 | 
			
		||||
    await inventory.save();
 | 
			
		||||
 | 
			
		||||
    res.send(1);
 | 
			
		||||
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user