Example #1
0
        public static DedimaniaPlayerArriveReply Parse(object multiCallResultElement)
        {
            if (multiCallResultElement == null || !multiCallResultElement.GetType().IsArray)
            {
                return(null);
            }

            object[] rootElements = (object[])multiCallResultElement;
            if (rootElements.Length != 1 || rootElements[0].GetType() != typeof(XmlRpcStruct))
            {
                return(null);
            }

            XmlRpcStruct replyStruct = (XmlRpcStruct)rootElements[0];

            if (!replyStruct.ContainsKey("Options") || !replyStruct.ContainsKey("Nation") || !replyStruct.ContainsKey("TeamName") || !replyStruct.ContainsKey("Login") || !replyStruct.ContainsKey("Aliases"))
            {
                return(null);
            }

            DedimaniaPlayerArriveReply result = new DedimaniaPlayerArriveReply();

            result.Aliases  = new List <AliasTextTool>();
            result.Options  = new List <OptionValueTool>();
            result.Login    = Convert.ToString(replyStruct["Login"]);
            result.TeamName = Convert.ToString(replyStruct["TeamName"]);
            result.Nation   = Convert.ToString(replyStruct["Nation"]);

            return(result);
        }
Example #2
0
        public List <DedimaniaPlayerArriveReply> PlayersArrive(params PlayerArriveParameters[] parameters)
        {
            if (parameters == null || parameters.Length == 0)
            {
                throw new ArgumentException("Parameters are empty");
            }

            RPCMethodInfo[] methodCalls = new RPCMethodInfo[parameters.Length + 2];
            methodCalls[0] = new RPCMethodInfo("dedimania.Authenticate", AuthParameters);
            methodCalls[methodCalls.Length - 1] = new RPCMethodInfo("dedimania.WarningsAndTTR");

            for (int i = 0; i < parameters.Length; i++)
            {
                PlayerArriveParameters arriveParameters = parameters[i];
                methodCalls[i + 1] = new RPCMethodInfo("dedimania.PlayerArrive", arriveParameters.Game, arriveParameters.Login, arriveParameters.Nickname, arriveParameters.Nation, arriveParameters.TeamName, arriveParameters.LadderRanking, arriveParameters.Spectating, arriveParameters.IsOff);
            }

            object[] multiCallRawResult = Proxy.MultiCall(methodCalls);

            MultiCallResult multiCallResult = MultiCallResult.Parse(multiCallRawResult);

            if (multiCallResult == null)
            {
                return(null);
            }

            List <DedimaniaPlayerArriveReply> result = new List <DedimaniaPlayerArriveReply>();

            for (int i = 1; i < multiCallRawResult.Length - 1; i++)
            {
                result.Add(DedimaniaPlayerArriveReply.Parse(multiCallRawResult[i]));
            }

            return(result);
        }