Пример #1
0
        // render moves in a grid
        //     | ○ |
        //  ---+---+---
        //   ─ | ☖| ─
        //  ---+---+---
        //   ○ |   | ○
        public void SetPiece(TaikyokuShogi game, PieceIdentity id)
        {
            var moves = game.GetMovement(id);

            headerText.Text = $"{Pieces.Name(id)}\n{Pieces.Kanji(id)} ({Pieces.Romanji(id)})";

            //////
            //
            // figure out the grid size
            //
            int maxMoves = 1;

            for (int i = 0; i < moves.StepRange.Length; ++i)
            {
                maxMoves = Math.Max(maxMoves, moves.StepRange[i] == Movement.Unlimited ? 2 : moves.StepRange[i]);
            }

            for (int i = 0; i < moves.JumpRange.Length; ++i)
            {
                var maxJump   = moves.JumpRange[i].JumpDistances?.Max();
                var jumpRange = maxJump == Movement.Unlimited ? 2 : maxJump + 1;
                jumpRange += moves.JumpRange[i].RangeAfter == Movement.Unlimited ? 1 : moves.JumpRange[i].RangeAfter;
                maxMoves   = Math.Max(maxMoves, jumpRange ?? 0);
            }

            for (int i = 0; i < moves.RangeCapture.Count; ++i)
            {
                maxMoves = Math.Max(maxMoves, moves.RangeCapture[i] ? 2 : 0);
            }

            maxMoves = Math.Max(maxMoves, moves.LionMove ? 3 : 0);

            maxMoves = Math.Max(maxMoves, moves.HookMove switch
            {
                HookType.Orthogonal => 2,
                HookType.Diagonal => 2,
                HookType.ForwardDiagnal => 3,
                _ => 0
            });