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); }
private void AddSoul(int soulType) { SoulLogic soul = new SoulLogic(); int soulId = soul.AddNewSoul(soulType); PlayerPackageLogic package = new PlayerPackageLogic(); package.SetUser(m_UserId); package.AddSoul(soulId, soulType); m_ResponsePacket.SoulInfo = new PBSoulInfo() { Id = soulId, Type = soulType, }; }
private void SetResponseData(PlayerChess playerChess) { m_ResponsePacket.GotCoin = playerChess.GotCoin; m_ResponsePacket.GotMoney = playerChess.GotMoney; m_ResponsePacket.GotStarEnergy = playerChess.GotStarEnergy; foreach (var item in playerChess.GotItems) { m_ResponsePacket.GotItems.Add(new PBItemInfo() { Type = item.Key, Count = item.Value }); } GearLogic gears = new GearLogic(); foreach (int gearId in playerChess.GotGears) { gears.SetGear(gearId); m_ResponsePacket.GotGears.Add(new PBGearInfo() { Id = gears.MyGear.Id, Level = gears.MyGear.Level, Type = gears.MyGear.TypeId }); } SoulLogic souls = new SoulLogic(); foreach (int soulId in playerChess.GotSouls) { souls.SetSoul(soulId); m_ResponsePacket.GotSouls.Add(new PBSoulInfo() { Id = souls.MySoul.Id, Type = souls.MySoul.TypeId }); } foreach (int epigraphId in playerChess.GotEpigraphs) { m_ResponsePacket.GotEpigraphs.Add(new PBEpigraphInfo() { Level = 1, Type = epigraphId }); } foreach (var heroHP in playerChess.HP) { m_ResponsePacket.HeroStatus.Add(new PBLobbyHeroStatus() { Type = heroHP.Key, CurHP = heroHP.Value }); } m_ResponsePacket.PlayCount = playerChess.Count; m_ResponsePacket.Anger = playerChess.Anger; m_ResponsePacket.TokenCount = playerChess.Token; m_ResponsePacket.Width = GameConsts.PlayerChess.ChessBoardWidth; PlayerLogic player = new PlayerLogic(); foreach (var chessField in playerChess.ChessBoard) { PBChessField cf = new PBChessField(); cf.Color = chessField.Color == ChessFieldColor.Empty || chessField.Color == ChessFieldColor.EmptyGray || chessField.Color == ChessFieldColor.RewardGray ? (int)ChessFieldColor.EmptyGray : (int)chessField.Color; if (chessField.Color == ChessFieldColor.Empty || chessField.Color == ChessFieldColor.EmptyGray || chessField.Color == ChessFieldColor.RewardGray) { var curField = chessField as RewardChessField; cf.IsOpened = curField.IsOpened; if (!cf.IsOpened) { cf.IsFree = curField.IsFree; if (cf.IsFree) { cf.Parent = curField.ParentId; } } } else { var curField = chessField as BattleChessField; player.SetUser(curField.EnemyPlayerId); cf.IsOpened = curField.IsOpened; if (cf.IsOpened) { cf.FreeCount = curField.Count; cf.Children.AddRange(curField.ChildrenId); } } m_ResponsePacket.ChessBoard.Add(cf); } if (playerChess.MyTeam != null) { m_ResponsePacket.HeroTeam.AddRange(playerChess.MyTeam); } }
public void GetItems(IDictionary<int, int> gotItems, ReceiveItemMethodType method, out PBReceivedItems receivedItems) { GearLogic gear = new GearLogic(); SoulLogic soul = new SoulLogic(); Dictionary<int, int> itemDict = new Dictionary<int, int>(); receivedItems = new PBReceivedItems(); foreach (var reward in gotItems) { if (IsGear(reward.Key)) { for (int i = 0; i < reward.Value; i++) { int gearId = gear.AddNewGear(reward.Key, m_UserId, method); AddGear(gearId, reward.Key); receivedItems.GearInfo.Add(new PBGearInfo() { Id = gearId, Type = reward.Key, Level = 1 }); } } else if (IsItem(reward.Key)) { AddInventory(new ItemListItem() { Id = reward.Key, Count = reward.Value }); GameUtils.MergeItem(itemDict, reward.Key, reward.Value); } else if (IsSoul(reward.Key)) { for (int i = 0; i < reward.Value; i++) { int soulId = soul.AddNewSoul(reward.Key); AddSoul(soulId, reward.Key); receivedItems.SoulInfo.Add(new PBSoulInfo() { Id = soulId, Type = reward.Key }); } } else if (IsEpigraph(reward.Key)) { for (int i = 0; i < reward.Value; i++) { ItemListItem item; if (GetNewEpigraph(reward.Key, out item)) { receivedItems.EpigraphInfo.Add(new PBEpigraphInfo() { Type = reward.Key, Level = m_Package.Epigraphs[reward.Key] }); } else { GameUtils.MergeItem(itemDict, item.Id, item.Count); } } } else { PlayerLogic p = new PlayerLogic(); p.SetUser(m_UserId); switch ((GiftItemType)reward.Key) { case GiftItemType.Coin: p.AddCoin(reward.Value); break; case GiftItemType.Money: p.AddMoney(reward.Value); break; case GiftItemType.Energy: long nextRecoverTime; p.AddEnergy(reward.Value, out nextRecoverTime); break; case GiftItemType.MeridianEnergy: p.AddStarEnergy(reward.Value); break; case GiftItemType.Spirit: p.AddSpirit(reward.Value); break; case GiftItemType.DragonStripeToken: p.AddDragonStripeToken(reward.Value); break; } } } foreach (var item in itemDict) { receivedItems.ItemInfo.Add(new PBItemInfo() { Type = item.Key, Count = m_Package.Inventories[item.Key] }); } }
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); }
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); }