private int NextSquareOfType(MonopolyType monopolyType, int currentSquareIndex) { var nextSquareOfType = squares.Skip(currentSquareIndex + 1) .FirstOrDefault(sq => sq.SquareType == monopolyType) ?? squares.FirstOrDefault(sq => sq.SquareType == monopolyType); return squares.FindIndex(sq => sq == nextSquareOfType); }
public MonopolySquare(string name, MonopolyType squareType) { Name = name; SquareType = squareType; }
private int ApplyCommunityChest(int currentStartIndex, MonopolyType monopolyType) { switch (monopolyType) { case MonopolyType.Standard: return currentStartIndex; case MonopolyType.GoToJail: return jailSquareIndex; case MonopolyType.Go: return goSquareIndex; default: throw new ApplicationException(string.Format("Unexpected community chest: {0}", monopolyType)); } }