_internal.classes.store._base.Store - vladzaharia/bitburner GitHub Wiki
_internal/classes/store/_base.Store
Abstract class representing an entity capable of purchasing and selling.
abstract
| Name | Description |
|---|---|
P |
The purchase parameters for implementing classes. |
S |
The sell parameters for implementing classes. |
-
Store
-
IPurchaseable<P> -
ISellable<S>
- _checkParams
- _checkParamsInternal
- _purchase
- _sell
- canPurchase
- getAvailableMoney
- getPurchaseCost
- purchase
- sell
• new Store<P, S>(ns, budget)
| Name |
|---|
P |
S |
| Name | Type | Description |
|---|---|---|
ns |
NS |
The Netscript object. |
budget |
number |
Budget, as whole number or percentage of max money. |
_internal/classes/store/_base.ts:31
• Private Readonly _budget: number
Budget available to this purchaser.
- If > 1, interpreted as exact budget.
- If < 1, interpreted as percentage of available money.
- Use 0 to disable purchasing.
_internal/classes/store/_base.ts:24
• Protected _ns: NS
The Netscript object.
_internal/classes/store/_base.ts:15
▸ Protected _checkParams(params): boolean
Verify the purchase parameters, must be overridden by implementing classes.
virtual Must be overridden by implementing classes.
| Name | Type | Description |
|---|---|---|
params |
P | S
|
Parameters for this transaction. |
boolean
Whether the parameters are valid.
_internal/classes/store/_base.ts:163
▸ Private _checkParamsInternal(params): true
Verify the purchase parameters, executed before canPurchase, purchase, and sell.
| Name | Type | Description |
|---|---|---|
params |
P | S
|
Parameters for this transaction. |
true
Whether the parameters are valid.
_internal/classes/store/_base.ts:147
▸ Protected _purchase(params): Promise<boolean>
Purchase an item, must be overridden by implementing classes.
virtual Must be overridden by implementing classes.
async
| Name | Type | Description |
|---|---|---|
params |
P |
Parameters for this transaction. |
Promise<boolean>
Whether the transaction was successful.
_internal/classes/store/_base.ts:110
▸ Protected _sell(params): Promise<boolean>
Sell an item with params params, must be overridden by implementing classes if supported.
virtual Must be overridden by implementing classes.
async
| Name | Type | Description |
|---|---|---|
params |
S |
Parameters for this sale. |
Promise<boolean>
Whether the transaction was successful.
_internal/classes/store/_base.ts:137
▸ canPurchase(params): boolean
Checks whether the user can purchase based on parameters params.
| Name | Type | Description |
|---|---|---|
params |
P |
Parameters for this transaction. |
boolean
Whether this transaction is possible.
_internal/classes/store/_base.ts:59
▸ getAvailableMoney(): number
Gets the amount of money available to this store.
number
Available money according to this._budget.
IPurchaseable.getAvailableMoney
_internal/classes/store/_base.ts:41
▸ getPurchaseCost(params): number
Get cost of purchase with parameters params.
virtual Must be overridden by implementing classes.
| Name | Type | Description |
|---|---|---|
params |
P |
Parameters for this transaction. |
number
Cost of the transaction.
_internal/classes/store/_base.ts:73
▸ purchase(params): Promise<boolean>
Purchase an item with parameters params if there is money available.
virtual Must be overridden by implementing classes.
async
| Name | Type | Description |
|---|---|---|
params |
P |
Parameters for this transaction. |
Promise<boolean>
Whether the transaction was successful.
_internal/classes/store/_base.ts:85
▸ sell(params): Promise<boolean>
Sell an item with params params, if possible.
async
| Name | Type | Description |
|---|---|---|
params |
S |
Parameters for this sale. |
Promise<boolean>
Whether the transaction was successful.