예제 #1
0
    //Get customized text for each enchantment
    string GetEnchantmentStringValue(Enchantments key)
    {
        //Cast the string to an enum for quicker calculating
        //JPS: I would like to replace the text, such as Ice, Fire, Crit+, etc. with images, so that they
        //	   are more visually descriptive, and are easier to generalize for all equipment
        switch (key)
        {
        case Enchantments.ICE_KEY:
            return("<b><color=aqua>Ice: " + thisEquipment.enchantments[key] * 100 + "%</color></b>");

        case Enchantments.FIRE_KEY:
            return("<b><color=red>Fire: " + thisEquipment.enchantments[key] * 100 + "%</color></b>");

        case Enchantments.ADDITIONAL_CRIT_KEY:
            return("<b><color=purple>Crit+: " + thisEquipment.enchantments[key] * 100 + "%</color></b>");

        case Enchantments.ADDITIONAL_DAMAGE_KEY:
            return("<b><color=maroon>Dmg+: " + thisEquipment.enchantments[key] * 100 + "%</color></b>");

        case Enchantments.WOUNDING_KEY:
            return("<b><color=brown>Wound: " + thisEquipment.enchantments[key] * 100 + "%</color></b>");

        default:
            return("<color=red>ERROR: No enchantment found</color>");
        }
    }
예제 #2
0
 /// <summary>Initializes a new instance of the <see cref="Playable{T}"/> class.</summary>
 /// <param name="controller">The controller.</param>
 /// <param name="card">The card.</param>
 /// <param name="tags">The tags.</param>
 /// <autogeneratedoc />
 protected Playable(Controller controller, Card card, Dictionary <GameTag, int> tags)
     : base(controller, card, tags)
 {
     if (Card.Enchantments != null)
     {
         Enchantments.AddRange(Card.Enchantments);
     }
 }
예제 #3
0
        public void Enchant(Enchantments enchantments)
        {
            if (!Enum.IsDefined(typeof(Enchantments), enchantments))
            {
                throw new ArgumentException("Incorrect enchantment", nameof(enchantments));
            }

            this.Enchantments |= enchantments;
        }
예제 #4
0
        public Armor(string spriteName, string charSpriteName, string name, float defense, Enchantments enchantment = Enchantments.None, float effectDefense = 0) : base(name, spriteName)
        {
            Name = name;
            Defense = defense;
            Enchantment = enchantment;
            EffectDefense = effectDefense;

            CharacterArmorSprite = charSpriteName;
        }
예제 #5
0
 public Weapon(string spriteName, string name, float damage, float attackTime, float staminaCost, Enchantments enchantment = Enchantments.None, float effectDamage = 0)
     : base(name, spriteName)
 {
     Name = name;
     Damage = damage;
     AttackTime = attackTime;
     StaminaCost = staminaCost;
     Enchantment = enchantment;
     EffectDamage = effectDamage;
 }
예제 #6
0
    private static string GetAdjectiveFromKey(Equipment thisEquipment, Enchantments key)
    {
        //Different equipment types have different adjectives
        if (thisEquipment.equipmentType == EquipmentType.Weapon)
        {
            switch (key)
            {
            case Enchantments.ICE_KEY:
                return("Frigid ");

            case Enchantments.FIRE_KEY:
                return("Scorched ");

            case Enchantments.ADDITIONAL_CRIT_KEY:
                return("Warped ");

            case Enchantments.ADDITIONAL_DAMAGE_KEY:
                return("Refined ");

            case Enchantments.WOUNDING_KEY:
                return("Pained ");

            default:
                return("<color=red>ERROR: Adjective could not be determined!</color>");
            }
        }
        else if (thisEquipment.equipmentType == EquipmentType.Armor)
        {
            switch (key)
            {
            case Enchantments.ICE_KEY:
                return("Frostbitten ");

            case Enchantments.FIRE_KEY:
                return("Charred ");

            case Enchantments.ADDITIONAL_CRIT_KEY:
                return("Twisted ");

            case Enchantments.ADDITIONAL_DAMAGE_KEY:
                return("Reinforced ");

            case Enchantments.WOUNDING_KEY:
                return("Bloodied ");

            default:
                return("<color=red>ERROR: Armor adjective could not be determined!</color>");
            }
        }
        else
        {
            return("<color=red>ERROR: Equipment type is not defined for adjective!</color>");
        }
    }
예제 #7
0
        public static void manageEnchantments(this Enchantments enchantmentWeWantToTransfer, Item enchantmentGiver, Item subjectItem)
        {
            var ourEnchantingHost    = subjectItem.enchantmentsOfItem;
            var ourEnchantingDonator = enchantmentGiver.enchantmentsOfItem;

            if ((subjectItem.IDofItem == 3 || subjectItem.IDofItem == 4) && enchantmentGiver.IDofItem == 5)
            {
                ourEnchantingHost.Add(enchantmentWeWantToTransfer);
                ourEnchantingDonator.RemoveAt(ourEnchantingDonator.IndexOf(enchantmentWeWantToTransfer));
            }
        }
예제 #8
0
    private static string GetNounFromKey(Equipment thisEquipment, Enchantments key)
    {
        //Different equipment types have different adjectives
        if (thisEquipment.equipmentType == EquipmentType.Weapon)
        {
            switch (key)
            {
            case Enchantments.ICE_KEY:
                return(" of Frost");

            case Enchantments.FIRE_KEY:
                return(" of Blazing");

            case Enchantments.ADDITIONAL_CRIT_KEY:
                return(" of Distortion");

            case Enchantments.ADDITIONAL_DAMAGE_KEY:
                return(" of Power");

            case Enchantments.WOUNDING_KEY:
                return(" of Wounding");

            default:
                return("<color=red>ERROR: Weapon noun could not be determined!</color>");
            }
        }
        else if (thisEquipment.equipmentType == EquipmentType.Armor)
        {
            switch (key)
            {
            case Enchantments.ICE_KEY:
                return(" of Crystalization");                         //JPS: Not a fan of this one

            case Enchantments.FIRE_KEY:
                return(" of Inferno");

            case Enchantments.ADDITIONAL_CRIT_KEY:
                return(" of Willbending");

            case Enchantments.ADDITIONAL_DAMAGE_KEY:
                return(" of Fortification");

            case Enchantments.WOUNDING_KEY:
                return(" of Bloodthirst");

            default:
                return("<color=red>ERROR: Armor noun could not be determined!</color>");
            }
        }
        else
        {
            return("<color=red>ERROR: Equipment type is not defined for noun!</color>");
        }
    }
예제 #9
0
        protected override void doRun()
        {
            // Show the question about cumulative enchantment.
            List <Response> responses = new ()
            {
                new Response("yes", Helper.Translation.Get($"enchantments.cumulative.yes")),
                new Response("no", Helper.Translation.Get($"enchantments.cumulative.no")),
            };

            Game1.drawObjectQuestionDialogue
                (Helper.Translation.Get("enchantments.cumulative.question"), responses);

            Game1.currentLocation.afterQuestion = (Farmer _who, string response) =>
            {
                Game1.currentLocation.afterQuestion = null;
                bool concurrent = response == "yes";

                // Gather the appropriate predictions.
                List <Enchantments.Prediction> predictions =
                    Enchantments.ListForTool(Game1.player.CurrentTool, 8u, concurrent);
                if (predictions.Count == 0)
                {
                    throw new Exception("Could not predict enhancements.");
                }

                // Build the list of predictions.
                List <string> lines = new ()
                {
                    Helper.Translation.Get($"enchantments.header.{response}", new
                    {
                        toolName = Game1.player.CurrentTool.DisplayName,
                    })
                };
                uint firstNumber = predictions.First().number;
                foreach (var prediction in predictions)
                {
                    lines.Add(unbreak(Helper.Translation.Get($"enchantments.prediction", new
                    {
                        num  = prediction.number - firstNumber + 1u,
                        name = prediction.enchantment?.GetDisplayName() ?? "-",
                    }).ToString()));
                }

                // Show a list of the predictions.
                showDialogues(new List <string> {
                    string.Join("^", lines)
                });
                Game1.afterDialogues = extinguish;
            };
        }
    }
예제 #10
0
        public void ItemEnchantmentArgument_ParseShouldSucceed_WithDefaultNamespace()
        {
            // Arrange
            ItemEnchantmentArgument argument = new ItemEnchantmentArgument();

            Enchantments.Set("[\"foo\", \"bar\"]");
            IStringReader reader = new StringReader("minecraft:foo");

            // Act
            ReadResults readResults = argument.Parse(reader, out _);

            // Assert
            Assert.IsTrue(readResults.Successful);
        }
예제 #11
0
        public void Enchantments_ShouldNotContainEnchantment()
        {
            // Arrange
            ItemEnchantmentArgument argument = new ItemEnchantmentArgument();

            Enchantments.Set("[\"foo\", \"bar\"]");
            IStringReader reader = new StringReader("baz");

            // Act
            ReadResults readResults = argument.Parse(reader, out _);

            // Assert
            Assert.IsFalse(readResults.Successful);
        }
예제 #12
0
    public void RemoveEnchantmentsOfStatus(List <UnitEnchantment.EnchantmentStatus> enchantmentStatuses)
    {
        var removeEnchantments = Enchantments.Where(x => enchantmentStatuses.Contains(x.Enchantment.Status));

        foreach (var statusEffectList in removeEnchantments.Select(x => x.Enchantment.StatusEffects))
        {
            CurrentStatusEffects.RemoveAll(x => statusEffectList.Contains(x));
        }

        Enchantments.RemoveAll(x => removeEnchantments.Contains(x));

        UpdateEnchantments();

        RefreshCounter();
    }
예제 #13
0
        public string Enchant(string user, Enchantments enchantmentId, int enchantmentLevel = 1)
        {
            if (string.IsNullOrWhiteSpace(user))
            {
                throw new ArgumentNullException("user", "You must provide the user you're enchanting.");
            }
            if (enchantmentLevel < 1 || enchantmentLevel > 5)
            {
                throw new ArgumentOutOfRangeException("dataValue", "You must provide an enchantment level between 1 and 5.");
            }
            string cmd    = string.Format(TonkaCommands.CMD_ENCHANT, user, EnumUtils.GetEnumDefaultValue(enchantmentId), enchantmentLevel);
            string result = SendCommand(cmd);

            return(result);
        }
예제 #14
0
    private static string DetermineNoun(Equipment thisEquipment)
    {
        //An equipment will have no distinguishing noun if:
        //1) The equipment has 3 or more gem slots, and each is filled with a unique enchantment
        //2) The equipment has only 1 unique enchantment filling all of its slots
        //3) The equipment has no enchantments
        if (thisEquipment.enchantments.Count == 5)
        {
            return("");
        }
        else if (thisEquipment.enchantments.Count == 4 && thisEquipment.numGemSlots == 4)
        {
            return("");
        }
        else if (thisEquipment.enchantments.Count == 3 && thisEquipment.numGemSlots == 3)
        {
            return("");
        }
        else if (thisEquipment.enchantments.Count == 1)
        {
            return("");
        }
        else if (thisEquipment.enchantments.Count == 0)
        {
            return("");
        }
        //Otherwise, find the enchantment that has the largest percent-chance value
        else
        {
            Enchantments currentLargestKey   = Enchantments.NUMBER_OF_ENCHANTMENTS;
            float        currentLargestValue = 0;
            foreach (Enchantments key in thisEquipment.enchantments.Keys)
            {
                if (thisEquipment.enchantments[key] >= currentLargestValue)
                {
                    currentLargestKey   = key;
                    currentLargestValue = thisEquipment.enchantments[key];
                }
            }

            return(GetNounFromKey(thisEquipment, currentLargestKey));
        }
    }
예제 #15
0
    private static string DetermineAdjective(Equipment thisEquipment)
    {
        //If the Armor has 3 or more unique enchantments, it has the following adjectives
        if (thisEquipment.enchantments.Count == 5)
        {
            return("Chromatic ");
        }
        else if (thisEquipment.enchantments.Count == 4)
        {
            return("Tetrad ");            //JPS: I'd like to change this...
        }
        else if (thisEquipment.enchantments.Count == 3)
        {
            return("Triad ");            //JPS: I'd like to change this...
        }
        //Armors with no enchantments have no adjectives
        else if (thisEquipment.enchantments.Count == 0)
        {
            return("");
        }
        //Otherwise, find the enchantment that is the smaller of the two in terms of percent-chance
        else
        {
            Enchantments currentSmallestKey   = Enchantments.NUMBER_OF_ENCHANTMENTS;
            float        currentSmallestValue = 1000;
            foreach (Enchantments key in thisEquipment.enchantments.Keys)
            {
                if (thisEquipment.enchantments[key] < currentSmallestValue)
                {
                    currentSmallestKey   = key;
                    currentSmallestValue = thisEquipment.enchantments[key];
                }
            }

            //JPS: Known bug.  In the case of 5 gem slots, with 3 unique enchantments, the enchantment
            //	   tied for first should determine the adjective, NOT the smallest valued one.

            return(GetAdjectiveFromKey(thisEquipment, currentSmallestKey));
        }
    }
예제 #16
0
    public void ModifyOverloadEnchantment(PlayerMana manaResource = null)
    {
        string overloadSourceString = "Overload Reduction";

        if (Owner.UsedResources.Contains(CardResources.Mana))
        {
            if (manaResource == null)
            {
                manaResource = (PlayerMana)Owner.Resources.Single(x => x.ResourceType == CardResources.Mana);
            }

            var overloadEnchantment = Enchantments.Select(x => x.Enchantment).SingleOrDefault(x => x.Source == overloadSourceString);
            var isNew = false;
            if (overloadEnchantment == null)
            {
                overloadEnchantment = new UnitEnchantment()
                {
                    Status = UnitEnchantment.EnchantmentStatus.OverloadPassive, Source = overloadSourceString
                };
                isNew = true;
            }

            overloadEnchantment.AddStatModifier(StatTypes.Attack, StatModifierTypes.Modify, manaResource.TotalOverload);

            if (isNew)
            {
                AddEnchantment(overloadEnchantment);
            }
            else
            {
                UpdateEnchantments();
            }
        }
        else
        {
            throw new Exception("Cannot modify overload enchantment for a non-mana class");
        }
    }
예제 #17
0
		public string Enchant(string user, Enchantments enchantmentId, int enchantmentLevel = 1)
		{
			if (string.IsNullOrWhiteSpace(user))
			{
				throw new ArgumentNullException("user", "You must provide the user you're enchanting.");
			}
			if (enchantmentLevel < 1 || enchantmentLevel > 5)
			{
				throw new ArgumentOutOfRangeException("dataValue", "You must provide an enchantment level between 1 and 5.");
			}
			string cmd = string.Format(TonkaCommands.CMD_ENCHANT, user, EnumUtils.GetEnumDefaultValue(enchantmentId), enchantmentLevel);
			string result = SendCommand(cmd);
			return result;
		}
예제 #18
0
 public void DeleteEnchantment(AppliedEnchantment enchantment)
 {
     Enchantments.Remove(enchantment);
     CurrentStatusEffects.RemoveAll(x => enchantment.Enchantment.StatusEffects.Contains(x));
     UpdateEnchantments();
 }
예제 #19
0
    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();
    }
예제 #20
0
    public void AddEnchantment(UnitEnchantment enchantment)
    {
        if (enchantment.ValidEnchantment)
        {
            var newEnchantment = new AppliedEnchantment()
            {
                Enchantment = enchantment
            };
            if (newEnchantment.Enchantment.Keywords.Contains(Keywords.Flying))
            {
                if (!HasStatusEffect(StatusEffects.Airborne))
                {
                    newEnchantment.Enchantment.StatusEffects.Add(StatusEffects.Airborne);
                    if (Status != UnitStatuses.Preparing)
                    {
                        CanFlyOrLand = true;
                    }
                }
            }
            if (newEnchantment.Enchantment.Keywords.Contains(Keywords.Stealth))
            {
                newEnchantment.Enchantment.StatusEffects.Add(StatusEffects.Stealthed);
            }

            if (Status != UnitStatuses.Preparing && Status != UnitStatuses.None)
            {
                if (newEnchantment.Enchantment.Keywords.Contains(Keywords.SpecialSwiftstrike))
                {
                    if (!HasKeyword(Keywords.Swiftstrike) && !HasKeyword(Keywords.SpecialSwiftstrike))
                    {
                        ModifyActions(2);
                    }
                    else if (HasKeyword(Keywords.Swiftstrike))
                    {
                        ModifyActions(1);
                    }
                }
                else if (newEnchantment.Enchantment.Keywords.Contains(Keywords.Swiftstrike))
                {
                    if (!HasKeyword(Keywords.Swiftstrike) && !HasKeyword(Keywords.SpecialSwiftstrike))
                    {
                        ModifyActions(1);
                    }
                }
            }

            Enchantments.Add(newEnchantment);
            UpdateEnchantments();

            if (HasKeyword(Keywords.Prepared) && (Status == UnitStatuses.Preparing || Status == UnitStatuses.None))
            {
                RefreshActions();
            }

            RefreshCounter();
        }
        else
        {
            throw new Exception("Enchantment is not valid to add to unit");
        }
    }
예제 #21
0
 public void Disenchant()
 {
     this.Enchantments = Enchantments.None;
 }