public override bool TakeCard(Player player, int index) { if (player.CanTakeOut == 0) { return(false); } if (player.IsActive == false || index < 0 || index > Cards.Length || player.FinishTakeCard || Cards[index] > 0) { return(false); } int gold = 0; int money = 0; int giftToken = 0; int medal = 0; int templateID = 0; List <ItemInfo> infos = null; if (DropInventory.CardDrop(RoomType, ref infos)) { if (infos != null) { foreach (ItemInfo info in infos) { ItemInfo.FindSpecialItemInfo(info, ref gold, ref money, ref giftToken, ref medal); //trminhpc if (info != null) { templateID = info.TemplateID; player.PlayerDetail.AddTemplate(info, eBageType.TempBag, info.Count); } } } } if (RoomType == eRoomType.Dungeon) { player.CanTakeOut--; if (player.CanTakeOut == 0) { player.FinishTakeCard = true; } } else { player.FinishTakeCard = true; } Cards[index] = 1; int count = 0; switch (templateID) { case -100: count = gold; break; case 0: templateID = -100; count = 500; break; case -300: count = giftToken; break; case -200: count = money; break; } player.PlayerDetail.AddGold(gold); player.PlayerDetail.AddMoney(money); player.PlayerDetail.LogAddMoney(AddMoneyType.Award, AddMoneyType.Award_BossDrop, player.PlayerDetail.PlayerCharacter.ID, money, player.PlayerDetail.PlayerCharacter.Money); player.PlayerDetail.AddGiftToken(giftToken); player.PlayerDetail.AddMedal(medal); //trminhpc //SendGamePlayerTakeCard(player, index, medal, gold, money, giftToken); SendGamePlayerTakeCard(player, index, templateID, count, false); return(true); }
private static bool GetDropItems(eDropType type, int dropId, ref List <ItemInfo> itemInfos) { bool result; if (dropId == 0) { result = false; } else { try { int dropItemCount = 1; List <DropItem> unFiltItems = DropMgr.FindDropItem(dropId); int maxRound = DropInventory.random.Next(( from s in unFiltItems select s.Random).Max()); List <DropItem> filtItems = ( from s in unFiltItems where s.Random >= maxRound select s).ToList <DropItem>(); int maxItems = filtItems.Count <DropItem>(); if (maxItems == 0) { result = false; return(result); } dropItemCount = ((dropItemCount > maxItems) ? maxItems : dropItemCount); int[] randomArray = DropInventory.GetRandomUnrepeatArray(0, maxItems - 1, dropItemCount); int[] array = randomArray; for (int j = 0; j < array.Length; j++) { int i = array[j]; int itemCount = DropInventory.random.Next(filtItems[i].BeginData, filtItems[i].EndData); ItemTemplateInfo temp = ItemMgr.FindItemTemplate(filtItems[i].ItemId); ItemInfo item = ItemInfo.CreateFromTemplate(temp, itemCount, 101); if (item != null) { item.IsBinds = filtItems[i].IsBind; item.ValidDate = filtItems[i].ValueDate; item.IsTips = filtItems[i].IsTips; item.IsLogs = filtItems[i].IsLogs; if (itemInfos == null) { itemInfos = new List <ItemInfo>(); } switch (type) { case eDropType.Cards: case eDropType.Box: case eDropType.NPC: case eDropType.Boss: case eDropType.Special: if (DropInfoMgr.CanDrop(temp.TemplateID)) { itemInfos.Add(item); } break; default: itemInfos.Add(item); break; } } } if (itemInfos != null && itemInfos.Count > 0) { result = true; return(result); } } catch (Exception ex) { //if (DropInventory.log.IsErrorEnabled) { DropInventory.log.Error(string.Concat(new object[] { "Drop Error:", type, " @ ", ex })); } } result = false; } return(result); }
private static bool GetDropItems(eDropType type, int dropId, ref List <ItemInfo> itemInfos) { if (dropId == 0) { return(false); } try { int num = 1; List <DropItem> source = DropMgr.FindDropItem(dropId); int maxRound = ThreadSafeRandom.NextStatic(( from s in source select s.Random).Max()); List <DropItem> list = ( from s in source where s.Random >= maxRound select s).ToList <DropItem>(); int num2 = list.Count <DropItem>(); bool result; if (num2 == 0) { result = false; return(result); } num = ((num > num2) ? num2 : num); int[] randomUnrepeatArray = DropInventory.GetRandomUnrepeatArray(0, num2 - 1, num); int[] array = randomUnrepeatArray; for (int i = 0; i < array.Length; i++) { int index = array[i]; int count = ThreadSafeRandom.NextStatic(list[index].BeginData, list[index].EndData); ItemTemplateInfo itemTemplateInfo = ItemMgr.FindItemTemplate(list[index].ItemId); ItemInfo itemInfo = ItemInfo.CreateFromTemplate(itemTemplateInfo, count, 101); if (itemInfo != null) { itemInfo.IsBinds = list[index].IsBind; itemInfo.ValidDate = list[index].ValueDate; if (itemInfos == null) { itemInfos = new List <ItemInfo>(); } if (DropInfoMgr.CanDrop(itemTemplateInfo.TemplateID)) { itemInfos.Add(itemInfo); } } } result = true; return(result); } catch (Exception ex) { if (DropInventory.log.IsErrorEnabled) { DropInventory.log.Error(string.Concat(new object[] { "Drop Error:", type, " @ ", ex })); } } return(false); }
public override bool TakeCard(Player player, int index, bool isSysTake) { bool result; if (player.CanTakeOut == 0) { result = false; } else { if (!player.IsActive || index < 0 || index > this.Cards.Length || player.FinishTakeCard || this.Cards[index] > 0) { result = false; } else { player.CanTakeOut--; int gold = 0; int money = 0; int giftToken = 0; int templateID = 0; List <ItemInfo> infos = null; if (DropInventory.CardDrop(base.RoomType, ref infos)) { if (infos != null) { foreach (ItemInfo info in infos) { templateID = info.Template.TemplateID; ItemInfo tempInfo = ItemInfo.FindSpecialItemInfo(info, ref gold, ref money, ref giftToken); if (tempInfo != null && templateID > 0) { player.PlayerDetail.AddTemplate(tempInfo, eBageType.TempBag, info.Count); } } } } player.FinishTakeCard = true; this.Cards[index] = 1; int count = 0; int num = templateID; if (num <= -200) { if (num != -300) { if (num == -200) { count = money; } } else { count = giftToken; } } else { if (num != -100) { if (num == 0) { templateID = -100; count = 500; } } else { count = gold; } } player.PlayerDetail.AddGold(gold); player.PlayerDetail.AddMoney(money, LogMoneyType.Award, LogMoneyType.Award_TakeCard); player.PlayerDetail.AddGiftToken(giftToken); base.SendGamePlayerTakeCard(player, index, templateID, count, isSysTake); result = true; } } return(result); }