예제 #1
0
 public SummonAction(IScope scope, ICost cost, UnitData unit, IScreenEffect screenEffect)
 {
     _scope = scope;
     _cost = cost;
     _unit = unit;
     _screenEffect = screenEffect;
 }
예제 #2
0
 void IPayabilityObserver.NotifyPayable(bool payable, ICost source)
 {
     foreach (var observer in impactObservers)
     {
         observer.NotifyImpact(payable, this);
     }
 }
        protected CostBatch addAssocCost(ICost cost)
        {
            CostBatch deltas       = new CostBatch();
            bool      containsItem = assocCostDictionary.ContainsKey(cost.Guid);

            if (containsItem)
            {
                CostSummaryItem item  = assocCostDictionary[cost.Guid];
                CostBatch       delta = item.AddQuantity(1);
                AssocTECCostTotal   += delta.GetCost(CostType.TEC);
                AssocTECLaborTotal  += delta.GetLabor(CostType.TEC);
                AssocElecCostTotal  += delta.GetCost(CostType.Electrical);
                AssocElecLaborTotal += delta.GetLabor(CostType.Electrical);
                deltas += delta;
            }
            else
            {
                CostSummaryItem item = new CostSummaryItem(cost);
                assocCostDictionary.Add(cost.Guid, item);
                if (cost.Type == CostType.TEC)
                {
                    _assocTECItems.Add(item);
                    AssocTECCostTotal  += item.TotalCost;
                    AssocTECLaborTotal += item.TotalLabor;
                }
                else if (cost.Type == CostType.Electrical)
                {
                    _assocElecItems.Add(item);
                    AssocElecCostTotal  += item.TotalCost;
                    AssocElecLaborTotal += item.TotalLabor;
                }
                deltas += new CostBatch(item.TotalCost, item.TotalLabor, cost.Type);
            }
            return(deltas);
        }
예제 #4
0
        public ResourceCost(ICost cost, ICost overtime)
        {
            if (cost == null)
            {
                throw new ArgumentNullException("cost");
            }

            if (cost.TableNameOrDescription != "ToolCost")
            {
                throw new ArgumentException($"Incorrect TableNameOrDescription: Expected ToolCost, got {cost.TableNameOrDescription}", "cost");
            }

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

            if (overtime.TableNameOrDescription != "ToolOvertimeCost")
            {
                throw new ArgumentException($"Incorrect TableNameOrDescription: Expected ToolOvertimeCost, got {overtime.TableNameOrDescription}", "overtime");
            }

            if (cost.ChargeTypeID != overtime.ChargeTypeID)
            {
                throw new ArgumentException($"ChargeTypeID mismatch: cost.ChargeTypeID = {cost.ChargeTypeID}, overtime.ChargeTypeID = {overtime.ChargeTypeID}");
            }

            ResourceID         = cost.RecordID.GetValueOrDefault();
            ChargeTypeID       = cost.ChargeTypeID;
            AcctPer            = cost.AcctPer;
            AddVal             = cost.AddVal;
            MulVal             = cost.MulVal;
            OvertimeMultiplier = overtime.MulVal;
        }
 public GiveAbnormalConditionAction(IScope scope, ICost cost, IScreenEffect screenEffect, IAbnormalCondition cond)
 {
     _scope = scope;
     _cost = cost;
     _screenEffect = screenEffect;
     _cond = cond;
 }
예제 #6
0
 public MagicAction(IScope scope, ICost cost, int power, AttackType attackType, IScreenEffect screenEffect)
 {
     _scope = scope;
     _cost = cost;
     _power = power;
     _attackType = attackType;
     _screenEffect = screenEffect;
 }
예제 #7
0
 public WallCrashAction(IScope scope, ICost cost, IScreenEffect screenEffect, int power, AttackType attackType)
 {
     _scope = scope;
     _cost = cost;
     _screenEffect = screenEffect;
     _power = power;
     _attackType = attackType;
 }
 public ActivatedAbilityBase(ICondition condition, ICost cost, IEffect effect)
 {
     Condition         = condition;
     Condition.Ability = this;
     Cost           = cost;
     Cost.Ability   = this;
     Effect         = effect;
     Effect.Ability = this;
 }
예제 #9
0
 public DelugeAction(IScope scope, ICost cost, IScreenEffect screenEffect, int power, AttackType attackType, Landform waterLandform)
 {
     _scope = scope;
     _cost = cost;
     _screenEffect = screenEffect;
     _brinkLandform = waterLandform;
     _power = power;
     _attackType = attackType;
 }
예제 #10
0
        void IPayabilityObserver.NotifyPayable(bool payable, ICost source)
        {
            payabilities[source] = payable;
            var allPayable = payabilities.All(payability => payability.Value);

            foreach (var observer in observers)
            {
                observer.NotifyPayable(allPayable, this);
            }
        }
예제 #11
0
 public void RemoveCost(ICost cost)
 {
     if (typeDictionary.ContainsKey(cost.Type))
     {
         typeDictionary[cost.Type] -= new CostObject(cost);
     }
     else
     {
         typeDictionary.Add(cost.Type, (new CostObject(cost) * -1));
     }
 }
예제 #12
0
 public void AddCost(ICost cost)
 {
     if (typeDictionary.ContainsKey(cost.Type))
     {
         typeDictionary[cost.Type] += new CostObject(cost);
     }
     else
     {
         typeDictionary.Add(cost.Type, new CostObject(cost));
     }
 }
예제 #13
0
 public SkillAction(IScope scope, ICost cost, int power, int maxTimes, AttackType attackType,
     AttackDependency atkDependency, DefenseDependency defDependency, IScreenEffect screenEffect)
 {
     _scope = scope;
     _cost = cost;
     _power = power;
     _maxTimes = Math.Max(1, maxTimes);
     _attackType = attackType;
     _atkDependency = atkDependency;
     _defDependency = defDependency;
     _screenEffect = screenEffect;
 }
예제 #14
0
 public CostSummaryItem(ICost cost) : base(Guid.NewGuid())
 {
     _cost = cost;
     if (cost is TECMisc misc)
     {
         _quantity = misc.Quantity;
     }
     else
     {
         _quantity = 1;
     }
     updateTotals();
 }
 public static void AssignRandomCostProperties(this ICost cost, TECCatalogs catalogs, Random rand)
 {
     if (cost is TECScope scope)
     {
         scope.AssignRandomScopeProperties(catalogs, rand);
     }
     else if (cost is TECTagged tagged)
     {
         tagged.AssignRandomTaggedProperties(catalogs, rand);
     }
     cost.Cost  = (rand.NextDouble() * 100);
     cost.Labor = (rand.NextDouble() * 100);
 }
예제 #16
0
 void IPayabilityObserver.NotifyPayable(bool payable, ICost source)
 {
     if (payable && !card.Faceup)
     {
         foreach (var observer in observers)
         {
             observer.NotifyRezzable(this);
         }
     }
     else
     {
         foreach (var observer in observers)
         {
             observer.NotifyNotRezzable();
         }
     }
 }
 protected CostBatch removeRatedCost(ICost cost, double length)
 {
     if (length > 0)
     {
         bool containsItem = ratedCostDictionary.ContainsKey(cost.Guid);
         if (containsItem)
         {
             RatedCostSummaryItem item  = ratedCostDictionary[cost.Guid];
             CostBatch            delta = item.RemoveLength(length);
             if (cost.Type == CostType.TEC)
             {
                 RatedTECCostTotal  += delta.GetCost(CostType.TEC);
                 RatedTECLaborTotal += delta.GetLabor(CostType.TEC);
             }
             else if (cost.Type == CostType.Electrical)
             {
                 RatedElecCostTotal  += delta.GetCost(CostType.Electrical);
                 RatedElecLaborTotal += delta.GetLabor(CostType.Electrical);
             }
             if (item.Length <= 0)
             {
                 ratedCostDictionary.Remove(cost.Guid);
                 if (cost.Type == CostType.TEC)
                 {
                     _ratedTECItems.Remove(item);
                 }
                 else if (cost.Type == CostType.Electrical)
                 {
                     _ratedElecItems.Remove(item);
                 }
             }
             return(delta);
         }
         else
         {
             logger.Error("Rated cost not found. Cannot remove rated cost length. Cost: {0}",
                          cost.Name);
             return(new CostBatch());
         }
     }
     else
     {
         return(new CostBatch());
     }
 }
        public void Load_Templates_AssociatedCosts()
        {
            Guid     expectedTECGuid  = new Guid("1c2a7631-9e3b-4006-ada7-12d6cee52f08");
            string   expectedTECName  = "Test TEC Associated Cost";
            double   expectedICost    = 31;
            double   expectedTECLabor = 13;
            CostType expectedTECType  = CostType.TEC;

            Guid     expectedElectricalGuid  = new Guid("63ed1eb7-c05b-440b-9e15-397f64ff05c7");
            string   expectedElectricalName  = "Test Electrical Associated Cost";
            double   expectedElectricalCost  = 42;
            double   expectedElectricalLabor = 24;
            CostType expectedElectricalType  = CostType.Electrical;

            ICost actualICost          = null;
            ICost actualElectricalCost = null;

            foreach (ICost cost in actualTemplates.Catalogs.AssociatedCosts)
            {
                if (cost.Guid == expectedTECGuid)
                {
                    actualICost = cost;
                }
                else if (cost.Guid == expectedElectricalGuid)
                {
                    actualElectricalCost = cost;
                }
                if (actualICost != null && actualElectricalCost != null)
                {
                    break;
                }
            }

            //Assert
            Assert.AreEqual(expectedTECName, actualICost.Name, "TEC cost name didn't load properly.");
            Assert.AreEqual(expectedICost, actualICost.Cost, "TEC cost cost didn't load properly.");
            Assert.AreEqual(expectedTECLabor, actualICost.Labor, "TEC cost labor didn't load properly.");
            Assert.AreEqual(expectedTECType, actualICost.Type, "TEC cost type didn't load properly.");

            Assert.AreEqual(expectedElectricalName, actualElectricalCost.Name, "Electrical cost name didn't load properly.");
            Assert.AreEqual(expectedElectricalCost, actualElectricalCost.Cost, "Electrical cost cost didn't load properly.");
            Assert.AreEqual(expectedElectricalLabor, actualElectricalCost.Labor, "Electrical cost labor didn't load properly.");
            Assert.AreEqual(expectedElectricalType, actualElectricalCost.Type, "Electrical cost type didn't load properly.");
        }
예제 #19
0
        public decimal Calculate(Ride ride)
        {
            cost = CostFactory.GetRateInstance(ride.State);

            var timed    = ride.Minutes / cost.PerMinute;
            var traveled = ride.Miles / cost.PerDistance;

            var total = cost.BaseFee
                        + cost.Tax
                        + ((timed + traveled) * cost.Rate);

            if (ride.StartDateTime.IsPeakHour())
            {
                total += cost.PeakCost;
            }
            if (ride.StartDateTime.IsNight())
            {
                total += cost.NightTimeRate;
            }
            return(total);
        }
        protected CostBatch addRatedCost(ICost cost, double length)
        {
            bool containsItem = ratedCostDictionary.ContainsKey(cost.Guid);

            if (containsItem)
            {
                RatedCostSummaryItem item  = ratedCostDictionary[cost.Guid];
                CostBatch            delta = item.AddLength(length);
                if (cost.Type == CostType.TEC)
                {
                    RatedTECCostTotal  += delta.GetCost(CostType.TEC);
                    RatedTECLaborTotal += delta.GetLabor(CostType.TEC);
                }
                else if (cost.Type == CostType.Electrical)
                {
                    RatedElecCostTotal  += delta.GetCost(CostType.Electrical);
                    RatedElecLaborTotal += delta.GetLabor(CostType.Electrical);
                }
                return(delta);
            }
            else
            {
                RatedCostSummaryItem item = new RatedCostSummaryItem(cost, length);
                ratedCostDictionary.Add(cost.Guid, item);
                if (cost.Type == CostType.TEC)
                {
                    _ratedTECItems.Add(item);
                    RatedTECCostTotal  += item.TotalCost;
                    RatedTECLaborTotal += item.TotalLabor;
                }
                else if (cost.Type == CostType.Electrical)
                {
                    _ratedElecItems.Add(item);
                    RatedElecCostTotal  += item.TotalCost;
                    RatedElecLaborTotal += item.TotalLabor;
                }
                return(new CostBatch(item.TotalCost, item.TotalLabor, cost.Type));
            }
        }
예제 #21
0
        private static double GetCost(ResourceUsage resource, Meter meter)
        {
            ICost costImplementation = null;

            if (meter.MeterRates.Count() == 1)
            {
                costImplementation = new DirectCost();
            }
            else if (meter.MeterRates.Count() > 1)
            {
                if (resource.Type == StorageAccountType)
                {
                    costImplementation = new BracketCost();
                }
                else
                {
                    costImplementation = new ScaledCost();
                }
            }

            return(costImplementation.CalculateCosts(resource, meter));
        }
예제 #22
0
        public CostBatch RemoveCost(ICost cost)
        {
            bool containsItem = assocCostDictionary.ContainsKey(cost.Guid);

            if (containsItem)
            {
                CostSummaryItem item  = assocCostDictionary[cost.Guid];
                CostBatch       delta = item.RemoveQuantity(1);
                if (cost.Type == CostType.TEC)
                {
                    AssocTECCostTotal  += delta.GetCost(CostType.TEC);
                    AssocTECLaborTotal += delta.GetLabor(CostType.TEC);
                }
                else if (cost.Type == CostType.Electrical)
                {
                    AssocElecCostTotal  += delta.GetCost(CostType.Electrical);
                    AssocElecLaborTotal += delta.GetLabor(CostType.Electrical);
                }
                if (item.Quantity < 1)
                {
                    assocCostDictionary.Remove(cost.Guid);
                    if (cost.Type == CostType.TEC)
                    {
                        _assocTECItems.Remove(item);
                    }
                    else if (cost.Type == CostType.Electrical)
                    {
                        _assocElecItems.Remove(item);
                    }
                }
                return(delta);
            }
            else
            {
                logger.Error("Cost not found. Cannot remove cost. Cost: {0}", cost.Name);
                return(new CostBatch());
            }
        }
예제 #23
0
 public CostBatch(ICost cost) : this()
 {
     typeDictionary.Add(cost.Type, new CostObject(cost));
 }
예제 #24
0
 public PayToTrash(ICost cost, Card card)
 {
     this.cost = cost;
     this.card = card;
 }
예제 #25
0
 public AI(ICost cost, uint depth, Player player)
 {
     _cost   = cost;
     _player = player;
     _depth  = depth;
 }
예제 #26
0
 public Cost(ICost strategy)
 {
     _strategy = strategy;
 }
예제 #27
0
 public Ability(ICost cost, IEffect effect)
 {
     this.cost   = cost;
     this.effect = effect;
 }
예제 #28
0
 void IPayabilityObserver.NotifyPayable(bool payable, ICost source)
 {
     this.payable = payable;
     Update();
 }
예제 #29
0
 public CostObject(ICost cost)
 {
     Cost  = cost.Cost;
     Labor = cost.Labor;
 }
예제 #30
0
 public ReportLogic(IInspections inspection, ICost cost)
 {
     _inspection = inspection;
     _cost       = cost;
 }
예제 #31
0
 public DrawCardActivatedAbility(ICost cost, IEffect effect) : base(new NoCondition(), cost, effect)
 {
 }
예제 #32
0
 public DrawCardActivatedAbility(ICondition condition, ICost cost, IEffect effect) : base(condition, cost, effect)
 {
 }
예제 #33
0
 internal Cost(CostType type)
 {
     TYPE         = type;
     costFunction = costFunctions[type];
 }
 public ClearBadConditonAction(IScope scope, ICost cost, IScreenEffect screenEffect)
 {
     _scope = scope;
     _cost = cost;
     _screenEffect = screenEffect;
 }
예제 #35
0
        private static (int nextRow, int nextColumn) addCostRow(IXLWorksheet worksheet, ICost cost, int startRow, int startColumn)
        {
            int x = startRow;
            int y = startColumn;

            worksheet.Cell(x, y).Value = cost.Name;
            y++;
            worksheet.Cell(x, y).Value = cost.Description;
            y++;
            worksheet.Cell(x, y).Value = cost.Cost;
            y++;
            worksheet.Cell(x, y).Value = cost.Labor;
            y++;
            worksheet.Cell(x, y).Value = cost.Type;
            y++;
            return(x + 1, y);
        }
 //Constructor
 public RatedCostSummaryItem(ICost ratedCost, double length) : base(Guid.NewGuid())
 {
     _ratedCost = ratedCost;
     _length    = length;
     updateTotals();
 }
예제 #37
0
 public ShippingCostController(ICost cost)
 {
     _cost = cost;
 }