public override bool CheckForWin(Goal goal, Player player)
        {
            //variables for checking each time
            bool numMet = false;

            GoalNumber g = (GoalNumber)goal;

            //if we are checking the number of keepers
            if (g.Keeper == true)
            {
                if (player.KeeperList.Count >= g.Number)
                {
                    numMet = true;
                }
            }
            //else we are checking the number in the hand
            else
            {
                if (player.HandList.Count >= g.Number)
                {
                    numMet = true;
                }
            }
            return(numMet);
        }
        /// <summary>
        /// the base method for Draws a goal card, sets current goal, removes from hand and checks for win
        /// </summary>
        /// <param name="b"></param>
        /// <param name="num"></param>
        /// <returns></returns>
        public Goal PlayGoalBase(Board b, int num)
        {
            Goal goalToAdd;

            //set goalToAdd to the selected goal
            goalToAdd = (Goal)_hand[num];
            if (goalToAdd is GoalKeeperType)
            {
                GoalKeeperType gK = (GoalKeeperType)goalToAdd;
                //create a new goal of correct type
                goalToAdd = new GoalKeeperType(gK.Bitmap, gK.Keeper1, gK.Keeper2);
            }
            else
            {
                GoalNumber gN = (GoalNumber)goalToAdd;
                //essesntially two types of GoalNUmber cards: Card requirement and Keeper requirement
                if (gN.Keeper == true)
                {
                    goalToAdd = new GoalNumber(gN.Bitmap, true, gN.Number);
                }
                else
                {
                    goalToAdd = new GoalNumber(gN.Bitmap, false, gN.Number);
                }
            }
            //draw the goalToAdd
            b.PaperTable.DrawImage(goalToAdd.Bitmap, _RESET_XPOS, goalToAdd.HEIGHT + goalToAdd.GAP);
            _hand.RemoveAt(num);
            return(goalToAdd);
        }
Exemplo n.º 3
0
        /// <summary>
        /// adds all the goals to the deck
        /// </summary>
        public void AddGoal()
        {
            //initialise array off image of each Goal
            Bitmap[] bArray = new Bitmap[]
            {
                Properties.Resources.Sleep___Music,
                Properties.Resources.Money___Love,
                Properties.Resources.Brain___Rocket,
                Properties.Resources.Party___Time,
                Properties.Resources.Milk___Cookies,
                Properties.Resources.Moon___Rocket,
                Properties.Resources.Cookies___Bread,
                Properties.Resources.Money___Television,
                Properties.Resources.Bread___Toaster,
                Properties.Resources._10_cards_in_hand,
                Properties.Resources._5_Keepers
            };

            //*add names of all the Goals from the embedded file so I don't have to add them individually
            Assembly assembly     = Assembly.GetExecutingAssembly();
            string   resourceName = "Fluxx.Resources.Goals.csv";

            Stream       stream = assembly.GetManifestResourceStream(resourceName);
            StreamReader reader = new StreamReader(stream);
            int          i      = 0;

            while (!reader.EndOfStream)
            {
                string   line     = reader.ReadLine();
                string[] csvArray = line.Split(',');
                string[] temp     = csvArray[0].Split('+');
                string   keeper1  = temp[0].Trim();
                string   keeper2  = temp[1].Trim();

                GoalKeeperType g = new GoalKeeperType(bArray[i], keeper1, keeper2);
                _cardList.Add(g);
                i++;
            }
            //only two types for this type of goal so just do it manually
            GoalNumber gNum = new GoalNumber(bArray[bArray.Length - 2], false, 10);

            _cardList.Add(gNum);
            GoalNumber gNum1 = new GoalNumber(bArray[bArray.Length - 1], true, 5);

            _cardList.Add(gNum1);
        }