Ejemplo n.º 1
0
 public static void Init(string fileName)
 {
     Banlists = new List<Banlist>();
     Banlist current = null;
     StreamReader reader = new StreamReader(fileName);
     while (!reader.EndOfStream)
     {
         string line = reader.ReadLine();
         if (line == null)
             continue;
         if (line.StartsWith("#"))
             continue;
         if (line.StartsWith("!"))
         {
         	current = new Banlist(line.Replace("!",""));
             Banlists.Add(current);
             continue;
         }
         if (!line.Contains(" "))
             continue;
         if (current == null)
             continue;
         string[] data = line.Split(' ');
         int id = int.Parse(data[0]);
         int count = int.Parse(data[1]);
         current.Add(id, count);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ban"></param>
        /// <param name="ocg"></param>
        /// <param name="tcg"></param>
        /// <returns>1数量,2空卡,卡片规则不符合</returns>
		public int Check(Banlist ban, bool ocg, bool tcg)
		{
			if (Main.Count < 40 || Main.Count > 60 || Extra.Count > 15 || Side.Count > 15)
				return 1;

			IDictionary<int, int> cards = new Dictionary<int, int>();

			IList<int>[] stacks = new IList<int>[] { Main, Extra, Side };
			foreach (IList<int> stack in stacks)
			{
				foreach (int id in stack)
				{
					Card card = Card.Get(id);
                    if(card == null)
                    {
                        return 2;
                    }
					AddToCards(cards, card);
					if (!ocg && card.Ot == 1 || !tcg && card.Ot == 2)
						return id;
				}
			}

			if (ban == null)
				return 0;

			foreach (KeyValuePair<int, int> pair in cards)
			{
				int max = ban.GetQuantity(pair.Key);
				if (pair.Value > max)
					return pair.Key;
			}

			return 0;
		}
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ban"></param>
        /// <param name="ocg"></param>
        /// <param name="tcg"></param>
        /// <returns>Number 1, 2 blank cards, card rule does not meet the</returns>
        public int Check(Banlist ban, bool ocg, bool tcg)
        {
            if (Main.Count < 40 || Main.Count > 60 || Extra.Count > 15 || Side.Count > 15)
            {
                return(1);
            }

            IDictionary <int, int> cards = new Dictionary <int, int>();

            IList <int>[] stacks = new IList <int>[] { Main, Extra, Side };
            foreach (IList <int> stack in stacks)
            {
                foreach (int id in stack)
                {
                    Card card = Card.Get(id);
                    if (card == null)
                    {
                        return(2);
                    }
                    AddToCards(cards, card);
                    if (!ocg && card.Ot == 1 || !tcg && card.Ot == 2)
                    {
                        return(id);
                    }
                }
            }

            if (ban == null)
            {
                return(0);
            }

            foreach (KeyValuePair <int, int> pair in cards)
            {
                int max = ban.GetQuantity(pair.Key);
                if (pair.Value > max)
                {
                    return(pair.Key);
                }
            }

            return(0);
        }
Ejemplo n.º 4
0
        public static void Init(string fileName)
        {
            Banlists = new List <Banlist>();
            Banlist      current = null;
            StreamReader reader  = new StreamReader(fileName);

            while (!reader.EndOfStream)
            {
                string line = reader.ReadLine();
                if (line == null)
                {
                    continue;
                }
                if (line.StartsWith("#"))
                {
                    continue;
                }
                if (line.StartsWith("!"))
                {
                    current = new Banlist(line.Replace("!", ""));
                    Banlists.Add(current);
                    continue;
                }
                if (!line.Contains(" "))
                {
                    continue;
                }
                if (current == null)
                {
                    continue;
                }
                string[] data  = line.Split(' ');
                int      id    = int.Parse(data[0]);
                int      count = int.Parse(data[1]);
                current.Add(id, count);
            }
        }