public bool TrySubtractAmount(MTGColor c, int amount) { switch (c) { case MTGColor.White: return TrySubtractAmount(amount, ref whiteAmount); case MTGColor.Blue: return TrySubtractAmount(amount, ref blueAmount); case MTGColor.Black: return TrySubtractAmount(amount, ref blackAmount); case MTGColor.Red: return TrySubtractAmount(amount, ref redAmount); case MTGColor.Green: return TrySubtractAmount(amount, ref greenAmount); case MTGColor.ColorlessMana: return TrySubtractAmount(amount, ref colorlessAmount); default: throw new ArgumentException("Invalid color for mana subtract!"); } }
public int Get(MTGColor c) { return amount.GetAmount(c); }
public void SetAmount(MTGColor c, int amount) { switch (c) { case MTGColor.White: whiteAmount = amount; break; case MTGColor.Blue: blueAmount = amount; break; case MTGColor.Black: blackAmount = amount; break; case MTGColor.Red: redAmount = amount; break; case MTGColor.Green: greenAmount = amount; break; case MTGColor.ColorlessMana: colorlessAmount = amount; break; default: throw new ArgumentException("Invalid color for mana set amount!"); } }
public int GetAmount(MTGColor c) { switch (c) { case MTGColor.White: return whiteAmount; case MTGColor.Blue: return blueAmount; case MTGColor.Black: return blackAmount; case MTGColor.Red: return redAmount; case MTGColor.Green: return greenAmount; case MTGColor.ColorlessMana: return colorlessAmount; default: throw new ArgumentException("Invalid color for mana get!"); } }
internal static int NumBits(MTGColor color) { int result = 0; foreach(MTGColor testColor in ManaPool.ManaTypesList) { if ((color & testColor) != 0) result++; } return result; }
internal ManaPaymentPart(MTGColor color, int amount) { this.color = color; this.amount = amount; }
static void AddParsedAmount(Dictionary<MTGColor, int> amounts, MTGColor color, int amount) { if (!amounts.ContainsKey(color)) amounts[color] = amount; else amounts[color] += amount; }