/// <summary> /// /// Gets the status of a particular resource- i.e. whether it is increase, decreased or not changed /// /// </summary> private StatisticStatuses GetResourceStatus(CardResources resource) { if (ResourceConvertedTo.HasValue) { return(StatisticStatuses.Converted); } var currentCost = ResourceCost.Single(x => x.ResourceType == resource).Value; var defaultCost = DefaultCost.Single(x => x.ResourceType == resource).Value; //Note that the signs are flipped as cost is always negative if (currentCost > defaultCost) { return(StatisticStatuses.Buffed); } else if (currentCost < defaultCost) { return(StatisticStatuses.Debuffed); } else { return(StatisticStatuses.None); } }
public bool RecalculateCost() { ResourceInit(); foreach (var adjustCostObject in CostAdjustments) { if (!adjustCostObject.MustBeGreaterThan.HasValue || adjustCostObject.MustBeGreaterThan.HasValue && TotalResource < -adjustCostObject.MustBeGreaterThan.Value) { if (adjustCostObject.TargetResource.HasValue) { if (!Resources.Contains(adjustCostObject.TargetResource.Value)) { return(false); } var resourceCost = ResourceCost.Single(x => x.ResourceType == adjustCostObject.TargetResource); switch (adjustCostObject.AdjustmentType) { case StatModifierTypes.Modify: resourceCost.ModifyValue(-adjustCostObject.Value, adjustCostObject.MinCost.HasValue, -adjustCostObject.MinCost); break; case StatModifierTypes.Set: resourceCost.SetValue(-adjustCostObject.Value); break; default: throw new Exception("Not a valid stat mod type"); } } else { foreach (var resourceCost in ResourceCost) { switch (adjustCostObject.AdjustmentType) { case StatModifierTypes.Modify: resourceCost.ModifyValue(-adjustCostObject.Value, adjustCostObject.MinCost.HasValue, -adjustCostObject.MinCost); break; case StatModifierTypes.Set: resourceCost.SetValue(-adjustCostObject.Value); break; default: throw new Exception("Not a valid stat mod type"); } } //Removing the mixed modify cost as it was perhaps too complicated/confusing. May add this in later //For now, modifying cost just modifies each resource in the list #region Mixed Modify Cost //if (Resources.Count == 1) //{ // var resourceCost = ResourceCost.FirstOrDefault(); // switch (statModType) // { // case StatModifierTypes.Modify: // resourceCost.ModifyValue(-value, true); // break; // case StatModifierTypes.Set: // resourceCost.SetValue(value); // break; // default: // throw new Exception("Not a valid stat mod type"); // } //} //else //{ // bool isOdd = false; // if (statModType == StatModifierTypes.Modify) // { // if (value % 2 == 1) // { // value -= 1; // isOdd = true; // } // else if (value % 2 == -1) // { // value += 1; // isOdd = true; // } // value /= Resources.Count; // } // switch (statModType) // { // case StatModifierTypes.Modify: // ResourceCost.ForEach(x => x.ModifyValue(-value, true)); // break; // case StatModifierTypes.Set: // ResourceCost.ForEach(x => x.SetValue(value)); // break; // default: // throw new Exception("Not a valid stat mod type"); // } // if (isOdd) // { // var highestResources = ResourceCost.Where(x => x.Value == ResourceCost.Min(y => y.Value)).ToList(); // var valueModifier = value > 0 ? -1 : 1; // if (highestResources.Count() == 1) // { // highestResources.FirstOrDefault().ModifyValue(valueModifier, true); // } // else // { // var randomResource = UnityEngine.Random.Range(0, highestResources.Count()); // highestResources[randomResource].ModifyValue(valueModifier, true); // } // } //} #endregion } } } //Loops through each resource to clamp the values of each resource foreach (var resourceCost in ResourceCost) { //Modifies the cost by 0 to clamp the resource value resourceCost.ModifyValue(0, true); } return(true); }