-
Notifications
You must be signed in to change notification settings - Fork 7
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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; | ||
} | ||
|
||
}; | ||
|
||
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. db mutated here, see my review comment. |
||
|
||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -185,6 +185,8 @@ class PathToTarkov implements IPreSptLoadMod, IPostSptLoadMod { | |
|
||
this.pathToTarkovController.tradersController.initTraders(this.config); | ||
|
||
this.pathToTarkovController.fleaController.initFlea(this.config); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'; | ||
|
@@ -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> = {}; | ||
|
@@ -99,6 +101,10 @@ export class PathToTarkovController { | |
configServer, | ||
this.logger, | ||
); | ||
this.fleaController = new FleaController( | ||
db, | ||
configServer, | ||
); | ||
this.overrideControllers(); | ||
} | ||
|
||
|
@@ -244,6 +250,12 @@ export class PathToTarkovController { | |
sessionId, | ||
); | ||
|
||
if (config.flea && config.flea.access_via) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typescript won't compile here because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. be sure those commands work on your machine:
|
||
this.fleaController.updateFlea( | ||
config.flea.access_via, | ||
offraidPosition, | ||
); | ||
|
||
this.saveServer.saveProfile(sessionId); | ||
} | ||
|
||
|
There was a problem hiding this comment.
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.