TG:Logic/Contract logic

Contract logic in the game breaks into several possibilities:
 * point-to-point transport over a long period (one to three years). E.g. 50t iron ore from Iron Ore Mine A to Steel Mill B per month for one year.
 * point-to-point transport one-time. E.g. 250t wheat from Wheat Farm A to Granary B within allotted period.
 * simple purchase (warehousing). E.g. Buy 200t iron ore from Iron Ore Mine A and do whatever you like with it.
 * simple sale (warehousing). E.g. Deliver 200t iron ore to Steel Mill B from wherever you like.

Point to point, long period
These will be the staple contract that a transport company will want to go for. They are created and managed by the production industries based on agreements these industries make with consumer industries.

The initial setup for such a contract involves the consumer contacting the producer and making an offer to buy some amount of raw material at some cost, which must allow for both transport costs and a profit to the producing industry.

Normally, the industries should prefer using non-player companies for transportation -- specifically, transporting by "truck" or "ship" (aka slow teleport). Player companies are allowed to bid on these contracts, but if they want to actually be awarded them, they must underbid the existing cost of transport. Contracts made out to a teleport company can be reevaluated at any time. Contracts made out to a player company are fixed for 1-3 years and can normally only be reevaluated when the contract is renewed.

However, in the case of extremely poor management by the player company (e.g. lost cargoes, spoiled cargoes), the industry may terminate the contract early at no penalty. Similarly, either industry or player may terminate a contract and pay a penalty sum to the other party -- this would be preferable to going bankrupt in a depression, for instance.

Point to point, one-time
These were pointed out as necessary by logical extension from the decision to add farms -- which produce goods only when in-season for harvesting. Thus, farms require the ability to contract with a granary for their wheat to be stored, and the granary will take care of the long-term contracts from there.

They will function much like the long-term contracts in terms of logic -- the producers own the contract and determine where their goods go.

One-time contracts have a deadline for delivery (the wheat will go bad if sitting around for too long in an inadequate facility), and in case the deadline is not met, the owning company will have to pay a large penalty.

There is some leeway to allow engine and wagon purchases to be done by player-created one-time contracts.

Simple purchase/sale
Both of these tie into the warehousing mechanic, wherein the player company may own a warehouse (or space in an AI-run one) and store goods there. This allows the player to stockpile goods in order to sell them later, hopefully at a profit. However, to prevent this from becoming the main game mechanic, the following controls are in place:

Firstly, storing goods in a warehouse implies a maintenance cost, differing by cargo type. Produce needs refrigerated facilities, which are expensive to run. Iron ore can simply be tossed in a pile somewhere and left out in the rain (maybe with a tarp on top), which is very cheap. Thus, some goods are more amenable to stockpiling than others.

On a related note, some goods are perishable and must be sold before they go bad. Even in perfectly-functioning refrigerated facilities, a ton of meat can only be stored for so long. Likewise, even if kept perfectly happily fed, livestock will eventually die of old age.

Another control is that sale contracts tend to be few and far between. Manufacturers and consumers prefer to set up long-term contracts to allow them a constant flow of goods, but they will occasionally accept a few (hundred?) tons of raw material for their own stockpile.

Finally, if perishable goods are stored for too long or the maintenance cost is deemed too high, it costs money to dump the goods from the warehouse. This should make the player think long and hard before purchasing the 1000t of produce that are being offered to him -- if he cannot sell them in time, he will have to pay out of pocket to free up space in the warehouse.

Initial bullet points (copy/pasted)

 * 2-sided contracts are owned by producing industries, which are polled by consuming industries in order of distance. For a steel mill 30 tiles away from an iron mine, it will likely be impossible for the player to afford to under-bid the road transportation for the contract.
 * One-sided contracts can be owned by anyone and request to deliver or take away a certain amount of goods, tying in with warehousing.
 * Interchange contracts -- between multiplayer companies or between the player company and the Class 1 in the area (if any).
 * Contract example: iron ore mine A is contracted to deliver 30 tons of iron ore to steel mill B per month for the next three years. It is currently making deliveries by truck, at a transport cost of $250/ton.
 * Contract bonuses?
 * similarly, it must be possible for contracts to be offered to the player company for the longer-distance runs, where trucks would be prohibitively expensive, but this should be the last option for an industry (perhaps difficulty-based? On lower difficulties, they may randomly make the offer to the player company rather than leaving them for last).
 * short-term contracts -- generated at random? When industries go bankrupt? Clear chance for bonuses.
 * contract signing bonus to encourage inertia (and encourage larger underbids on contracts)
 * industries should prefer companies they already have working relationships with.
 * contract failure -- if red company fails a contract, blue company gets offered the contract.