示例#1
0
 private bool CheckTurnOptionsHasAny(PieceTurnOptions opt)
 {
     foreach (var option in opt.Options.options)
     {
         if (option.components.Count > 0)
         {
             return(true);
         }
     }
     return(false);
 }
示例#2
0
 private bool CheckTurnOptionsCanPromote(PieceTurnOptions opt, IntVector2 p)
 {
     foreach (var option in opt.Options.options)
     {
         foreach (var comp in option.components)
         {
             if (comp.type == TurnActionComponentType.PromotePiece && comp.actor.x == p.x - 1 && comp.actor.y == p.y - 1)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
示例#3
0
        private bool CheckCanMove(string player)
        {
            PlayerTurnOrder turnOrder = LuaTranslator.GetPlayerFromLua(player);

            for (int p = 0; p < board.Pieces.Count; p++)
            {
                Piece piece = board.Pieces[p];
                if (!piece.IsCaptured && piece.OwnerPlayer == turnOrder)
                {
                    PieceTurnOptions luaOptions = CacheTurnOptions(p);
                    if (CheckTurnOptionsHasAny(luaOptions))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
示例#4
0
        private PieceTurnOptions CacheTurnOptions(int logicPieceIndex)
        {
            PieceTurnOptions luaOptions;

            if (!optionCache.TryGetValue(logicPieceIndex, out luaOptions))
            {
                luaOptions = new PieceTurnOptions();
                optionCache[logicPieceIndex] = luaOptions;
                luaOptions.Piece             = lastCalcState.Board.Pieces[logicPieceIndex];
                luaOptions.QHasOptions       = turnOptionsHasOptions;
                luaOptions.QCanMove          = turnOptionsCanMove;
                luaOptions.QCanCapture       = turnOptionsCanCapture;
                luaOptions.QCanPromote       = turnOptionsCanPromote;

                lastCalcState.MovingPiece = luaOptions.Piece.Index;
                luaOptions.Options        = actionCalculator.Send(new TurnOptionCalculatorArgs()
                {
                    luaState   = lastCalcState,
                    pieceIndex = logicPieceIndex,
                });
            }
            return(luaOptions);
        }