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); } } }
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); }
public static Marble GoRight(Marble marbel) { return(marbel.Right); }
public static Marble GoLeft(Marble marbel) { return(marbel.Left); }
public static Marble Remove(Marble currentMarbel) { currentMarbel.Left.Right = currentMarbel.Right; currentMarbel.Right.Left = currentMarbel.Left; return(currentMarbel.Right); }
public void SetLeftRight(Marble left, Marble right) { this.Left = left; this.Right = right; }