Ejemplo n.º 1
0
        public override bool TakeAction()
        {
            PlayerHeroLogic playerHero = new PlayerHeroLogic();

            playerHero.SetUser(m_UserId).SetHero(m_RequestPacket.HeroType);
            if (!playerHero.DataCheck())
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "wrong HeroId";
                return(false);
            }
            if (playerHero.GetHeroInfo().HeroStarLevel < GameConsts.Hero.MaxStarLevel)
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "Star level not enough";
                return(false);
            }
            Hero myHero = playerHero.GetHeroInfo();
            DTHeroConsciousnessBase heroConsciousness = CacheSet.HeroConsciousnessBaseTable.GetData(myHero.ConsciousnessLevel);

            if (heroConsciousness.LevelUpItemId == -1)
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "reached max level";
                return(false);
            }
            PlayerLogic p = new PlayerLogic();

            p.SetUser(m_UserId);
            if (!p.DeductSpirit(heroConsciousness.LevelUpItemCount))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "Spirit not enough";
                return(false);
            }
            playerHero.ConsciousnessLevelUp();
            myHero = playerHero.GetHeroInfo();
            m_ResponsePacket.LobbyHeroInfo = new PBLobbyHeroInfo()
            {
                Type = myHero.HeroType,
                ConsciousnessLevel = myHero.ConsciousnessLevel,
                Might = myHero.Might,
            };
            m_ResponsePacket.PlayerInfo = new PBPlayerInfo()
            {
                Id = p.MyPlayer.Id, Spirit = p.MyPlayer.Spirit
            };
            return(true);
        }
Ejemplo n.º 2
0
        public override bool TakeAction()
        {
            DTInstanceStory instanceData = CacheSet.InstanceStoryTable.GetData(m_RequestPacket.InstanceId);
            PlayerHeroLogic ph           = new PlayerHeroLogic();

            ph.SetUser(m_UserId).SetHero(instanceData.HeroId);
            if (ph.GetHeroInfo() == null)
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "You can not enter this instance";
                return(false);
            }
            PlayerStoryInstanceLogic ps = new PlayerStoryInstanceLogic();

            ps.SetUser(m_UserId);
            CacheDictionary <int, int> dropItems = new CacheDictionary <int, int>();

            foreach (int dropId in instanceData.DropIds)
            {
                var itemDict = ps.GetDropItems(dropId, m_RequestPacket.StarLevel);
                dropItems = GameUtils.MergeItemDict(dropItems, itemDict) as CacheDictionary <int, int>;
            }
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            PBReceivedItems receivedItems;

            pp.GetItems(dropItems, ReceiveItemMethodType.CompleteInstance, out receivedItems);
            m_ResponsePacket.ReceivedItems = receivedItems;
            m_ResponsePacket.Count         = ps.GetCount();
            m_ResponsePacket.StarLevel     = m_RequestPacket.StarLevel;
            return(true);
        }
Ejemplo n.º 3
0
        public override bool TakeAction()
        {
            PlayerHeroLogic ph = new PlayerHeroLogic();

            ph.SetUser(m_UserId).SetHero(m_RequestPacket.HeroType);
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);

            if (!pp.DeductInventory(new ItemListItem()
            {
                Id = m_RequestPacket.ItemId, Count = 1
            }))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "You have not enough item";
                return(false);
            }
            int exp = int.Parse(CacheSet.ItemTable.GetData(m_RequestPacket.ItemId).FunctionParams);

            ph.AddSkillExp(m_RequestPacket.SkillIndex, exp);
            var hero = ph.GetHeroInfo();

            m_ResponsePacket.HeroInfo = new PBLobbyHeroInfo()
            {
                Type = hero.HeroType
            };
            m_ResponsePacket.HeroInfo.SkillExps.AddRange(hero.SkillExps);
            m_ResponsePacket.ItemInfo = new PBItemInfo()
            {
                Type  = m_RequestPacket.ItemId,
                Count = pp.MyPackage.Inventories[m_RequestPacket.ItemId]
            };
            return(true);
        }
Ejemplo n.º 4
0
        public override bool TakeAction()
        {
            var heroData = CacheSet.HeroTable.GetData(m_RequestPacket.HeroId);
            PlayerPackageLogic package = new PlayerPackageLogic();

            package.SetUser(m_UserId);
            ItemListItem item = new ItemListItem();

            item.Id    = heroData.StarLevelUpItemId;
            item.Count = heroData.StarLevelUpItemCount[0];
            if (!package.DeductInventory(item))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "you have not enough item";
                return(false);
            }
            PlayerHeroLogic ph = new PlayerHeroLogic();

            ph.SetUser(m_UserId);
            ph.AddNewHero(m_RequestPacket.HeroId, ReceiveItemMethodType.HeroPieceCompose);
            var heroInfo = ph.GetHeroInfo();

            m_ResponsePacket.NewHero = new PBLobbyHeroInfo()
            {
                Type               = heroInfo.HeroType,
                Level              = heroInfo.HeroLv,
                ElevationLevel     = heroInfo.ElevationLevel,
                ConsciousnessLevel = heroInfo.ConsciousnessLevel,
                Exp       = heroInfo.HeroExp,
                StarLevel = heroInfo.HeroStarLevel
            };
            return(true);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
        public override bool TakeAction()
        {
            DTHero          heroData   = CacheSet.HeroTable.GetData(m_RequestPacket.HeroType);
            PlayerHeroLogic playerHero = new PlayerHeroLogic();

            playerHero.SetUser(m_UserId).SetHero(m_RequestPacket.HeroType);
            if (!playerHero.DataCheck())
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "wrong HeroId";
                return(false);
            }

            Hero myHero = playerHero.GetHeroInfo();
            PlayerPackageLogic package = new PlayerPackageLogic();

            package.SetUser(m_UserId);
            ItemListItem item = new ItemListItem();

            item.Id    = heroData.StarLevelUpItemId;
            item.Count = heroData.StarLevelUpItemCount[myHero.HeroStarLevel];
            if (!package.DeductInventory(item))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "not enough piece";
                return(false);
            }
            playerHero.StarLevelUp();
            myHero = playerHero.GetHeroInfo();
            m_ResponsePacket.LobbyHeroInfo = new PBLobbyHeroInfo()
            {
                Type      = m_RequestPacket.HeroType,
                StarLevel = myHero.HeroStarLevel,
                Might     = myHero.Might,
            };
            m_ResponsePacket.ItemInfo = new PBItemInfo()
            {
                Type  = item.Id,
                Count = package.MyPackage.Inventories[item.Id]
            };
            return(true);
        }
Ejemplo n.º 8
0
        public override bool TakeAction()
        {
            PlayerFriendsLogic pf = new PlayerFriendsLogic();

            pf.SetUser(m_UserId);
            var               nearbyPlayers = pf.GetOnlinePlayers();
            var               friends       = pf.GetFriends();
            HeroTeamLogic     ht            = new HeroTeamLogic();
            PlayerHeroLogic   ph            = new PlayerHeroLogic();
            NearbyPlayerLogic np            = new NearbyPlayerLogic();

            foreach (var player in nearbyPlayers)
            {
                ht.SetUser(player.Id);
                ph.SetUser(player.Id).SetHero(ht.GetTeam()[0]);
                Hero hero = ph.GetHeroInfo();
                if (hero == null)
                {
                    continue;
                }
                m_ResponsePacket.Heroes.Add(new PBLobbyHeroInfo()
                {
                    Type               = hero.HeroType,
                    Level              = hero.HeroLv,
                    StarLevel          = hero.HeroStarLevel,
                    ConsciousnessLevel = hero.ConsciousnessLevel,
                    ElevationLevel     = hero.ElevationLevel
                });
                np.SetUser(player.Id);
                m_ResponsePacket.Players.Add(new PBPlayerInfo()
                {
                    Id               = player.Id,
                    Name             = player.Name,
                    Level            = player.Level,
                    VipLevel         = player.VIPLevel,
                    PortraitType     = player.PortraitType,
                    LastLoginInTicks = player.LastLoginTime,
                    PositionX        = np.NearbyPlayers.MyPositionX,
                    PositionY        = np.NearbyPlayers.MyPositionY,
                    DisplayId        = player.UUID
                });
                if (friends.ContainsKey(player.Id))
                {
                    m_ResponsePacket.IsMyFriend.Add(true);
                }
                else
                {
                    m_ResponsePacket.IsMyFriend.Add(false);
                }
            }
            return(true);
        }
Ejemplo n.º 9
0
        public override bool TakeAction()
        {
            PlayerHeroLogic ph = new PlayerHeroLogic();

            ph.SetUser(m_UserId).SetHero(m_RequestPacket.HeroId);
            foreach (var iteminfo in m_RequestPacket.Items)
            {
                ItemListItem item = new ItemListItem()
                {
                    Id    = iteminfo.Type,
                    Count = iteminfo.Count
                };
                DTItem             itemData = CacheSet.ItemTable.GetData(item.Id);
                PlayerPackageLogic pp       = new PlayerPackageLogic();
                pp.SetUser(m_UserId);
                if (!pp.DeductInventory(item))
                {
                    ErrorCode = (int)ErrorType.RequireNotMet;
                    ErrorInfo = "You have not enough item";
                    return(false);
                }

                switch ((ItemFunctions)itemData.FunctionId)
                {
                case ItemFunctions.AddHeroExp:
                    ph.AddExp(int.Parse(itemData.FunctionParams) * item.Count);
                    var heroInfo = ph.GetHeroInfo();
                    m_ResponsePacket.HeroInfo = new PBLobbyHeroInfo()
                    {
                        Type  = heroInfo.HeroType,
                        Level = heroInfo.HeroLv,
                        Exp   = heroInfo.HeroExp,
                        Might = heroInfo.Might,
                    };
                    break;

                case ItemFunctions.HeroPiece:
                    AddSpirit(item.Count);
                    break;

                default:
                    break;
                }
                m_ResponsePacket.ItemInfo.Add(new PBItemInfo()
                {
                    Type  = item.Id,
                    Count = pp.MyPackage.Inventories[item.Id]
                });
            }
            return(true);
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
0
        public override bool TakeAction()
        {
            var          heroData    = CacheSet.HeroTable.GetData(m_RequestPacket.HeroType);
            ItemListItem composeItem = new ItemListItem()
            {
                Id    = heroData.StarLevelUpItemId,
                Count = GameConfigs.GetInt("Pieces_Per_Hero", 10)
            };
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            if (!pp.DeductInventory(composeItem))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "You have not enough pieces";
                return(false);
            }
            PlayerHeroLogic ph = new PlayerHeroLogic();

            ph.SetUser(m_UserId);
            if (ph.AddNewHero(m_RequestPacket.HeroType, ReceiveItemMethodType.HeroPieceCompose) != null)
            {
                ErrorCode = (int)ErrorType.CannotOpenChance;
                ErrorInfo = "You have already got this hero";
                return(false);
            }
            m_ResponsePacket.HeroPieceItem = new PBItemInfo()
            {
                Type  = composeItem.Id,
                Count = pp.MyPackage.Inventories[composeItem.Id]
            };
            Hero newHero = ph.GetHeroInfo();

            m_ResponsePacket.NewHero = new PBLobbyHeroInfo()
            {
                Type               = m_RequestPacket.HeroType,
                Level              = newHero.HeroLv,
                Exp                = newHero.HeroExp,
                ElevationLevel     = newHero.ElevationLevel,
                ConsciousnessLevel = newHero.ConsciousnessLevel,
                StarLevel          = newHero.HeroStarLevel
            };
            m_ResponsePacket.NewHero.SkillLevels.AddRange(newHero.SkillLevels);
            return(true);
        }
Ejemplo n.º 12
0
        public override bool TakeAction()
        {
            PlayerHeroLogic ph = new PlayerHeroLogic();

            ph.SetUser(m_UserId).SetHero(m_RequestPacket.HeroType);
            Hero           hero       = ph.GetHeroInfo();
            int            skillLevel = hero.SkillLevels[m_RequestPacket.SkillIndex];
            DTSkillLevelUp skillData  = CacheSet.SkillLevelUpTable.GetData(h => (h.HeroType == m_RequestPacket.HeroType && h.SkillIndex == m_RequestPacket.SkillIndex && h.SkillLevel == skillLevel));
            PlayerLogic    p          = new PlayerLogic();

            p.SetUser(m_UserId);
            if (hero.HeroLv < skillData.RequiresHeroLevel || hero.HeroStarLevel < skillData.RequiresHeroStarLevel)
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "require not met";
                return(false);
            }
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            if (!p.DeductCoin(skillData.CoinCost))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "You do not have enough coin";
                return(false);
            }
            if (!ph.SkillLevelUp(m_RequestPacket.SkillIndex, skillData.CostEXP))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "You do not have enough exp";
                return(false);
            }

            m_ResponsePacket.HeroInfo = new PBLobbyHeroInfo()
            {
                Type = hero.HeroType,
            };
            m_ResponsePacket.HeroInfo.SkillLevels.AddRange(hero.SkillLevels);
            m_ResponsePacket.HeroInfo.SkillExps.AddRange(hero.SkillExps);
            return(true);
        }
Ejemplo n.º 13
0
        public override bool TakeAction()
        {
            PlayerChessLogic playerChess = new PlayerChessLogic();

            playerChess.SetUser(m_UserId);
            PlayerHeroLogic playerHero = new PlayerHeroLogic();

            playerHero.SetUser(m_UserId);
            foreach (int heroId in m_RequestPacket.HeroTeamInfo.HeroType)
            {
                playerHero.SetHero(heroId);
                if (playerHero.GetHeroInfo() == null)
                {
                    ErrorCode = (int)ErrorType.CannotOpenChance;
                    ErrorInfo = "wrong heroId";
                    return(false);
                }
            }
            playerChess.ChangeTeam(m_RequestPacket.HeroTeamInfo.HeroType);
            m_ResponsePacket.HeroTeamInfo = new PBHeroTeamInfo();
            m_ResponsePacket.HeroTeamInfo.HeroType.AddRange(m_RequestPacket.HeroTeamInfo.HeroType);
            return(true);
        }
Ejemplo n.º 14
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);
        }
Ejemplo n.º 15
0
        public override bool TakeAction()
        {
            if (m_RequestPacket.TakeOffGearId == 0 && m_RequestPacket.PutOnGearId == 0)
            {
                ErrorCode = (int)ErrorType.CannotOpenChance;
                ErrorInfo = "invalid param";
                return(false);
            }
            PlayerPackageLogic package = new PlayerPackageLogic();

            package.SetUser(m_UserId);
            GearLogic       gear       = new GearLogic();
            PlayerHeroLogic playerHero = new PlayerHeroLogic();

            playerHero.SetUser(m_UserId);
            GearType position;

            if (m_RequestPacket.PutOnGearId == 0)
            {
                playerHero.SetHero(m_RequestPacket.TakeOffHeroId);
                gear.SetGear(m_RequestPacket.TakeOffGearId);
                DTGear geardata = CacheSet.GearTable.GetData(gear.MyGear.TypeId);
                position = (GearType)geardata.Type;
                if (playerHero.GetHeroInfo().Gears[position] != m_RequestPacket.TakeOffGearId)
                {
                    ErrorCode = (int)ErrorType.CannotOpenChance;
                    ErrorInfo = "wrong take off gear ID";
                    return(false);
                }
                package.AddGear(m_RequestPacket.TakeOffGearId, gear.MyGear.TypeId);
            }
            else if (m_RequestPacket.TakeOffGearId == 0)
            {
                playerHero.SetHero(m_RequestPacket.PutOnHeroId);
                gear.SetGear(m_RequestPacket.PutOnGearId);
                DTGear geardata = CacheSet.GearTable.GetData(gear.MyGear.TypeId);
                position = (GearType)geardata.Type;
                if (m_RequestPacket.TakeOffHeroId == 0)
                {
                    if (!package.MyPackage.Gears.ContainsKey(m_RequestPacket.PutOnGearId))
                    {
                        ErrorCode = (int)ErrorType.CannotOpenChance;
                        ErrorInfo = "wrong put on gear ID";
                        return(false);
                    }
                    package.DeductGear(m_RequestPacket.PutOnGearId);
                }
                else
                {
                    if (playerHero.MyHeros.Heros[m_RequestPacket.TakeOffHeroId].Gears[position] != m_RequestPacket.PutOnGearId)
                    {
                        ErrorCode = (int)ErrorType.CannotOpenChance;
                        ErrorInfo = "wrong put on gear ID";
                        return(false);
                    }
                    playerHero.SetHero(m_RequestPacket.TakeOffHeroId);
                    playerHero.WearGear(position, 0);
                    playerHero.SetHero(m_RequestPacket.PutOnHeroId);
                }
            }
            else
            {
                playerHero.SetHero(m_RequestPacket.PutOnHeroId);
                gear.SetGear(m_RequestPacket.PutOnGearId);
                DTGear geardata = CacheSet.GearTable.GetData(gear.MyGear.TypeId);
                position = (GearType)geardata.Type;
                if (m_RequestPacket.TakeOffHeroId == 0)
                {
                    if (!package.MyPackage.Gears.ContainsKey(m_RequestPacket.PutOnGearId))
                    {
                        ErrorCode = (int)ErrorType.CannotOpenChance;
                        ErrorInfo = "wrong put on gear ID";
                        return(false);
                    }
                    if (playerHero.MyHeros.Heros[m_RequestPacket.PutOnHeroId].Gears[position] != m_RequestPacket.TakeOffGearId)
                    {
                        ErrorCode = (int)ErrorType.CannotOpenChance;
                        ErrorInfo = "wrong take off gear ID";
                        return(false);
                    }
                    package.DeductGear(m_RequestPacket.PutOnGearId);
                }
                else
                {
                    if (playerHero.MyHeros.Heros[m_RequestPacket.TakeOffHeroId].Gears[position] != m_RequestPacket.PutOnGearId)
                    {
                        ErrorCode = (int)ErrorType.CannotOpenChance;
                        ErrorInfo = "wrong put on gear ID";
                        return(false);
                    }
                    if (playerHero.MyHeros.Heros[m_RequestPacket.PutOnHeroId].Gears[position] != m_RequestPacket.TakeOffGearId)
                    {
                        ErrorCode = (int)ErrorType.CannotOpenChance;
                        ErrorInfo = "wrong take off gear ID";
                        return(false);
                    }
                    playerHero.SetHero(m_RequestPacket.TakeOffHeroId);
                    playerHero.WearGear(position, 0);
                    playerHero.SetHero(m_RequestPacket.PutOnHeroId);
                }
                package.AddGear(m_RequestPacket.TakeOffGearId, gear.MyGear.TypeId);
            }
            playerHero.WearGear(position, m_RequestPacket.PutOnGearId);
            m_ResponsePacket.PutOnGearId   = m_RequestPacket.PutOnGearId;
            m_ResponsePacket.TakeOffGearId = m_RequestPacket.TakeOffGearId;
            if (m_RequestPacket.PutOnHeroId > 0)
            {
                m_ResponsePacket.PutOnHeroInfo = new PBLobbyHeroInfo()
                {
                    Type  = m_RequestPacket.PutOnHeroId,
                    Might = playerHero.SetHero(m_RequestPacket.PutOnHeroId).GetHeroInfo().Might
                };
            }
            if (m_RequestPacket.TakeOffHeroId > 0)
            {
                m_ResponsePacket.TakeOffHeroInfo = new PBLobbyHeroInfo()
                {
                    Type  = m_RequestPacket.TakeOffHeroId,
                    Might = playerHero.SetHero(m_RequestPacket.TakeOffHeroId).GetHeroInfo().Might
                };
            }
            return(true);
        }
Ejemplo n.º 16
0
        public override bool TakeAction()
        {
            PlayerLogic p = new PlayerLogic();

            p.SetUser(m_RequestPacket.EnemyPlayerId);
            ArenaRankLogic ar = new ArenaRankLogic();

            m_ResponsePacket.EnemyInfo            = new PBArenaPlayerAndTeamInfo();
            m_ResponsePacket.EnemyInfo.PlayerInfo = new PBPlayerInfo()
            {
                Id           = p.MyPlayer.Id,
                Name         = p.MyPlayer.Name,
                PortraitType = p.MyPlayer.PortraitType,
                Level        = p.MyPlayer.Level,
            };
            m_ResponsePacket.EnemyInfo.Rank = ar.GetPlayerRank(m_RequestPacket.EnemyPlayerId);
            PlayerHeroLogic ph = new PlayerHeroLogic();

            ph.SetUser(m_RequestPacket.EnemyPlayerId);
            HeroTeamLogic ht = new HeroTeamLogic();

            ht.SetUser(m_RequestPacket.EnemyPlayerId);
            GearLogic gear = new GearLogic();
            SoulLogic soul = new SoulLogic();

            foreach (int heroId in ht.GetTeam())
            {
                if (heroId == 0)
                {
                    continue;
                }
                ph.SetHero(heroId);
                Hero            heroInfo = ph.GetHeroInfo();
                PBLobbyHeroInfo pbhero   = new PBLobbyHeroInfo()
                {
                    Type  = heroInfo.HeroType,
                    Level = heroInfo.HeroLv,
                    ConsciousnessLevel = heroInfo.ConsciousnessLevel,
                    ElevationLevel     = heroInfo.ElevationLevel,
                    StarLevel          = heroInfo.HeroStarLevel,
                };
                pbhero.SkillLevels.AddRange(heroInfo.SkillLevels);
                foreach (var equipedGear in heroInfo.Gears)
                {
                    gear.SetGear(equipedGear.Value);
                    PBGearInfo heroGear = new PBGearInfo()
                    {
                        Id              = gear.MyGear.Id,
                        Type            = gear.MyGear.TypeId,
                        Level           = gear.MyGear.Level,
                        StrengthenLevel = gear.MyGear.StrengthenLevel
                    };
                    pbhero.GearInfo.Add(heroGear);
                }
                foreach (var equipedSoul in heroInfo.Souls)
                {
                    soul.SetSoul(equipedSoul.Value);
                    PBSoulInfo heroSoul = new PBSoulInfo()
                    {
                        Id   = soul.MySoul.Id,
                        Type = soul.MySoul.TypeId
                    };
                    pbhero.SoulInfo.Add(heroSoul);
                }
                m_ResponsePacket.EnemyInfo.HeroTeam.Add(pbhero);
            }
            return(true);
        }
Ejemplo n.º 17
0
        public override bool TakeAction()
        {
            PlayerHeroLogic playerHero = new PlayerHeroLogic();

            playerHero.SetUser(m_UserId).SetHero(m_RequestPacket.HeroType);
            if (!playerHero.DataCheck())
            {
                ErrorCode = (int)ErrorType.CannotOpenChance;
                ErrorInfo = "wrong HeroId";
                return(false);
            }

            PlayerPackageLogic package = new PlayerPackageLogic();

            package.SetUser(m_UserId);
            Hero myHero = playerHero.GetHeroInfo();
            DTHeroElevationBase heroElevationData = CacheSet.HeroElevationBaseTable.GetData(myHero.ElevationLevel);

            if (heroElevationData.LevelUpItemId == -1)
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "reached max level";
                return(false);
            }

            ItemListItem item = new ItemListItem()
            {
                Id    = heroElevationData.LevelUpItemId,
                Count = heroElevationData.LevelUpItemCount
            };

            if (!package.DeductInventory(item))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "not enough piece";
                return(false);
            }
            for (int i = 0; i < GameConsts.Hero.ElevationLevelUpGearCount; i++)
            {
                if (heroElevationData.LevelUpGearType[i] == -1 || heroElevationData.LevelUpGearMinQuality[i] == -1)
                {
                    break;
                }
                int gearTypeId = 0;
                if (package.MyPackage.Gears.ContainsKey(m_RequestPacket.GearId[i]))
                {
                    gearTypeId = package.MyPackage.Gears[m_RequestPacket.GearId[i]];
                }
                else
                {
                    ErrorCode = (int)ErrorType.RequireNotMet;
                    ErrorInfo = "do not have this gear";
                    return(false);
                }
                DTGear gear = CacheSet.GearTable.GetData(gearTypeId);
                if (gear.Type == heroElevationData.LevelUpGearType[i] && gear.Quality >= heroElevationData.LevelUpGearMinQuality[i])
                {
                    package.DeductGear(m_RequestPacket.GearId[i]);
                }
                else
                {
                    ErrorCode = (int)ErrorType.CannotOpenChance;
                    ErrorInfo = "gear" + i.ToString() + " do not match this slot";
                    return(false);
                }
            }
            playerHero.ElevationLevelUp();
            var heroInfo = playerHero.GetHeroInfo();

            m_ResponsePacket.LobbyHeroInfo = new PBLobbyHeroInfo()
            {
                Type           = heroInfo.HeroType,
                ElevationLevel = heroInfo.ElevationLevel,
                Might          = heroInfo.Might,
            };
            m_ResponsePacket.RemovedGears.AddRange(m_RequestPacket.GearId);
            m_ResponsePacket.ItemInfo = new PBItemInfo()
            {
                Type = item.Id, Count = package.MyPackage.Inventories[item.Id]
            };
            return(true);
        }
Ejemplo n.º 18
0
        private static PBRoomPlayerInfo GetPlayerRoomData(int playerId)
        {
            PBRoomPlayerInfo retData = new PBRoomPlayerInfo();
            PlayerLogic      p       = new PlayerLogic();

            p.SetUser(playerId);
            retData.PlayerInfo = new PBPlayerInfo()
            {
                Id           = playerId,
                Name         = p.MyPlayer.Name,
                Level        = p.MyPlayer.Level,
                VipLevel     = p.MyPlayer.VIPLevel,
                PortraitType = p.MyPlayer.PortraitType,
                Might        = p.MyPlayer.Might,
            };
            HeroTeamLogic heroTeam = new HeroTeamLogic();

            heroTeam.SetUser(playerId);
            CacheList <int> team = heroTeam.GetTeam();
            PlayerHeroLogic ph   = new PlayerHeroLogic().SetUser(playerId);

            foreach (int heroType in team)
            {
                if (heroType == 0)
                {
                    continue;
                }
                ph.SetHero(heroType);
                var             heroInfo      = ph.GetHeroInfo();
                PBLobbyHeroInfo lobbyHeroInfo = new PBLobbyHeroInfo();
                lobbyHeroInfo.Type               = heroInfo.HeroType;
                lobbyHeroInfo.Level              = heroInfo.HeroLv;
                lobbyHeroInfo.Exp                = heroInfo.HeroExp;
                lobbyHeroInfo.StarLevel          = heroInfo.HeroStarLevel;
                lobbyHeroInfo.ConsciousnessLevel = heroInfo.ConsciousnessLevel;
                lobbyHeroInfo.ElevationLevel     = heroInfo.ElevationLevel;
                lobbyHeroInfo.SkillLevels.AddRange(heroInfo.SkillLevels);
                foreach (var gear in heroInfo.Gears)
                {
                    if (gear.Value == 0)
                    {
                        continue;
                    }
                    PBGearInfo gearInfo = new PBGearInfo();
                    gearInfo.Id = gear.Value;
                    Gears gearData = CacheSet.GearCache.FindKey(gear.Value);
                    gearInfo.Level           = gearData.Level;
                    gearInfo.Type            = gearData.TypeId;
                    gearInfo.StrengthenLevel = gearData.StrengthenLevel;
                    lobbyHeroInfo.GearInfo.Add(gearInfo);
                }
                foreach (var soul in heroInfo.Souls)
                {
                    if (soul.Value == 0)
                    {
                        continue;
                    }
                    PBSoulInfo soulInfo = new PBSoulInfo();
                    soulInfo.Id = soul.Value;
                    Souls soulData = CacheSet.SoulCache.FindKey(soul.Value);
                    soulInfo.Type = soulData.TypeId;
                    lobbyHeroInfo.SoulInfo.Add(soulInfo);
                }
                PBRoomHeroInfo roomHeroInfo = new PBRoomHeroInfo()
                {
                    LobbyHeroInfo = lobbyHeroInfo,
                };
                retData.RoomHeroInfo.Add(roomHeroInfo);
            }
            retData.LobbyServerId = int.Parse(ConfigUtils.GetSetting("Server.Id"));
            PlayerSinglePvpLogic psp = new PlayerSinglePvpLogic();

            psp.SetUser(playerId);
            retData.Score = psp.MyPvp.SinglePvpScore;
            return(retData);
        }
Ejemplo n.º 19
0
        public override bool TakeAction()
        {
            IList <int> heroes;

            if (m_RequestPacket.HeroTypes.Count == 0)
            {
                HeroTeamLogic ht = new HeroTeamLogic();
                ht.SetUser(m_UserId);
                heroes = ht.GetTeam();
            }
            else
            {
                heroes = m_RequestPacket.HeroTypes;
            }
            PlayerHeroLogic ph = new PlayerHeroLogic();

            ph.SetUser(m_RequestPacket.PlayerId);
            GearLogic gear = new GearLogic();
            SoulLogic soul = new SoulLogic();

            foreach (int heroId in heroes)
            {
                if (heroId == 0)
                {
                    continue;
                }
                ph.SetHero(heroId);
                Hero            heroInfo = ph.GetHeroInfo();
                PBLobbyHeroInfo pbhero   = new PBLobbyHeroInfo()
                {
                    Type  = heroInfo.HeroType,
                    Level = heroInfo.HeroLv,
                    ConsciousnessLevel = heroInfo.ConsciousnessLevel,
                    ElevationLevel     = heroInfo.ElevationLevel,
                    StarLevel          = heroInfo.HeroStarLevel,
                };
                foreach (var equipedGear in heroInfo.Gears)
                {
                    gear.SetGear(equipedGear.Value);
                    PBGearInfo heroGear = new PBGearInfo()
                    {
                        Id              = gear.MyGear.Id,
                        Type            = gear.MyGear.TypeId,
                        Level           = gear.MyGear.Level,
                        StrengthenLevel = gear.MyGear.StrengthenLevel
                    };
                    pbhero.GearInfo.Add(heroGear);
                }
                foreach (var equipedSoul in heroInfo.Souls)
                {
                    soul.SetSoul(equipedSoul.Value);
                    PBSoulInfo heroSoul = new PBSoulInfo()
                    {
                        Id   = soul.MySoul.Id,
                        Type = soul.MySoul.TypeId
                    };
                    pbhero.SoulInfo.Add(heroSoul);
                }
                m_ResponsePacket.Heroes.Add(pbhero);
            }
            m_ResponsePacket.PlayerId = m_RequestPacket.PlayerId;
            return(true);
        }