Esempio n. 1
0
        private static void PlayGame()
        {
            //Initial Marble
            Marble marbel = new Marble(0);

            marbel.SetLeftRight(marbel, marbel);
            Marble currentMarbel = marbel;

            while (turn < goal)
            {
                turn++;
                if (turn % 23 == 0)
                {
                    playerScores[turn % playerScores.Count()] += turn;
                    for (int i = 0; i < 7; i++)
                    {
                        currentMarbel = Marble.GoLeft(currentMarbel);
                    }
                    playerScores[turn % playerScores.Count()] += currentMarbel.Value;
                    currentMarbel = Marble.Remove(currentMarbel);
                }
                else
                {
                    currentMarbel = Marble.GoRight(currentMarbel);
                    currentMarbel = Marble.Add(turn, currentMarbel);
                }
            }
        }
Esempio n. 2
0
        public static Marble Add(int value, Marble currentMarbel)
        {
            Marble newMarbel = new Marble(value);

            newMarbel.Left       = currentMarbel;
            newMarbel.Right      = newMarbel.Left.Right;
            newMarbel.Right.Left = newMarbel;
            newMarbel.Left.Right = newMarbel;
            return(newMarbel);
        }
Esempio n. 3
0
 public static Marble GoRight(Marble marbel)
 {
     return(marbel.Right);
 }
Esempio n. 4
0
 public static Marble GoLeft(Marble marbel)
 {
     return(marbel.Left);
 }
Esempio n. 5
0
 public static Marble Remove(Marble currentMarbel)
 {
     currentMarbel.Left.Right = currentMarbel.Right;
     currentMarbel.Right.Left = currentMarbel.Left;
     return(currentMarbel.Right);
 }
Esempio n. 6
0
 public void SetLeftRight(Marble left, Marble right)
 {
     this.Left  = left;
     this.Right = right;
 }