public static GiftCode GenerateRandom(XmlData data, int minGold=0, int maxGold=10000, int minFame=0, int maxFame=10000, int minCharSlots=0, int maxCharSlots=4, int minVaultChests=0, int maxVaultChests=4, int maxItemStack=10, int minItemStack=1, int maxItemTypes=10, int minItemTypes=1) { var rand = new Random(); var ret = new GiftCode(); var types = rand.Next(minItemTypes, maxItemTypes); var c = rand.Next(minItemStack, maxItemStack); for (var i = 0; i < types; i++) { var t = data.Items.ElementAt(rand.Next(0, data.Items.Count)).Key; for (var j = 0; j < c; j++) ret.Gifts.Add(t); c = rand.Next(minItemStack, maxItemStack); } ret.CharSlots = rand.Next(minCharSlots, maxCharSlots); ret.VaultChests = rand.Next(minVaultChests, maxVaultChests); ret.Gold = rand.Next(minGold, maxGold); ret.Fame = rand.Next(minFame, maxFame); return ret; }
public static GiftCode GenerateRandom(XmlData data, int minGold = 0, int maxGold = 10000, int minFame = 0, int maxFame = 10000, int minCharSlots = 0, int maxCharSlots = 4, int minVaultChests = 0, int maxVaultChests = 4, int maxItemStack = 10, int minItemStack = 1, int maxItemTypes = 10, int minItemTypes = 1) { var rand = new Random(); var ret = new GiftCode(); var types = rand.Next(minItemTypes, maxItemTypes); var c = rand.Next(minItemStack, maxItemStack); for (var i = 0; i < types; i++) { var t = data.Items.ElementAt(rand.Next(0, data.Items.Count)).Key; for (var j = 0; j < c; j++) ret.Gifts.Add(t); c = rand.Next(minItemStack, maxItemStack); } ret.CharSlots = rand.Next(minCharSlots, maxCharSlots); ret.VaultChests = rand.Next(minVaultChests, maxVaultChests); ret.Gold = rand.Next(minGold, maxGold); ret.Fame = rand.Next(minFame, maxFame); return ret; }
private void AddGiftCode(GiftCode code) { Manager.Database.DoActionAsync(db => { var key = db.GenerateGiftcode(code.ToJson(), Account.AccountId); //var message = new MailMessage(); //message.To.Add(Account.Email); //message.IsBodyHtml = true; //message.Subject = "You received a new GiftCode"; //message.From = new MailAddress(Program.Settings.GetValue<string>("serverEmail", "")); //message.Body = "<center>Your giftcode is: " + code + "</br> Check the items in your giftcode <a href=\"" + Program.Settings.GetValue<string>("serverDomain", "localhost") + "/CheckGiftCode.html\" target=\"_blank\">here</a> or redeem the code <a href=\"" + Program.Settings.GetValue<string>("serverDomain", "localhost") + "/RedeemGiftCode.html\" target=\"_blank\">here</a></center>"; //Program.SendEmail(message); Player.SendInfo($"You have received a new GiftCode: {key}\nRedeem it at: {Program.Settings.GetValue("serverDomain")}/GiftCode.html or\n type /giftcode to scan it with your mobile via qr code"); }); }
private void AddGiftCode(GiftCode code, string type = "random") { Manager.Database.DoActionAsync(db => { var key = db.GenerateGiftcode(code.ToJson(), Account.AccountId); Player.SendInfo($"You have received a new GiftCode: {key}\nRedeem it at: {Program.Settings.GetValue("serverDomain")}/GiftCode.html or\n type /giftcode to scan it with your mobile via qr code"); }); }