public override void OnResponse(Mobile from, string text) { bool invalid = false; // Pattern match for invalid characters Regex InvalidPatt = new Regex("[^0-9]"); if (InvalidPatt.IsMatch(text)) { invalid = true; } else if (text.Length > 3) { invalid = true; } else if (Convert.ToInt16(text) > 255 || Convert.ToInt16(text) < 1) { invalid = true; } if (invalid == true) { // Invalid chars from.SendMessage("You may only use numbers (1-255) to define indexes."); from.SendMessage("Please enter a number instead :"); from.Prompt = new IndexPrompt(state, from, RareFactory.ViewingDOD); } else { // The property we set + whether we send an additional prompt // is dependent on our entry state switch (state) { case 0: { m_DODInst.StartIndex = Convert.ToInt16(text); from.SendMessage("Please enter the 'Last Index' of the rare : "); from.Prompt = new IndexPrompt(((short)(state + 1)), from, m_DODInst); break; } case 1: { m_DODInst.LastIndex = Convert.ToInt16(text); from.SendMessage("Please enter the 'Start Date' of the rare : "); from.Prompt = new DatePrompt(((short)0), from, m_DODInst); break; } } // Update their display RareFactory.ReloadViews(from); } }
public override void OnResponse(Mobile from, string text) { // Pattern match for invalid characters Regex InvalidPatt = new Regex("[^-a-zA-Z0-9' ]"); DateTime resDateTime = new DateTime(); try { resDateTime = Convert.ToDateTime(text); } catch (Exception e) { from.SendMessage("You must use a valid date/time format."); from.SendMessage("Please re-enter in the format <DD/MM/YYYY HH:MM:SS> :"); from.Prompt = new DatePrompt(state, from, RareFactory.ViewingDOD); LogHelper.LogException(e); return; } try { // The property we set + whether we send an additional prompt // is dependent on our entry state switch (state) { case 0: { m_DODInst.StartDate = Convert.ToDateTime(text); from.SendMessage("Please enter the 'End Date' of the rare : "); from.Prompt = new DatePrompt(((short)(state + 1)), from, m_DODInst); break; } case 1: { m_DODInst.EndDate = Convert.ToDateTime(text); from.SendMessage("Sucessfully defined new rare '" + m_DODInst.Name + "'!"); break; } } } catch (Exception e) { // Console.WriteLine("RFControlGump() : Caught exception trying to set date properties : {0}", e); LogHelper.LogException(e); } // Update their display RareFactory.ReloadViews(from); }
public override void OnResponse(Mobile from, string text) { if (text.ToLower() == "y") { RareFactory.ViewingDOD.Expire(); if (RareFactory.ViewingDODIndex > 0) { RareFactory.ViewingDODIndex -= 1; } } else { from.SendMessage("Rare deletion cancelled."); } RareFactory.ReloadViews(from); }
public override void OnResponse(Mobile from, string text) { if (text.ToLower() == "y") { // Delete all the DOD instances first DODGroup dg = (DODGroup)RareFactory.DODGroup[m_idg]; for (int i = 0; i < dg.DODInst.Count; i++) { string sName = ""; if (dg.DODInst[i] is DODInstance) { sName = ((DODInstance)dg.DODInst[i]).Name; } from.SendMessage("Deleting rare '{0}'...", sName); for (int inst = 0; inst < RareFactory.DODInst.Count; inst++) { if (((DODInstance)RareFactory.DODInst[inst]) == dg.DODInst[i]) { // There should never be more than one of these right? RareFactory.DODInst.RemoveAt(inst); break; } } } from.SendMessage("Deleting group '{0}'", dg.Name); RareFactory.DODGroup.RemoveAt(m_idg); from.SendMessage("Rare group deletion complete."); if (RareFactory.ViewingDODGroupIndex > 0) { RareFactory.ViewingDODGroupIndex -= 1; } } else { from.SendMessage("Rare group deletion cancelled."); } RareFactory.ReloadViews(from); }
public override void OnResponse(Mobile from, string text) { // Pattern match for invalid characters Regex InvalidPatt = new Regex("[^-a-zA-Z0-9' ]"); if (InvalidPatt.IsMatch(text) || text.Length < 1 || text.Length > 15) { // Invalid chars from.SendMessage("You may only use numbers, letters, apostrophes, hyphens and spaces (1-15 characters)."); from.SendMessage("Please re-enter an allowed name :"); from.Prompt = new RareNamePrompt(from, RareFactory.ViewingDOD); } else { m_DODInst.Name = text; from.SendMessage("Please enter the 'Start Index' of the rare :"); from.Prompt = new IndexPrompt(0, from, m_DODInst); // Update their display RareFactory.ReloadViews(from); } }
public override void OnResponse(NetState state, RelayInfo info) { Mobile from = state.Mobile; switch ((RFButtons)info.ButtonID) { case RFButtons.AddRareButton: { // Make sure a group has been defined (if one has, one will be // selected by default - group 0) if (RareFactory.DODGroup.Count == 0) { from.SendMessage("You must define a Dynamic Object Definition Group before adding rares."); break; } from.SendMessage("Select the item you wish to use as a template for this rare..."); from.Target = new RareTarget(); break; } case RFButtons.DelRareButton: { if (RareFactory.ViewingDODGroup.DODInst.Count == 0) { from.SendMessage("There are no rares to delete!"); break; } from.SendMessage("Are you sure you wish to delete this rare? (y/n)"); from.Prompt = new DelConfirmPrompt(from); break; } case RFButtons.NextRareButton: { if (RareFactory.DODGroup.Count == 0) { from.SendMessage("No rares defined!"); break; } // The .ViewingDODIndex references the relative index // within this particular DODGroup DODGroup dg = (DODGroup)RareFactory.DODGroup[RareFactory.ViewingDODGroupIndex]; if ((RareFactory.ViewingDODIndex + 1) >= dg.DODInst.Count) { from.SendMessage("Last rare in group!"); break; } else { RareFactory.ViewingDODIndex++; break; } } case RFButtons.PrevRareButton: { if (RareFactory.DODGroup.Count == 0) { from.SendMessage("No rares defined!"); break; } // The .ViewingDODIndex references the relative index // within this particular DODGroup if (RareFactory.ViewingDODIndex == 0) { from.SendMessage("First rare in group!"); break; } else { RareFactory.ViewingDODIndex--; break; } } case RFButtons.TestButton: { if (RareFactory.DODGroup.Count == 0) { from.SendMessage("Define Dynamic Object Definition Groups and objects (rares) before attempting to generate test batches."); break; } if (((DODGroup)RareFactory.DODGroup[RareFactory.ViewingDODGroupIndex]).DODInst.Count == 0) { from.SendMessage("You must add rares to the group before attempting to generate test batches."); break; } int prevCur = RareFactory.ViewingDOD.CurIndex; // Generates a complete set of rares as a test from.SendMessage("Generating example rare set..."); for (int i = RareFactory.ViewingDOD.StartIndex; i <= RareFactory.ViewingDOD.LastIndex; i++) { // Create a new item DODInstance dodi = RareFactory.ViewingDOD; Item newitem = RareFactory.DupeItem(dodi.RareTemplate); newitem.Movable = true; dodi.CurIndex = (short)i; dodi.DynamicFill(newitem); from.AddToBackpack(newitem); } RareFactory.ViewingDOD.CurIndex = (short)prevCur; from.SendMessage("Completed. {0} rares generated and added to your backpack.", (RareFactory.ViewingDOD.LastIndex - RareFactory.ViewingDOD.StartIndex) + 1); break; } default: { return; } } RareFactory.ReloadViews(from); }
public override void OnResponse(NetState state, RelayInfo info) { Mobile from = state.Mobile; // Console.WriteLine("Group button {0} pressed", info.ButtonID); switch (info.ButtonID) { case 0: { return; } case 1: { RareFactory.ReloadViews(from); from.SendGump(new RFNewGroupGump("", 0)); /* * from.SendMessage("Enter name for new rare group :"); * from.Prompt = new GroupNamePrompt(from); */ return; } case 2: { // Next Page if (curPage == numPages) { from.SendMessage("You are already viewing the last page of DOD groups."); break; } curPage++; break; } case 3: { // Prev Page if (curPage == 0) { from.SendMessage("You are already viewing the first page of DOD groups."); break; } curPage--; break; } default: { // Work out whether we're deleting or selecting and // act accordingly // 1 - view, 2 - delete etc. (odd = view, even = delete) if (info.ButtonID % 2 > 0) { // odd, so we're deleting int grpNum = (((info.ButtonID + 1) / 2) - 3); from.SendMessage(string.Format("Are you sure you wish to delete rare group '{0}' and all associated rares? (y/n)", ((DODGroup)RareFactory.DODGroup[grpNum]).Name)); from.Prompt = new GrpDelConfirmPrompt(from, (short)grpNum); break; } else { // even, so we're viewing int grpNum = ((info.ButtonID / 2) - 2); RareFactory.ViewingDODGroupIndex = grpNum; } break; } } RareFactory.ViewingDODGroupPage = curPage; RareFactory.ReloadViews(from); }
public override void OnResponse(NetState state, RelayInfo info) { Mobile from = state.Mobile; switch (info.ButtonID) { case 0: { // Close this gump return; } case 1: { // Raise rarity if (m_RarityLevel >= 10) { from.SendMessage("Maximum rarity level is 10 (most unique)"); break; } m_RarityLevel++; break; } case 2: { // Lower rarity if (m_RarityLevel == 0) { from.SendMessage("Minimum rarity level is 0 (most common)"); break; } m_RarityLevel--; break; } case 3: { // Make sure they've specified a name :P if (m_GroupName == "") { from.SendMessage("You must specify a group name to identify this group by!"); break; } // Now make sure that the name doesn't already exist :) if (RareFactory.DODGroup.Count > 0) { for (int i = 0; i < RareFactory.DODGroup.Count; i++) { DODGroup dg = (DODGroup)RareFactory.DODGroup[i]; if (dg.Name == m_GroupName) { // Don't bother with the rest of this code - they messed up! from.SendMessage("DOD Group names must be unique - the name you have chosen already exists! Please try again."); break; } } } // Accept + create RareFactory.DODGroup.Add(new DODGroup(m_GroupName, m_RarityLevel)); // Update their display RareFactory.ReloadViews(from); return; } case 4: { // Cancel the whole thing return; } case 5: { // Set the group name from.SendMessage("Enter the name you wish to use to represent this group of rares :"); from.Prompt = new GroupNamePrompt(from, this); return; } default: { break; } } Refresh(from); }