Beispiel #1
0
        public PlayerkillMatchResponse GetMatchResult(Guid managerId, Guid matchId)
        {
            var match = PlayerkillMatchMgr.GetById(matchId);

            if (match == null)
            {
                return(ResponseHelper.InvalidParameter <PlayerkillMatchResponse>("match is null"));
            }
            if (match.HomeId != managerId)
            {
                return(ResponseHelper.InvalidParameter <PlayerkillMatchResponse>("HomeId!=managerId"));
            }
            if (match.Status == 0)
            {
                match.PrizeItemCode = 0;
            }
            var response = ResponseHelper.CreateSuccess <PlayerkillMatchResponse>();

            response.Data = match;
            var popMsg = MemcachedFactory.MatchPopClient.Get <List <PopMessageEntity> >(matchId);

            if (popMsg != null)
            {
                MemcachedFactory.MatchPopClient.Delete(matchId);
                response.Data.PopMsg = popMsg;
            }
            //是否有vip效果
            var manager = ManagerCore.Instance.GetManager(managerId);

            if (manager != null)
            {
                var winType = ShareUtil.CalWinType(match.HomeScore, match.AwayScore);
                var prize   = CacheFactory.PlayerKillCache.GetPrize(winType);
                var vipRate = CacheFactory.VipdicCache.GetEffectValue(manager.VipLevel, EnumVipEffect.PkOrLeagueExpPlus);
                response.Data.VipExp = prize.Exp * vipRate / 100;
            }
            return(response);
        }
Beispiel #2
0
        /// <summary>
        /// 比赛抽卡
        /// </summary>
        /// <param name="managerId"></param>
        /// <param name="matchId"></param>
        /// <returns></returns>
        public TourLotteryResponse Lottery(Guid managerId, Guid matchId)
        {
            var pkMatch = PlayerkillMatchMgr.GetById(matchId);

            if (pkMatch == null || pkMatch.HomeId != managerId)
            {
                return(ResponseHelper.InvalidParameter <TourLotteryResponse>());
            }
            var pkInfo = PlayerkillInfoMgr.GetById(managerId);

            if (pkInfo == null || pkInfo.LotteryMatchId != matchId)
            {
                return(ResponseHelper.InvalidParameter <TourLotteryResponse>());
            }
            //var itemBinding = ShareUtil.GetItemBinding(EnumItemPrizeType.PlayerKillPrize, ManagerUtil.GetVipLevel(managerId));

            var itemBinding = true;

            //处理抽奖
            if (pkMatch.Status == -1)
            {
                var package = ItemCore.Instance.GetPackage(managerId, EnumTransactionType.FriendShip);

                var itemDic = CacheFactory.ItemsdicCache.GetItem(pkMatch.PrizeItemCode);
                if (itemDic == null)
                {
                    return(ResponseHelper.InvalidParameter <TourLotteryResponse>());
                }
                MailBuilder       mail = null;
                EquipmentProperty equipmentProperty = null;
                MessageCode       result            = MessageCode.Success;
                var itemCount = 1;
                int point     = 0;
                if (itemDic.ItemType == (int)EnumItemType.Equipment)
                {
                    equipmentProperty = CacheFactory.EquipmentCache.RandomEquipmentProperty(itemDic.LinkId);
                    result            = package.AddEquipment(pkMatch.PrizeItemCode, itemBinding, false, equipmentProperty);
                }
                else if (itemDic.ItemType == (int)EnumItemType.FriendshipPoint)//友情点
                {
                    itemCount = itemDic.FourthType;
                    var manager = ManagerCore.Instance.GetManager(managerId);
                    ManagerCore.Instance.UpdateFriendShipPoint(manager, itemDic.FourthType, EnumActionType.Add);
                }
                else if (itemDic.ItemType == (int)EnumItemType.Point)//钻石
                {
                    itemCount = pkMatch.PrizeItemCount;
                    point     = itemCount;
                    //欧洲杯狂欢
                    ActivityExThread.Instance.EuropeCarnival(5, ref point);
                }
                else
                {
                    result = package.AddItem(pkMatch.PrizeItemCode, itemBinding, false);
                }
                if (result != MessageCode.Success)
                {
                    package = null;
                    mail    = new MailBuilder(managerId, pkMatch.PrizeItemCode, itemBinding, equipmentProperty, pkMatch.AwayName);
                }

                point += 1;//场次获胜额外获得1钻石

                //var code = SaveLottery(pkMatch.Idx, pkMatch.HomeId, package, mail, (int)MessageCode.TourLotteryRepeat);
                var code = SaveLottery(pkMatch.Idx, pkMatch.HomeId, (int)MessageCode.TourLotteryRepeat, package, mail, point);
                if (code == MessageCode.Success)
                {
                    var response = ResponseHelper.CreateSuccess <TourLotteryResponse>();
                    response.Data                   = new TourLotteryEntity();
                    response.Data.ItemCode          = pkMatch.PrizeItemCode;
                    response.Data.EquipmentProperty = equipmentProperty;
                    response.Data.IsBinding         = itemBinding;
                    response.Data.ItemCount         = 1;
                    if (itemDic.ItemType == (int)EnumItemType.Point)  //钻石 友情点
                    {
                        response.Data.ItemCount = point - 1;
                    }
                    else if (itemDic.ItemType == (int)EnumItemType.FriendshipPoint)
                    {
                        response.Data.ItemCount = itemCount;
                    }

                    //奥运金牌掉落
                    response.Data.OlympicTheGoldMedalId = OlympicCore.Instance.GetOlympicTheGoldMedal(
                        managerId, EnumOlympicGeyType.FriendMatch);
                    return(response);
                }
                else
                {
                    return(ResponseHelper.Create <TourLotteryResponse>(code));
                }
            }
            else
            {
                return(ResponseHelper.Create <TourLotteryResponse>(MessageCode.TourLotteryRepeat));
            }
        }