public void FindGame(byte[] requestGuid, BnetGameType gameType, int scenario, long deckId, long aiDeckId, bool setScenarioIdAttr)
 {
     if (this.s_gameRequest != 0)
     {
         Debug.LogWarning("WARNING: FindGame called with an active game");
         this.CancelFindGame(this.s_gameRequest);
         this.s_gameRequest = 0L;
     }
     if (this.IsNoAccountTutorialGame(gameType))
     {
         this.GoToNoAccountTutorialServer(scenario);
     }
     else
     {
         object[] args = new object[] { gameType, scenario, deckId, aiDeckId, !setScenarioIdAttr ? 0 : 1, (requestGuid != null) ? requestGuid.ToHexString() : "null" };
         base.ApiLog.LogInfo("FindGame type={0} scenario={1} deck={2} aideck={3} setScenId={4} request_guid={5}", args);
         bnet.protocol.game_master.Player val = new bnet.protocol.game_master.Player();
         Identity identity = new Identity();
         identity.SetGameAccountId(base.m_battleNet.GameAccountId);
         val.SetIdentity(identity);
         val.AddAttribute(ProtocolHelper.CreateAttribute("type", (long)gameType));
         val.AddAttribute(ProtocolHelper.CreateAttribute("scenario", (long)scenario));
         val.AddAttribute(ProtocolHelper.CreateAttribute("deck", (long)((int)deckId)));
         val.AddAttribute(ProtocolHelper.CreateAttribute("aideck", (long)((int)aiDeckId)));
         val.AddAttribute(ProtocolHelper.CreateAttribute("request_guid", requestGuid));
         GameProperties  properties = new GameProperties();
         AttributeFilter filter     = new AttributeFilter();
         filter.SetOp(AttributeFilter.Types.Operation.MATCH_ALL);
         if (!BattleNet.IsVersionInt() && (BattleNet.GetVersionString() == "PAX"))
         {
             filter.AddAttribute(ProtocolHelper.CreateAttribute("version", BattleNet.GetVersionString() + BattleNet.GetVersionInt().ToString()));
         }
         else if (BattleNet.IsVersionInt())
         {
             filter.AddAttribute(ProtocolHelper.CreateAttribute("version", (long)BattleNet.GetVersionInt()));
         }
         else
         {
             filter.AddAttribute(ProtocolHelper.CreateAttribute("version", BattleNet.GetVersionString()));
         }
         filter.AddAttribute(ProtocolHelper.CreateAttribute("GameType", (long)gameType));
         if (setScenarioIdAttr)
         {
             filter.AddAttribute(ProtocolHelper.CreateAttribute("ScenarioId", (long)scenario));
         }
         properties.SetFilter(filter);
         properties.AddCreationAttributes(ProtocolHelper.CreateAttribute("type", (long)gameType));
         properties.AddCreationAttributes(ProtocolHelper.CreateAttribute("scenario", (long)scenario));
         FindGameRequest request = new FindGameRequest();
         request.AddPlayer(val);
         request.SetProperties(properties);
         request.SetAdvancedNotification(true);
         FindGameRequest request2 = request;
         this.PrintFindGameRequest(request2);
         this.IsFindGamePending = true;
         base.m_rpcConnection.QueueRequest(this.m_gameMasterService.Id, 3, request2, new RPCContextDelegate(this.FindGameCallback), 0);
     }
 }
    public void CreateFriendlyChallengeGame(long myDeck, long hisDeck, EntityId hisGameAccount, int scenario)
    {
        FindGameRequest request = new FindGameRequest();

        bnet.protocol.game_master.Player val = new bnet.protocol.game_master.Player();
        Identity identity = new Identity();

        identity.SetGameAccountId(base.m_battleNet.GameAccountId);
        GameProperties  properties = new GameProperties();
        AttributeFilter filter     = new AttributeFilter();

        filter.SetOp(AttributeFilter.Types.Operation.MATCH_ALL);
        if (!BattleNet.IsVersionInt() && (BattleNet.GetVersionString() == "PAX"))
        {
            filter.AddAttribute(ProtocolHelper.CreateAttribute("version", BattleNet.GetVersionString() + BattleNet.GetVersionInt().ToString()));
        }
        else if (BattleNet.IsVersionInt())
        {
            filter.AddAttribute(ProtocolHelper.CreateAttribute("version", (long)BattleNet.GetVersionInt()));
        }
        else
        {
            filter.AddAttribute(ProtocolHelper.CreateAttribute("version", BattleNet.GetVersionString()));
        }
        filter.AddAttribute(ProtocolHelper.CreateAttribute("GameType", (long)1L));
        filter.AddAttribute(ProtocolHelper.CreateAttribute("ScenarioId", (long)scenario));
        properties.SetFilter(filter);
        properties.AddCreationAttributes(ProtocolHelper.CreateAttribute("type", (long)1L));
        properties.AddCreationAttributes(ProtocolHelper.CreateAttribute("scenario", (long)scenario));
        val.SetIdentity(identity);
        val.AddAttribute(ProtocolHelper.CreateAttribute("type", (long)1L));
        val.AddAttribute(ProtocolHelper.CreateAttribute("scenario", (long)scenario));
        val.AddAttribute(ProtocolHelper.CreateAttribute("deck", (long)((int)myDeck)));
        request.AddPlayer(val);
        identity = new Identity();
        val      = new bnet.protocol.game_master.Player();
        identity.SetGameAccountId(hisGameAccount);
        val.SetIdentity(identity);
        val.AddAttribute(ProtocolHelper.CreateAttribute("type", (long)1L));
        val.AddAttribute(ProtocolHelper.CreateAttribute("scenario", (long)scenario));
        val.AddAttribute(ProtocolHelper.CreateAttribute("deck", (long)((int)hisDeck)));
        request.AddPlayer(val);
        request.SetProperties(properties);
        request.SetAdvancedNotification(true);
        FindGameRequest request2 = request;

        this.PrintFindGameRequest(request2);
        this.IsFindGamePending = true;
        base.m_rpcConnection.QueueRequest(this.m_gameMasterService.Id, 3, request2, new RPCContextDelegate(this.FindGameCallback), 0);
    }
    private void CancelFindGame(ulong gameRequestId)
    {
        BnetGameType findingBnetGameType = Network.Get().GetFindingBnetGameType();

        if (!this.IsNoAccountTutorialGame(findingBnetGameType))
        {
            CancelGameEntryRequest message = new CancelGameEntryRequest {
                RequestId = gameRequestId
            };
            bnet.protocol.game_master.Player val = new bnet.protocol.game_master.Player();
            Identity identity = new Identity();
            identity.SetGameAccountId(base.m_battleNet.GameAccountId);
            val.SetIdentity(identity);
            message.AddPlayer(val);
            CancelGameContext context = new CancelGameContext(gameRequestId);
            base.m_rpcConnection.QueueRequest(this.m_gameMasterService.Id, 4, message, new RPCContextDelegate(context.CancelGameCallback), 0);
        }
    }
    private string PrintPlayer(bnet.protocol.game_master.Player player)
    {
        string str = string.Empty + "Player: [";

        if (player.HasIdentity)
        {
            this.PrintGameMasterIdentity(player.Identity);
        }
        int attributeCount = player.AttributeCount;

        str = str + "Attributes: ";
        for (int i = 0; i < attributeCount; i++)
        {
            bnet.protocol.attribute.Attribute attribute = player.Attribute[i];
            string   str2      = str;
            object[] objArray1 = new object[] { str2, "[Name: ", attribute.Name, " Value: ", attribute.Value, "] " };
            str = string.Concat(objArray1);
        }
        return(str + "] ");
    }
    private void PrintFindGameRequest(FindGameRequest request)
    {
        string str2;
        string message     = "FindGameRequest: { ";
        int    playerCount = request.PlayerCount;

        for (int i = 0; i < playerCount; i++)
        {
            bnet.protocol.game_master.Player player = request.Player[i];
            message = message + this.PrintPlayer(player);
        }
        if (request.HasFactoryId)
        {
            str2 = message;
            object[] objArray1 = new object[] { str2, "Factory Id: ", request.FactoryId, " " };
            message = string.Concat(objArray1);
        }
        if (request.HasProperties)
        {
            message = message + this.PrintGameProperties(request.Properties);
        }
        if (request.HasObjectId)
        {
            str2 = message;
            object[] objArray2 = new object[] { str2, "Obj Id: ", request.ObjectId, " " };
            message = string.Concat(objArray2);
        }
        if (request.HasRequestId)
        {
            str2 = message;
            object[] objArray3 = new object[] { str2, "Request Id: ", request.RequestId, " " };
            message = string.Concat(objArray3);
        }
        message = message + "}";
        base.ApiLog.LogDebug(message);
    }