Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flea market options #64

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/flea-controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import type { DatabaseServer } from '@spt/servers/DatabaseServer';
import type { ConfigServer } from '@spt/servers/ConfigServer';
import type { ConfigTypes } from '@spt/models/enums/ConfigTypes';
import type { Config } from './config';
import { checkAccessVia } from './helpers';

export class FleaController{

constructor(
private readonly db: DatabaseServer,
private readonly configServer: ConfigServer,
) {};

initFlea(config: Config): void {

if (config.flea && config.flea.min_level)
{
const fleaConfig = this.db.getTables().globals.config.RagFair;
fleaConfig.minUserLevel = config.flea.min_level;
Comment on lines +18 to +19
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

db mutated here, see my review comment.

}

};

updateFlea(
access_via: string | string[],
offraidPosition: string,
): void {

const fleaConfig = this.db.getTables().globals.config.RagFair;
fleaConfig.enabled = checkAccessVia(access_via, offraidPosition);
Comment on lines +29 to +30
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

db mutated here, see my review comment.


}

}
2 changes: 2 additions & 0 deletions src/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ class PathToTarkov implements IPreSptLoadMod, IPostSptLoadMod {

this.pathToTarkovController.tradersController.initTraders(this.config);

this.pathToTarkovController.fleaController.initFlea(this.config);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the config is directly passed here, see my review comment. I can guide you through a correct implementation here.


Object.keys(profiles).forEach(profileId => {
this.pathToTarkovController.cleanupLegacySecondaryStashesLink(profileId);
});
Expand Down
12 changes: 12 additions & 0 deletions src/path-to-tarkov-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {

import { getTemplateIdFromStashId, StashController } from './stash-controller';
import { TradersController } from './traders-controller';
import { FleaController } from './flea-controller';
import type { DependencyContainer } from 'tsyringe';
import type { LocationController } from '@spt/controllers/LocationController';
import { deepClone, shuffle } from './utils';
Expand Down Expand Up @@ -60,6 +61,7 @@ const getIndexedLocations = (locations: ILocations): IndexedLocations => {
export class PathToTarkovController {
public stashController: StashController;
public tradersController: TradersController;
public fleaController: FleaController;

// configs are indexed by sessionId
private configCache: Record<string, Config> = {};
Expand Down Expand Up @@ -99,6 +101,10 @@ export class PathToTarkovController {
configServer,
this.logger,
);
this.fleaController = new FleaController(
db,
configServer,
);
this.overrideControllers();
}

Expand Down Expand Up @@ -244,6 +250,12 @@ export class PathToTarkovController {
sessionId,
);

if (config.flea && config.flea.access_via)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typescript won't compile here because flea is missing in the config type

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be sure those commands work on your machine:

npm install
npm run build

this.fleaController.updateFlea(
config.flea.access_via,
offraidPosition,
);

this.saveServer.saveProfile(sessionId);
}

Expand Down
Loading