public LobbySeek(TimeControl timeControl, string variant, bool symmetrical, GamePlayer owner) { TimeControl = timeControl; Variant = variant; Symmetrical = symmetrical; Owner = owner; }
public LobbySeek(TimeControl timeControl, string variant, Position position, bool symmetrical, int whitePosition, int blackPosition, GamePlayer owner) { TimeControl = timeControl; Variant = variant; ChosenPosition = position; Symmetrical = position == Position.Random ? symmetrical : whitePosition == blackPosition; WhitePosition = whitePosition; BlackPosition = blackPosition; Owner = owner; }
public Dictionary <string, string> SeekJson(IUserRepository userRepository) { Dictionary <string, string> data = new Dictionary <string, string>(); data.Add("l", FullVariantName); if (Owner is RegisteredPlayer) { data.Add("o", userRepository.FindById((Owner as RegisteredPlayer).UserId).Username); } else { data.Add("o", "(Anonymous)"); } data.Add("c", TimeControl.ToString()); data.Add("i", ID); return(data); }
public Game(string id, GamePlayer white, GamePlayer black, string shortVariant, string fullVariant, int nWhite, int nBlack, bool isSymmetrical, TimeControl tc, DateTime startedUtc, int rematchLevel, IGameConstructor gameConstructor) { ID = id; White = white; PositionWhite = nWhite; Black = black; PositionBlack = nBlack; IsSymmetrical = isSymmetrical; Result = Results.ONGOING; Termination = Terminations.UNTERMINATED; TimeControl = tc; ShortVariantName = shortVariant; FullVariantName = fullVariant; string fen; if (shortVariant == "Horde") { fen = ChessUtilities.FenForHorde960(nBlack); } else if (shortVariant == "RacingKings") { fen = ChessUtilities.FenForRacingKings1440Asymmetrical(nWhite, nBlack); } else { fen = ChessUtilities.FenForChess960Asymmetrical(nWhite, nBlack); } ChessGame = gameConstructor.Construct(shortVariant, fen); InitialFEN = LatestFEN = ChessGame.GetFen(); PlayerChats = new List <ChatMessage>(); SpectatorChats = new List <ChatMessage>(); StartedUtc = startedUtc; EndedUtc = null; ClockWhite = new Clock(tc); ClockBlack = new Clock(tc); ClockTimes = new List <double>(); WhiteWantsRematch = false; BlackWantsRematch = false; WhiteWantsDraw = false; BlackWantsDraw = false; RematchLevel = rematchLevel; UciMoves = new List <string>(); }
public Game(string id, GamePlayer white, GamePlayer black, string shortVariant, string fullVariant, int nWhite, int nBlack, bool isSymmetrical, TimeControl tc, DateTime startedUtc, int rematchLevel) { ID = id; White = white; PositionWhite = nWhite; Black = black; PositionBlack = nBlack; IsSymmetrical = isSymmetrical; Result = Results.ONGOING; Termination = Terminations.UNTERMINATED; TimeControl = tc; ShortVariantName = shortVariant; FullVariantName = fullVariant; switch (fullVariant) { case Variants.ANTICHESS960ASYMMETRICAL: ChessGame = new AntichessGame(ChessUtilities.FenForChess960Asymmetrical(nWhite, nBlack)); break; case Variants.ANTICHESS960SYMMETRICAL: ChessGame = new AntichessGame(ChessUtilities.FenForChess960Symmetrical(nWhite)); break; case Variants.ATOMIC960ASYMMETRICAL: ChessGame = new AtomicChessGame(ChessUtilities.FenForChess960Asymmetrical(nWhite, nBlack)); break; case Variants.ATOMIC960SYMMETRICAL: ChessGame = new AtomicChessGame(ChessUtilities.FenForChess960Symmetrical(nWhite)); break; case Variants.CRAZYHOUSE960ASYMMETRICAL: ChessGame = new CrazyhouseChessGame(ChessUtilities.FenForChess960Asymmetrical(nWhite, nBlack)); break; case Variants.CRAZYHOUSE960SYMMETRICAL: ChessGame = new CrazyhouseChessGame(ChessUtilities.FenForChess960Symmetrical(nWhite)); break; case Variants.HORDE960: ChessGame = new HordeChessGame(ChessUtilities.FenForHorde960(nWhite)); break; case Variants.KOTH960ASYMMETRICAL: ChessGame = new KingOfTheHillChessGame(ChessUtilities.FenForChess960Asymmetrical(nWhite, nBlack)); break; case Variants.KOTH960SYMMETRICAL: ChessGame = new KingOfTheHillChessGame(ChessUtilities.FenForChess960Symmetrical(nWhite)); break; case Variants.RK1440ASYMMETRICAL: ChessGame = new RacingKingsChessGame(ChessUtilities.FenForRacingKings1440Asymmetrical(nWhite, nBlack)); break; case Variants.RK1440SYMMETRICAL: ChessGame = new RacingKingsChessGame(ChessUtilities.FenForRacingKings1440Symmetrical(nWhite)); break; case Variants.THREECHECK960ASYMMETRICAL: ChessGame = new ThreeCheckChessGame(ChessUtilities.FenForChess960Asymmetrical(nWhite, nBlack)); break; case Variants.THREECHECK960SYMMETRICAL: ChessGame = new ThreeCheckChessGame(ChessUtilities.FenForChess960Symmetrical(nWhite)); break; default: throw new InvalidOperationException("Game constructor: invalid variant '" + fullVariant + "'"); } InitialFEN = LatestFEN = ChessGame.GetFen(); PlayerChats = new List <ChatMessage>(); SpectatorChats = new List <ChatMessage>(); StartedUtc = startedUtc; EndedUtc = null; ClockWhite = new Clock(tc); ClockBlack = new Clock(tc); ClockTimes = new List <double>(); WhiteWantsRematch = false; BlackWantsRematch = false; WhiteWantsDraw = false; BlackWantsDraw = false; RematchLevel = rematchLevel; UciMoves = new List <string>(); }
public Clock(TimeControl tc) : this() { Increment = tc.Increment; SecondsLeftAfterLatestMove = tc.InitialSeconds != 0 ? tc.InitialSeconds : Math.Max(tc.Increment, 3); }