public IOngoingDeal PerformProposal() { if (!CanPerformProposal()) { throw new InvalidOperationException("CanPerformProposal must return true"); } var ongoingFromSender = new List <IOngoingDiplomaticExchange>(); var ongoingToReceiver = new List <IOngoingDiplomaticExchange>(); var ongoingBilateral = new List <IOngoingDiplomaticExchange>(); foreach (var offer in offeredBySender) { var ongoingExchange = offer.ExecuteBetweenCivs(Sender, Receiver); if (ongoingExchange != null) { ongoingFromSender.Add(ongoingExchange); } } foreach (var demand in demandedOfReceiver) { var ongoingExchange = demand.ExecuteBetweenCivs(Receiver, Sender); if (ongoingExchange != null) { ongoingToReceiver.Add(ongoingExchange); } } foreach (var bilateralExchange in bilateralExchanges) { var ongoingExchange = bilateralExchange.ExecuteBetweenCivs(Sender, Receiver); if (ongoingExchange != null) { ongoingBilateral.Add(ongoingExchange); } } if (ongoingFromSender.Count > 0 || ongoingToReceiver.Count > 0 || ongoingBilateral.Count > 0) { var ongoingDeal = new OngoingDeal(Sender, Receiver, ongoingFromSender, ongoingToReceiver, ongoingBilateral); return(ongoingDeal); } else { return(null); } }