Ejemplo n.º 1
0
        internal bool StartChallenge(ulong challenger_guid, ulong target_guid, int sign)
        {
            ArenaInfo challenger = GetArenaInfoById(challenger_guid);

            if (challenger == null)
            {
                ErrorCode = GeneralOperationResult.LC_Failure_Arena_NotFindTarget;
                return(false);
            }
            if (challenger.IsInBattleCd())
            {
                ErrorCode = GeneralOperationResult.LC_Failure_InCd;
                return(false);
            }
            if (challenger.LeftFightCount <= 0)
            {
                ErrorCode = GeneralOperationResult.LC_Failure_NoFightCount;
                return(false);
            }
            ArenaInfo target_info = GetArenaInfoById(target_guid);

            if (target_info == null)
            {
                ErrorCode = GeneralOperationResult.LC_Failure_Arena_NotFindTarget;
                return(false);
            }
            if (challenger.GetId() == target_info.GetId())
            {
                ErrorCode = GeneralOperationResult.LC_Failure_Arena_NotFindTarget;
                return(false);
            }
            m_ChallengeManager.BeginChallenge(challenger, target_info, sign);
            return(true);
            //m_ArenaRank.ExchangeRank(cur_rank, target_info.GetRank());
        }
Ejemplo n.º 2
0
 internal void HandleRequestExpeditionInfo(ulong guid, int hp, int mp, int rage, int request_num, bool is_reset, bool allow_cost_gold, long timestamp)
 {
     long c_DeltaTime = 60 * 10;
     UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(guid);
     if (user != null && null != user.Expedition)
     {
         GeneralOperationResult result = GeneralOperationResult.LC_Failure_Unknown;
         long dif_time = Convert.ToInt64(TimeUtility.CurTimestamp) - timestamp;
         bool is_valid_timestamp = Math.Abs(dif_time) <= c_DeltaTime ? true : false;
         if (is_reset && !is_valid_timestamp)
         {
             result = GeneralOperationResult.LC_Failure_Time;
         }
         else
         {
             result = user.Expedition.RequestExpeditionInfo(guid, request_num, is_reset, m_UsableImages);
         }
         if (GeneralOperationResult.LC_Succeed == result)
         {
             user.Expedition.SyncExpeditionInfo(guid, hp, mp, rage, request_num, result);
         }
         else
         {
             JsonMessageWithGuid resetMsg = new JsonMessageWithGuid(JsonMessageID.ExpeditionResetResult);
             resetMsg.m_Guid = guid;
             ArkCrossEngineMessage.Msg_LC_ExpeditionResetResult protoData = new ArkCrossEngineMessage.Msg_LC_ExpeditionResetResult();
             protoData.m_Result = (int)result;
             resetMsg.m_ProtoData = protoData;
             JsonMessageDispatcher.SendDcoreMessage(user.NodeName, resetMsg);
         }
     }
 }
Ejemplo n.º 3
0
        internal void NotifyRequestDareResult(ulong guid, string nickname, GeneralOperationResult result)
        {
            UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(guid);

            if (null == user)
            {
                return;
            }
            JsonMessageWithGuid rdMsg = new JsonMessageWithGuid(JsonMessageID.RequestDareResult);

            rdMsg.m_Guid = guid;
            ArkCrossEngineMessage.Msg_LC_RequestDareResult protoData = new ArkCrossEngineMessage.Msg_LC_RequestDareResult();
            protoData.m_Nickname = nickname;
            protoData.m_Result   = (int)result;
            rdMsg.m_ProtoData    = protoData;
            JsonMessageDispatcher.SendDcoreMessage(user.NodeName, rdMsg);
        }
Ejemplo n.º 4
0
 internal void HandleExchangeGift(ulong userGuid, string giftcode)
 {
     UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(userGuid);
     if (user == null)
     {
         return;
     }
     int giftId = 0;
     GeneralOperationResult ret = m_GiftCodeSystem.ExchangeGift(userGuid, giftcode, out giftId);
     JsonMessageWithGuid jsonMsg = new JsonMessageWithGuid(JsonMessageID.ExchangeGiftResult);
     jsonMsg.m_Guid = userGuid;
     ArkCrossEngineMessage.Msg_LC_ExchangeGiftResult protoData = new ArkCrossEngineMessage.Msg_LC_ExchangeGiftResult();
     protoData.m_GiftId = giftId;
     protoData.m_Result = (int)ret;
     jsonMsg.m_ProtoData = protoData;
     JsonMessageDispatcher.SendDcoreMessage(user.NodeName, jsonMsg);
 }
Ejemplo n.º 5
0
        public async Task <GeneralOperationResult> SendSmsAsync(string numbers, string message)
        {
            string userId   = "*****@*****.**";
            string password = "******";
            string sender   = "Oasis CS-AD";
            var    url      = string.Format("http://api.unifonic.com/wrapper/sendSMS.php?userid={0}&password={1}&msg={2}&sender={3}&to={4}", userId, password, HttpUtility.UrlEncode(message), HttpUtility.UrlEncode(sender), numbers);

            //Send the GET request
            //HttpClient client = clientFactory.CreateClient();
            //HttpRequestMessage httpRequest = new HttpRequestMessage(HttpMethod.Get, url);
            //var response = await client.SendAsync(httpRequest);

            //if (response.IsSuccessStatusCode)
            //{
            //    var responseResult = await response.Content.ReadAsStringAsync();
            //    var resultObj = JObject.Parse(responseResult);
            //    status = resultObj["success"].ToString();
            //    Console.WriteLine(responseResult);
            //}

            var baseAddress = new Uri("https://api.unifonic.com/rest/");
            var status      = "false";
            GeneralOperationResult sendSmsResult;

            using (var httpClient = new HttpClient {
                BaseAddress = baseAddress
            })
            {
                using (var content = new StringContent("AppSid=VxcprXsqv7PCrpSJGMXL9cON4Wg3p&Recipient=" + numbers + "&Body=" + message + "&SenderID=" + sender, System.Text.Encoding.UTF8, "application/x-www-form-urlencoded"))
                {
                    using (var response = await httpClient.PostAsync("Messages/Send", content))
                    {
                        var responseData = await response.Content.ReadAsStringAsync();

                        var resultObj = JObject.Parse(responseData);
                        status        = resultObj["success"].ToString();
                        sendSmsResult = new GeneralOperationResult(status == "true", resultObj["success"].ToString());
                        Console.WriteLine(responseData);
                        Console.WriteLine(status);
                    }
                }
            }

            return(sendSmsResult);
        }
Ejemplo n.º 6
0
        private bool CanStart(DareInfo info)
        {
            UserInfo offense_user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(info.offense);

            if (null == offense_user)
            {
                return(false);
            }
            UserInfo defence_user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(info.defence);

            if (null == defence_user)
            {
                return(false);
            }
            GeneralOperationResult ret = GeneralOperationResult.LC_Failure_NotUnLock;

            if (offense_user.Level < UNLOCK_LEVEL)
            {
                NotifyRequestDareResult(offense_user.Guid, offense_user.Nickname, ret);
                NotifyRequestDareResult(defence_user.Guid, offense_user.Nickname, ret);
                return(false);
            }
            if (defence_user.Level < UNLOCK_LEVEL)
            {
                NotifyRequestDareResult(offense_user.Guid, defence_user.Nickname, ret);
                NotifyRequestDareResult(defence_user.Guid, defence_user.Nickname, ret);
                return(false);
            }
            ret = GeneralOperationResult.LC_Failuer_Busy;
            if (UserState.Online != offense_user.CurrentState)
            {
                NotifyRequestDareResult(defence_user.Guid, offense_user.Nickname, ret);
                return(false);
            }
            if (UserState.Online != defence_user.CurrentState)
            {
                NotifyRequestDareResult(offense_user.Guid, defence_user.Nickname, ret);
                return(false);
            }
            if (offense_user.Guid == defence_user.Guid)
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 7
0
        private void HandleExchangeGiftResult(JsonMessage lobbyMsg)
        {
            JsonData jsonData = lobbyMsg.m_JsonData;

            ArkCrossEngineMessage.Msg_LC_ExchangeGiftResult protoMsg = lobbyMsg.m_ProtoData as ArkCrossEngineMessage.Msg_LC_ExchangeGiftResult;
            if (null == protoMsg)
            {
                return;
            }
            int giftId = protoMsg.m_GiftId;
            GeneralOperationResult result = (GeneralOperationResult)protoMsg.m_Result;

            //礼品码兑换结果,通知UI显示提示信息
            //返回结果的含义:
            //GeneralOperationResult.LC_Succeed               //礼品兑换成功
            //GeneralOperationResult.LC_Failure_Unknown       //礼品码兑换失败
            //GeneralOperationResult.LC_Failure_Code_Used     //礼品码已经被使用,无效
            //GeneralOperationResult.LC_Failure_Code_Error    //礼品码错误
            //GeneralOperationResult.LC_Failure_Overflow      //礼品领取次数超过限制
            GfxSystem.PublishGfxEvent("ge_exchange_gift_result", "ui", result, giftId);
        }
Ejemplo n.º 8
0
 private void HandleEnterSceneResult(NodeMessage lobbyMsg)
 {
     GameFrameworkMessage.EnterSceneResult protoData = lobbyMsg.m_ProtoData as GameFrameworkMessage.EnterSceneResult;
     if (null != protoData)
     {
         GeneralOperationResult result = (GeneralOperationResult)protoData.result;
         if (GeneralOperationResult.LC_Succeed == result)
         {
             uint   key     = protoData.key;
             string ip      = protoData.server_ip;
             int    port    = (int)protoData.server_port;
             int    campId  = protoData.camp_id;
             int    sceneId = protoData.scene_type;
             ClientInfo.Instance.PropertyKey = protoData.prime;
             //延迟处理,防止当前正在切场景过程中
             PluginFramework.Instance.QueueAction(PluginFramework.Instance.TryEnterScene, key, ip, port, campId, sceneId);
         }
         else
         {
             PluginFramework.Instance.HighlightPrompt("Tip_SceneEnterFailed");
         }
     }
 }
Ejemplo n.º 9
0
        //领取礼品
        internal GeneralOperationResult ExchangeGift(ulong userGuid, string giftcode, out int giftId)
        {
            giftId = 0;
            GeneralOperationResult ret       = GeneralOperationResult.LC_Failure_Unknown;
            DataProcessScheduler   scheduler = LobbyServer.Instance.DataProcessScheduler;
            UserInfo user = scheduler.GetUserInfo(userGuid);

            if (null != user)
            {
                GiftCodeInfo giftcodeInfo = null;
                m_GiftCodes.TryGetValue(giftcode, out giftcodeInfo);
                if (giftcodeInfo != null)
                {
                    giftId = giftcodeInfo.GiftId;
                    Dictionary <int, int> giftCountDict = null;
                    if (m_UserGiftCountDict.TryGetValue(user.Guid, out giftCountDict))
                    {
                        int count = 0;
                        if (giftCountDict.TryGetValue(giftId, out count))
                        {
                            if (count >= s_UserMaxGiftCount)
                            {
                                //该种礼包的领取次数超过限制
                                ret = GeneralOperationResult.LC_Failure_Overflow;
                                return(ret);
                            }
                        }
                    }
                    if (giftcodeInfo.IsUsed == false)
                    {
                        //礼品码可用
                        GiftConfig giftConfig = GiftConfigProvider.Instance.GetDataById(giftcodeInfo.GiftId);
                        if (null != giftConfig)
                        {
                            //扣
                            giftcodeInfo.IsUsed   = true;
                            giftcodeInfo.UserGuid = userGuid;
                            if (giftCountDict != null)
                            {
                                int count = 0;
                                if (giftCountDict.TryGetValue(giftId, out count))
                                {
                                    giftCountDict[giftId]++;
                                }
                                else
                                {
                                    giftCountDict.Add(giftId, 1);
                                }
                            }
                            else
                            {
                                giftCountDict = new Dictionary <int, int>();
                                giftCountDict.Add(giftId, 1);
                                m_UserGiftCountDict.Add(userGuid, giftCountDict);
                            }
                            var ds_thread = LobbyServer.Instance.DataStoreThread;
                            if (ds_thread.DataStoreAvailable)
                            {
                                ds_thread.DSSaveGiftCode(giftcodeInfo, true);
                            }
                            //给
                            for (int i = 0; i < giftConfig.ItemIdList.Count; ++i)
                            {
                                if (giftConfig.ItemIdList[i] > 0)
                                {
                                    scheduler.DispatchAction(scheduler.DoAddItem, userGuid, giftConfig.ItemIdList[i], giftConfig.ItemNumList[i], GainConsumePos.Gift.ToString());
                                }
                            }
                            ret = GeneralOperationResult.LC_Succeed;
                        }
                    }
                    else
                    {
                        //礼品码已经使用
                        ret = GeneralOperationResult.LC_Failure_Code_Used;
                    }
                }
                else
                {
                    //礼品码错误
                    ret = GeneralOperationResult.LC_Failure_Code_Error;
                }
            }
            return(ret);
        }
Ejemplo n.º 10
0
        internal void RequestSinglePVE(ulong guid, int sceneId)
        {
            Data_SceneConfig cfg = SceneConfigProvider.Instance.GetSceneConfigById(sceneId);

            if (null == cfg || cfg.m_Type == (int)SceneTypeEnum.TYPE_PVE)
            {
                //单人pve不建立房间,直接开始游戏(todo:奖励记到人身上[多人的奖励也是这样])
                DataProcessScheduler dataProcess = LobbyServer.Instance.DataProcessScheduler;
                UserInfo             user        = dataProcess.GetUserInfo(guid);
                if (user != null)
                {
                    user.CurrentBattleInfo.init(sceneId, user.HeroId);
                    SyncCombatData(user);
                    JsonMessageWithGuid startGameResultMsg = new JsonMessageWithGuid(JsonMessageID.StartGameResult);
                    startGameResultMsg.m_Guid = user.Guid;
                    ArkCrossEngineMessage.Msg_LC_StartGameResult protoData = new ArkCrossEngineMessage.Msg_LC_StartGameResult();
                    GeneralOperationResult result = GeneralOperationResult.LC_Succeed;
                    if (user.CurStamina >= cfg.m_CostStamina)
                    {
                        if (!GlobalVariables.Instance.IsDebug)
                        {
                            int preSceneId = SceneConfigProvider.Instance.GetPreSceneId(sceneId);
                            if (-1 != preSceneId)
                            {
                                if (!user.SceneData.ContainsKey(preSceneId))
                                {
                                    LogSystem.Error("player {0} try to enter an Illegal scene {1}", user.Guid, sceneId);
                                    return;
                                }
                            }
                            if (cfg.m_SubType == (int)SceneSubTypeEnum.TYPE_ELITE && user.GetCompletedSceneCount(sceneId) >= user.MaxEliteSceneCompletedCount)
                            {
                                LogSystem.Error("player {0} enter an Elite scene {1} too many times {2}", user.Guid, sceneId, user.GetCompletedSceneCount(sceneId));
                                return;
                            }
                        }
                        protoData.server_ip   = "127.0.0.1";
                        protoData.server_port = 9001;
                        protoData.key         = user.Key;
                        protoData.hero_id     = user.HeroId;
                        protoData.camp_id     = (int)CampIdEnum.Blue;
                        protoData.scene_type  = sceneId;
                        protoData.match_key   = user.CurrentBattleInfo.MatchKey;
                        result            = GeneralOperationResult.LC_Succeed;
                        user.CurrentState = UserState.Pve;
                    }
                    else
                    {
                        result = GeneralOperationResult.LC_Failure_CostError;
                    }
                    protoData.result = (int)result;
                    startGameResultMsg.m_ProtoData = protoData;
                    JsonMessageDispatcher.SendDcoreMessage(user.NodeName, startGameResultMsg);
                    LogSys.Log(LOG_TYPE.INFO, "Single Player Room will run on Lobby without room and roomserver, user {0} scene {1}", guid, sceneId);
                    /// norm log
                    AccountInfo accountInfo = dataProcess.FindAccountInfoById(user.AccountId);
                    if (null != accountInfo)
                    {
                        /// pvefight
                        LogSys.NormLog("PVEfight", LobbyConfig.AppKeyStr, accountInfo.ClientGameVersion, Module.pvefight, LobbyConfig.LogNormVersionStr,
                                       "B4110", accountInfo.LogicServerId, accountInfo.AccountId, user.Guid, user.Level, sceneId, (int)FightingType.General, "null",
                                       (int)PvefightResult.Failure, "null", "null");
                    }
                }
            }
        }