public static Cost Parse(string costString) { if (costString.ToLower() == "no cost") { return(null); } if (costString.ToLower() == "any") { return(new Mana(ManaTypes.Any)); } if (costString.ToLower() == "combo any") { return(new Mana(ManaTypes.ComboAny)); } Costs sum = new Costs(); string[] tmp = costString.Split(new char[] { }); foreach (string c in tmp) { if (string.IsNullOrWhiteSpace(c)) { continue; } switch (c) { case "T": sum += new Cost(CostTypes.Tap); continue; } if (c.StartsWith("Discard")) { sum += CardCost.Parse(CostTypes.Discard, c); continue; } else if (c.StartsWith("Sac")) { sum += CardCost.Parse(CostTypes.Sacrifice, c); continue; } else if (c.StartsWith("SubCounter")) { sum += CardCost.Parse(CostTypes.SubCounter, c); continue; } string number = ""; ManaChoice choice = new ManaChoice(); for (int i = 0; i < c.Length; i++) { if (char.IsDigit(c[i])) { number += c[i]; if (i < c.Length - 1) { if (char.IsDigit(c[i + 1])) { continue; } } choice += new Mana(int.Parse(number)); number = null; } else { switch (c[i]) { case 'W': choice += ManaTypes.White; break; case 'R': choice += ManaTypes.Red; break; case 'G': choice += ManaTypes.Green; break; case 'B': choice += ManaTypes.Black; break; case 'U': choice += ManaTypes.Blue; break; case 'P': choice += ManaTypes.Life; break; case 'X': choice += new Mana(-1); break; case '/': continue; default: break; } } } if (choice.Manas.Count == 1) { sum += choice.Manas[0]; } else { sum += choice; } } if (sum.CostList.Count == 0) { return(null); } if (sum.CostList.Count == 1) { return(sum.CostList[0]); } else { return(sum); } return(sum); }
public bool IsSameType(Cost m) { return(m.CostType == this.CostType ? true : false);//?????? }
public virtual void PayCost(ref Cost _amount) { RemainingCost = RemainingCost.Pay(ref _amount); }