internal bool CanBeUpgraded(UpgradePair upgrade, bool left) { if (upgrade == null) { throw new ArgumentNullException(); } if (_upgrades.All(x => x.UpgradeType != upgrade.UpgradeType)) { return(true); } if (_upgrades.Count(x => x.UpgradeType != upgrade.UpgradeType) >= 2) { return(false); } var u = Upgrades.First(x => x.UpgradeType == upgrade.UpgradeType) as UpgradePair; if (left) { return(u.LeftAnimal != this); } else { return(u.RightAnimal != this); } }
internal void RemoveUpgrade(UpgradePair upgrade) { if (_upgrades.Contains(upgrade)) { _upgrades.Remove(upgrade); } }
public void AddUpgrade(IAnimal animalLeft, Card card, UpgradePair upgrade) { if (card.Upgrade1 != upgrade && card.Upgrade2 != upgrade) { throw new CardUpgradeIncostintenceException(); } Animals.AddUpgrade(animalLeft, upgrade); _cards.Remove(card); }
public void RemoveUpgrade(IAnimal animalLeft, UpgradePair upgrade) { if (animalLeft == null || upgrade == null) { throw new ArgumentNullException(); } (animalLeft as Animal).RemoveUpgrade(upgrade); NextAnimal(animalLeft).RemoveUpgrade(upgrade); }
public void AddUpgrade(IAnimal animalLeft, UpgradePair upgrade) { if (CanBeUpgraded(animalLeft, upgrade)) { (animalLeft as Animal).AddUpgrade(upgrade, true); NextAnimal(animalLeft).AddUpgrade(upgrade, false); } else { throw new UpgradesIncompatibleException(); } }
public bool CanBeUpgraded(IAnimal animalLeft, UpgradePair upgrade) { var i1 = GetPosition(animalLeft); if (i1 == Count - 1) { return(false); } var animalRight = _animals[i1 + 1]; return((animalLeft as Animal).CanBeUpgraded(upgrade, true) && (animalRight as Animal).CanBeUpgraded(upgrade, false)); }
internal void AddUpgrade(UpgradePair upgrade, bool left) { if (CanBeUpgraded(upgrade, left)) { if (left) { upgrade.LeftAnimal = this; } else { upgrade.RightAnimal = this; } _upgrades.Add(upgrade); } else { throw new UpgradesIncompatibleException(); } }