public void TakeTurn(int marbleNum) { _playerEnum.MoveNext(); var currPlayerOrder = _playerEnum.Current; var marbleToAdd = new Marble(marbleNum); if (marbleToAdd.Value % 23 == 0) { var currPlayer = PlayerDict[currPlayerOrder.PlayerNumber]; currPlayer.KeepMarble(marbleToAdd); //remove marble 7 marbles counter-clockwise from current marble var marbleToRemove = Board.CircularMoveBack(CurrentMarbleNode, 7); currPlayer.KeepMarble(marbleToRemove.Value); if (Board.Last == marbleToRemove) { SetCurrentMarble(Board.First.Value, Board.First); } else { SetCurrentMarble(marbleToRemove.Next.Value, marbleToRemove.Next); } Board.Remove(marbleToRemove); } else { AddMarble(marbleToAdd); } }
private void SetCurrentMarble(Marble marble) { if (CurrentMarble != null) { CurrentMarble.IsCurrent = false; } marble.IsCurrent = true; CurrentMarble = marble; }
public void AddMarble() { if (!this.Circle.Any()) { var newMarble = new Marble(CurrentNum++); this._currentMarble = this.Circle.AddFirst(newMarble); return; } this._currentMarble = Circle.AddAfter(_currentMarble.NextOrFirst(), new Marble(CurrentNum++)); }
public void AddMarble(Marble marble) { if (CurrentMarble == null) { var added = Board.AddFirst(marble); SetCurrentMarble(marble, added); } else { if (CurrentMarble == Board.Last.Value) { var added = Board.AddAfter(Board.First, marble); SetCurrentMarble(marble, added); } else { //var currentMarbleNode = Board.Find(CurrentMarble); var added = Board.AddAfter(CurrentMarbleNode.Next, marble); SetCurrentMarble(marble, added); } } }
private void SetCurrentMarble(Marble marble, LinkedListNode <Marble> marbleNode) { CurrentMarbleNode = marbleNode; SetCurrentMarble(marble); }
//public ulong Score //{ // get // { // ulong score = 0; // foreach (var marb in KeptMarbles) // score += (ulong) marb.Value; // return score; // } //} public void KeepMarble(Marble marble) { Score += (UInt64)marble.Value; }