Example #1
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);
        }
Example #2
0
 public static void InitRankList()
 {
     if (CacheSet.ArenaRankCache.FindAll().Count == 0)
     {
         PlayerLogic   player = new PlayerLogic();
         HeroTeamLogic ht     = new HeroTeamLogic();
         for (int i = 0; i < GameConsts.Arena.RobotCount; i++)
         {
             player.AddRobot();
             PlayerHeroLogic ph = new PlayerHeroLogic();
             ph.SetUser(player.MyPlayer.Id);
             ht.SetUser(player.MyPlayer.Id);
             var heros = new int[] { 1, 2, 5 };//GameUtils.RandomChoose(1, 4, GameConsts.Hero.MaxHeroTeamCount);
             foreach (int heroId in heros)
             {
                 ph.AddNewHero(heroId);
                 ph.MyHeros.Heros[heroId].HeroLv = player.MyPlayer.Level;
             }
             List <int> heroTeam = new List <int>();
             heroTeam.AddRange(heros);
             ht.AssignHero(heroTeam);
             AddNewPlayer(player.MyPlayer.Id);
             PlayerArena pa = new PlayerArena();
             pa.UserId  = player.MyPlayer.Id;
             pa.EnemyId = 0;
             CacheSet.PlayerArenaCache.Add(pa);
         }
     }
 }
Example #3
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);
        }
Example #4
0
        public override bool TakeAction()
        {
            if (m_RequestPacket.Name.Length < 1 || m_RequestPacket.Name.Length > 30)
            {
                ErrorCode = (int)ErrorType.WrongInput;
                ErrorInfo = "wrong length";
                return(false);
            }
            if (PlayerLogic.FindUserByName(m_RequestPacket.Name) != null)
            {
                ErrorCode = (int)ErrorType.DuplicateName;
                ErrorInfo = "Duplicate name";
                return(false);
            }
            PlayerLogic p = new PlayerLogic();

            p.SetUser(m_UserId);
            p.MyPlayer.ModifyLocked(() =>
            {
                p.MyPlayer.Name         = m_RequestPacket.Name;
                p.MyPlayer.PortraitType = m_RequestPacket.PortraitType;
                p.MyPlayer.IsFemale     = m_RequestPacket.IsFemale;
            });
            PlayerHeroLogic ph = new PlayerHeroLogic();

            ph.SetUser(m_UserId);
            ph.AddNewHero(m_RequestPacket.FirstHeroType);
            HeroTeamLogic ht = new HeroTeamLogic();

            ht.SetUser(m_UserId);
            List <int> heroTeam = new List <int>()
            {
                m_RequestPacket.FirstHeroType
            };

            ht.AssignHero(heroTeam);
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            return(true);
        }
Example #5
0
 private void GetItems(DropItem item)
 {
     if (PlayerPackageLogic.IsItem(item.ItemId))
     {
         var itemData = CacheSet.ItemTable.GetData(item.ItemId);
         if (itemData == null)
         {
             TraceLog.WriteError("Wrong Item ID in drop table : " + item.ItemId.ToString());
         }
         if (itemData.FunctionId == (int)ItemFunctions.AddHero)
         {
             PlayerHeroLogic ph = new PlayerHeroLogic();
             ph.SetUser(m_UserId);
             int          heroId = int.Parse(itemData.FunctionParams);
             ItemListItem piece  = ph.AddNewHero(heroId);
             if (piece == null)
             {
                 Hero newHero = ph.MyHeros.Heros[heroId];
                 m_ResponsePacket.LobbyHeroInfo.Add(new PBLobbyHeroInfo()
                 {
                     Type               = newHero.HeroType,
                     Level              = newHero.HeroLv,
                     Exp                = newHero.HeroExp,
                     ElevationLevel     = newHero.ElevationLevel,
                     ConsciousnessLevel = newHero.ConsciousnessLevel,
                     StarLevel          = newHero.HeroStarLevel
                 });
                 return;
             }
             else
             {
                 AddItem(piece.Id, piece.Count);
                 return;
             }
         }
         AddItem(item.ItemId, item.ItemCount);
         return;
     }
     AddItem(item.ItemId, item.ItemCount);
     return;
 }
Example #6
0
        private void AddHero(int heroId)
        {
            PlayerHeroLogic ph = new PlayerHeroLogic();

            ph.SetUser(m_UserId);
            if (ph.AddNewHero(heroId) == null)
            {
                m_ResponsePacket.LobbyHeroInfo = new PBLobbyHeroInfo()
                {
                    Type               = ph.MyHeros.Heros[heroId].HeroType,
                    Level              = ph.MyHeros.Heros[heroId].HeroLv,
                    Exp                = ph.MyHeros.Heros[heroId].HeroExp,
                    StarLevel          = ph.MyHeros.Heros[heroId].HeroStarLevel,
                    ConsciousnessLevel = ph.MyHeros.Heros[heroId].ConsciousnessLevel,
                    ElevationLevel     = ph.MyHeros.Heros[heroId].ElevationLevel,
                    Might              = ph.MyHeros.Heros[heroId].Might,
                };
                m_ResponsePacket.LobbyHeroInfo.SkillExps.AddRange(ph.MyHeros.Heros[heroId].SkillExps);
                m_ResponsePacket.LobbyHeroInfo.SkillLevels.AddRange(ph.MyHeros.Heros[heroId].SkillLevels);
            }
        }
Example #7
0
        private void GetReward(DropItem item)
        {
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            var type = m_RequestPacket.ChanceType == (int)ChanceType.Money ? ReceiveItemMethodType.MoneyChance : ReceiveItemMethodType.CoinChance;

            if (PlayerPackageLogic.IsItem(item.ItemId))
            {
                m_ResponsePacket.ReceivedItems = new PBReceivedItems();
                var itemData = CacheSet.ItemTable.GetData(item.ItemId);
                if (itemData.FunctionId == (int)ItemFunctions.AddHero)
                {
                    PlayerHeroLogic ph = new PlayerHeroLogic();
                    ph.SetUser(m_UserId);
                    int          heroId = int.Parse(itemData.FunctionParams);
                    ItemListItem piece  = ph.AddNewHero(heroId, type);
                    if (piece == null)
                    {
                        Hero newHero = ph.MyHeros.Heros[heroId];
                        m_ResponsePacket.LobbyHeroInfo = new PBLobbyHeroInfo()
                        {
                            Type               = newHero.HeroType,
                            Level              = newHero.HeroLv,
                            Exp                = newHero.HeroExp,
                            ElevationLevel     = newHero.ElevationLevel,
                            ConsciousnessLevel = newHero.ConsciousnessLevel,
                            StarLevel          = newHero.HeroStarLevel
                        };
                    }
                    else
                    {
                        pp.AddInventory(piece);
                        m_ResponsePacket.ReceivedItems.ItemInfo.Add(new PBItemInfo()
                        {
                            Type  = piece.Id,
                            Count = pp.MyPackage.Inventories[piece.Id]
                        });
                    }
                }
                else
                {
                    pp.AddInventory(new ItemListItem()
                    {
                        Id = item.ItemId, Count = item.ItemCount
                    });
                    m_ResponsePacket.ReceivedItems.ItemInfo.Add(new PBItemInfo()
                    {
                        Type  = item.ItemId,
                        Count = pp.MyPackage.Inventories[item.ItemId]
                    });
                }
            }
            else
            {
                Dictionary <int, int> itemDict = new Dictionary <int, int>();
                itemDict.Add(item.ItemId, item.ItemCount);
                PBReceivedItems receivedItems;
                pp.GetItems(itemDict, type, out receivedItems);
                m_ResponsePacket.ReceivedItems = receivedItems;
            }
        }