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); }
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); }
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); }
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); }
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); }
public override bool TakeAction() { PlayerPackageLogic pp = new PlayerPackageLogic(); pp.SetUser(m_UserId); PlayerLogic player = new PlayerLogic(); player.SetUser(m_UserId); int totalCoin = 0; foreach (var item in m_RequestPacket.SoldItems) { ItemListItem tmpItem = new ItemListItem() { Id = item.Type, Count = item.Count }; if (!pp.DeductInventory(tmpItem)) { ErrorCode = (int)ErrorType.RequireNotMet; ErrorInfo = "You have not enough item"; return(false); } DTItem itemData = CacheSet.ItemTable.GetData(item.Type); totalCoin += item.Count * itemData.Price; m_ResponsePacket.ItemInfo.Add(item); } foreach (var gear in m_RequestPacket.SoldGears) { if (!pp.DeductGear(gear.Id)) { ErrorCode = (int)ErrorType.RequireNotMet; ErrorInfo = "You have not this gear"; return(false); } DTGear gearData = CacheSet.GearTable.GetData(gear.Type); totalCoin += gearData.Price; m_ResponsePacket.GearInfo.Add(gear); } player.AddCoin(totalCoin); m_ResponsePacket.PlayerInfo = new PBPlayerInfo() { Id = player.MyPlayer.Id, Coin = player.MyPlayer.Coin }; return(true); }
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); }
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); }
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); }
public override bool TakeAction() { Transaction t = new Transaction(); PlayerLogic player = new PlayerLogic(); player.SetUser(m_UserId); PlayerPackageLogic package = new PlayerPackageLogic(); package.SetUser(m_UserId); GearLogic gear = new GearLogic(); gear.SetGear(m_RequestPacket.GearId[0]); int quality = CacheSet.GearTable.GetData(gear.MyGear.TypeId).Quality; t.DumpEntity(package.MyPackage); t.DumpEntity(player.MyPlayer); int costCoin = gear.GetComposeCost(quality); if (quality == (int)GearQuality.Orange) { t.RollBack(); ErrorCode = (int)ErrorType.CannotOpenChance; ErrorInfo = "wrong gearId"; return(false); } if (!player.DeductCoin(costCoin)) { t.RollBack(); ErrorCode = (int)ErrorType.RequireNotMet; ErrorInfo = "You don't have enough Coin"; return(false); } foreach (int gearId in m_RequestPacket.GearId) { gear.SetGear(gearId); if (quality != CacheSet.GearTable.GetData(gear.MyGear.TypeId).Quality) { t.RollBack(); ErrorCode = (int)ErrorType.CannotOpenChance; ErrorInfo = "wrong gearId"; return(false); } if (!package.DeductGear(gearId)) { t.RollBack(); ErrorCode = (int)ErrorType.RequireNotMet; ErrorInfo = "You don't have enough Gear"; return(false); } gear.RemoveGear(); } int position = 0; if (m_RequestPacket.HasItemId && m_RequestPacket.ItemId != 0) { if (!package.DeductInventory(new ItemListItem() { Id = m_RequestPacket.ItemId, Count = 1 })) { t.RollBack(); ErrorCode = (int)ErrorType.RequireNotMet; ErrorInfo = "You don't have enough Item"; return(false); } position = int.Parse(CacheSet.ItemTable.GetData(m_RequestPacket.ItemId).FunctionParams); m_ResponsePacket.ItemInfo = new PBItemInfo() { Type = m_RequestPacket.ItemId, Count = package.MyPackage.Inventories[m_RequestPacket.ItemId] }; } m_ResponsePacket.PlayerInfo = new PBPlayerInfo() { Id = player.MyPlayer.Id, Coin = player.MyPlayer.Coin }; m_ResponsePacket.RemovedGears.AddRange(m_RequestPacket.GearId); Gears newGear = gear.GetComposeResult(quality, position, m_UserId); if (newGear == null) { return(true); } package.AddGear(newGear.Id, newGear.TypeId); m_ResponsePacket.NewGear = new PBGearInfo() { Id = newGear.Id, Type = newGear.TypeId, Level = newGear.Level }; return(true); }