public static void RunStats(MT19337 rng, IItemPlacementFlags flags, IncentiveData incentivesData, ItemShopSlot caravanItemLocation, OverworldMap overworldMap) { Dictionary <MapLocation, Tuple <List <MapChange>, AccessRequirement> > fullLocationRequirements = overworldMap.FullLocationRequirements; var placedItems = new List <IRewardSource>(); var treasurePool = ItemLocations.AllTreasures.Where(x => !x.IsUnused).Select(x => x.Item) .Concat(ItemLists.AllNonTreasureChestItems).ToList(); var requirementChecks = ItemLists.AllQuestItems.ToDictionary(x => x, x => 0); requirementChecks[Item.Ribbon] = 0; var requirementsToCheck = new List <Item> { Item.Crown, Item.Crystal, Item.Herb, Item.Tnt, Item.Adamant, Item.Slab, Item.Ruby, Item.Bottle, Item.Floater, Item.Ship, Item.Bridge, Item.Canal }; const int maxIterations = 255; var forcedIceCount = 0; var itemPlacementStats = ItemLists.AllQuestItems.ToDictionary(x => x, x => new List <int>()); itemPlacementStats[Item.Ribbon] = new List <int>(); var itemPlacementZones = ItemLists.AllQuestItems.ToDictionary(x => x, x => new List <string>()); itemPlacementZones[Item.Ribbon] = new List <string>(); long iterations = 0; var timeElapsed = new Stopwatch(); while (iterations < maxIterations) { iterations++; // When Enemy Status Shuffle is turned on Coneria is reduced to 11% chance with other shops spliting the remaining 89% var shopTownSelected = ItemShops.PickRandom(rng); var itemShopItem = new ItemShopSlot(ItemLocations.CaravanItemShop1.Address, $"{Enum.GetName(typeof(MapLocation), shopTownSelected)}Shop", shopTownSelected, Item.Bottle); timeElapsed.Start(); placedItems = ItemPlacement.PlaceSaneItems(rng, flags, incentivesData, treasurePool, itemShopItem, overworldMap); timeElapsed.Stop(); var outputIndexes = placedItems.ToLookup(x => x.Item, x => x); foreach (Item item in itemPlacementStats.Keys) { itemPlacementStats[item].AddRange(outputIndexes[item].Select(x => x.Address).ToList()); } var outputZones = placedItems .ToLookup(x => x.Item, x => Enum.GetName(typeof(MapLocation), x.MapLocation)); foreach (Item item in itemPlacementZones.Keys) { if (!outputZones[item].Any()) { continue; } itemPlacementZones[item].AddRange(outputZones[item]); } var matoyaShip = placedItems.Any(x => x.Address == ItemLocations.Matoya.Address && x.Item == Item.Ship); var crystalIceCave = placedItems.Any(x => x.Item == Item.Crystal && x.Address >= ItemLocations.IceCave1.Address && x.Address <= ItemLocations.IceCaveMajor.Address); var keyIceCave = placedItems.Any(x => x.Item == Item.Key && x.Address >= ItemLocations.IceCave1.Address && x.Address <= ItemLocations.IceCaveMajor.Address); var keyLockedCrystal = placedItems.Any(x => x.Item == Item.Crystal && x.AccessRequirement.HasFlag(AccessRequirement.Key)); var keyLockedShip = placedItems.Any(x => x.Item == Item.Ship && x.AccessRequirement.HasFlag(AccessRequirement.Key)); if ((keyLockedShip && keyIceCave) || (matoyaShip && crystalIceCave) || (matoyaShip && keyLockedCrystal && keyIceCave)) { forcedIceCount++; } foreach (Item item in requirementsToCheck) { if (!ItemPlacement.CheckSanity(placedItems.Where(x => x.Item != item).ToList(), fullLocationRequirements, new Flags { OnlyRequireGameIsBeatable = true })) { requirementChecks[item]++; } } } if (iterations > 10) { Debug.WriteLine(PrintStats(maxIterations, itemPlacementStats, itemPlacementZones, requirementChecks)); Debug.WriteLine($"Forced Early Ice Cave for Ship: {forcedIceCount} out of {maxIterations}"); Debug.WriteLine($"Time per iteration: {1.0 * timeElapsed.ElapsedMilliseconds / iterations}"); } }
public static void RunStats(MT19337 rng, ITreasureShuffleFlags flags, IncentiveData incentivesData) { var forcedItems = ItemLocations.AllOtherItemLocations.ToList(); if (!flags.NPCItems) { forcedItems = ItemLocations.AllNonTreasureItemLocations.ToList(); } var placedItems = new List <IRewardSource>(); var treasurePool = ItemLocations.AllTreasures.Where(x => !x.IsUnused).Select(x => x.Item).ToList(); var requirementChecks = ItemLists.AllQuestItems.ToDictionary(x => x, x => 0); requirementChecks[Item.Ribbon] = 0; var requirementsToCheck = new List <Item> { Item.Crown, Item.Crystal, Item.Herb, Item.Tnt, Item.Adamant, Item.Slab, Item.Ruby, Item.Bottle, Item.Canal }; const int maxIterations = 10000; var forcedIceCount = 0; var itemPlacementStats = ItemLists.AllQuestItems.ToDictionary(x => x, x => new List <int>()); itemPlacementStats[Item.Ribbon] = new List <int>(); var itemPlacementZones = ItemLists.AllQuestItems.ToDictionary(x => x, x => new List <string>()); itemPlacementZones[Item.Ribbon] = new List <string>(); var mapLocationRequirements = ItemLocations.MapLocationRequirements.ToDictionary(x => x.Key, x => x.Value.ToList()); long iterations = 0; while (iterations < maxIterations) { iterations++; // When Enemy Status Shuffle is turned on Coneria is reduced to 11% chance with other shops spliting the remaining 89% var shopTownSelected = ItemShops.PickRandom(rng); var itemShopItem = new ItemShopSlot(ItemLocations.CaravanItemShop1.Address, $"{Enum.GetName(typeof(MapLocation), shopTownSelected)}Shop", shopTownSelected, Item.Bottle); placedItems = ItemPlacement.PlaceSaneItems(rng, flags, incentivesData, treasurePool, itemShopItem, mapLocationRequirements); var outputIndexes = placedItems.ToLookup(x => x.Item, x => x); foreach (Item item in itemPlacementStats.Keys) { itemPlacementStats[item].AddRange(outputIndexes[item].Select(x => x.Address).ToList()); } var outputZones = placedItems .ToLookup(x => x.Item, x => Enum.GetName(typeof(MapLocation), x.MapLocation)); foreach (Item item in itemPlacementZones.Keys) { if (!outputZones[item].Any()) { continue; } itemPlacementZones[item].AddRange(outputZones[item]); } var matoyaShip = placedItems.Any(x => x.Address == ItemLocations.Matoya.Address && x.Item == Item.Ship); var crystalIceCave = placedItems.Any(x => x.Item == Item.Crystal && x.Address >= ItemLocations.IceCave1.Address && x.Address <= ItemLocations.IceCaveMajor.Address); var keyIceCave = placedItems.Any(x => x.Item == Item.Key && x.Address >= ItemLocations.IceCave1.Address && x.Address <= ItemLocations.IceCaveMajor.Address); var keyLockedCrystal = placedItems.Any(x => x.Item == Item.Crystal && x.AccessRequirement.HasFlag(AccessRequirement.Key)); var keyLockedShip = placedItems.Any(x => x.Item == Item.Ship && x.AccessRequirement.HasFlag(AccessRequirement.Key)); if ((keyLockedShip && keyIceCave) || (matoyaShip && crystalIceCave) || (matoyaShip && keyLockedCrystal && keyIceCave)) { forcedIceCount++; } foreach (Item item in requirementsToCheck) { if (!ItemPlacement.CheckSanity(placedItems.Where(x => x.Item != item).ToList(), flags, mapLocationRequirements)) { requirementChecks[item]++; } } } if (iterations > 10) { Debug.WriteLine(PrintStats(maxIterations, itemPlacementStats, itemPlacementZones, requirementChecks)); Debug.WriteLine($"Forced Early Ice Cave for Ship: {forcedIceCount} out of {maxIterations}"); } }
public int updateEmailtrackerIncentive(string p1, string p2, EmailDetails details, IncentiveData obj3, string AuthorName1) { try { return(obj.updateEmailtrackerIncentive(p1, p2, details, obj3, AuthorName1)); } catch (Exception ex) { throw ex; } }
private void SendMail() { EmailDetails details = new EmailDetails(); IncentiveBusiness b = new IncentiveBusiness(); SendMailObject obj = new SendMailObject(); Business e = new Business(); try { bool resultv = false; int rowIndex = 0; string emailid = null; details.Module = "IPE"; string AuthorName = null; string Isstudent = null; details.EmailSubject = "Incentive Point Adjustment"; string empcode = txtboxMemberId.Text; string type = e.selectMemberType(empcode, txtReferenceId.Text); if (type == "M") { //Isstudent = "N"; emailid = b.SelectAuthorEmailId(empcode); AuthorName = b.SelectAuthorName(empcode); Session["AuthorName"] = AuthorName; if (emailid == "") { int result; //string AuthorName; AuthorName = b.SelectAuthorName(empcode); result = e.insertEmailtrackerIncentive(AuthorName, details, txtReferenceId.Text); } } else { //Isstudent = "S"; emailid = b.SelectStudentEmailId(empcode, txtReferenceId.Text); AuthorName = b.SelectStudentAuthorName(empcode, txtReferenceId.Text); Session["AuthorName"] = AuthorName; if (emailid == "") { int result; AuthorName = b.SelectStudentAuthorName(empcode, txtReferenceId.Text); result = e.insertEmailtrackerIncentive(AuthorName, details, txtReferenceId.Text); //Session["AuthorName"] = AuthorName; } } details.FromEmail = ConfigurationManager.AppSettings["FromAddress"].ToString(); if (emailid != "") { details.ToEmail = emailid; } string hremailid = b.SelectHRMailID(empcode, type, txtReferenceId.Text); string InstWiseHRMailid = b.SelectInstwiseHRMailid(empcode, type, txtReferenceId.Text); if (details.ToEmail != null && details.ToEmail != "") { if (InstWiseHRMailid != null) { if (InstWiseHRMailid != "") { if (details.ToEmail != null) { details.ToEmail = details.ToEmail + "," + InstWiseHRMailid; } else { details.ToEmail = InstWiseHRMailid; } } else { // details.ToEmail = details.ToEmail; } } else { // details.ToEmail = details.ToEmail; } } else { if (InstWiseHRMailid != null) { if (InstWiseHRMailid != "") { if (details.ToEmail != null) { details.ToEmail = InstWiseHRMailid; } else { details.ToEmail = InstWiseHRMailid; } } else { // details.ToEmail = details.ToEmail; } } else { // details.ToEmail = details.ToEmail; } } ArrayList list = new ArrayList(); list = b.SelectHODMailid(empcode, type, txtReferenceId.Text); for (int j = 0; j < list.Count; j++) { if (j == 0) { if (list[j].ToString() != "") { details.HODmailid = list[j].ToString(); } } else { if (list[j].ToString() != "") { details.HODmailid = details.HODmailid + ',' + list[j].ToString(); } } } if (details.ToEmail != null && details.ToEmail != "") { if (hremailid != null) { if (hremailid != "") { details.ToEmail = details.ToEmail + "," + hremailid; } else { // details.ToEmail = details.ToEmail; } } else { // details.ToEmail = details.ToEmail; } } else { if (hremailid != null) { if (hremailid != "") { details.ToEmail = hremailid; } else { // details.ToEmail = details.ToEmail; } } else { // details.ToEmail = details.ToEmail; } } if (details.ToEmail != null && details.ToEmail != "") { if (details.HODmailid != null) { if (details.HODmailid != "") { details.ToEmail = details.ToEmail + "," + details.HODmailid; //details.ToEmail = details.ToEmail + "," + hremailid + "," + details.HODmailid; } else { //details.ToEmail = details.ToEmail; } } else { //details.ToEmail = details.ToEmail; } } else { if (details.HODmailid != null) { if (details.HODmailid != "") { details.ToEmail = details.HODmailid; //details.ToEmail = details.ToEmail + "," + hremailid + "," + details.HODmailid; } else { //details.ToEmail = details.ToEmail; } } else { //details.ToEmail = details.ToEmail; } } // details.CCEmail = hremailid; // details.CCEmail = Session["emailId"].ToString(); details.Module = "IPE"; details.EmailSubject = "Incentive Point Adjustment"; //details.Type = DropDownListPublicationEntry.SelectedValue; details.Id = txtReferenceId.Text; string FooterText = ConfigurationManager.AppSettings["FooterText"].ToString(); string isStudent = Session["IsStudent"].ToString(); if (isStudent == "Y") { if (type == "S") { details.MsgBody = "<span style=\"font-size: 10pt; color: #3300cc; font-family: Verdana\"><h4>Dear Sir/Madam,</h4> <br>" + "<p>For Certificate of Appreciation and encashment of research incentive points, request you to contact student research section of your institution/department along with the Bank detail form available in RMS Portal.</p>" + "<b>Incentive points with the rating : " + txtTotalPoint.Text + "" + Session["Numbertype"].ToString() + "<br>" + "<br>" + "Author Name : " + Session["AuthorName"].ToString() + "<br>" + "Publication Id : " + txtReferenceId.Text + "<br>" + "Article Name :" + Session["Title"].ToString() + "<br>" + "<br>" + FooterText + " </b><br><b> </b></span>"; } else { details.MsgBody = "<span style=\"font-size: 10pt; color: #3300cc; font-family: Verdana\"><h4>Dear Sir/Madam,</h4> <br>" + //"<b> Incentive points with the rating '" + total.Text + "' added. <br> " + "<b>Incentive points with the rating : " + txtTotalPoint.Text + " " + Session["Numbertype"].ToString() + "<br>" + "<br>" + "Author Name : " + Session["AuthorName"].ToString() + "<br>" + "Publication Id : " + txtReferenceId.Text + "<br>" + "Article Name :" + Session["Title"].ToString() + "<br>" + "<br>" + FooterText + " </b><br><b> </b></span>"; } } else { if (type == "S") { details.MsgBody = "<span style=\"font-size: 10pt; color: #3300cc; font-family: Verdana\"><h4>Dear Sir/Madam,</h4> <br>" + "<p>For encashment of research incentive points, request you to contact student research section of your institution/department along with the Bank detail form available in RMS Portal.</p>" + "<b>Incentive points with the rating : " + txtTotalPoint.Text + " " + Session["Numbertype"].ToString() + "<br>" + //"<b> Incentive points with the rating '" + total.Text + "' added. <br> " + "<br>" + "Author Name : " + Session["AuthorName"].ToString() + "<br>" + "Publication Id : " + txtReferenceId.Text + "<br>" + "Article Name :" + Session["Title"].ToString() + "<br>" + "<br>" + FooterText + " </b><br><b> </b></span>"; } else { details.MsgBody = "<span style=\"font-size: 10pt; color: #3300cc; font-family: Verdana\"><h4>Dear Sir/Madam,</h4> <br>" + //"<b> Incentive points with the rating '" + total.Text + "' added. <br> " + "<b>Incentive points with the rating : " + txtTotalPoint.Text + " " + Session["Numbertype"].ToString() + "<br>" + "<br>" + "Author Name : " + Session["AuthorName"].ToString() + "<br>" + "Publication Id : " + txtReferenceId.Text + "<br>" + "Article Name :" + Session["Title"].ToString() + "<br>" + "<br>" + FooterText + " </b><br><b> </b></span>"; } } if (details.ToEmail != "" && details.ToEmail != null) { resultv = obj.InsertIntoEmailQueue(details); } IncentiveData obj3 = new IncentiveData(); IncentiveBusiness C = new IncentiveBusiness(); if (emailid == "") { string AuthorName1 = Session["AuthorName"].ToString(); obj3 = C.CheckUniqueIdIncentive(txtReferenceId.Text, "JA", details); int data = C.updateEmailtrackerIncentive(txtReferenceId.Text, "JA", details, obj3, AuthorName1); } if (resultv == true) { string CloseWindow1 = "alert('Mail Sent successfully')"; ScriptManager.RegisterStartupScript(this, this.GetType(), "newWindow", CloseWindow1, true); } else { string CloseWindow1 = "alert('Problem while sending mail')"; ScriptManager.RegisterStartupScript(this, this.GetType(), "newWindow", CloseWindow1, true); } } catch (Exception ex) { string CloseWindow1 = "alert('Problem while sending mail')"; ScriptManager.RegisterStartupScript(this, this.GetType(), "newWindow", CloseWindow1, true); log.Error(ex.Message); log.Error(ex.StackTrace); } }