Ejemplo n.º 1
0
        private void DoExternalTradeWithInternalResources(List <TradingResource> TradingResources, ResourceTypes.ResourceType resourceType, double resourceRatio)
        {
            if (resourceRatio == 0)
            {
                return;
            }
            double exportRatio = 1 - (1 / resourceRatio);

            if (exportRatio <= 0)
            {
                return;
            }

            double transportTimeOutOfRigion = Ownregion.GetTransportTime() / 2;

            foreach (TradingResource tradingResounce in TradingResources)
            {
                double totalSellAmount = tradingResounce.Amount * exportRatio;

                foreach (TradeRegion tradeRegion in TradeRegions)
                {
                    double tradeRegionRatio = tradeRegion.GetTransportAmount(resourceType);
                    if (tradeRegionRatio <= 0)
                    {
                        continue;
                    }

                    if (tradingResounce.AffordTransport(tradeRegionRatio, tradingResounce.Amount))
                    {
                        ExternatlTradingResourcesInTransit.TradingResourceList.Add(tradingResounce.SplitAmountExternal(totalSellAmount * tradeRegionRatio, tradeRegion.GetExternalMarket(), transportTimeOutOfRigion));
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public void FinilizeTrades()
 {
     foreach (ExternatlTradingResource newExternatlTradingResource in NewExternatlTradingResources)
     {
         newExternatlTradingResource.SetDaysRemaning(Ownregion.GetTransportTime() / 2);
         ExternatlTradingResources.Add(newExternatlTradingResource);
     }
     NewExternatlTradingResources.Clear();
 }
Ejemplo n.º 3
0
        private void DoExternalTradeWithExternalResources(double priceRatio, double demand, ExternalTradingResources externalTradingResources, ResourceTypes.ResourceType resourceType)
        {
            double amountOfResources = externalTradingResources.TradingResourceList.Count;

            if (amountOfResources == 0)
            {
                return;
            }
            double transportTimeOutOfRigion = Ownregion.GetTransportTime() / 2;
            double keepAmount = getSendRatio(demand, priceRatio);

            if (keepAmount >= amountOfResources)
            {
                return;
            }
            double exportRatio = (amountOfResources - keepAmount) / amountOfResources;

            foreach (ExternalTradingResource externalTradingResource in externalTradingResources.TradingResourceList)
            {
                double totalSellAmount = externalTradingResource.Amount * exportRatio;

                foreach (TradeRegion tradeRegion in TradeRegions)
                {
                    double tradeRegionRatio = tradeRegion.GetTransportAmount(resourceType);
                    if (tradeRegionRatio <= 0)
                    {
                        continue;
                    }

                    if (externalTradingResource.AffordTransport(tradeRegionRatio, externalTradingResource.Amount))
                    {
                        ExternatlTradingResourcesInTransit.TradingResourceList.Add(externalTradingResource.SplitAmountExternal(totalSellAmount * tradeRegionRatio,
                                                                                                                               tradeRegion.GetExternalMarket(), transportTimeOutOfRigion));
                    }
                }
            }
        }
Ejemplo n.º 4
0
 public void StartTrade(List <TradingResource> TradingResources, double ratio, ExternalMarket destination)
 {
     foreach (TradingResource tradingResounce in TradingResources)
     {
         if (tradingResounce.AffordTransport())
         {
             ExternatlTradingResources.Add(tradingResounce.SplitExternal(ratio, destination, Ownregion.GetTransportTime() / 2));
         }
     }
 }