Example #1
0
        /// <summary>
        /// 加精铸属性
        /// </summary>
        /// <param name="equipmentProperty"></param>
        /// <param name="quality"></param>
        /// <returns></returns>
        public PrecisionCastingPropertyEntity AddPrecisionCastingProperty(EquipmentProperty equipmentProperty, int quality, bool isActivity = false)
        {
            PrecisionCastingPropertyEntity plus = null;

            //限制
            for (int i = 0; i < 10; i++)
            {
                plus = RandomPrecisionCastingProperty(quality, isActivity);
                if (plus.PropertyQuality == 4)
                {
                    if (!CheckProperty(equipmentProperty, plus))
                    {
                        return(plus);
                    }
                }
                else
                {
                    if (!HaveSameProperty(equipmentProperty, plus))
                    {
                        return(plus);
                    }
                }
            }
            return(plus);
        }
Example #2
0
        bool CheckProperty(EquipmentProperty equipmentProperty, PrecisionCastingPropertyEntity plus)
        {
            if (IsHadOrangeProperty(equipmentProperty))
            {
                return(true);
            }

            if (HaveSameProperty(equipmentProperty, plus))
            {
                return(true);
            }
            return(false);
        }
Example #3
0
 public bool AddAttachment(int count, int itemCode, bool isBinding, EquipmentProperty property)
 {
     if (_mail.MailAttachment == null)
     {
         _mail.MailAttachment = new MailAttachmentEntity();
     }
     if (itemCode == 0)
     {
         return(false);
     }
     _mail.MailAttachment.AddAttachmentEquipment(count, itemCode, isBinding, property);
     _mail.HasAttach = true;
     return(true);
 }
Example #4
0
        /// <summary>
        /// 友谊背包满了
        /// </summary>
        /// <param name="managerId"></param>
        /// <param name="itemInfo"></param>
        /// <param name="awayName"></param>
        public MailBuilder(Guid managerId, int itemCode, bool isBinding, EquipmentProperty equipmentProperty, string awayName, int itemCount = 1)
            : this()
        {
            //H(主队比分)|A(客队比分)|N(对手名)|AM(比赛id)|AW(胜负类型)
            string content = string.Format("N,{0}", awayName);

            if (equipmentProperty != null)
            {
                AddAttachment(itemCount, itemCode, isBinding, equipmentProperty);
            }
            else
            {
                AddAttachment(itemCount, itemCode, isBinding, 1);
            }
            Builder(managerId, EnumMailType.TourPrize, content);
        }
Example #5
0
        void WriteEquipmentProperty(BinaryWriter writer, EquipmentProperty property)
        {
            ByteWriter.WriteTo(writer, property != null);
            if (property == null)
            {
                return;
            }
            int num1 = (property.PropertyPluses == null) ? 0 : property.PropertyPluses.Count;

            ByteWriter.WriteTo(writer, num1);
            if (num1 > 0)
            {
                for (int i = 0; i < property.PropertyPluses.Count; i++)
                {
                    WriteEquipmentPropertyPlus(writer, property.PropertyPluses[i]);
                }
            }
        }
Example #6
0
        EquipmentProperty RandomProperty(int equipmentId, out ConfigEquipmentplusEntity plusEntity, int level = 0)
        {
            var equipEntity = GetEquipment(equipmentId);

            if (equipEntity == null)
            {
                throw new CacheException("can't find equip,id:" + equipmentId);
            }
            plusEntity = GetEquipmentPlus(equipEntity.Quality);
            if (plusEntity == null)
            {
                throw new CacheException("can't find equip plus,quality:" + equipEntity.Quality);
            }
            var itemProperty = new EquipmentProperty();

            itemProperty.PropertyPluses = new List <PropertyPlusEntity>(2);
            var plus1 = new PropertyPlusEntity(EnumPlusType.Abs, equipEntity.PropertyType1, RandomPlus1(plusEntity));

            itemProperty.PropertyPluses.Add(plus1);
            var plus2 = new PropertyPlusEntity(EnumPlusType.Percent, equipEntity.PropertyType2, RandomPlus2(plusEntity));

            itemProperty.PropertyPluses.Add(plus2);

            if (level > 0)
            {
                var upgradeEntity = PandoraCache.Instance.GetEquipmentUpgradeEntityByTarget(equipEntity.Quality, level);
                if (upgradeEntity != null)
                {
                    itemProperty.PrecisionCastingPropertis =
                        new List <PrecisionCastingPropertyEntity>(upgradeEntity.PropertyNum);

                    for (int i = 0; i < upgradeEntity.PropertyNum; i++)
                    {
                        var plus = AddPrecisionCastingProperty(itemProperty, equipEntity.Quality);
                        if (plus != null)
                        {
                            itemProperty.PrecisionCastingPropertis.Add(plus);
                        }
                    }
                }
            }
            return(itemProperty);
        }
Example #7
0
        EquipmentProperty ReadEquipmentProperty(byte[] buffer, ref int offset)
        {
            EquipmentProperty property = null;
            var flag = ByteReader.ReadBoolean(buffer, ref offset);

            if (flag)
            {
                property = new EquipmentProperty();
                int num1 = ByteReader.ReadInt32(buffer, ref offset);
                if (num1 > 0)
                {
                    for (int i = 0; i < num1; i++)
                    {
                        var plus = ReadEquipmentPropertyPlus(buffer, ref offset);
                        property.PropertyPluses.Add(plus);
                    }
                }
            }
            return(property);
        }
Example #8
0
 //检查是否有相同的属性存在
 bool HaveSameProperty(EquipmentProperty equipmentProperty, PrecisionCastingPropertyEntity entity)
 {
     return(equipmentProperty.PrecisionCastingPropertis.Exists(d => d.PropertyId == entity.PropertyId));
 }
Example #9
0
 //检查是否已经有橙色的属性存在
 bool IsHadOrangeProperty(EquipmentProperty equipmentProperty)
 {
     return(equipmentProperty.PrecisionCastingPropertis.Exists(d => d.PropertyQuality == 4));
 }
Example #10
0
        private static void Sort(List <EquipmentViewModel> viewModels, SortOption sortOption, EquipmentProperty property)
        {
            switch (property)
            {
            case EquipmentProperty.SerialNumber:
                viewModels.Sort((x, y) => string.Compare(x.SerialNumber, y.SerialNumber, StringComparison.OrdinalIgnoreCase));
                break;

            case EquipmentProperty.Power:
                viewModels.Sort((x, y) =>
                {
                    var cmp = x.Model.Power.CompareTo(y.Model.Power);
                    if (cmp == 0)
                    {
                        cmp = x.Model.Id.CompareTo(y.Model.Id);
                    }
                    return(cmp);
                });
                break;

            case EquipmentProperty.LastChecked:
                viewModels.Sort((x, y) =>
                {
                    var cmp = (x.Model.LastChecked ?? DateTime.MinValue).CompareTo((y.Model.LastChecked ?? DateTime.MinValue));
                    if (cmp == 0)
                    {
                        cmp = x.Model.Id.CompareTo(y.Model.Id);
                    }
                    return(cmp);
                });
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if ((sortOption.SortDirection ?? SortDirection.Asc) == SortDirection.Desc)
            {
                viewModels.Reverse();
            }
        }
Example #11
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));
            }
        }