public bool HasKeyword(Keywords keyword) { return(CurrentKeywords.Contains(keyword)); }
public void UpdateEnchantments() { ResetStats(); CurrentKeywords.Clear(); foreach (var enchantment in Enchantments.OrderBy(x => x.Enchantment.Status)) { if (enchantment.Enchantment.Status != UnitEnchantment.EnchantmentStatus.None) { if (enchantment.IsActive) { if (enchantment.Enchantment.Status == UnitEnchantment.EnchantmentStatus.OverloadPassive) { var totalOverload = 0; if (Owner.UsedResources.Contains(CardResources.Mana)) { totalOverload = ((PlayerMana)Owner.Resources.Single(x => x.ResourceType == CardResources.Mana)).TotalOverload; } var currentAttack = GetStat(StatTypes.Attack); int attackModifier; if (currentAttack > 0) { attackModifier = Mathf.Min(totalOverload, currentAttack - 1); } else { attackModifier = 0; } enchantment.Enchantment.AddStatModifier(StatTypes.Attack, StatModifierTypes.Modify, -attackModifier); } foreach (var statModifier in enchantment.Enchantment.StatModifiers) { ModifyStat(statModifier.ModType, statModifier.StatType, statModifier.Value); if (!enchantment.IsApplied) { switch (statModifier.ModType) { case StatModifierTypes.Modify: if (statModifier.StatType == StatTypes.MaxHealth) { CurrentHealth += statModifier.Value; } if (statModifier.StatType == StatTypes.Speed && (Status != UnitStatuses.Preparing || Status != UnitStatuses.Enemy)) { RemainingSpeed += statModifier.Value; if (CanMove && Status != UnitStatuses.Enemy && Status != UnitStatuses.Start) { Status = UnitStatuses.Middle; } } break; case StatModifierTypes.Set: if (statModifier.StatType == StatTypes.MaxHealth) { CurrentHealth = GetStat(StatTypes.MaxHealth); } if (statModifier.StatType == StatTypes.Speed && (Status != UnitStatuses.Preparing || Status != UnitStatuses.Enemy)) { RemainingSpeed = GetStat(StatTypes.Speed); if (CanMove && Status != UnitStatuses.Enemy && Status != UnitStatuses.Start) { Status = UnitStatuses.Middle; } } break; default: break; } if (statModifier.StatType == StatTypes.Empowered && IsDeployed) { Owner.ModifyEmpowered(statModifier.Value); } } } foreach (var keyword in enchantment.Enchantment.Keywords) { if (!HasKeyword(keyword)) { CurrentKeywords.Add(keyword); } } foreach (var statusEffect in enchantment.Enchantment.StatusEffects) { if (!enchantment.IsApplied) { if (!HasStatusEffect(statusEffect)) { CurrentStatusEffects.Add(statusEffect); } } } enchantment.IsApplied = true; } } else { throw new Exception("Not a valid enchantment"); } } //Resets the health and speed to cap them out at their max CurrentHealth = currentHealth; RemainingSpeed = remainingSpeed; if (GetStat(StatTypes.Attack) < 0) { ModifyStat(StatModifierTypes.Set, StatTypes.Attack, 0); } GameManager.instance.CheckWarden(); RefreshCounter(); }