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); }
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; }
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); }
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); }
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); }
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); }
public override bool TakeAction() { PlayerLogic player = new PlayerLogic(); player.SetUser(m_RequestPacket.PlayerId); PlayerHeroLogic ph = new PlayerHeroLogic(); ph.SetUser(m_RequestPacket.PlayerId); m_ResponsePacket.Player = new PBPlayerInfo() { Id = player.MyPlayer.Id, Name = player.MyPlayer.Name, VipLevel = player.MyPlayer.VIPLevel, Level = player.MyPlayer.Level, PlayerHeroCount = ph.MyHeros.Heros.Count, Might = player.MyPlayer.Might, DisplayId = player.MyPlayer.UUID }; PlayerFriendsLogic pf = new PlayerFriendsLogic(); pf.SetUser(m_RequestPacket.PlayerId); var friends = pf.GetFriends(); if (friends.ContainsKey(m_UserId)) { m_ResponsePacket.IsMyFriend = true; } else { m_ResponsePacket.IsMyFriend = false; } HeroTeamLogic ht = new HeroTeamLogic(); ht.SetUser(m_RequestPacket.PlayerId); GearLogic g = new GearLogic(); SoulLogic s = new SoulLogic(); foreach (int heroType in ht.MyHeroTeam.Team) { if (heroType == 0) { continue; } var hero = ph.SetHero(heroType).GetHeroInfo(); var heroInfo = new PBLobbyHeroInfo() { Type = hero.HeroType, Level = hero.HeroLv, ConsciousnessLevel = hero.ConsciousnessLevel, ElevationLevel = hero.ElevationLevel, StarLevel = hero.HeroStarLevel, Might = hero.Might, }; heroInfo.SkillLevels.AddRange(hero.SkillLevels); foreach (var gear in hero.Gears) { g.SetGear(gear.Value); heroInfo.GearInfo.Add(new PBGearInfo() { Id = g.MyGear.Id, Type = g.MyGear.TypeId, Level = g.MyGear.Level, StrengthenLevel = g.MyGear.StrengthenLevel }); } foreach (var soul in hero.Souls) { s.SetSoul(soul.Value); heroInfo.SoulInfo.Add(new PBSoulInfo() { Id = s.MySoul.Id, Type = s.MySoul.TypeId, }); } m_ResponsePacket.HeroTeam.Add(heroInfo); } return(true); }
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); }