Esempio n. 1
0
        public override bool TakeAction()
        {
            // TODO: Add code here.
            GearLogic gearlogic = new GearLogic();

            gearlogic.SetGear(m_RequestPacket.GearId);
            PlayerLogic player = new PlayerLogic();

            player.SetUser(m_UserId);
            if (gearlogic.MyGear.Level >= player.MyPlayer.Level)
            {
                ErrorCode = (int)ErrorType.CannotOpenChance;
                ErrorInfo = "Can not upgrade,gear reached max level.";
                return(false);
            }
            int targetLevel;

            if (m_RequestPacket.IsUpToMax)
            {
                targetLevel = player.MyPlayer.Level;
            }
            else
            {
                targetLevel = gearlogic.MyGear.Level + 1;
            }
            int totalcost = gearlogic.GetLevelUpCost(targetLevel);

            if (!player.DeductCoin(totalcost))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "Can not upgrade, coin not enough.";
                return(false);
            }
            gearlogic.GearLevelUp(targetLevel, m_UserId);
            if (m_RequestPacket.HeroType > 0)
            {
                PlayerHeroLogic ph = new PlayerHeroLogic();
                ph.SetUser(m_UserId).SetHero(m_RequestPacket.HeroType);
                ph.RefreshMight();
                var heroInfo = ph.GetHeroInfo();
                m_ResponsePacket.HeroInfo = new PBLobbyHeroInfo()
                {
                    Type  = heroInfo.HeroType,
                    Might = heroInfo.Might
                };
            }
            m_ResponsePacket.LevelUpedGear = new PBGearInfo()
            {
                Id    = m_RequestPacket.GearId,
                Level = gearlogic.MyGear.Level
            };
            m_ResponsePacket.PlayerInfo = new PBPlayerInfo()
            {
                Id   = m_UserId,
                Coin = player.MyPlayer.Coin
            };
            return(true);
        }
Esempio n. 2
0
        public override bool TakeAction()
        {
            GearLogic gear = new GearLogic();

            gear.SetGear(m_RequestPacket.GearId);
            int materialId             = CacheSet.GearTable.GetData(gear.MyGear.TypeId).StrengthenItemId;
            PlayerPackageLogic package = new PlayerPackageLogic();

            package.SetUser(m_UserId);
            if (!package.DeductInventory(new ItemListItem()
            {
                Id = materialId, Count = 1
            }))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "Not enough material";
                return(false);
            }
            if (!gear.Strengthen(m_UserId))
            {
                m_ResponsePacket.ItemInfo = new PBItemInfo()
                {
                    Type  = materialId,
                    Count = package.MyPackage.Inventories[materialId]
                };
                m_ResponsePacket.LevelUpedGear = null;
                m_ResponsePacket.HeroInfo      = null;
                return(true);
            }

            if (m_RequestPacket.HeroType > 0)
            {
                PlayerHeroLogic ph = new PlayerHeroLogic();
                ph.SetUser(m_UserId).SetHero(m_RequestPacket.HeroType);
                ph.RefreshMight();
                var heroInfo = ph.GetHeroInfo();
                m_ResponsePacket.HeroInfo = new PBLobbyHeroInfo()
                {
                    Type  = heroInfo.HeroType,
                    Might = heroInfo.Might
                };
            }
            m_ResponsePacket.ItemInfo = new PBItemInfo()
            {
                Type  = materialId,
                Count = package.MyPackage.Inventories[materialId]
            };
            m_ResponsePacket.LevelUpedGear = new PBGearInfo()
            {
                Id              = m_RequestPacket.GearId,
                Type            = gear.MyGear.TypeId,
                Level           = gear.MyGear.Level,
                StrengthenLevel = gear.MyGear.StrengthenLevel
            };
            return(true);
        }
Esempio n. 3
0
        public override bool TakeAction()
        {
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            SoulLogic soul = new SoulLogic();

            soul.SetSoul(m_RequestPacket.Id);
            int type     = soul.MySoul.TypeId;
            var soulData = CacheSet.SoulTable.GetData(type);

            if (soulData.UpgradedId == -1)
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "This soul can not be upgraded";
                return(false);
            }
            ItemListItem cost = new ItemListItem();

            cost.Id    = soulData.StrengthenItemId;
            cost.Count = soulData.StrengthenItemCount;
            if (!pp.DeductInventory(cost))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "Not enough item";
                return(false);
            }
            soul.Upgrade(soulData.UpgradedId, pp);
            if (m_RequestPacket.HeroType > 0)
            {
                PlayerHeroLogic ph = new PlayerHeroLogic();
                ph.SetUser(m_UserId).SetHero(m_RequestPacket.HeroType);
                ph.RefreshMight();
                m_ResponsePacket.HeroInfo = new PBLobbyHeroInfo()
                {
                    Type  = m_RequestPacket.HeroType,
                    Might = ph.GetHeroInfo().Might
                };
            }
            m_ResponsePacket.SoulInfo = new PBSoulInfo()
            {
                Id   = soul.MySoul.Id,
                Type = soul.MySoul.TypeId
            };
            m_ResponsePacket.ItemInfo = new PBItemInfo()
            {
                Type  = cost.Id,
                Count = pp.MyPackage.Inventories[cost.Id]
            };
            return(true);
        }
Esempio n. 4
0
        public override bool TakeAction()
        {
            PlayerHeroLogic hero = new PlayerHeroLogic();

            hero.SetUser(m_UserId).SetHero(m_RequestPacket.HeroId);
            SoulLogic          soul    = new SoulLogic();
            PlayerPackageLogic package = new PlayerPackageLogic();

            package.SetUser(m_UserId);
            if (m_RequestPacket.HasPutOnSoulId)
            {
                soul.SetSoul(m_RequestPacket.PutOnSoulId);
                if (soul.MySoul == null)
                {
                    ErrorCode = (int)ErrorType.CannotOpenChance;
                    ErrorInfo = "wrong soulID";
                    return(false);
                }
                int eid = CacheSet.SoulTable.GetData(soul.MySoul.TypeId).Type;
                if (!package.DeductSoul(m_RequestPacket.PutOnSoulId))
                {
                    ErrorCode = (int)ErrorType.RequireNotMet;
                    ErrorInfo = "wrong soulID";
                    return(false);
                }
                if (!hero.DressSoul(eid, m_RequestPacket.PutOnSoulId))
                {
                    ErrorCode = (int)ErrorType.CannotOpenChance;
                    ErrorInfo = "wrong soulID";
                    return(false);
                }
                m_ResponsePacket.PutOnSoulId = m_RequestPacket.PutOnSoulId;
                m_ResponsePacket.HeroId      = m_RequestPacket.HeroId;
            }
            else if (m_RequestPacket.HasTakeOffSoulId)
            {
                soul.SetSoul(m_RequestPacket.TakeOffSoulId);
                if (soul.MySoul == null)
                {
                    ErrorCode = (int)ErrorType.CannotOpenChance;
                    ErrorInfo = "wrong soulID";
                    return(false);
                }
                int eid = CacheSet.SoulTable.GetData(soul.MySoul.TypeId).Type;
                if (!hero.UndressSoul(eid, m_RequestPacket.TakeOffSoulId))
                {
                    ErrorCode = (int)ErrorType.CannotOpenChance;
                    ErrorInfo = "wrong soulID";
                    return(false);
                }
                package.AddSoul(m_RequestPacket.TakeOffSoulId, soul.MySoul.TypeId);
                m_ResponsePacket.HeroId        = m_RequestPacket.HeroId;
                m_ResponsePacket.TakeOffSoulId = m_RequestPacket.TakeOffSoulId;
            }
            else
            {
                //TODO
            }
            if (m_RequestPacket.HeroId > 0)
            {
                hero.RefreshMight();
                var heroInfo = hero.GetHeroInfo();
                m_ResponsePacket.HeroInfo = new PBLobbyHeroInfo()
                {
                    Type  = heroInfo.HeroType,
                    Might = heroInfo.Might,
                };
            }
            return(true);
        }