Class Market
Handles market logic so the player can buy and sell products/items.
Namespace: Backend
Assembly: cs.temp.dll.dll
Syntax
public static class Market
Fields
PlotsPerTubewell
How many plots a single tubewell can irrigate.
Declaration
public const int PlotsPerTubewell = 8
Field Value
Type | Description |
---|---|
int |
Methods
ActivateProduct(string)
If a product is disabled in the market, re-enable it.
Declaration
public static void ActivateProduct(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The product to enable. |
Buy(string, Household)
Handle when buyer
wants to buy name
.
Declaration
public static string Buy(string name, Household buyer)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the item to buy. |
Household | buyer | The buyer. |
Returns
Type | Description |
---|---|
string | Returns a string with a message if purchase is unsuccessful, empty string otherwise. |
CanBuyerBuy(Household, string)
Test if buyer
can actually buy productName
.
Declaration
public static bool CanBuyerBuy(Household buyer, string productName)
Parameters
Type | Name | Description |
---|---|---|
Household | buyer | The buyer. |
string | productName | The product to buy. |
Returns
Type | Description |
---|---|
bool | Whether the buyer can buy it. |
DeactivateProduct(string)
Disable a product from being able to be purchased.
Declaration
public static void DeactivateProduct(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name |
GetDescription(string)
Get a product's description.
Declaration
public static string GetDescription(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The product's name. |
Returns
Type | Description |
---|---|
string | The product's description. |
GetPrice(string)
Returns the actual selling price of a product, taking price multiplier into account.
Declaration
public static int GetPrice(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The product name. |
Returns
Type | Description |
---|---|
int | The selling price. |
Initialize()
Initialize the Market and set its products; should be called in GameState.Initialize
Declaration
public static void Initialize()
IsBuyable(string)
Checks if a product is enabled for purchase.
Declaration
public static bool IsBuyable(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The product's name. |
Returns
Type | Description |
---|---|
bool | If the product can be purchased. |
Sell(Household, int, string)
seller
wants to sell quantity
of product
.
The actual sold amount will not exceed how much of product
the seller actually owns.
Seller's money is automatically increased.
Declaration
public static void Sell(Household seller, int quantity, string product)
Parameters
Type | Name | Description |
---|---|---|
Household | seller | The seller. |
int | quantity | The quantity to sell. |
string | product | The product to sell. |
SetPriceMultiplier(string, float)
Set a product's price multiplier.
Declaration
public static void SetPriceMultiplier(string name, float mult)
Parameters
Type | Name | Description |
---|---|---|
string | name | Name of product. |
float | mult | Desired price multiplier. |
UpdateWheatPrice()
Changes global wheat price to something between 1 and 10 (inclusive).
Declaration
public static void UpdateWheatPrice()