示例#1
0
        public bool Reset()
        {
            if (m_Chess.Token < 1)
            {
                return(false);
            }
            m_Chess.Anger         = 0;
            m_Chess.Count         = GameConsts.PlayerChess.DailyPlayCount;
            m_Chess.Token        -= 1;
            m_Chess.GotCoin       = 0;
            m_Chess.GotMoney      = 0;
            m_Chess.GotStarEnergy = 0;
            m_Chess.GotGears.Clear();
            m_Chess.GotItems.Clear();
            m_Chess.GotSouls.Clear();
            m_Chess.GotEpigraphs.Clear();
            PlayerHeroLogic playerHero = new PlayerHeroLogic();

            m_Chess.HP = new CacheDictionary <int, int>();
            foreach (var hero in playerHero.SetUser(m_UserId).MyHeros.Heros)
            {
                m_Chess.HP[hero.Key] = hero.Value.MaxHP;
            }
            m_Chess.ChessBoard = GetChessBoard();
            m_Chess.OpenCount  = GameConsts.PlayerChess.EmptyGrayFieldCount + GameConsts.PlayerChess.RewardGrayFieldCount + GameConsts.PlayerChess.EmptyFieldCount;
            return(true);
        }
示例#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);
        }
示例#3
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);
         }
     }
 }
示例#4
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);
        }
        private void InitGearLevelAchievementProgress(TrackingAchievement achievement)
        {
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            PlayerHeroLogic ph = new PlayerHeroLogic();

            ph.SetUser(m_UserId);
            int       progress = 0;
            GearLogic g        = new GearLogic();

            foreach (var hero in ph.GetHeroList())
            {
                foreach (var gear in hero.Value.Gears)
                {
                    g.SetGear(gear.Value);
                    if (g.MyGear.Level >= achievement.Params[0])
                    {
                        progress++;
                    }
                }
            }
            foreach (var gear in pp.MyPackage.Gears)
            {
                g.SetGear(gear.Key);
                if (g.MyGear.Level >= achievement.Params[0])
                {
                    progress++;
                }
            }
            achievement.Progress = progress;
        }
        private void InitHeroCountProgress(TrackingAchievement achievement)
        {
            PlayerHeroLogic ph = new PlayerHeroLogic();

            ph.SetUser(m_UserId);
            achievement.Progress = ph.GetHeroList().Count;
        }
示例#7
0
        public bool AssignHero(List <int> heroTeam)
        {
            if (heroTeam.Count > 3 || heroTeam.Count == 0)
            {
                return(false);
            }
            PlayerHeroLogic ph = new PlayerHeroLogic();

            ph.SetUser(m_UserId);
            foreach (int heroId in heroTeam)
            {
                if (!ph.SetHero(heroId).DataCheck())
                {
                    return(false);
                }
            }
            for (int i = 0; i < GameConsts.Hero.MaxHeroTeamCount; i++)
            {
                if (i + 1 > heroTeam.Count)
                {
                    m_Team.Team[i] = 0;
                }
                else
                {
                    m_Team.Team[i] = heroTeam[i];
                }
            }
            PlayerLogic p = new PlayerLogic();

            p.SetUser(m_UserId);
            p.RefreshMight();
            return(true);
        }
示例#8
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);
        }
示例#9
0
        private void ProcessEffect1(int count, string funcParams)
        {
            int             totalAddExp = count * int.Parse(funcParams);
            PlayerHeroLogic playerHero  = new PlayerHeroLogic();

            playerHero.SetUser(m_UserId).SetHero(m_HeroId);
            playerHero.AddExp(totalAddExp);
        }
示例#10
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);
        }
示例#11
0
        private void GetInstanceReward(PlayerInstanceLogic instance)
        {
            int         instanceId = instance.MyInstance.InstanceId;
            PlayerLogic player     = new PlayerLogic();

            player.SetUser(m_UserId);
            long nextRecoverTime;

            if (!m_RequestPacket.Win)
            {
                int feedbackEnergy = PlayerInstanceLogic.GetFeedBackEnergy(instanceId);
                player.AddEnergy(feedbackEnergy, out nextRecoverTime);
                m_ResponsePacket.PlayerInfo        = new PBPlayerInfo();
                m_ResponsePacket.PlayerInfo.Energy = player.MyPlayer.Energy;
                m_ResponsePacket.PlayerInfo.NextEnergyRecoveryTime = nextRecoverTime;
                return;
            }
            DTInstance instanceData = PlayerInstanceLogic.GetInstanceData(instanceId);

            player.MyPlayer.Coin += instanceData.Coin;
            player.AddExp(instanceData.PlayerExp);
            m_ResponsePacket.PlayerInfo       = new PBPlayerInfo();
            m_ResponsePacket.PlayerInfo.Id    = player.MyPlayer.Id;
            m_ResponsePacket.PlayerInfo.Coin  = player.MyPlayer.Coin;
            m_ResponsePacket.PlayerInfo.Exp   = player.MyPlayer.Exp;
            m_ResponsePacket.PlayerInfo.Level = player.MyPlayer.Level;
            HeroTeamLogic heroTeam = new HeroTeamLogic();

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

            playerHero.SetUser(m_UserId);
            foreach (int heroId in heroTeam.MyHeroTeam.Team)
            {
                if (heroId == 0)
                {
                    continue;
                }
                playerHero.SetHero(heroId).AddExp(instanceData.HeroExp);
                m_ResponsePacket.LobbyHeroInfo.Add(new PBLobbyHeroInfo()
                {
                    Type  = heroId,
                    Exp   = playerHero.MyHeros.Heros[heroId].HeroExp,
                    Level = playerHero.MyHeros.Heros[heroId].HeroLv,
                    Might = playerHero.MyHeros.Heros[heroId].Might,
                });
            }
            m_ResponsePacket.InstanceType = instance.MyInstance.InstanceId;
            CacheDictionary <int, int> dropDict = instance.GetDropList();
            PlayerPackageLogic         package  = new PlayerPackageLogic();

            package.SetUser(m_UserId);
            PBReceivedItems receivedItems;

            package.GetItems(dropDict, ReceiveItemMethodType.CompleteInstance, out receivedItems);
            m_ResponsePacket.ReceivedItems = receivedItems;
        }
示例#12
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);
        }
示例#13
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);
        }
示例#14
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);
        }
示例#15
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);
        }
示例#16
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);
        }
示例#17
0
        private void SetHeroInfo()
        {
            PlayerHeroLogic playerHeros = new PlayerHeroLogic();

            playerHeros.SetUser(m_UserId);
            CacheDictionary <int, Hero> heros = playerHeros.GetHeroList();

            foreach (var hero in heros)
            {
                PBLobbyHeroInfo heroInfo = new PBLobbyHeroInfo();
                heroInfo.Type               = hero.Key;
                heroInfo.Level              = hero.Value.HeroLv;
                heroInfo.Exp                = hero.Value.HeroExp;
                heroInfo.StarLevel          = hero.Value.HeroStarLevel;
                heroInfo.ConsciousnessLevel = hero.Value.ConsciousnessLevel;
                heroInfo.ElevationLevel     = hero.Value.ElevationLevel;
                heroInfo.SkillLevels.AddRange(hero.Value.SkillLevels);
                heroInfo.SkillExps.AddRange(hero.Value.SkillExps);
                heroInfo.Might = hero.Value.Might;
                foreach (var gear in hero.Value.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.StrengthenLevel = gearData.StrengthenLevel;
                    gearInfo.Type            = gearData.TypeId;
                    heroInfo.GearInfo.Add(gearInfo);
                }
                foreach (var soul in hero.Value.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;
                    heroInfo.SoulInfo.Add(soulInfo);
                }
                m_ResponsePacket.LobbyHeroInfo.Add(heroInfo);
            }
        }
示例#18
0
        private void InitHeroStarLevelProgress(TrackingAchievement achievement)
        {
            PlayerHeroLogic ph = new PlayerHeroLogic();

            ph.SetUser(m_UserId);
            int progress = 0;

            foreach (var hero in ph.GetHeroList())
            {
                if (hero.Value.HeroStarLevel >= achievement.Params[0])
                {
                    progress++;
                }
            }
            achievement.Progress = progress;
        }
示例#19
0
        private void InitHeroLevelAchievementProgress(TrackingAchievement achievement)
        {
            PlayerHeroLogic ph = new PlayerHeroLogic();

            ph.SetUser(m_UserId);
            int progress = 0;

            foreach (var hero in ph.GetHeroList())
            {
                if (hero.Value.HeroLv > progress)
                {
                    progress = hero.Value.HeroLv;
                }
            }
            achievement.Progress = progress;
        }
示例#20
0
        private void HeroLevelUp(int heroId, int addLevel)
        {
            PlayerHeroLogic ph = new PlayerHeroLogic();

            ph.SetUser(m_UserId).SetHero(heroId);
            if (!ph.DataCheck())
            {
                return;
            }
            ph.AddLevel(addLevel);
            m_ResponsePacket.LobbyHeroInfo = new PBLobbyHeroInfo()
            {
                Type  = heroId,
                Level = ph.MyHeros.Heros[heroId].HeroLv,
                Exp   = ph.MyHeros.Heros[heroId].HeroExp
            };
        }
示例#21
0
        public static BattleChessField GetBattleChessField(ChessFieldColor color, int enemyId, int count)
        {
            BattleChessField field = new BattleChessField();

            field.Color         = color;
            field.IsOpened      = false;
            field.Count         = count;
            field.EnemyAnger    = 0;
            field.EnemyPlayerId = enemyId;
            HeroTeamLogic heroTeam = new HeroTeamLogic();

            heroTeam.SetUser(field.EnemyPlayerId);
            PlayerHeroLogic playerHero = new PlayerHeroLogic();

            playerHero.SetUser(field.EnemyPlayerId);
            int i = 0;

            foreach (int heroId in heroTeam.MyHeroTeam.Team)
            {
                if (heroId == 0)
                {
                    break;
                }
                field.EnemyPlayerHeroTeam[i]                    = new Hero();
                field.EnemyPlayerHeroTeam[i].HeroType           = playerHero.MyHeros.Heros[heroId].HeroType;
                field.EnemyPlayerHeroTeam[i].HeroLv             = playerHero.MyHeros.Heros[heroId].HeroLv;
                field.EnemyPlayerHeroTeam[i].HeroStarLevel      = playerHero.MyHeros.Heros[heroId].HeroStarLevel;
                field.EnemyPlayerHeroTeam[i].ElevationLevel     = playerHero.MyHeros.Heros[heroId].ElevationLevel;
                field.EnemyPlayerHeroTeam[i].ConsciousnessLevel = playerHero.MyHeros.Heros[heroId].ConsciousnessLevel;
                field.EnemyPlayerHeroTeam[i].Gears              = new CacheDictionary <GearType, int>();
                field.EnemyPlayerHeroTeam[i].SkillLevels.AddRange(playerHero.MyHeros.Heros[heroId].SkillLevels);
                foreach (var gear in playerHero.MyHeros.Heros[heroId].Gears)
                {
                    field.EnemyPlayerHeroTeam[i].Gears[gear.Key] = gear.Value;
                }
                field.EnemyPlayerHeroTeam[i].Souls = new CacheDictionary <int, int>();
                foreach (var soul in playerHero.MyHeros.Heros[heroId].Souls)
                {
                    field.EnemyPlayerHeroTeam[i].Souls[soul.Key] = soul.Value;
                }
                //field.EnemyHeroHP.Add(MaxHP);
                i++;
            }
            return(field);
        }
示例#22
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);
        }
示例#23
0
        public void RefreshMight()
        {
            HeroTeamLogic ht = new HeroTeamLogic();

            ht.SetUser(MyPlayer.Id);
            PlayerHeroLogic ph = new PlayerHeroLogic();

            ph.SetUser(MyPlayer.Id);
            int newMight = 0;

            foreach (int heroId in ht.GetTeam())
            {
                if (heroId > 0)
                {
                    newMight += ph.MyHeros.Heros[heroId].Might;
                }
            }
            MyPlayer.Might = newMight;
        }
示例#24
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);
        }
示例#25
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;
 }
示例#26
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);
        }
示例#27
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);
        }
示例#28
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);
            }
        }
示例#29
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);
        }
示例#30
0
        public override bool TakeAction()
        {
            InstanceProgressLogic ip = new InstanceProgressLogic();

            ip.SetUser(m_UserId);
            if (!(ip.GetInstanceProgress()).ContainsKey(m_RequestPacket.InstanceId))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "You have not passed this instance";
                return(false);
            }
            PlayerInstanceLogic pi = new PlayerInstanceLogic();

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

            for (int i = 0; i < m_RequestPacket.Count; i++)
            {
                PBInstanceDrop    instanceDrop = new PBInstanceDrop();
                List <PBDropInfo> dropList     = new List <PBDropInfo>();
                List <PBDropInfo> dropPack;
                var dropDict = pi.GenerateDropList(m_RequestPacket.InstanceId, true, out dropPack);
                GameUtils.MergeItemDict(dropItems, dropDict);
                foreach (var dropItem in dropDict)
                {
                    PBDropInfo item = new PBDropInfo()
                    {
                        DropId    = dropItem.Key,
                        DropCount = dropItem.Value
                    };
                    instanceDrop.Items.Add(item);
                }
                m_ResponsePacket.Drops.Add(instanceDrop);
            }
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            if (!pp.CheckPackageSlot(dropItems))
            {
                ErrorCode = (int)ErrorType.PackageSlotFull;
                ErrorInfo = "Package full";
                return(false);
            }
            PlayerLogic p = new PlayerLogic();

            p.SetUser(m_UserId);
            int  energy = PlayerInstanceLogic.GetInstanceEnergy(m_RequestPacket.InstanceId);
            long nextRecoverTime;

            if (!p.DeductEnergy(energy * m_RequestPacket.Count, out nextRecoverTime))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "You have not enough energy";
                return(false);
            }
            PBReceivedItems receivedItems;

            pp.GetItems(dropItems, ReceiveItemMethodType.CompleteInstance, out receivedItems);
            m_ResponsePacket.ReceivedItems = receivedItems;
            DTInstance instanceData = PlayerInstanceLogic.GetInstanceData(m_RequestPacket.InstanceId);

            p.AddCoin(instanceData.Coin * m_RequestPacket.Count);
            p.AddExp(instanceData.PlayerExp * m_RequestPacket.Count);
            m_ResponsePacket.Count      = m_RequestPacket.Count;
            m_ResponsePacket.InstanceId = m_RequestPacket.InstanceId;
            m_ResponsePacket.PlayerInfo = new PBPlayerInfo()
            {
                Id     = m_UserId,
                Coin   = p.MyPlayer.Coin,
                Exp    = p.MyPlayer.Exp,
                Level  = p.MyPlayer.Level,
                Energy = p.MyPlayer.Energy,
                NextEnergyRecoveryTime = nextRecoverTime
            };
            HeroTeamLogic heroTeam = new HeroTeamLogic();

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

            playerHero.SetUser(m_UserId);
            foreach (int heroId in heroTeam.MyHeroTeam.Team)
            {
                if (heroId == 0)
                {
                    continue;
                }
                //playerHero.SetHero(heroId).AddExp(instanceData.HeroExp);
                m_ResponsePacket.LobbyHeroInfo.Add(new PBLobbyHeroInfo()
                {
                    Type  = heroId,
                    Exp   = playerHero.MyHeros.Heros[heroId].HeroExp,
                    Level = playerHero.MyHeros.Heros[heroId].HeroLv
                });
            }
            PlayerDailyQuestLogic.GetInstance(m_UserId).UpdateDailyQuest(DailyQuestType.CleanOutInstance, m_RequestPacket.Count);
            return(true);
        }