public BaseEquipment(string[] fields, DamageSet damageSet, DamageSet secondaryDamageSet, string name) { this.Reference = fields[0]; this.Unique = fields[1] != "0"; this.DamageSet = damageSet; this.SecondaryDamageSet = secondaryDamageSet; this.Name = name; this.EquipmentType = (EquipmentType)Enum.Parse(typeof(EquipmentType), fields[2]); }
public bool CanDefeatWith(List <Equipment> playerEquipment) { var playerAttack = new DamageSet(); var playerDefense = new DamageSet(); var playerJewelry = new DamageSet(); // TODO: Player wilds and jewelry // In the first pass, weapons, shields, and body armour is calculated // Rings are amulets are calculated afterwards and split as needed between attack/defense foreach (Equipment equipment in playerEquipment) { switch (equipment.EquipmentType) { case EquipmentType.OneHand: case EquipmentType.TwoHand: playerAttack += equipment.DamageSet; break; case EquipmentType.Body: case EquipmentType.Shield: playerDefense += equipment.DamageSet; break; case EquipmentType.Ring: case EquipmentType.Amulet: playerAttack.Physical += equipment.DamageSet.Physical; playerDefense.Block += equipment.DamageSet.Block; playerJewelry += equipment.DamageSet; break; } } // These have been moved to attack and defense playerJewelry.Physical = 0; playerJewelry.Block = 0; playerAttack = (playerAttack - this.Defense).ConvertToExtra(); playerDefense = (playerDefense - this.Attack).ConvertToExtra(); // If player attack isn't strong enough, try to borrow stats from Jewelry if (!playerAttack.DamageSatisfied()) { int attackDeficit = playerAttack.DamageDeficit; foreach (DamageSet jewelryAllocation in playerJewelry.Subsets(attackDeficit)) { if ((playerAttack + jewelryAllocation).ConvertToExtra().DamageSatisfied() && (playerDefense + playerJewelry - jewelryAllocation).ConvertToExtra().DamageSatisfied()) { return(true); } } } return(playerAttack.DamageSatisfied() && (playerDefense + playerJewelry).ConvertToExtra().DamageSatisfied()); }
public void SetDamage(DamageSet damageSet) { ClearDamage(); this.Add(DamageType.BLOCK, damageSet.Block); this.Add(DamageType.PHYSICAL, damageSet.Physical); this.Add(DamageType.FIRE, damageSet.Fire); this.Add(DamageType.COLD, damageSet.Cold); this.Add(DamageType.LIGHTNING, damageSet.Lightning); this.Add(DamageType.CHAOS, damageSet.Chaos); this.Add(DamageType.WILD, damageSet.Wild); this.Add(DamageType.LIFE, damageSet.Extra); }
public IEnumerable <DamageSet> Subsets(int size) { // Build initial state DamageSet tmp = new DamageSet(); for (int i = 0; i < SIZE && size > 0; i++) { int sizeAtIndex = Math.Min(size, this[i]); tmp[i] = sizeAtIndex; size -= sizeAtIndex; } int rightmost, next; if (size == 0) { yield return(tmp); } else { yield break; } do { rightmost = tmp.RightmostNonZero(); next = this.NextNonZero(rightmost); if (next != -1) { tmp[rightmost]--; tmp[next]++; } else { int falloff = tmp[rightmost]; tmp[rightmost] = 0; rightmost = tmp.RightmostNonZero(); if (rightmost <= 0) { break; } tmp[rightmost++]--; tmp[rightmost] = falloff + 1; } if (!(this - tmp).AnyNegative) { yield return(tmp); } } while (true); }
public void Setup() { var enemyOneAttack = new DamageSet { Fire = 3 }; var enemyOneDefense = new DamageSet { Cold = 3 }; this.enemyOne = new Enemy(enemyOneAttack, enemyOneDefense); var enemyTwoAttack = new DamageSet { Fire = 3 }; var enemyTwoDefense = new DamageSet { Cold = 3, Extra = 2 }; this.enemyTwo = new Enemy(enemyTwoAttack, enemyTwoDefense); var enemyThreeAttack = new DamageSet { Fire = 3, Extra = 2 }; var enemyThreeDefense = new DamageSet { Cold = 3 }; this.enemyThree = new Enemy(enemyThreeAttack, enemyThreeDefense); var enemyFourAttack = new DamageSet { Block = 5, Extra = 2 }; var enemyFourDefense = new DamageSet { Physical = 5, Extra = 2 }; this.enemyFour = new Enemy(enemyFourAttack, enemyFourDefense); }
public DamageSetConfig(string[] fields, Translation translation) { this.Reference = fields[0]; this.DamageSet = new DamageSet(fields); this.Translation = translation == null ? string.Empty : translation.Value; }
public DamageSetConfig(DamageSet damageSet) { this.DamageSet = damageSet; }
public BaseEquipment(EquipmentType type, DamageSet damage) { this.EquipmentType = type; this.DamageSet = damage; }
public Enemy(DamageSet attack, DamageSet defense) { this.Attack = attack; this.Defense = defense; }
public Equipment(EquipmentType type, DamageSet baseDamage) { this.Base = new BaseEquipment(type, baseDamage); }