Exemplo n.º 1
0
        /// <summary>
        /// 副本结算
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="now"></param>
        /// <param name="nowTicks"></param>
        private void ProcessEnd(CoupleArenaCopyScene scene, DateTime now, long nowTicks)
        {
            GameManager.CopyMapMgr.KillAllMonster(scene.CopyMap);

            //结算奖励
            scene.m_eStatus    = GameSceneStatuses.STATUS_AWARD;
            scene.m_lEndTime   = nowTicks;
            scene.m_lLeaveTime = scene.m_lEndTime + WarCfg.ClearSec * TimeUtil.SECOND;

            scene.StateTimeData.GameType = (int)GameTypes.CoupleArena;
            scene.StateTimeData.State    = (int)GameSceneStatuses.STATUS_END;
            scene.StateTimeData.EndTicks = scene.m_lLeaveTime;
            GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, scene.StateTimeData, scene.CopyMap);

            CoupleArenaFuBenData fubenData = null;

            if (!GameId2FuBenData.TryGetValue(scene.GameId, out fubenData))
            {
                return;
            }

            List <RoleData4Selector> selectorList = new List <RoleData4Selector>();

            foreach (var roledata in fubenData.RoleList)
            {
                RoleData4Selector _roleInfo = Global.sendToDB <RoleData4Selector,
                                                               string>((int)TCPGameServerCmds.CMD_SPR_GETROLEUSINGGOODSDATALIST, string.Format("{0}", roledata.RoleId), roledata.ServerId);
                if (_roleInfo == null)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("加载RoleData4Selector失败, serverid={0}, roleid={1}", roledata.ServerId, roledata.RoleId));
                    return;
                }
                selectorList.Add(_roleInfo);
            }

            if (selectorList[0].RoleSex == (int)ERoleSex.Girl)
            {
                var tmp = selectorList[0];
                selectorList[0] = selectorList[1];
                selectorList[1] = tmp;
            }

            if (selectorList[2].RoleSex == (int)ERoleSex.Girl)
            {
                var tmp = selectorList[2];
                selectorList[2] = selectorList[3];
                selectorList[3] = tmp;
            }

            // selectorList 存储的分别为男1,女1,男2,女2
            CoupleArenaPkResultReq req = new CoupleArenaPkResultReq();

            req.GameId  = scene.GameId;
            req.winSide = scene.WinSide;

            req.ManRole1      = selectorList[0].RoleID;
            req.ManZoneId1    = selectorList[0].ZoneId;
            req.ManSelector1  = DataHelper.ObjectToBytes <RoleData4Selector>(selectorList[0]);
            req.WifeRole1     = selectorList[1].RoleID;
            req.WifeZoneId1   = selectorList[1].ZoneId;
            req.WifeSelector1 = DataHelper.ObjectToBytes <RoleData4Selector>(selectorList[1]);
            req.ManRole2      = selectorList[2].RoleID;
            req.ManZoneId2    = selectorList[2].ZoneId;
            req.ManSelector2  = DataHelper.ObjectToBytes <RoleData4Selector>(selectorList[2]);
            req.WifeRole2     = selectorList[3].RoleID;
            req.WifeZoneId2   = selectorList[3].ZoneId;
            req.WifeSelector2 = DataHelper.ObjectToBytes <RoleData4Selector>(selectorList[3]);
            CoupleArenaPkResultRsp rsp = TianTiClient.getInstance().CoupleArenaPkResult(req);

            if (rsp == null)
            {
                return;
            }

            if (rsp.Couple1RetData != null)
            {
                if (rsp.Couple1RetData.Result != (int)ECoupleArenaPkResult.Invalid)
                {
                    CoupleArenaZhanBaoSaveDbData saveData = new CoupleArenaZhanBaoSaveDbData();
                    saveData.FromMan      = req.ManRole1;
                    saveData.FromWife     = req.WifeRole1;
                    saveData.FirstWeekday = TimeUtil.MakeFirstWeekday(now);
                    saveData.ZhanBao      = new CoupleArenaZhanBaoItemData()
                    {
                        TargetManZoneId    = req.ManZoneId2,
                        TargetManRoleName  = selectorList[2].RoleName,
                        TargetWifeZoneId   = req.WifeZoneId2,
                        TargetWifeRoleName = selectorList[3].RoleName,
                        IsWin    = rsp.Couple1RetData.Result == (int)ECoupleArenaPkResult.Win,
                        GetJiFen = rsp.Couple1RetData.GetJiFen
                    };
                    Global.sendToDB <bool, CoupleArenaZhanBaoSaveDbData>((int)TCPGameServerCmds.CMD_COUPLE_ARENA_DB_SAVE_ZHAN_BAO, saveData, fubenData.RoleList[0].ServerId);
                }
                NtfAwardData(req.ManRole1, rsp.Couple1RetData);
                NtfAwardData(req.WifeRole1, rsp.Couple1RetData);
            }

            if (rsp.Couple2RetData != null)
            {
                if (rsp.Couple2RetData.Result != (int)ECoupleArenaPkResult.Invalid)
                {
                    CoupleArenaZhanBaoSaveDbData saveData = new CoupleArenaZhanBaoSaveDbData();
                    saveData.FirstWeekday = TimeUtil.MakeFirstWeekday(now);
                    saveData.FromMan      = req.ManRole2;
                    saveData.FromWife     = req.WifeRole2;
                    saveData.ZhanBao      = new CoupleArenaZhanBaoItemData()
                    {
                        TargetManZoneId    = req.ManZoneId1,
                        TargetManRoleName  = selectorList[0].RoleName,
                        TargetWifeZoneId   = req.WifeZoneId1,
                        TargetWifeRoleName = selectorList[1].RoleName,
                        IsWin    = rsp.Couple2RetData.Result == (int)ECoupleArenaPkResult.Win,
                        GetJiFen = rsp.Couple2RetData.GetJiFen
                    };
                    Global.sendToDB <bool, CoupleArenaZhanBaoSaveDbData>((int)TCPGameServerCmds.CMD_COUPLE_ARENA_DB_SAVE_ZHAN_BAO, saveData, fubenData.RoleList[2].ServerId);
                }
                NtfAwardData(req.ManRole2, rsp.Couple2RetData);
                NtfAwardData(req.WifeRole2, rsp.Couple2RetData);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 上报pk结果, 中心进行分数计算,因为中心上玩家的数据(段位信息)才是最准确的
        /// </summary>
        /// <param name="gameId"></param>
        /// <param name="couple1"></param>
        /// <param name="couple2"></param>
        /// <param name="winSide"></param>
        /// <returns></returns>
        public CoupleArenaPkResultRsp CoupleArenaPkResult(CoupleArenaPkResultReq req)
        {
            if (req == null)
            {
                return(null);
            }

            DateTime now = TimeUtil.NowDateTime();

            lock (Mutex)
            {
                if (!IsValidCoupleIfExist(req.ManRole1, req.WifeRole1) ||
                    !IsValidCoupleIfExist(req.ManRole2, req.WifeRole2))
                {
                    return(null);
                }

                CoupleArenaFuBenData fuben;
                if (!GameFuBenDict.TryGetValue(req.GameId, out fuben))
                {
                    return(null);
                }

                CoupleArenaPkResultRsp rsp = new CoupleArenaPkResultRsp();

                if (req.winSide == 0)
                {
                    rsp.Couple1RetData.Result = (int)ECoupleArenaPkResult.Invalid;
                    rsp.Couple2RetData.Result = (int)ECoupleArenaPkResult.Invalid;
                }
                else if (req.winSide == 1)
                {
                    rsp.Couple1RetData.Result = DivorceRecord.IsDivorce(req.ManRole1, req.WifeRole1) ? (int)ECoupleArenaPkResult.Invalid : (int)ECoupleArenaPkResult.Win;
                    rsp.Couple2RetData.Result = DivorceRecord.IsDivorce(req.ManRole2, req.WifeRole2) ? (int)ECoupleArenaPkResult.Invalid : (int)ECoupleArenaPkResult.Fail;
                }
                else
                {
                    rsp.Couple1RetData.Result = DivorceRecord.IsDivorce(req.ManRole1, req.WifeRole1) ? (int)ECoupleArenaPkResult.Invalid : (int)ECoupleArenaPkResult.Fail;
                    rsp.Couple2RetData.Result = DivorceRecord.IsDivorce(req.ManRole2, req.WifeRole2) ? (int)ECoupleArenaPkResult.Invalid : (int)ECoupleArenaPkResult.Win;
                }

                // 胜利按对方的段位奖励,失败按自己的段位扣除
                int duanweiType1 = _DuanWeiCfgList[0].DuanWeiType, duanweiLevel1 = _DuanWeiCfgList[0].DuanWeiLevel;
                int duanweiType2 = _DuanWeiCfgList[0].DuanWeiType, duanweiLevel2 = _DuanWeiCfgList[0].DuanWeiLevel;
                if (SyncData.RoleDict.ContainsKey(req.ManRole1))
                {
                    duanweiType1  = SyncData.RoleDict[req.ManRole1].DuanWeiType;
                    duanweiLevel1 = SyncData.RoleDict[req.ManRole1].DuanWeiLevel;
                }
                if (SyncData.RoleDict.ContainsKey(req.ManRole2))
                {
                    duanweiType2  = SyncData.RoleDict[req.ManRole2].DuanWeiType;
                    duanweiLevel2 = SyncData.RoleDict[req.ManRole2].DuanWeiLevel;
                }

                HandlePkResult(req.ManRole1, req.ManZoneId1, req.ManSelector1, req.WifeRole1, req.WifeZoneId1, req.WifeSelector1, duanweiType2, duanweiLevel2, rsp.Couple1RetData);
                HandlePkResult(req.ManRole2, req.ManZoneId2, req.ManSelector2, req.WifeRole2, req.WifeZoneId2, req.WifeSelector2, duanweiType1, duanweiLevel1, rsp.Couple2RetData);

                RemoveFuBen(req.GameId);
                Persistence.AddPkLog(fuben.GameId, fuben.StartTime, TimeUtil.NowDateTime(),
                                     req.ManRole1, req.WifeRole1, rsp.Couple1RetData.Result,
                                     req.ManRole2, req.WifeRole2, rsp.Couple2RetData.Result);
                return(rsp);
            }
        }
Exemplo n.º 3
0
        public CoupleArenaPkResultRsp CoupleArenaPkResult(CoupleArenaPkResultReq req)
        {
            CoupleArenaPkResultRsp result;

            if (req == null)
            {
                result = null;
            }
            else
            {
                DateTime now = TimeUtil.NowDateTime();
                lock (this.Mutex)
                {
                    CoupleArenaFuBenData fuben;
                    if (!this.IsValidCoupleIfExist(req.ManRole1, req.WifeRole1) || !this.IsValidCoupleIfExist(req.ManRole2, req.WifeRole2))
                    {
                        result = null;
                    }
                    else if (!this.GameFuBenDict.TryGetValue(req.GameId, out fuben))
                    {
                        result = null;
                    }
                    else
                    {
                        CoupleArenaPkResultRsp rsp = new CoupleArenaPkResultRsp();
                        if (req.winSide == 0)
                        {
                            rsp.Couple1RetData.Result = 0;
                            rsp.Couple2RetData.Result = 0;
                        }
                        else if (req.winSide == 1)
                        {
                            rsp.Couple1RetData.Result = (this.DivorceRecord.IsDivorce(req.ManRole1, req.WifeRole1) ? 0 : 1);
                            rsp.Couple2RetData.Result = (this.DivorceRecord.IsDivorce(req.ManRole2, req.WifeRole2) ? 0 : 2);
                        }
                        else
                        {
                            rsp.Couple1RetData.Result = (this.DivorceRecord.IsDivorce(req.ManRole1, req.WifeRole1) ? 0 : 2);
                            rsp.Couple2RetData.Result = (this.DivorceRecord.IsDivorce(req.ManRole2, req.WifeRole2) ? 0 : 1);
                        }
                        int duanweiType   = this._DuanWeiCfgList[0].DuanWeiType;
                        int duanweiLevel  = this._DuanWeiCfgList[0].DuanWeiLevel;
                        int duanweiType2  = this._DuanWeiCfgList[0].DuanWeiType;
                        int duanweiLevel2 = this._DuanWeiCfgList[0].DuanWeiLevel;
                        if (this.SyncData.RoleDict.ContainsKey(req.ManRole1))
                        {
                            duanweiType  = this.SyncData.RoleDict[req.ManRole1].DuanWeiType;
                            duanweiLevel = this.SyncData.RoleDict[req.ManRole1].DuanWeiLevel;
                        }
                        if (this.SyncData.RoleDict.ContainsKey(req.ManRole2))
                        {
                            duanweiType2  = this.SyncData.RoleDict[req.ManRole2].DuanWeiType;
                            duanweiLevel2 = this.SyncData.RoleDict[req.ManRole2].DuanWeiLevel;
                        }
                        this.HandlePkResult(req.ManRole1, req.ManZoneId1, req.ManSelector1, req.WifeRole1, req.WifeZoneId1, req.WifeSelector1, duanweiType2, duanweiLevel2, rsp.Couple1RetData);
                        this.HandlePkResult(req.ManRole2, req.ManZoneId2, req.ManSelector2, req.WifeRole2, req.WifeZoneId2, req.WifeSelector2, duanweiType, duanweiLevel, rsp.Couple2RetData);
                        this.RemoveFuBen(req.GameId);
                        this.Persistence.AddPkLog(fuben.GameId, fuben.StartTime, TimeUtil.NowDateTime(), req.ManRole1, req.WifeRole1, rsp.Couple1RetData.Result, req.ManRole2, req.WifeRole2, rsp.Couple2RetData.Result);
                        result = rsp;
                    }
                }
            }
            return(result);
        }