org.mars_sim.msp.core.person.ai.mission
Class TradeUtil

java.lang.Object
  extended by org.mars_sim.msp.core.person.ai.mission.TradeUtil

public final class TradeUtil
extends java.lang.Object

Utility class for static trade methods.


Method Summary
static java.util.Map<Good,java.lang.Integer> addNonProfitsToLoad(Settlement buyingSettlement, Settlement sellingSettlement, Rover rover, java.util.Map<Good,java.lang.Integer> currentLoad, java.util.Set<Good> nonAddGoods, double currentValue, double targetValue)
          Adds to a goods load between a buying settlement and a selling settlement.
static java.util.Map<Good,java.lang.Integer> determineLoad(Settlement buyingSettlement, Settlement sellingSettlement, Rover rover)
          Determines the load between a buying settlement and a selling settlement.
static double determineLoadValue(java.util.Map<Good,java.lang.Integer> load, Settlement settlement, boolean buy)
          Determines the value of a load to a settlement.
static java.util.Map<Good,java.lang.Integer> getDesiredBuyLoad(Settlement startingSettlement, Rover rover, Settlement tradingSettlement)
          Gets the desired buy load from a trading settlement.
static double getEstimatedMissionCost(Settlement startingSettlement, Rover rover, double distance)
          Gets the estimated trade mission cost.
static double getNumInInventory(Good good, Inventory inventory)
          Gets the number of a good currently in the inventory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDesiredBuyLoad

public static java.util.Map<Good,java.lang.Integer> getDesiredBuyLoad(Settlement startingSettlement,
                                                                      Rover rover,
                                                                      Settlement tradingSettlement)
                                                               throws java.lang.Exception
Gets the desired buy load from a trading settlement.

Parameters:
startingSettlement - the settlement that is buying.
rover - the rover used for trade.
tradingSettlement - the settlement to buy from.
Returns:
the desired buy load.
Throws:
java.lang.Exception - if error determining the buy load.

determineLoad

public static java.util.Map<Good,java.lang.Integer> determineLoad(Settlement buyingSettlement,
                                                                  Settlement sellingSettlement,
                                                                  Rover rover)
                                                           throws java.lang.Exception
Determines the load between a buying settlement and a selling settlement.

Parameters:
buyingSettlement - the settlement buying the goods.
sellingSettlement - the settlement selling the goods.
rover - the rover to carry the goods.
Returns:
map of goods and their number.
Throws:
java.lang.Exception - if error determining the load.

addNonProfitsToLoad

public static java.util.Map<Good,java.lang.Integer> addNonProfitsToLoad(Settlement buyingSettlement,
                                                                        Settlement sellingSettlement,
                                                                        Rover rover,
                                                                        java.util.Map<Good,java.lang.Integer> currentLoad,
                                                                        java.util.Set<Good> nonAddGoods,
                                                                        double currentValue,
                                                                        double targetValue)
                                                                 throws java.lang.Exception
Adds to a goods load between a buying settlement and a selling settlement.

Parameters:
buyingSettlement - the settlement buying the goods.
sellingSettlement - the settlement selling the goods.
rover - the rover to carry the goods.
currentLoad - the current trade load.
nonAddGoods - set of goods not to be added.
currentValue - the current load value to the buying settlement.
targetValue - the target load value to the buying settlement.
Returns:
map of goods and their number.
Throws:
java.lang.Exception - if error determining the load.

determineLoadValue

public static double determineLoadValue(java.util.Map<Good,java.lang.Integer> load,
                                        Settlement settlement,
                                        boolean buy)
                                 throws java.lang.Exception
Determines the value of a load to a settlement.

Parameters:
load - a map of the goods and their number.
settlement - the settlement valuing the load.
buy - true if settlement is buying the load, false if selling.
Returns:
value of the load (value points).
Throws:
java.lang.Exception - if error determining the load value.

getNumInInventory

public static double getNumInInventory(Good good,
                                       Inventory inventory)
                                throws java.lang.Exception
Gets the number of a good currently in the inventory.

Parameters:
good - the good to check.
inventory - the inventory to check.
Returns:
number of goods in inventory.
Throws:
java.lang.Exception - if error getting number of goods in inventory.

getEstimatedMissionCost

public static double getEstimatedMissionCost(Settlement startingSettlement,
                                             Rover rover,
                                             double distance)
                                      throws java.lang.Exception
Gets the estimated trade mission cost.

Parameters:
startingSettlement - the settlement starting the trade mission.
rover - the mission rover.
distance - the distance (km) of the mission trip.
Returns:
the cost of the mission (value points).
Throws:
java.lang.Exception - if error getting the estimated mission cost.