Example #1
0
 private void CacheDepotResources(IDepot depot)
 {
     _depotResources = depot.GetResources();
 }
Example #2
0
        protected bool CheckBerthCost(IDepot depot, CrewRoutePayload routePayload)
        {
            var depotResources   = depot.GetResources();
            var economyBerthCost = routePayload.EconomyBerths * BERTH_COST_MULTIPLIER;
            var luxuryBerthCost  = routePayload.LuxuryBerths * BERTH_COST_MULTIPLIER;
            var totalBerthCost   = economyBerthCost + luxuryBerthCost;
            var originHab        = depotResources
                                   .FirstOrDefault(r => r.ResourceName == "Habitation");

            if (originHab == null)
            {
                DisplayMessage(string.Format(
                                   _insufficientHabitationMessage,
                                   totalBerthCost));
                return(false);
            }
            if (originHab.Available < totalBerthCost)
            {
                DisplayMessage(string.Format(
                                   _insufficientHabitationMessage,
                                   totalBerthCost - originHab.Available));
                return(false);
            }
            var originLifeSupport = depotResources
                                    .FirstOrDefault(r => r.ResourceName == "LifeSupport");

            if (originLifeSupport == null)
            {
                DisplayMessage(string.Format(
                                   _insufficientLifeSupportMessage,
                                   totalBerthCost));
                return(false);
            }
            if (originLifeSupport.Available < totalBerthCost)
            {
                DisplayMessage(string.Format(
                                   _insufficientLifeSupportMessage,
                                   totalBerthCost - originLifeSupport.Available));
                return(false);
            }
            if (luxuryBerthCost > 0)
            {
                var originColonySupplies = depotResources
                                           .FirstOrDefault(r => r.ResourceName == "ColonySupplies");
                if (originColonySupplies == null)
                {
                    DisplayMessage(string.Format(
                                       _insufficientColonySuppliesMessage,
                                       luxuryBerthCost));
                    return(false);
                }
                if (originColonySupplies.Available < luxuryBerthCost)
                {
                    DisplayMessage(string.Format(
                                       _insufficientColonySuppliesMessage,
                                       luxuryBerthCost - originColonySupplies.Available));
                    return(false);
                }
            }
            return(true);
        }