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); }
public double Trigger(EnchantmentParameters ep) { double ret = 0.0; bool conditionsMet = true; foreach (Calculable c in conditions) { double?calc = c.Calculate(ep); if (calc == null || calc <= 0) { conditionsMet = false; } } if (conditionsMet) { foreach (Triggerable t in ifResults) { ret += t.Trigger(ep); } } else { foreach (Triggerable t in elseResults) { ret += t.Trigger(ep); } } return(ret); }
public double?Calculate(EnchantmentParameters ep) { if (SourceType == ep.triggerSource) { return(1); } return(0); }
public double?Calculate(EnchantmentParameters ep) { object ret = GetVariables()[varName][1]; double d = 0.0; Double.TryParse(ret.ToString(), out d); return(d); }
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 double Trigger(EnchantmentParameters ep) { double?valn = valueToReturn.Calculate(ep); if (valn == null) { return(0); } return((double)valn); }
public double Trigger(EnchantmentParameters ep) { double?dn = setTo.Calculate(ep); if (dn == null) { return(0); } double d = (double)dn; GetVariables()[varName][1] = d; return(0.0); }
public double Trigger(EnchantmentParameters ep) { Character c = GetParentChar(); Logic recurse = this; while (recurse.Parent != null) { recurse = recurse.Parent; } double idx = recurse.GetHashCode(); c.EnchantmentMessagesForGoogle[idx] = "\n" + message + "\n"; return(0.0); }
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 Character getCharByAccessString(EnchantmentParameters ep, string str) { switch (str) { case "Attacker": return(ep.ao.Attacker); case "Defender": return(ep.ao.Defender); case "Caster": return(ep.stc.caster); default: return(new Character()); } }
public double?Calculate(EnchantmentParameters ep) { switch (operation) { case EnchantmentUtilities.MathTypes.Add: return(left.Calculate(ep) + right.Calculate(ep)); case EnchantmentUtilities.MathTypes.Divide: return(left.Calculate(ep) / right.Calculate(ep)); case EnchantmentUtilities.MathTypes.Multiply: return(left.Calculate(ep) * right.Calculate(ep)); case EnchantmentUtilities.MathTypes.Subtract: return(left.Calculate(ep) - right.Calculate(ep)); case EnchantmentUtilities.MathTypes.EqualTo: double?lequal = left.Calculate(ep); double?requal = right.Calculate(ep); if (lequal == requal) { return(1); } else { return(0); } case EnchantmentUtilities.MathTypes.GreaterThan: double?lgreater = left.Calculate(ep); double?rlessthan = right.Calculate(ep); if (lgreater > rlessthan) { return(1); } else { return(0); } } return(0); }
public static double triggerAllEnchantmentsForChar(Character c, EnchantmentParameters ep) { if (ep.ao == null) { ep.ao = c.CombatStuff.aoForEnchantments; } if (ep.stc == null) { ep.stc = c.CombatStuff.stcForEnchantments; } double ret = 0.0; foreach (IfElseLogic iel in c.Enchantments.Keys) { ret += iel.Trigger(ep); } foreach (Item i in c.Items) { foreach (IfElseLogic iel in i.Enchantments.Keys) { ret += iel.Trigger(ep); } } if (c.CombatStuff != null) { if (c.CombatStuff.CombatWeapon != null) { if (c.CombatStuff.CombatWeapon.ItemEffects != null) { foreach (IfElseLogic iel in c.CombatStuff.CombatWeapon.Enchantments.Keys) { ret += iel.Trigger(ep); } } } } return(ret); }
public double?Calculate(EnchantmentParameters ep) { return(val); }
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); } }