The marketplace will allow the user to trade resources for coins. Some graphics are already created but not currently in the project. For reference, the marketplace is 256x256 and the coin will go in the inventory (32x32). Additional graphics will include traders of varying rarities that will have a walking animation and be carrying carts. The different rarities will cause the carts to have different stuff in them - ranging from hides to shiny gems.
The current idea for the market place will be similar to Banished trading ports, except land-based:
A marketplace requires mobile entities which are also containers running a trading task with the market as a target to do anything. See the trading task note below.
Each tick, the market has a chance to spawn a trader. Initially, this chance is very small and it raises for each consecutive millisecond that it doesn't spawn.
A trader can be spawned from any pathable edge of the map. The easiest way to do this is choose random potential locations and attempt to calculate a path to the marketplace, and upon failing simply attempt a new location. The trader must be assigned a rarity (see note below).
Once the trader arrives and the marketplace it will run the trading task with the marketplace, and will stay for a few minutes.
In order to interact with the marketplace, you must setup a worker to run a trading task with the marketplace at the same time. It is not possible to know exactly what a trader is selling, but the traders hover text should specify what a typical trader of that rarity sells.
Notes:
Trading task - The marketplace facilitates trades among active participants. The trading task allows entities to register themselves as active participants, assuming they are within interaction range. An active participant must specify what items it will buy, the highest price it will buy for, and the maximum number it will buy as well as what items it will sell, the lowest price it will sell for, and the maximum number it will sell. The participant is not alerted of the other participants in the market. Participants may change their status by leaving and reentering the market. A participant may not have an offer to sell a given item at a price lower than or equal to its current offer to buy that given item. The minimum denomination per unit is 1 gold coin. When a participant joins the marketplace, the next time the marketplace ticks it should see if any trades are viable. The trade should always favor the purchaser - that is to say, if a participant is offering to sell X at 3gps and a new participant offers to buy them at 5gps, the trade will be made at 3 gps. Similarly, if a participant is offering to buy Y at 2gps and a new participant offers to sell Y at 1gps, the trade will be made at 1 gps. When registering for a trade, you must provide the container with which you are trading. This will allow the market place to prevent you from spending resources or gold pieces that you don't have.
Rarity - A rarity of trader will affect the texture, collision mesh, and wares the trader has. A traders wares will be a material, a range of amount it carries, a range for the price it will sell for, a range for the amount of money the trader carries, and what wares the trader will purchase, a range for the number it will purchase, and a range of prices it will purchase for. Care should be taken to ensure it will not purchase for a lower price than it will sell for. The trader should stop offering to purchase items if it runs out of money. When spawning a trader of a specific rarity, the numbers must be calculated randomly from within the specified ranges.
The marketplace will allow the user to trade resources for coins. Some graphics are already created but not currently in the project. For reference, the marketplace is 256x256 and the coin will go in the inventory (32x32). Additional graphics will include traders of varying rarities that will have a walking animation and be carrying carts. The different rarities will cause the carts to have different stuff in them - ranging from hides to shiny gems.
The current idea for the market place will be similar to Banished trading ports, except land-based:
Notes:
Trading task - The marketplace facilitates trades among active participants. The trading task allows entities to register themselves as active participants, assuming they are within interaction range. An active participant must specify what items it will buy, the highest price it will buy for, and the maximum number it will buy as well as what items it will sell, the lowest price it will sell for, and the maximum number it will sell. The participant is not alerted of the other participants in the market. Participants may change their status by leaving and reentering the market. A participant may not have an offer to sell a given item at a price lower than or equal to its current offer to buy that given item. The minimum denomination per unit is 1 gold coin. When a participant joins the marketplace, the next time the marketplace ticks it should see if any trades are viable. The trade should always favor the purchaser - that is to say, if a participant is offering to sell X at 3gps and a new participant offers to buy them at 5gps, the trade will be made at 3 gps. Similarly, if a participant is offering to buy Y at 2gps and a new participant offers to sell Y at 1gps, the trade will be made at 1 gps. When registering for a trade, you must provide the container with which you are trading. This will allow the market place to prevent you from spending resources or gold pieces that you don't have.
Rarity - A rarity of trader will affect the texture, collision mesh, and wares the trader has. A traders wares will be a material, a range of amount it carries, a range for the price it will sell for, a range for the amount of money the trader carries, and what wares the trader will purchase, a range for the number it will purchase, and a range of prices it will purchase for. Care should be taken to ensure it will not purchase for a lower price than it will sell for. The trader should stop offering to purchase items if it runs out of money. When spawning a trader of a specific rarity, the numbers must be calculated randomly from within the specified ranges.