public static string[] GetItems(SpecifierType specifierType, DateTimeFormatInfo dateTimeFormat) { switch (specifierType) { case SpecifierType.ddd: return(dateTimeFormat.AbbreviatedDayNames); case SpecifierType.dddd: return(dateTimeFormat.DayNames); case SpecifierType.MMM: return(dateTimeFormat.AbbreviatedMonthNames); case SpecifierType.MMMM: return(dateTimeFormat.MonthNames); case SpecifierType.t: string amDesignator = dateTimeFormat.AMDesignator; string pmDesignator = dateTimeFormat.PMDesignator; string[] items = new string[] { !string.IsNullOrEmpty(amDesignator) ? amDesignator.Substring(0, 1) : string.Empty, !string.IsNullOrEmpty(pmDesignator) ? pmDesignator.Substring(0, 1) : string.Empty, }; return(items); case SpecifierType.tt: return(new string[] { dateTimeFormat.AMDesignator, dateTimeFormat.PMDesignator, }); default: throw new ArgumentOutOfRangeException("specifierType"); } }
public SpecifierInfo(SpecifierType type, ValueType valueType, string symbol, int max, bool matchesExtraSymbols) : this() { MatchesExtraSymbols = matchesExtraSymbols; MaxLength = max; Symbol = symbol; Type = type; ValueType = valueType; }
} // 0 for none, 1 for check, 2 for checkmate public Move(byte source, byte destination, PieceColour colour, Piece movingPiece, MoveResult result, string fen, int checkOrCheckmate, SpecifierType specifierRequired = SpecifierType.None, PieceType?promoteTo = null) { Source = source; Destination = destination; Colour = colour; MovingPiece = movingPiece; SpecifierRequired = specifierRequired; PromoteTo = promoteTo; Result = result; FEN = fen; CheckOrCheckmate = checkOrCheckmate; }
public DataPrecisionDetails(Old_RaidBossFight _BossFight, RealmDB _RealmDB) { m_FightPrecision = (float)_BossFight.CalculatePrecision(_RealmDB.RD_IsPlayerFunc(_BossFight)); m_HasResetsMidFight = _BossFight.GetFightData().HasResetsMidFight(); m_ContainCorruptSWSync = _BossFight.GetUnrealisticPlayerSpikes(_RealmDB.RD_GetPlayerIdentifierFunc(_BossFight)).Count != 0; m_AddonVersion = _BossFight.GetFightData().AddonVersion; m_RecordedBy = _BossFight.GetFightData().RecordedByPlayer; var timeSlices = _BossFight.GetFightData().TimeSlices; float bossPart1Percentage = 0.0f; float bossPart2Percentage = 0.0f; string startY = "Start_Y"; if (_BossFight.GetBossName() == "Razorgore the Untamed" && (_BossFight.GetStartDateTime() < new DateTime(2014, 3, 12) || m_AddonVersion == "1.8.2" || m_AddonVersion == "1.8.1" || m_AddonVersion == "1.7")) { startY = "Start_Y=Grethok the Controller"; } for (int i = 0; i < timeSlices.Count; ++i) { if (m_StartSpecifier != SpecifierType.YellSpecifier && timeSlices[i].IsStartEvent()) { if (timeSlices[i].IsEvent(startY) == true) { m_StartSpecifier = SpecifierType.YellSpecifier; } else { m_StartSpecifier = SpecifierType.HealthSpecifier; } } if (m_HealthPercentageFirstSeen < 0.99f && timeSlices[i].IsBossHealthEvent()) { if (_BossFight.GetBossName() == "C'Thun") { float eyeofcthunMax = timeSlices[i].GetTotalBossPercentage("Eye of C'Thun", true) * 0.5f; if (eyeofcthunMax > bossPart1Percentage) { bossPart1Percentage = eyeofcthunMax; } float cthunMax = timeSlices[i].GetTotalBossPercentage("C'Thun", true) * 0.5f; if (cthunMax > bossPart2Percentage) { bossPart2Percentage = cthunMax; } if (bossPart1Percentage + bossPart2Percentage > m_HealthPercentageFirstSeen) { m_HealthPercentageFirstSeen = bossPart1Percentage + bossPart2Percentage; } } else { var healthPercentage = timeSlices[i].GetTotalBossPercentage(_BossFight.GetBossName()); if (healthPercentage > m_HealthPercentageFirstSeen) { m_HealthPercentageFirstSeen = healthPercentage; } } } if (m_EndSpecifier != SpecifierType.YellSpecifier && timeSlices[i].IsDeadEvent()) { if (timeSlices[i].IsEvent("Dead_Y") == true) { m_EndSpecifier = SpecifierType.YellSpecifier; break; } else { m_EndSpecifier = SpecifierType.HealthSpecifier; } } } }
public static List <Tuple <Move, string> > getPossibleMoveNotations(Board gameBoard) { List <Tuple <Move, string> > possibleMoveNotations = new List <Tuple <Move, string> >(); for (int i = 0; i < gameBoard.Squares.Length; i++) { if (gameBoard.Squares[i].Piece != null) { for (int j = 0; j < gameBoard.Squares[i].Piece.LegalMoves.Count; j++) { SpecifierType disambiguationNeeded = checkDisabiguationNeeded(gameBoard, (byte)i, gameBoard.Squares[i].Piece.LegalMoves[j]); Board copiedBoard = new Board(gameBoard, true); MoveResult result = MoveResult.None; if ((gameBoard.Squares[i].Piece.Type == PieceType.Pawn) && (Array.IndexOf(copiedBoard.pawnPromotionDestinations, gameBoard.Squares[i].Piece.LegalMoves[j]) != -1)) { //Promotion result = copiedBoard.MakeMove((byte)i, gameBoard.Squares[i].Piece.LegalMoves[j], PieceType.Queen); string copiedBoardFEN = copiedBoard.ToFEN(); int checkOrCheckmate = 0; GameStatus mateState = copiedBoard.CheckForMate(); if (mateState == GameStatus.WhiteCheckmate || mateState == GameStatus.BlackCheckmate) { checkOrCheckmate = 2; } else if (copiedBoard.WhiteCheck || copiedBoard.BlackCheck) { checkOrCheckmate = 1; } Move newMove = new Move((byte)i, gameBoard.Squares[i].Piece.LegalMoves[j], gameBoard.Squares[i].Piece.Colour, gameBoard.Squares[i].Piece, result, copiedBoardFEN, checkOrCheckmate, disambiguationNeeded, PieceType.Queen); Tuple <Move, string> newTuple = new Tuple <Move, string>(newMove, MoveToNotation(newMove)); possibleMoveNotations.Add(newTuple); newMove = new Move((byte)i, gameBoard.Squares[i].Piece.LegalMoves[j], gameBoard.Squares[i].Piece.Colour, gameBoard.Squares[i].Piece, result, copiedBoardFEN, checkOrCheckmate, disambiguationNeeded, PieceType.Rook); newTuple = new Tuple <Move, string>(newMove, MoveToNotation(newMove)); possibleMoveNotations.Add(newTuple); newMove = new Move((byte)i, gameBoard.Squares[i].Piece.LegalMoves[j], gameBoard.Squares[i].Piece.Colour, gameBoard.Squares[i].Piece, result, copiedBoardFEN, checkOrCheckmate, disambiguationNeeded, PieceType.Bishop); newTuple = new Tuple <Move, string>(newMove, MoveToNotation(newMove)); possibleMoveNotations.Add(newTuple); newMove = new Move((byte)i, gameBoard.Squares[i].Piece.LegalMoves[j], gameBoard.Squares[i].Piece.Colour, gameBoard.Squares[i].Piece, result, copiedBoardFEN, checkOrCheckmate, disambiguationNeeded, PieceType.Knight); newTuple = new Tuple <Move, string>(newMove, MoveToNotation(newMove)); possibleMoveNotations.Add(newTuple); } else { result = copiedBoard.MakeMove((byte)i, gameBoard.Squares[i].Piece.LegalMoves[j]); string copiedBoardFEN = copiedBoard.ToFEN(); int checkOrCheckmate = 0; GameStatus mateState = copiedBoard.CheckForMate(); if (mateState == GameStatus.WhiteCheckmate || mateState == GameStatus.BlackCheckmate) { checkOrCheckmate = 2; } else if (copiedBoard.WhiteCheck || copiedBoard.BlackCheck) { checkOrCheckmate = 1; } Move newMove = new Move((byte)i, gameBoard.Squares[i].Piece.LegalMoves[j], gameBoard.Squares[i].Piece.Colour, gameBoard.Squares[i].Piece, result, copiedBoardFEN, checkOrCheckmate, disambiguationNeeded, null); Tuple <Move, string> newTuple = new Tuple <Move, string>(newMove, MoveToNotation(newMove)); possibleMoveNotations.Add(newTuple); } } } } return(possibleMoveNotations); }
public string[] GetItems(SpecifierType specifierType) { return(GetItems(specifierType, this.DateTimeFormat)); }
protected void OnPieceClick(object o, ButtonPressEventArgs args) { double transx = Math.Abs((BoardArea.Allocation.Width - (boardBackground.Width * 0.75))) / 2; PointD clickLocation = new PointD(args.Event.X - transx, args.Event.Y - transx); if (clickLocation.X < 30 || clickLocation.Y < 30 || clickLocation.X > 522 || clickLocation.Y > 522) { return; } PointD pieceLocation = PieceDisplay.pieceCoordinates [0]; int pieceIndex = 0; for (int i = 0; i < PieceDisplay.pieceCoordinates.Length; i++) { PointD p = PieceDisplay.pieceCoordinates[i]; double x1 = p.X * 0.75; double y1 = p.Y * 0.75; double x2 = x1 + 61.5; double y2 = y1 + 61.5; if (x1 <= clickLocation.X && clickLocation.X <= x2) { if (y1 <= clickLocation.Y && clickLocation.Y <= y2) { pieceLocation = p; pieceIndex = MainClass.BoardOrientation == PieceColour.White ? i : Math.Abs(i - 63); break; } } } if (currentSelectionState == PieceSelectionState.None) { if (MainClass.CurrentBoard.Squares [pieceIndex].Piece == null) { return; } selectedPiece = (byte)pieceIndex; boardContext = Gdk.CairoHelper.Create(BoardArea.GdkWindow); boardContext.Translate(transx, 0); boardContext.Scale(0.75, 0.75); selectionBorder.Show(boardContext, pieceLocation.X + 1, pieceLocation.Y + 1); boardContext.Dispose(); currentSelectionState = PieceSelectionState.Selected; } else { if (!MainClass.CurrentBoard.IsMoveValid(selectedPiece, (byte)pieceIndex)) { currentSelectionState = PieceSelectionState.None; Gtk.Application.Invoke(delegate { RedrawBoard(); }); return; } if (MainClass.CurrentGameStatus != GameStatus.Active && MainClass.CurrentGameStatus != GameStatus.Inactive) { Console.Error.WriteLine("(EE) Attempted move during finished game."); MessageDialog errorDialog = new MessageDialog( this, DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Ok, "The game is over!"); errorDialog.Run(); errorDialog.Destroy(); return; } // Handle pawn promotion PieceType?promoteTo = null; if (MainClass.CurrentBoard.Squares [selectedPiece].Piece.Type == PieceType.Pawn && MainClass.CurrentBoard.IsMoveValid(selectedPiece, (byte)pieceIndex) && Array.IndexOf(MainClass.CurrentBoard.pawnPromotionDestinations, (byte)pieceIndex) != -1) { PawnPromotionDialog dialog = new PawnPromotionDialog(); if (dialog.Run() == (int)Gtk.ResponseType.Ok) { promoteTo = dialog.PromoteTo; } else { dialog.Destroy(); return; } dialog.Destroy(); } try { SpecifierType specifierRequired = GameHistory.checkDisabiguationNeeded(MainClass.CurrentBoard, selectedPiece, (byte)pieceIndex); MoveResult result = MainClass.CurrentBoard.MakeMove(selectedPiece, (byte)pieceIndex, promoteTo); Piece movingPiece = null; if (promoteTo == null) { movingPiece = MainClass.CurrentBoard.Squares[(byte)pieceIndex].Piece; } else { movingPiece = new Piece(MainClass.CurrentBoard.Squares [(byte)pieceIndex].Piece.Colour, PieceType.Pawn); } if (result == MoveResult.Capture && movingPiece.Type == PieceType.Pawn) { specifierRequired = SpecifierType.File; } int checkOrCheckmate = 0; GameStatus mateState = MainClass.CurrentBoard.CheckForMate(); if (mateState == GameStatus.WhiteCheckmate || mateState == GameStatus.BlackCheckmate) { checkOrCheckmate = 2; } else if (MainClass.CurrentBoard.WhiteCheck || MainClass.CurrentBoard.BlackCheck) { checkOrCheckmate = 1; } string fenPosition = MainClass.CurrentBoard.ToFEN().Split(' ')[0]; MainClass.CurrentGameHistory.AddMove(new Move(selectedPiece, (byte)pieceIndex, MainClass.CurrentBoard.Squares [(byte)pieceIndex].Piece.Colour, movingPiece, result, MainClass.CurrentBoard.ToFEN(), checkOrCheckmate, specifierRequired, promoteTo), fenPosition); UpdateGameHistoryView(); if (MainClass.CurrentGameHistory.UpdateFiftyMoveCount(result) == GameStatus.DrawFifty) { MainClass.CurrentGameStatus = GameStatus.DrawFifty; } else if (MainClass.CurrentGameHistory.CheckThreefoldRepetition() == GameStatus.DrawRepetition) { MainClass.CurrentGameStatus = GameStatus.DrawRepetition; } } catch (InvalidOperationException) { } Gtk.Application.Invoke(delegate { RedrawBoard(); }); GameStatus isMate = MainClass.CurrentBoard.CheckForMate(); if (isMate != GameStatus.Active) { MainClass.CurrentGameStatus = isMate; } if (MainClass.CurrentGameStatus != GameStatus.Active && MainClass.CurrentGameStatus != GameStatus.Inactive) { ShowGameOverDialog(MainClass.CurrentGameStatus); } if (MainClass.CurrentGameStatus == GameStatus.Inactive) { MainClass.CurrentGameStatus = GameStatus.Active; } Gtk.Application.Invoke(delegate { MainClass.UpdateClock(); UpdatePlayerToMove(); }); currentSelectionState = PieceSelectionState.None; } }