/// <summary> /// Removes a List of AlchymicEffects from effects, the Item's AlchymicEffects List /// </summary> /// <param name="effects">AlchymicEffects to be removed</param> public void RemoveEffects(List <AlchymicEffect> effects) { foreach (AlchymicEffect effect in effects) { this.effects = this.effects & (~effect); } }
public AlchymicEffect Brew() { List <AlchymicEffect> effects = new List <AlchymicEffect>(); effects.Add(ingredient1.effects); effects.Add(ingredient2.effects); effects.Add(ingredient3.effects); craftedPotion.components = ingredients; // List of effects that appear in the list more than once // we're going to keep these AlchymicEffect appearedMoreThanOnce = new AlchymicEffect(); // List that will save whether that ingredient has appeared yet AlchymicEffect appearedOnce = 0; foreach (AlchymicEffect effect in effects) { if ((appearedOnce & effect) > 0) { appearedMoreThanOnce = appearedMoreThanOnce | (appearedOnce & effect); } appearedOnce = appearedOnce | effect; } return(appearedMoreThanOnce); }
/// <summary> /// Removes an array of AlchymicEffects from effects, the Item's AlchymicEffects List /// </summary> /// <param name="effects">AlchymicEffects to be removed</param> public void RemoveEffects(params AlchymicEffect[] effects) { foreach (AlchymicEffect effect in effects) { this.effects = this.effects & (~effect); } }
/// <summary> /// Adds an AlchymicEffect to effects, the Item's AlchymicEffects List /// </summary> /// <param name="effect">AlchymicEffect to be add</param> public void AddEffect(AlchymicEffect effect) { if ((this.effects & effect) != effect) { this.effects = this.effects ^ effect; } }
private Potion Brew(List <Ingredient> ingredients) { List <AlchymicEffect> effects = new List <AlchymicEffect>(); foreach (Ingredient ingredient in ingredients) { effects.Add(ingredient.effects); } // List of effects that appear in the list more than once // we're going to keep these AlchymicEffect appearedMoreThanOnce = new AlchymicEffect(); // List that will save whether that ingredient has appeared yet AlchymicEffect appearedOnce = 0; foreach (AlchymicEffect effect in effects) { if ((appearedOnce & effect) > 0) { appearedMoreThanOnce = appearedMoreThanOnce | (appearedOnce & effect); } appearedOnce = appearedOnce | effect; } Potion potion = new Potion(ingredients); potion.effects = appearedMoreThanOnce; return(potion); }
/// <summary> /// Adds a List of AlchymicEffect to effects, the Item's AlchymicEffects List, Doesn't allow duplicate AlchymicEffects /// </summary> /// <param name="effects">AlchymicEffects to be added</param> public void AddEffects(List <AlchymicEffect> effects) { foreach (AlchymicEffect effect in effects) { if ((this.effects & effect) != effect) { this.effects = this.effects ^ effect; } } }
/// <summary> /// Adds an array of AlchymicEffect to effects, the Item's AlchymicEffects List, Doesn't allow duplicate AlchymicEffects /// </summary> /// <param name="effects">AlchymicEffects to be added</param> public void AddEffects(params AlchymicEffect[] effects) { foreach (AlchymicEffect effect in effects) { if ((this.effects & effect) != effect) { this.effects = this.effects ^ effect; } } }
public int countEffects(AlchymicEffect effects) { long effectValue = (long)effects; int count = 0; while (effectValue > 0) { effectValue &= (effectValue - 1); count++; } return(count); }
private String ConvertEffectsToString(AlchymicEffect effects) { Array allEffects = Enum.GetValues(typeof(AlchymicEffect)); String effectsString = ""; int addedCount = 0, goalCount = this.countEffects(effects); foreach (AlchymicEffect effect in allEffects) { if ((effects & effect) == effect) { if (goalCount == 1) { return(effect.ToString()); } else { if (addedCount == 0) { effectsString = effect.ToString(); } else if (addedCount == goalCount - 1) { if (goalCount >= 3) { effectsString += ", and " + effect.ToString(); } else { effectsString += " and " + effect.ToString(); } } else { effectsString += ", " + effect.ToString(); } addedCount++; } } } return(effectsString); }
public void priceTest() { Player player = new Player("", 500); Ingredient ingredient1 = new Ingredient("Flaming Tail", "beast.png", 700, Rarity.Uncommon, (AlchymicEffect)8448); //0010000100000000 Ingredient ingredient2 = new Ingredient("Koro Tentacle", "fish.png", 3500, Rarity.Godlike, (AlchymicEffect)12560); //0011000100010000 Ingredient ingredient3 = new Ingredient("Twisted Root", "plant.png", 200, Rarity.Inferior, (AlchymicEffect)30); //0000000000011110 List <Ingredient> ingredients = new List <Ingredient>(); AlchymicEffect effects = 0; ingredients.Add(ingredient1); ingredients.Add(ingredient2); ingredients.Add(ingredient3); Potion potion = new Potion("", "potion.png", ((ingredient1.price + ingredient2.price + ingredient3.price) * (int)Rarity.Rubbish), Rarity.Rubbish, ingredients, effects); AlchymyTable table = new AlchymyTable(player, ingredient1, ingredient2, ingredient3, potion); table.craftPotion(); //i1 0010000100000000 //i2 0011000100010000 //i3 0000000000011110 //result0010000100010000 Assert.AreEqual((4400 * 7), table.Potion.price); }
/// <summary> /// Removes an AlchymicEffect from effects, the Item's AlchymicEffects List /// </summary> /// <param name="effect">AlchymicEffect to be removed</param> public void RemoveEffect(AlchymicEffect effect) { this.effects = this.effects & (~effect); }
public AlchymicItem(string name, String imagePath, int price, Rarity rarity, AlchymicEffect effects) : base(name, imagePath, price, rarity) { this.effects = effects; }
/// <summary> /// Makes a Potion /// </summary> /// <param name="name">Name of the Potion</param> /// <param name="price">Base Price of the Potion</param> /// <param name="rarity">Rarity of the Item</param> /// <param name="components">Ingredients used to make the Potion</param> /// <param name="effects">Effects from the Ingredients that make the Potion</param> public Potion(String name, String imagePath, int price, Rarity rarity, List <Ingredient> components, AlchymicEffect effects) : base(name, imagePath, price, rarity, effects) { if (name == null || name == "") { this.name = GenerateName(); } else { this.name = name; } this.components = components; this.imagePath = imagePath; this.price = price; this.rarity = rarity; this.effects = effects; }
public Ingredient(String name, String imagePath, int price, Rarity rarity, AlchymicEffect effects) : base(name, imagePath, price, rarity, effects) { }