public void Setup(Logic l)
        {
            _data = (MathLogic)l;
            if (_data.display != null && _data.display != this)
            {
                _data.display.Close();
            }
            _data.display = this;

            comboBoxLeft.DataSource  = EnchantmentUtilities.getCalculableTypes();
            comboBoxRight.DataSource = EnchantmentUtilities.getCalculableTypes();
            comboBoxMathTypes.SelectedIndexChanged -= comboBoxMathTypes_SelectedIndexChanged;
            comboBoxMathTypes.DataSource            = Enum.GetValues(typeof(EnchantmentUtilities.MathTypes));
            comboBoxMathTypes.SelectedIndexChanged += comboBoxMathTypes_SelectedIndexChanged;
            comboBoxMathTypes.SelectedItem          = _data.operation;
            if (_data.left != null)
            {
                comboBoxLeft.SelectedItem = ((Logic)_data.left).LogicType;
                labelLeft.Text            = ((Logic)_data.left).LogicType;
            }
            if (_data.right != null)
            {
                comboBoxRight.SelectedItem = ((Logic)_data.right).LogicType;
                labelRight.Text            = ((Logic)_data.right).LogicType;
            }
        }
 private void buttonEditElseResult_Click(object sender, EventArgs e)
 {
     if (_data.elseResults.Any() && comboBoxElseResults.Text != "")
     {
         EnchantmentUtilities.EditLogicWithRightForm((Logic)_data.elseResults[comboBoxElseResults.SelectedIndex]);
     }
 }
Beispiel #3
0
        public double Trigger(EnchantmentParameters ep)
        {
            Character charAttacker = getCharByAccessString(ep, attacker.ToString());
            Character charDefender = getCharByAccessString(ep, defender.ToString());

            if (charAttacker.enchantmentLayersDeep > 0)
            {
                return(0);
            }
            charAttacker.enchantmentLayersDeep++;
            double?an = attackValue.Calculate(ep);
            double?dn = defenceValue.Calculate(ep);

            if (an != null && dn != null)
            {
                double a = (double)an;
                double d = (double)dn;

                Weapon save = charAttacker.CombatStuff.CombatWeapon;

                string selectedWepforcalc = EnchantmentUtilities.checkForVariable(selectedWeap, this);
                charAttacker.CombatStuff.CombatWeapon = Utilities.GetWeaponByName(selectedWepforcalc);

                AttackOutcome outcome = CombatScripts.RunCombat(charAttacker, charDefender, a, d, null);
                CombatScripts.applyAttackOutcome(outcome);

                charAttacker.CombatStuff.CombatWeapon = save;
            }
            charAttacker.enchantmentLayersDeep--;
            return(0.0);
        }
 private void buttonEditCondition_Click(object sender, EventArgs e)
 {
     if (_data.conditions.Any() && comboBoxCurrentConditions.Text != "")
     {
         EnchantmentUtilities.EditLogicWithRightForm((Logic)_data.conditions[comboBoxCurrentConditions.SelectedIndex]);
     }
 }
        public void Setup(Logic l)
        {
            _data = (SetVariable)l;
            if (_data.display != null && _data.display != this)
            {
                _data.display.Close();
            }
            _data.display = this;

            comboBoxCalculables.DataSource = EnchantmentUtilities.getCalculableTypes();
            if (_data.setTo != null)
            {
                comboBoxCalculables.SelectedItem = ((Logic)_data.setTo).LogicType;
                label1.Text = ((Logic)_data.setTo).LogicType;
            }

            if (_data.parent != null)
            {
                comboBoxVariables.SelectedIndexChanged -= comboBoxVariables_SelectedIndexChanged;
                EnchantmentUtilities.FillComboboxWithVariableNames(comboBoxVariables, _data);
                comboBoxVariables.SelectedIndexChanged += comboBoxVariables_SelectedIndexChanged;
                if (_data.varName != null)
                {
                    comboBoxVariables.SelectedItem = _data.varName;
                }
            }
        }
        public double Trigger(EnchantmentParameters ep)
        {
            double?pot = potency.Calculate(ep);
            double?len = length.Calculate(ep);
            double?det = deterioration.Calculate(ep);

            if (pot != null && len != null && det != null)
            {
                double p = (double)pot;
                double l = (double)len;
                double d = (double)det;

                Character charToEffect = getCharByAccessString(ep, target.ToString());
                if (charToEffect.CombatStuff == null ||
                    charToEffect.CombatStuff.CombatName == "" ||
                    !CombatHolder._inCombatChars.Any(A => A.CombatStuff.CombatName == charToEffect.CombatStuff.CombatName))
                {
                    return(0.0);
                }
                EffectHolder.EffectType efftype;
                bool parsedType = Enum.TryParse(EnchantmentUtilities.checkForVariable(effectType, this), out efftype);
                if (effectType != null && effectType != "" && !parsedType)
                {
                    MessageBox.Show("Invalid effect Type");
                    return(0.0);
                }
                EffectHolder.EffectTag efftag;
                bool parsedTag = Enum.TryParse(EnchantmentUtilities.checkForVariable(effectTag, this), out efftag);
                if (effectTag != null && effectTag != "" && !parsedTag)
                {
                    MessageBox.Show("Invalid effect tag");
                    return(0.0);
                }
                Utilities.DamageType?damtype;
                Utilities.DamageType tempdamtype;
                bool parsedDam = Enum.TryParse(EnchantmentUtilities.checkForVariable(damageType, this), out tempdamtype);
                damtype = tempdamtype;
                if (EnchantmentUtilities.checkForVariable(damageType, this) == "")
                {
                    damtype = null;
                }
                if (damageType != null && damageType != "" && !parsedDam)
                {
                    MessageBox.Show("Invalid damage Type");
                    return(0.0);
                }
                Effect e = new Effect(efftype, p, (int)l, d);
                e.effectTag = efftag;

                Utilities.forceTypesToConformToTag(e);

                e.damageType = damtype;

                EffectHolder.CreateEffect(e, charToEffect, false);
            }
            return(0.0);
        }
        public void Setup(Logic l)
        {
            _data = (CreateEffect)l;
            if (_data.display != null && _data.display != this)
            {
                _data.display.Close();
            }
            _data.display = this;

            comboBoxTarget.SelectedIndexChanged -= comboBoxTarget_SelectedIndexChanged;
            comboBoxTarget.DataSource            = Enum.GetValues(typeof(EnchantmentUtilities.CharacterSelectionSubmenu));
            comboBoxTarget.SelectedIndexChanged += comboBoxTarget_SelectedIndexChanged;

            comboBoxEffectType.SelectedIndexChanged -= comboBoxEffectType_SelectedIndexChanged;
            comboBoxEffectType.DataSource            = Enum.GetValues(typeof(EffectHolder.EffectType));
            comboBoxEffectType.SelectedIndexChanged += comboBoxEffectType_SelectedIndexChanged;

            comboBoxEffectTag.SelectedIndexChanged -= comboBoxEffectTag_SelectedIndexChanged;
            comboBoxEffectTag.DataSource            = Enum.GetValues(typeof(EffectHolder.EffectTag));
            comboBoxEffectTag.SelectedIndex         = -1;
            comboBoxEffectTag.SelectedIndexChanged += comboBoxEffectTag_SelectedIndexChanged;

            comboBoxDamageType.SelectedIndexChanged -= comboBoxDamageType_SelectedIndexChanged;
            comboBoxDamageType.DataSource            = Enum.GetValues(typeof(Utilities.DamageType));
            comboBoxDamageType.SelectedIndex         = -1;
            comboBoxDamageType.SelectedIndexChanged += comboBoxDamageType_SelectedIndexChanged;

            comboBoxLength.SelectedIndexChanged -= comboBoxLength_SelectedIndexChanged;
            comboBoxLength.DataSource            = EnchantmentUtilities.getCalculableTypes();
            if (_data.length != null)
            {
                comboBoxLength.SelectedItem = ((Logic)_data.length).LogicType;
            }
            comboBoxLength.SelectedIndexChanged += comboBoxLength_SelectedIndexChanged;

            comboBoxPotency.SelectedIndexChanged -= comboBoxPotency_SelectedIndexChanged;
            comboBoxPotency.DataSource            = EnchantmentUtilities.getCalculableTypes();
            if (_data.potency != null)
            {
                comboBoxPotency.SelectedItem = ((Logic)_data.potency).LogicType;
            }
            comboBoxPotency.SelectedIndexChanged += comboBoxPotency_SelectedIndexChanged;

            comboBoxDeterioration.SelectedIndexChanged -= comboBoxDeterioration_SelectedIndexChanged;
            comboBoxDeterioration.DataSource            = EnchantmentUtilities.getCalculableTypes();
            if (_data.deterioration != null)
            {
                comboBoxDeterioration.SelectedItem = ((Logic)_data.deterioration).LogicType;
            }
            comboBoxDeterioration.SelectedIndexChanged += comboBoxDeterioration_SelectedIndexChanged;

            comboBoxTarget.SelectedItem = _data.target;
            comboBoxEffectType.Text     = _data.effectType;
            comboBoxEffectTag.Text      = _data.effectTag;
            comboBoxDamageType.Text     = _data.damageType;
        }
        private void buttonAddCondition_Click(object sender, EventArgs e)
        {
            FormWithLogicSetup temp = EnchantmentUtilities.getCorrectFormType(comboBoxConditions.Text);

            temp.Data().Parent = _data;
            temp.Setup(temp.Data());
            _data.conditions.Add((Calculable)temp.Data());
            Setup(_data);
            temp.Show();
        }
        public double?Calculate(EnchantmentParameters ep)
        {
            string effTagforcalc  = EnchantmentUtilities.checkForVariable(effTag, this);
            string effTypeforcalc = EnchantmentUtilities.checkForVariable(effType, this);
            string damTypeforcalc = EnchantmentUtilities.checkForVariable(damType, this);

            if ((ep.eta == null || effTagforcalc == ep.eta.ToString()) &&
                (ep.ety == null || effTypeforcalc == ep.ety.ToString()) &&
                (damTypeforcalc ?? "") == ep.dty.ToString())
            {
                return(1);
            }
            return(0);
        }
        public void Setup(Logic l)
        {
            _data = (ReturnValue)l;
            if (_data.display != null && _data.display != this)
            {
                _data.display.Close();
            }
            _data.display = this;

            comboBoxValue.DataSource = EnchantmentUtilities.getCalculableTypes();
            if (_data.valueToReturn != null)
            {
                comboBoxValue.SelectedItem = ((Logic)_data.valueToReturn).LogicType;
                labelValue.Text            = ((Logic)_data.valueToReturn).LogicType;
            }
        }
        private void buttonAddElseResult_Click(object sender, EventArgs e)
        {
            FormWithLogicSetup temp;

            if (Enum.GetNames(typeof(EnchantmentUtilities.TriggerableTypes)).Contains(comboBoxResults.Text))
            {
                temp = EnchantmentUtilities.getCorrectFormType(comboBoxResults.Text);
            }
            else
            {
                temp = new IfElseLogicForm(Utilities.GetEnchantmentByName(comboBoxResults.Text));
            }
            temp.Data().Parent = _data;
            temp.Setup(temp.Data());
            _data.elseResults.Add((Triggerable)temp.Data());
            Setup(_data);
            temp.Show();
        }
        public void Setup(Logic l)
        {
            _data = (IfElseLogic)l;
            if (_data.display != null && _data.display != this)
            {
                _data.display.Close();
            }
            _data.display             = this;
            richTextBoxVariables.Text = "Variables:\n";
            foreach (object[] oarr in _data.variables)
            {
                richTextBoxVariables.Text += oarr[0] + "   " + oarr[1].ToString() + "\n";
            }

            richTextBoxVariables.Text += "\nVariables From Parent:\n";
            if (_data.parent != null)
            {
                Dictionary <String, Object[]> forDisplay = _data.parent.GetVariables();
                foreach (String s in forDisplay.Keys)
                {
                    richTextBoxVariables.Text += forDisplay[s][0] + "\t\t" + forDisplay[s][1].ToString() + "\n";
                }
            }

            EnchantmentUtilities.FillComboboxWithVariableNames(comboBoxVariables, _data);

            comboBoxConditions.DataSource = EnchantmentUtilities.getCalculableTypes();
            comboBoxResults.DataSource    = EnchantmentUtilities.getTriggerableTypes(checkBoxPremades.Checked);
            EnchantmentUtilities.FillComboboxWithNames(comboBoxCurrentConditions, _data.conditions);
            EnchantmentUtilities.FillComboboxWithNames(comboBoxIfResults, _data.ifResults);
            EnchantmentUtilities.FillComboboxWithNames(comboBoxElseResults, _data.elseResults);
            comboBoxCurrentConditions.Text          = "";
            comboBoxElseResults.Text                = "";
            comboBoxIfResults.Text                  = "";
            comboBoxCurrentConditions.SelectedIndex = comboBoxCurrentConditions.Items.Count - 1;
            comboBoxElseResults.SelectedIndex       = comboBoxElseResults.Items.Count - 1;
            comboBoxIfResults.SelectedIndex         = comboBoxIfResults.Items.Count - 1;
            textBoxLogicName.TextChanged           -= textBoxLogicName_TextChanged;
            textBoxLogicName.Text         = _data.name;
            textBoxLogicName.TextChanged += textBoxLogicName_TextChanged;
        }
 private void comboBoxPotency_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (_data.potency == null)
     {
         FormWithLogicSetup temp = EnchantmentUtilities.getCorrectFormType(comboBoxPotency.Text);
         temp.Data().Parent      = _data;
         temp.Setup(temp.Data());
         _data.potency = ((Calculable)temp.Data());
         temp.Show();
         Setup(_data);
     }
     else if (((Logic)_data.potency).LogicType == comboBoxPotency.Text)
     {
         EnchantmentUtilities.EditLogicWithRightForm((Logic)_data.potency);
     }
     else if (checkBoxChangeable.Checked)
     {
         ((Logic)_data.potency).Delete();
         _data.potency = null;
         comboBoxPotency_SelectedIndexChanged(sender, e);
     }
 }
Beispiel #14
0
 public void Setup(Logic l)
 {
     _data = (GetVariable)l;
     if (_data.display != null && _data.display != this)
     {
         _data.display.Close();
     }
     _data.display = this;
     if (_data.parent != null)
     {
         comboBoxVariables.SelectedIndexChanged -= comboBoxVariables_SelectedIndexChanged;
         EnchantmentUtilities.FillComboboxWithVariableNames(comboBoxVariables, _data);
         comboBoxVariables.SelectedIndexChanged += comboBoxVariables_SelectedIndexChanged;
         if (_data.varName != null)
         {
             if (_data.GetVariables().ContainsKey(_data.varName))
             {
                 comboBoxVariables.SelectedItem = _data.varName;
             }
         }
     }
 }
 // change defence val
 private void buttonChangeRight_Click(object sender, EventArgs e)
 {
     if (_data.defenceValue == null)
     {
         FormWithLogicSetup temp = EnchantmentUtilities.getCorrectFormType(comboBoxDefenderCalc.Text);
         temp.Data().Parent      = _data;
         temp.Setup(temp.Data());
         _data.defenceValue = ((Calculable)temp.Data());
         Setup(_data);
         temp.Show();
     }
     else if (((Logic)_data.defenceValue).LogicType == comboBoxDefenderCalc.Text)
     {
         EnchantmentUtilities.EditLogicWithRightForm((Logic)_data.defenceValue);
     }
     else if (checkBoxChangeable.Checked)
     {
         ((Logic)_data.defenceValue).Delete();
         _data.defenceValue = null;
         buttonChangeRight_Click(sender, e);
     }
 }
        public void Setup(Logic l)
        {
            _data = (MakeAttack)l;
            if (_data.display != null && _data.display != this)
            {
                _data.display.Close();
            }
            _data.display = this;

            comboBoxAttackerCalc.DataSource        = EnchantmentUtilities.getCalculableTypes();
            comboBoxDefenderCalc.DataSource        = EnchantmentUtilities.getCalculableTypes();
            comboBoxAttacker.SelectedIndexChanged -= comboBoxAttacker_SelectedIndexChanged;
            comboBoxAttacker.DataSource            = Enum.GetValues(typeof(EnchantmentUtilities.CharacterSelectionSubmenu));
            comboBoxAttacker.SelectedIndexChanged += comboBoxAttacker_SelectedIndexChanged;
            comboBoxDefender.SelectedIndexChanged -= comboBoxDefender_SelectedIndexChanged;
            comboBoxDefender.DataSource            = Enum.GetValues(typeof(EnchantmentUtilities.CharacterSelectionSubmenu));
            comboBoxDefender.SelectedIndexChanged += comboBoxDefender_SelectedIndexChanged;
            comboBoxWeapon.SelectedIndexChanged   -= comboBoxWeapon_SelectedIndexChanged;
            comboBoxWeapon.DataSource              = Utilities.GetWeaponNames();
            comboBoxWeapon.SelectedIndexChanged   += comboBoxWeapon_SelectedIndexChanged;

            if (_data.attackValue != null)
            {
                comboBoxAttackerCalc.SelectedItem = ((Logic)_data.attackValue).LogicType;
                labelLeft.Text = ((Logic)_data.attackValue).LogicType;
            }
            if (_data.defenceValue != null)
            {
                comboBoxDefenderCalc.SelectedItem = ((Logic)_data.defenceValue).LogicType;
                labelRight.Text = ((Logic)_data.defenceValue).LogicType;
            }
            comboBoxAttacker.SelectedItem = _data.attacker;
            comboBoxDefender.SelectedItem = _data.defender;
            if (_data.selectedWeap != null)
            {
                comboBoxWeapon.Text = _data.selectedWeap;
            }
        }
        public double?CalculateWithCharacter(Character c)
        {
            string Branch3forcalc = EnchantmentUtilities.checkForVariable(Branch3, this);
            string Branch4forcalc = EnchantmentUtilities.checkForVariable(Branch4, this);

            switch (Branch3forcalc)
            {
            case "Strength":
                return(c.Statistics.Strength + EffectHolder.GetValidEffectsByEffect(c, EffectHolder.EffectType.Strength, true));

            case "Dexterity":
                return(c.Statistics.Dexterity + EffectHolder.GetValidEffectsByEffect(c, EffectHolder.EffectType.Dexterity, true));

            case "Constitution":
                return(c.Statistics.Constitution + EffectHolder.GetValidEffectsByEffect(c, EffectHolder.EffectType.Constitution, true));

            case "Intelligence":
                return(c.Statistics.Intelligence + EffectHolder.GetValidEffectsByEffect(c, EffectHolder.EffectType.Intelligence, true));

            case "Wisdom":
                return(c.Statistics.Wisdom + EffectHolder.GetValidEffectsByEffect(c, EffectHolder.EffectType.Wisdom, true));

            case "Charisma":
                return(c.Statistics.Charisma + EffectHolder.GetValidEffectsByEffect(c, EffectHolder.EffectType.Charisma, true));

            case "Health":
                return(c.HitPoints);

            case "Stamina":
                return(c.Stamina);

            case "SelectedWeaponName":
                if (c.CombatStuff == null || c.CombatStuff.CombatWeapon == null)
                {
                    return(null);
                }
                double ret = 0;
                if (c.CombatStuff.CombatWeapon.ItemName == Branch4forcalc)
                {
                    ret = 1;
                }
                return(ret);

            case "SelectedWeaponType":
                if (c.CombatStuff == null || c.CombatStuff.CombatWeapon == null || c.CombatStuff.CombatWeapon.WeaponTypes == null)
                {
                    return(null);
                }
                double ret3 = 0;
                if (c.CombatStuff.CombatWeapon.WeaponTypes.Any(A => A.ToString() == Branch4forcalc))
                {
                    ret3 = 1;
                }
                return(ret3);

            case "Effects":
                EffectHolder.EffectType ety;
                EffectHolder.EffectTag  eta;

                Enum.TryParse(Branch4forcalc, out ety);
                Enum.TryParse(Branch4forcalc, out eta);
                if (ety.ToString() == Branch4forcalc)
                {
                    return(EffectHolder.GetValidEffectsByTag(c, eta, false));
                }
                return(EffectHolder.GetValidEffectsByEffect(c, ety, false));

            case "IsParentChar":
                double ret1 = 0;
                if (c == GetParentChar())
                {
                    ret1 = 1;
                }
                return(ret1);

            case "CreatureType":
                if (c.CreatureTypes == null)
                {
                    return(null);
                }
                double ret2 = 0;
                if (c.CreatureTypes.Any(A => A.ToString() == Branch4forcalc))
                {
                    ret2 = 1;
                }
                return(ret2);

            default:
                return(0);
            }
        }
        public double?Calculate(EnchantmentParameters ep)
        {
            string Branch1forcalc = EnchantmentUtilities.checkForVariable(Branch1, this);
            string Branch2forcalc = EnchantmentUtilities.checkForVariable(Branch2, this);
            string Branch3forcalc = EnchantmentUtilities.checkForVariable(Branch3, this);

            try
            {
                switch (Branch1forcalc)
                {
                case "AttackStats":
                    if (ep.ao == null)
                    {
                        return(null);
                    }
                    switch (Branch2forcalc)
                    {
                    case "AttackResult":
                        double ret = 0;
                        if (ep.ao.Othertext.ToString() == Branch3forcalc)
                        {
                            ret = 1;
                        }
                        return(ret);

                    case "AttackRoll":
                        return(ep.ao.Notes.attackroll);

                    case "DefendRoll":
                        return(ep.ao.Notes.defendRoll);

                    case "AttackValue":
                        return(ep.ao.Notes.attackValue);

                    case "DefendValue":
                        return(ep.ao.Notes.defendValue);

                    case "AttackAfterParry":
                        return(ep.ao.Notes.attackAfterParry);

                    case "Damage":
                        return(ep.ao.TotalStrikeAmountFromAllTypes());

                    case "Harm":
                        return(ep.ao.harm);

                    case "Bleed":
                        return(ep.ao.bleed);

                    case "Disorientation":
                        return(ep.ao.disorientation);

                    case "Impairment":
                        return(ep.ao.impairment);

                    case "Trauma":
                        return(ep.ao.trauma);

                    case "Ko":
                        return(ep.ao.ko);

                    default:
                        return(0);
                    }

                case "Character":
                    switch (Branch2forcalc)
                    {
                    case "Attacker":
                        if (ep.ao == null)
                        {
                            return(null);
                        }
                        return(CalculateWithCharacter(ep.ao.Attacker));

                    case "Defender":
                        if (ep.ao == null)
                        {
                            return(null);
                        }
                        return(CalculateWithCharacter(ep.ao.Defender));

                    case "Caster":
                        if (ep.stc == null)
                        {
                            return(null);
                        }
                        return(CalculateWithCharacter(ep.stc.caster));

                    case "Parent":
                        return(CalculateWithCharacter(GetParentChar()));

                    default:
                        return(0);
                    }

                case "Spell":
                    if (ep.stc == null)
                    {
                        return(null);
                    }
                    switch (Branch2forcalc)
                    {
                    case "SpellPower":
                        return(ep.stc.spellPower);

                    case "SpellEffects":
                        EffectHolder.EffectType ety;
                        EffectHolder.EffectTag  eta;

                        Enum.TryParse(Branch3forcalc, out ety);
                        Enum.TryParse(Branch3forcalc, out eta);

                        double ret = 0;;
                        foreach (Effect e in ep.stc.spell.SpellEffects.Keys)
                        {
                            if ((ety.ToString() == Branch3forcalc && e.effectTypes.Contains(ety)) ||
                                (eta.ToString() == Branch3forcalc && e.effectTag == eta))
                            {
                                //potency, length, deterioration
                                Tuple <Double, Double, Double> t = ep.stc.spell.SpellEffects[e];
                                ret += t.Item1 * System.Math.Abs(t.Item2);
                            }
                        }
                        return(ret);

                    default:
                        return(0);
                    }

                default:
                    return(0);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                //MessageBox.Show(e.Message + "\n" + e.StackTrace);
                return(null);
            }
        }