public ItemRandomClass GetRareItem(UInt32 CoinTypeID, byte Pooling) { ItemRandomClass result; result = new ItemRandomClass(); switch (Pooling) { case 0: foreach (IffMemorialRareItemData Item in this) { result.AddItems(Item.TypeID, 1, Item.RareType, (ushort)result.rnd.Next((int)Item.Probabilities - result.rnd.Next(20))); } break; default: foreach (IffMemorialRareItemData Item in this) { if (Item.CharacterType == Pooling) { result.AddItems(Item.TypeID, 1, Item.RareType, (ushort)result.rnd.Next((int)Item.Probabilities + result.rnd.Next(20))); } } break; } result.SetCanDup(false); result.Arrange(); return(result); }
static ScratchCardSystem() { ItemRandom ItemInfo; uint[] SupplyTypeID; RandomWeight = new ItemRandomClass(); try { if (File.Exists("Json/ScratchCard.json")) { SupplyTypeID = new uint[4]; foreach (var item in JsonValue.ParseFile("Json/ScratchCard.json")["ScratchCardData"].AsJsonArray) { SupplyTypeID[0] = (uint)item["SupplyTypeID"].AsInteger; SupplyTypeID[1] = (uint)item["SupplyTypeID2"].AsInteger; SupplyTypeID[2] = (uint)item["SupplyTypeID3"].AsInteger; SupplyTypeID[3] = (uint)item["SupplyTypeID4"].AsInteger; foreach (var Reward in item["Items"].AsJsonArray) { ItemInfo = new ItemRandom() { TypeId = (uint)Reward["TypeID"].AsInteger, MaxQuantity = (uint)Reward["MaxQuan"].AsInteger, RareType = (uint)Reward["TypeRare"].AsInteger, Probs = (ushort)Reward["Probability"].AsInteger, Active = Reward["Valid"].AsBoolean }; RandomWeight.AddItems(ItemInfo); } } RandomWeight.AddSupply(SupplyTypeID[0]); RandomWeight.AddSupply(SupplyTypeID[1]); RandomWeight.AddSupply(SupplyTypeID[2]); RandomWeight.AddSupply(SupplyTypeID[3]); RandomWeight.SetCanDup(false); } else { throw new Exception(" ScratchCard.json file in folder not found !"); } } catch (Exception ex) { WriteConsole.WriteLine(ex.Message, ConsoleColor.Red); Console.ReadKey(); Environment.Exit(0); } }
public List <Dictionary <uint, byte> > GetCard(uint PackTypeID) { ushort GetProb(byte RareType) { switch (RareType) { case 0: return(100); case 1: return(6); case 2: return(2); case 3: return(1); default: return((ushort)GameTools.MathRand.Rand.Next(0, 120)); } } ushort GetFreshUPProb(byte RareType) { switch (RareType) { case 1: return(100); case 2: return(10); case 3: return(4); default: return((ushort)GameTools.MathRand.Rand.Next(0, 120)); } } List <Dictionary <uint, byte> > result; ItemRandomClass CRandom; byte CQty; ItemRandom CItem; result = new List <Dictionary <uint, byte> >(); CRandom = new ItemRandomClass(); try { PackData.TryGetValue(PackTypeID, out CardPack CPack); if (CPack == null) { return(result); } switch (CPack.CardTypePack) { case TPACKCARD.Pack1: foreach (var PZCard in ListCard) { if (PZCard.Volumn == 1) { CRandom.AddItems(PZCard.Base.TypeID, 1, PZCard.Rarity, GetProb(PZCard.Rarity)); } } break; case TPACKCARD.Pack2: foreach (var PZCard in ListCard) { if (PZCard.Volumn == 2) { CRandom.AddItems(PZCard.Base.TypeID, 1, PZCard.Rarity, GetProb(PZCard.Rarity)); } } break; case TPACKCARD.Pack3: foreach (var PZCard in ListCard) { if (PZCard.Volumn == 3) { CRandom.AddItems(PZCard.Base.TypeID, 1, PZCard.Rarity, GetProb(PZCard.Rarity)); } } break; case TPACKCARD.Pack4: foreach (var PZCard in ListCard) { if (PZCard.Volumn == 4) { CRandom.AddItems(PZCard.Base.TypeID, 1, PZCard.Rarity, GetProb(PZCard.Rarity)); } } break; case TPACKCARD.Rare: foreach (var PZCard in ListCard) { if (PZCard.Rarity >= 1) { CRandom.AddItems(PZCard.Base.TypeID, 1, PZCard.Rarity, GetFreshUPProb(PZCard.Rarity)); } } break; case TPACKCARD.All: foreach (var PZCard in ListCard) { CRandom.AddItems(PZCard.Base.TypeID, 1, PZCard.Rarity, GetProb(PZCard.Rarity)); } break; } // ## set random class CRandom.SetCanDup(false); CRandom.Arrange(); for (CQty = 1; CQty <= CPack.Quantity; CQty++) { CItem = CRandom.GetItems(); result.Add(new Dictionary <uint, byte> { { CItem.TypeId, (byte)CItem.RareType } }); } return(result); } finally { CRandom = null; } }