public ExchangeSummary BuildAllValidExchangesBetween(ICivilization sender, ICivilization receiver)
        {
            var retval = new ExchangeSummary();

            if (WarCanon.CanEstablishPeace(sender, receiver))
            {
                retval.BilateralExchanges.Add(Container.Instantiate <EstablishPeaceDiplomaticExchange>());
            }

            if (sender.GoldStockpile > 0)
            {
                retval.AllPossibleOffersFromSender.Add(Container.Instantiate <GoldDiplomaticExchange>());
                retval.MaxOfferableGoldFromSender = sender.GoldStockpile;
            }

            if (receiver.GoldStockpile > 0)
            {
                retval.AllPossibleDemandsOfReceiver.Add(Container.Instantiate <GoldDiplomaticExchange>());
                retval.MaxDemandableGoldOfReceiver = receiver.GoldStockpile;
            }

            BuildCityExchanges(sender, receiver, retval);

            ResourceExchangeBuilder.BuildResourceExchanges(sender, receiver, retval);

            return(retval);
        }
        private void BuildCityExchanges(
            ICivilization sender, ICivilization receiver, ExchangeSummary summary
            )
        {
            foreach (var cityOfSender in CityPossessionCanon.GetPossessionsOfOwner(sender))
            {
                var cityOffer = Container.Instantiate <CityDiplomaticExchange>();

                cityOffer.CityInput = cityOfSender;

                summary.AllPossibleOffersFromSender.Add(cityOffer);
            }

            foreach (var cityOfReceiver in CityPossessionCanon.GetPossessionsOfOwner(receiver))
            {
                var cityOffer = Container.Instantiate <CityDiplomaticExchange>();

                cityOffer.CityInput = cityOfReceiver;

                summary.AllPossibleDemandsOfReceiver.Add(cityOffer);
            }
        }
        public void BuildResourceExchanges(
            ICivilization sender, ICivilization receiver, ExchangeSummary summary
            )
        {
            if (sender == null)
            {
                throw new ArgumentNullException("sender");
            }

            if (receiver == null)
            {
                throw new ArgumentNullException("receiver");
            }

            if (!CivilizationConnectionLogic.AreCivilizationsConnected(sender, receiver))
            {
                return;
            }

            var tradeableOfSender = AvailableResources.Where(
                resource => ResourceTransferCanon.GetTradeableCopiesOfResourceForCiv(resource, sender) > 0
                ).ToList();

            var tradeableOfReceiver = AvailableResources.Where(
                resource => ResourceTransferCanon.GetTradeableCopiesOfResourceForCiv(resource, receiver) > 0
                ).ToList();

            var tradeableLuxuriesOfSender = tradeableOfSender
                                            .Where(resource => resource.Type == ResourceType.Luxury)
                                            .Where(resource => FreeResourcesLogic.GetFreeCopiesOfResourceForCiv(resource, receiver) <= 0);

            var tradeableStrategicsOfSender = tradeableOfSender.Where(resource => resource.Type == MapResources.ResourceType.Strategic);

            var tradeableLuxuriesOfReceiver = tradeableOfReceiver
                                              .Where(resource => resource.Type == ResourceType.Luxury)
                                              .Where(resource => FreeResourcesLogic.GetFreeCopiesOfResourceForCiv(resource, sender) <= 0);

            var tradeableStrategicsOfReceiver = tradeableOfReceiver.Where(resource => resource.Type == MapResources.ResourceType.Strategic);

            foreach (var luxury in tradeableLuxuriesOfSender)
            {
                var luxuryExchange = Container.Instantiate <ResourceDiplomaticExchange>();

                luxuryExchange.ResourceInput = luxury;
                luxuryExchange.IntegerInput  = 1;

                summary.AllPossibleOffersFromSender.Add(luxuryExchange);
            }

            foreach (var strategic in tradeableStrategicsOfSender)
            {
                var strategicExchange = Container.Instantiate <ResourceDiplomaticExchange>();

                strategicExchange.ResourceInput = strategic;
                strategicExchange.IntegerInput  = ResourceTransferCanon.GetTradeableCopiesOfResourceForCiv(strategic, sender);

                summary.AllPossibleOffersFromSender.Add(strategicExchange);
            }

            foreach (var luxury in tradeableLuxuriesOfReceiver)
            {
                var luxuryExchange = Container.Instantiate <ResourceDiplomaticExchange>();

                luxuryExchange.ResourceInput = luxury;
                luxuryExchange.IntegerInput  = 1;

                summary.AllPossibleDemandsOfReceiver.Add(luxuryExchange);
            }

            foreach (var strategic in tradeableStrategicsOfReceiver)
            {
                var strategicExchange = Container.Instantiate <ResourceDiplomaticExchange>();

                strategicExchange.ResourceInput = strategic;
                strategicExchange.IntegerInput  = ResourceTransferCanon.GetTradeableCopiesOfResourceForCiv(strategic, receiver);

                summary.AllPossibleDemandsOfReceiver.Add(strategicExchange);
            }
        }