Exemplo n.º 1
0
        public void UpdateAllTargetObject(int playerID, TargetFilter filter, TargetFixer updater)
        {
            Player.PublicInfo[] info = new Player.PublicInfo[] { player[0].GetPublicInfo(), player[1].GetPublicInfo() };
            int[] playerPattern;
            if (player[0].ID == playerID)
            {
                playerPattern = new int[] { Action.SELF, Action.OPP }
            }
            ;
            else
            {
                playerPattern = new int[] { Action.OPP, Action.SELF }
            };

            for (int i = 0; i < 2; ++i)
            {
                int         facePattern = playerPattern[i] | Action.FACE;
                Player.Face face        = info[i].face;
                if (filter(facePattern, face))
                {
                    updater(face);
                    player[i].UpdateFace(face);
                }
                List <int>         indices = new List <int>();
                List <BoardObject> objs    = new List <BoardObject>();
                for (int j = 0; j < info[i].board.Count; ++j)
                {
                    int         boardPattern = playerPattern[i] | Action.BOARD | (j & Action.INDEX_MASK);
                    BoardObject obj          = info[i].board[j];
                    if (filter(boardPattern, obj))
                    {
                        updater(obj);
                        indices.Add(j);
                        objs.Add(obj);
                    }
                }
                if (indices.Count > 0)
                {
                    player[i].UpdateBoard(indices, objs);
                }
            }
        }
    }
Exemplo n.º 2
0
        public void UpdateTargetObject(int playerID, int targetPattern, TargetObject target, TargetFixer updater)
        {
            updater(target);

            Player player = GetPlayer(playerID, (targetPattern & Action.SELF) != 0);

            if ((targetPattern & Action.FACE) != 0)
            {
                Player.Face f = target as Player.Face;
                if (f.hp <= 0)
                {
                    winner = GetPlayer(player.ID, false);
                }
                player.UpdateFace(f);
            }
            if ((targetPattern & Action.BOARD) != 0)
            {
                player.UpdateBoard(targetPattern & Action.INDEX_MASK, target as BoardObject);
            }
        }