コード例 #1
0
ファイル: SetLogic.cs プロジェクト: EMPIR/TSGames
 public static bool Contains(SetPiece p, List<SetPiece> list)
 {
     foreach (SetPiece s in list)
     {
         if (p.Equals(s))
             return true;
     }
     return false;
 }
コード例 #2
0
ファイル: SetLogic.cs プロジェクト: EMPIR/TSGames
        /// <summary>
        /// Given 3 set pieces, this routine determines is there is a Match.
        /// To get a Match, all 4 variables (Color, Shape, Fill, and Number)
        /// must all be the same or all be different.  If a Match is found,
        /// the function returns true.  Otherwise,  it returns false.
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <param name="c"></param>
        /// <returns></returns>
        public static bool ContainsMatch(SetPiece a, SetPiece b, SetPiece c)
        {
            bool ret = true;
            if (!Match(a.Number, b.Number, c.Number))
                ret = false;
            if (ret && !Match(a.Color, b.Color, c.Color))
                ret = false;
            if (ret && !Match(a.Shape, b.Shape, c.Shape))
                ret = false;
            if (ret && !Match(a.Fill, b.Fill, c.Fill))
                ret = false;

            return ret;
        }
コード例 #3
0
ファイル: SetLogic.cs プロジェクト: EMPIR/TSGames
        /// <summary>
        /// Creates a Set Piece with Random color, number, shape. Fill is constant
        /// </summary>
        /// <returns></returns>
        public static SetPiece CreateSimplePiece()
        {
            SetPiece p = new SetPiece();

            p.Color = GameLogic.RandomNumber(1, 3);
            p.Number = GameLogic.RandomNumber(1, 3);
            p.Shape = GameLogic.RandomNumber(1, 3);
            p.Fill = 1;
            return p;
        }
コード例 #4
0
ファイル: SetLogic.cs プロジェクト: EMPIR/TSGames
        /// <summary>
        /// Creates a Set Piece with Random color, number, shape, fill that does not exist in the 
        /// given list of pieces
        /// </summary>
        /// <returns></returns>
        public static SetPiece CreatePiece(List<SetPiece> list)
        {
            bool cont = true;
            SetPiece p = new SetPiece();
            while (cont)
            {

                p.Color = GameLogic.RandomNumber(1, 3);
                p.Number = GameLogic.RandomNumber(1, 3);
                p.Shape = GameLogic.RandomNumber(1, 3);
                p.Fill = GameLogic.RandomNumber(1, 3);
                if (!Contains(p, list))
                {
                    //found a new card!
                    cont = false;
                }
            }
            return p;
        }