public static BountyBoardEntry AddEntry(Mobile Owner, Mobile Wanted, int price, DateTime expireTime) { foreach (BountyBoardEntry entry in m_Entries) { if (entry.Owner == Owner && entry.Wanted == Wanted) { entry.Price += price; entry.ExpireTime = expireTime; return(entry); } } BountyBoardEntry be = new BountyBoardEntry(Owner, Wanted, price, expireTime); m_Entries.Add(be); ArrayList instances = BountyBoard.Instances; for (int i = 0; i < instances.Count; ++i) { ((BountyBoard)instances[i]).InvalidateProperties(); } return(be); }
public int Compare(object x, object y) { if (x == null && y == null) { return(0); } else if (x == null) { return(-1); } else if (y == null) { return(1); } BountyBoardEntry a = x as BountyBoardEntry; BountyBoardEntry b = y as BountyBoardEntry; if (a == null || b == null) { throw new ArgumentException(); } int result = 0; switch (m_SortType) { case SortType.Price: { result = b.Price.CompareTo(a.Price); // result = a.Price.CompareTo( b.Price ); break; } case SortType.Owner: { result = a.Owner.Name.CompareTo(b.Owner.Name); break; } case SortType.Wanted: { result = a.Wanted.Name.CompareTo(b.Wanted.Name); break; } case SortType.Expires: { result = a.ExpireTime.CompareTo(b.ExpireTime); break; } } return(result); }
public static void AddEntry(BountyBoardEntry be) { m_Entries.Add(be); ArrayList instances = BountyBoard.Instances; for (int i = 0; i < instances.Count; ++i) { ((BountyBoard)instances[i]).InvalidateProperties(); } }
public static void RemoveEntry(BountyBoardEntry be, bool refund) { m_Entries.Remove(be); ArrayList instances = BountyBoard.Instances; for (int i = 0; i < instances.Count; ++i) { ((BountyBoard)instances[i]).InvalidateProperties(); } if (refund && be.Owner != null) { string msg = String.Format("Your bounty in the amount of {0} on {1}'s head has ended.", be.Price, be.Wanted.Name); if (NetState.Instances.Contains(be.Owner.NetState)) { be.Owner.SendMessage(msg); } else { ((PlayerMobile)be.Owner).ShowBountyUpdate = true; ((PlayerMobile)be.Owner).BountyUpdateList.Add(msg); } if (Banker.Deposit(be.Owner, be.Price)) { be.Owner.SendLocalizedMessage(1060397, be.Price.ToString()); // ~1_AMOUNT~ gold has been deposited into your bank box. } else { be.Owner.AddToBackpack(new Gold(be.Price)); be.Owner.SendMessage("The bounty of {0} has been added to your backpack.", be.Price); } } else if (be.Owner != null) { string msg = String.Format("Your bounty in the amount of {0} on {1}'s head has been claimed.", be.Price, be.Wanted.Name); if (NetState.Instances.Contains(be.Owner.NetState)) { be.Owner.SendMessage(msg); } else { ((PlayerMobile)be.Owner).ShowBountyUpdate = true; ((PlayerMobile)be.Owner).BountyUpdateList.Add(msg); } } NotifyBountyEnd(be); }
public static void NotifyBountyEnd(BountyBoardEntry be) { foreach (PlayerMobile player in be.Accepted) { string msg = String.Format("The bounty hunt on {0}'s head is over.", be.Wanted.Name); if (NetState.Instances.Contains(player.NetState)) { player.SendMessage(msg); } else { player.ShowBountyUpdate = true; player.BountyUpdateList.Add(msg); } } }
public static bool hasBounty(Mobile claimer, Mobile killer, out BountyBoardEntry bountyEntry, out bool canClaim) { bountyEntry = null; canClaim = false; DateTime expireTime = DateTime.MaxValue; bool hasBounty = false; foreach (BountyBoardEntry entry in m_Entries) { if (entry.Wanted == killer) { hasBounty = true; canClaim = entry.Accepted.Contains(claimer); if (/*canClaim &&*/ entry.ExpireTime < expireTime) // crash bugfix { bountyEntry = entry; expireTime = entry.ExpireTime; } } } return(hasBounty); }
public static void saveGlobalList( WorldSaveEventArgs e ) { if( !System.IO.File.Exists( xmlSchema ) ) { Console.WriteLine( "Could not open {0}.", xmlSchema ); Console.WriteLine( "{0} must be in .\\Data\\Bounty System", xmlSchema ); Console.WriteLine( "Cannot save bounties." ); return; } if( System.IO.File.Exists(xmlFileBackup) ) System.IO.File.Delete(xmlFileBackup); if( System.IO.File.Exists( xmlFile ) ) { System.IO.File.Move(xmlFile, xmlFileBackup); } DataSet ds = new DataSet(); ds.ReadXmlSchema( xmlSchema ); DataRow bountyRow, OwnerRow, WantedRow, requestedRow, acceptedRow; try { var entries = new BountyBoardEntry[m_Entries.Count]; m_Entries.CopyTo(entries); foreach (BountyBoardEntry entry in m_Entries) { if (entry == null) continue; if (entry.Owner == null || entry.Owner.Deleted) continue; if (entry.Wanted == null || entry.Wanted.Deleted) { BountyBoard.RemoveEntry(entry, true); continue; } bountyRow = ds.Tables["Bounty"].NewRow(); bountyRow["Price"] = entry.Price; bountyRow["ExpireTime"] = entry.ExpireTime; ds.Tables["Bounty"].Rows.Add(bountyRow); OwnerRow = ds.Tables["Owner"].NewRow(); OwnerRow["Name"] = entry.Owner.Name; OwnerRow["Serial"] = entry.Owner.Serial.Value; OwnerRow.SetParentRow(bountyRow, ds.Relations["Bounty_Owner"]); ds.Tables["Owner"].Rows.Add(OwnerRow); WantedRow = ds.Tables["Wanted"].NewRow(); WantedRow["Name"] = entry.Wanted.Name; WantedRow["Serial"] = entry.Wanted.Serial.Value; WantedRow.SetParentRow(bountyRow, ds.Relations["Bounty_Wanted"]); ds.Tables["Wanted"].Rows.Add(WantedRow); foreach (Mobile requested in entry.Requested) { if (requested == null || requested.Deleted) continue; requestedRow = ds.Tables["Requested"].NewRow(); requestedRow["Name"] = requested.Name; requestedRow["Serial"] = requested.Serial.Value; requestedRow.SetParentRow(bountyRow, ds.Relations["Bounty_Requested"]); ds.Tables["Requested"].Rows.Add(requestedRow); } foreach (Mobile accepted in entry.Accepted) { if (accepted == null || accepted.Deleted) continue; acceptedRow = ds.Tables["Accepted"].NewRow(); acceptedRow["Name"] = accepted.Name; acceptedRow["Serial"] = accepted.Serial.Value; acceptedRow.SetParentRow(bountyRow, ds.Relations["Bounty_Accepted"]); ds.Tables["Accepted"].Rows.Add(acceptedRow); } ds.WriteXml(xmlFile); } } catch (Exception exception) { Console.WriteLine(exception); } }
public BountyBoardGump(Mobile from, BountyBoard board, int page, ArrayList list, SortType sortType) : base(0, 24) { from.CloseGump(typeof(BountyBoardGump)); from.CloseGump(typeof(EditBountyGump)); m_From = from; m_Board = board; m_Page = page; m_SortType = sortType; if (list == null) { list = new ArrayList(); for (int i = BountyBoard.Entries.Count - 1; BountyBoard.Entries != null && i >= 0; --i) { if (i >= BountyBoard.Entries.Count) { continue; } BountyBoardEntry entry = (BountyBoardEntry)BountyBoard.Entries[i]; if (entry.Expired) { BountyBoard.RemoveEntry(entry, true); } else { list.Add(entry); } } } if (m_SortType != SortType.None) { list.Sort(new InternalSorter(m_SortType)); } m_List = list; int index = GetIndexForPage(page); int count = 10; int tableIndex = 0; AddPage(0); AddBackground(10, 10, 750, 439, 5054); AddImageTiled(18, 20, 733, 420, 2624); AddImageTiled(18, 64, 46, 352, 1416); // remove AddImageTiled(67, 64, 170, 352, 200); // wanted AddImageTiled(240, 64, 170, 352, 1416); // owner AddImageTiled(413, 64, 65, 352, 200); // price AddImageTiled(481, 64, 30, 352, 1416); // edit AddImageTiled(514, 64, 60, 352, 200); // request AddImageTiled(577, 64, 170, 352, 200); // Expires for (int i = index; i < (index + count) && i >= 0 && i < list.Count; ++i) { object obj = list[i]; AddImageTiled(24, 94 + (tableIndex * 32), 723, 2, 2624); ++tableIndex; } // alpha plus four corners AddAlphaRegion(18, 20, 733, 420); AddImage(5, 5, 10460); AddImage(735, 5, 10460); AddImage(5, 424, 10460); AddImage(735, 424, 10460); //text AddHtmlLocalized(22, 64, 200, 32, 1011403, HtmlColor, false, false); // Remove AddButton(120, 67, 2117, 2118, 1, GumpButtonType.Reply, 0); // wanted sort AddHtml(70, 64, 200, 32, Color("Wanted", HtmlColor), false, false); AddButton(283, 67, 2117, 2118, 2, GumpButtonType.Reply, 0); // owner sort AddHtml(243, 64, 200, 32, Color("Owner", HtmlColor), false, false); AddButton(446, 67, 2117, 2118, 3, GumpButtonType.Reply, 0); // price sort AddHtmlLocalized(416, 64, 200, 32, 1062218, HtmlColor, false, false); // Price AddHtmlLocalized(484, 64, 200, 32, 3005101, HtmlColor, false, false); // Edit AddHtml(517, 64, 200, 32, Color("Request", HtmlColor), false, false); AddHtml(580, 64, 200, 32, Color("Expires", HtmlColor), false, false); // AddButton(446, 67, 2117, 2118, 4, GumpButtonType.Reply, 0); // expire sort AddHtml(350, 32, 200, 32, Color("BOUNTIES", HtmlColor), false, false); AddHtmlLocalized(710, 416, 120, 20, 1011441, HtmlColor, false, false); // EXIT AddButton(675, 416, 4017, 4018, 0, GumpButtonType.Reply, 0); //exit btn if (page > 0) { AddHtmlLocalized(110, 416, 150, 20, 1011067, HtmlColor, false, false); // Previous page AddButton(75, 416, 4014, 4016, 4, GumpButtonType.Reply, 0); } if (GetIndexForPage(page + 1) < list.Count) { AddHtmlLocalized(410, 416, 150, 20, 1011066, HtmlColor, false, false); // Next page AddButton(375, 416, 4005, 4007, 5, GumpButtonType.Reply, 0); } tableIndex = 0; for (int i = index; i < (index + count) && i >= 0 && i < list.Count; ++i) { object obj = list[i]; int y = 96 + (tableIndex++ *32); BountyBoardEntry entry = (BountyBoardEntry)obj; if (m_From == entry.Owner || m_From.AccessLevel > AccessLevel.Player) { AddButton(31, y + 2, 5602, 5606, 6 + (i * 3), GumpButtonType.Reply, 0); // remove btn AddButton(488, y + 2, 2117, 2118, 7 + (i * 3), GumpButtonType.Reply, 0); //edit btn } else if (entry.Accepted.Contains(m_From)) { AddHtml(517, y, 200, 32, Color("Accepted", HtmlColor), false, false); } else if (m_From != entry.Wanted && m_From.Account != entry.Wanted.Account) { AddButton(536, y + 2, 2117, 2118, 8 + (i * 3), GumpButtonType.Reply, 0); //request btn } /* * else if( ( m_From != entry.Wanted && !entry.Accepted.Contains( m_From ) && * m_From.Account != entry.Wanted.Account ) ) * { * AddButton(559, y+2, 2117, 2118, 8 + (i * 3), GumpButtonType.Reply, 0); //request btn * } * /* * if( entry.Accepted.Contains( m_From )) * { * AddHtml( 550, y, 200, 32, Color( "Accepted", HtmlColor ), false, false ); * } */ AddHtml(70, y, 200, 32, Color(entry.Wanted.Name, HtmlColor), false, false); AddHtml(243, y, 200, 32, Color(entry.Owner.Name, HtmlColor), false, false); AddHtml(416, y, 200, 32, Color(entry.Price.ToString(), HtmlColor), false, false); AddHtml(580, y, 200, 32, Color(entry.ExpireTime.ToString(), HtmlColor), false, false); } }
public override void OnResponse(Server.Network.NetState sender, RelayInfo info) { int index = info.ButtonID; switch (index) { case 0: // EXIT { break; } case 1: // sort by wanted { m_From.SendGump(new BountyBoardGump(m_From, m_Board, 0, null, SortType.Wanted)); break; } case 2: // sort by owner { m_From.SendGump(new BountyBoardGump(m_From, m_Board, 0, null, SortType.Owner)); break; } case 3: // sort by price { m_From.SendGump(new BountyBoardGump(m_From, m_Board, 0, null, SortType.Price)); break; } case 4: // Previous page { if (m_Page > 0) { m_From.SendGump(new BountyBoardGump(m_From, m_Board, m_Page - 1, m_List, m_SortType)); } return; } case 5: // Next page { if (GetIndexForPage(m_Page + 1) < m_List.Count) { m_From.SendGump(new BountyBoardGump(m_From, m_Board, m_Page + 1, m_List, m_SortType)); } break; } default: { index -= 6; int type = index % 3; index /= 3; if (index < 0 || index >= m_List.Count) { break; } object obj = m_List[index]; if (!BountyBoard.Entries.Contains(obj)) { m_From.SendMessage("The bounty selected is not available."); m_From.SendGump(new BountyBoardGump(m_From, m_Board, 0, null, m_SortType)); return; } BountyBoardEntry entry = (BountyBoardEntry)obj; if (type == 0) // remove { BountyBoard.RemoveEntry((BountyBoardEntry)obj, true); m_From.SendMessage("The bounty has been removed."); if (BountyBoard.Entries.Count > 0) { m_From.SendGump(new BountyBoardGump(m_From, m_Board, 0, null, m_SortType)); } else { m_From.SendMessage("The bounty board is empty."); } } else if (type == 1) // edit { m_From.SendGump(new EditBountyGump(m_From, (BountyBoardEntry)obj)); } else // request { if (!entry.Requested.Contains(m_From)) { entry.Requested.Add(m_From); m_From.SendMessage("You have requested this bounty."); m_From.SendGump(new BountyBoardGump(m_From, m_Board, 0, null, m_SortType)); string msg = String.Format("{0} has requested permission to seek the bounty on {1}, accept him by using a bounty board.", m_From.Name, entry.Wanted.Name); if (NetState.Instances.Contains(entry.Owner.NetState)) { entry.Owner.SendMessage(msg); } else { (entry.Owner as PlayerMobile).ShowBountyUpdate = true; (entry.Owner as PlayerMobile).BountyUpdateList.Add(msg); } } else { m_From.SendMessage("You have already requested this bounty."); } } break; } } }
public EditBountyGump( Mobile from, BountyBoardEntry entry ) : this(from, entry, 0, null, null) { }
public static void NotifyBountyEnd( BountyBoardEntry be ) { foreach ( PlayerMobile player in be.Accepted ) { string msg = String.Format( "The bounty hunt on {0}'s head is over.", be.Wanted.Name ); if( NetState.Instances.Contains( player.NetState ) ) { player.SendMessage( msg ); } else { player.ShowBountyUpdate = true; player.BountyUpdateList.Add( msg ); } } }
public static void AddEntry( BountyBoardEntry be ) { m_Entries.Add( be ); ArrayList instances = BountyBoard.Instances; for ( int i = 0; i < instances.Count; ++i ) ((BountyBoard)instances[i]).InvalidateProperties(); }
public static void loadGlobalList() { if (!System.IO.File.Exists(xmlSchema)) { Console.WriteLine("Could not open {0}.", xmlSchema); Console.WriteLine("{0} must be in .\\Data\\Bounty System", xmlSchema); Console.WriteLine("Cannot save bounties."); return; } if (!System.IO.File.Exists(xmlFile)) { Console.WriteLine("Could not open {0}.", xmlFile); Console.WriteLine("{0} must be in .\\Data\\Bounty System", xmlFile); Console.WriteLine("This is okay if this is the first run after installation of the Bounty system."); return; } DataSet ds = new DataSet(); try { ds.ReadXmlSchema(xmlSchema); ds.ReadXml(xmlFile); } catch { Console.WriteLine("Error reading {0}. File may be corrupt.", xmlFile); return; } Mobile Owner = null; Mobile Wanted = null; Mobile requested = null; Mobile accepted = null; int price; DateTime expireTime; BountyBoardEntry entry; foreach (DataRow bountyRow in ds.Tables["Bounty"].Rows) { foreach (DataRow childRow in bountyRow.GetChildRows("Bounty_Owner")) { Owner = World.FindMobile((int)childRow["Serial"]); } if (Owner == null || Owner.Deleted || !(Owner is PlayerMobile)) { continue; } foreach (DataRow childRow in bountyRow.GetChildRows("Bounty_Wanted")) { Wanted = World.FindMobile((int)childRow["Serial"]); } price = (int)bountyRow["Price"]; expireTime = (DateTime)bountyRow["ExpireTime"]; entry = new BountyBoardEntry(Owner, Wanted, price, expireTime); foreach (DataRow childRow in bountyRow.GetChildRows("Bounty_requested")) { requested = World.FindMobile((int)childRow["Serial"]); if (requested != null && !requested.Deleted && requested is PlayerMobile) { entry.Requested.Add(requested); } } foreach (DataRow childRow in bountyRow.GetChildRows("Bounty_accepted")) { accepted = World.FindMobile((int)childRow["Serial"]); if (accepted != null && !accepted.Deleted && accepted is PlayerMobile) { entry.Accepted.Add(accepted); } } if (!entry.Expired) { BountyBoard.AddEntry(entry); } else { NotifyBountyEnd(entry); if (!Banker.Deposit(entry.Owner, price)) { entry.Owner.AddToBackpack(new Gold(price)); } } if (Wanted == null || Wanted.Deleted || !(Wanted is PlayerMobile)) { BountyBoard.RemoveEntry(entry, true); } } }
public EditBountyGump( Mobile from, BountyBoardEntry entry, int page, ArrayList requestList, ArrayList acceptList ) : base(50, 50) { if(entry == null) return; m_From = from; m_Entry = entry; m_Page = page; if ( requestList == null ) { requestList = new ArrayList( entry.Requested.Count ); for ( int i = 0; i < entry.Requested.Count; ++i ) { Mobile request = (Mobile) entry.Requested[i]; requestList.Add( request ); } } m_Requested = requestList; if ( acceptList == null ) { acceptList = new ArrayList( entry.Accepted.Count ); for ( int i = 0; i < entry.Accepted.Count; ++i ) { Mobile accept = (Mobile) entry.Accepted[i]; acceptList.Add( accept ); } } m_Accepted = acceptList; int index = GetIndexForPage( page ); int count = 5; int tableIndex = 0; Closable=true; Disposable=true; Dragable=true; Resizable=false; AddPage(0); AddBackground(0, 0, 440, 324, 9200); AddHtml(160, 5, 200, 32, Color( "Edit Bounty", HtmlColor ), false, false ); AddHtml(10, 32, 200, 32, Color( "Wanted", HtmlColor ), false, false ); AddHtml(175, 32, 200, 32, Color( "Price", HtmlColor ), false, false ); AddHtml(260, 32, 200, 32, Color( "Expires", HtmlColor ), false, false ); AddImageTiled( 10, 50, 400, 2, 2624 ); AddHtml(10, 96, 200, 32, Color( "Requested", HtmlColor ), false, false ); AddHtml(230, 96, 200, 32, Color( "Approved", HtmlColor ), false, false ); AddImageTiled( 10, 115, 400, 2, 2624 ); AddHtmlLocalized( 370, 290, 200, 32, 1011441, HtmlColor, false, false ); // exit AddButton(340, 290, 4017, 4018, 0, GumpButtonType.Reply, 0); // exit AddHtml( 10, 64, 200, 32, Color( m_Entry.Wanted.Name, HtmlColor ), false, false ); AddHtml( 175, 64, 200, 32, Color( m_Entry.Price.ToString(), HtmlColor ), false, false ); AddHtml( 260, 64, 200, 32, Color( m_Entry.ExpireTime.ToString(), HtmlColor ), false, false ); if ( page > 0 ) { AddHtmlLocalized( 60, 290, 150, 20, 1011067, HtmlColor, false, false ); // Previous page AddButton(30, 290, 4014, 4016, 1, GumpButtonType.Reply, 0); } if ( ( GetIndexForPage( page + 1 ) < m_Requested.Count ) || ( GetIndexForPage( page + 1 ) < m_Accepted.Count ) ) { AddHtmlLocalized( 230, 290, 150, 20, 1011066, HtmlColor, false, false ); // Next page AddButton(200, 290, 4005, 4007, 2, GumpButtonType.Reply, 0); } tableIndex = 0; for ( int i = index; i < (index + count) && i >= 0 && i < m_Requested.Count; ++i ) { Mobile request = (Mobile) m_Requested[i]; int y = 128 + (tableIndex++ * 32); AddButton(10, y, 2117, 2118, 3 + (i * 1), GumpButtonType.Reply, 0); AddHtml( 40, y, 200, 32, Color( request.Name, HtmlColor ), false, false ); } tableIndex = 0; for ( int i = index; i < (index + count) && i >= 0 && i < m_Accepted.Count; ++i ) { Mobile accept = (Mobile) m_Accepted[i]; int y = 128 + (tableIndex++ * 32); AddHtml( 230, y, 200, 32, Color( accept.Name, HtmlColor ), false, false ); } }
public static void loadGlobalList() { if( !System.IO.File.Exists( xmlSchema ) ) { Console.WriteLine( "Could not open {0}.", xmlSchema ); Console.WriteLine( "{0} must be in .\\Data\\Bounty System", xmlSchema ); Console.WriteLine( "Cannot save bounties." ); return; } if( !System.IO.File.Exists( xmlFile ) ) { Console.WriteLine( "Could not open {0}.", xmlFile ); Console.WriteLine( "{0} must be in .\\Data\\Bounty System", xmlFile ); Console.WriteLine( "This is okay if this is the first run after installation of the Bounty system." ); return; } DataSet ds = new DataSet(); try { ds.ReadXmlSchema( xmlSchema ); ds.ReadXml( xmlFile ); } catch { Console.WriteLine( "Error reading {0}. File may be corrupt.", xmlFile); return; } Mobile Owner = null; Mobile Wanted = null; Mobile requested = null; Mobile accepted = null; int price; DateTime expireTime; BountyBoardEntry entry; foreach( DataRow bountyRow in ds.Tables["Bounty"].Rows ) { foreach( DataRow childRow in bountyRow.GetChildRows( "Bounty_Owner" ) ) Owner = World.FindMobile( (int) childRow["Serial"] ); if(Owner == null || Owner.Deleted || !(Owner is PlayerMobile) ) continue; foreach( DataRow childRow in bountyRow.GetChildRows( "Bounty_Wanted" ) ) Wanted = World.FindMobile( (int) childRow["Serial"] ); price = (int) bountyRow["Price"]; expireTime = (DateTime) bountyRow["ExpireTime"]; entry = new BountyBoardEntry( Owner, Wanted, price, expireTime ); foreach( DataRow childRow in bountyRow.GetChildRows( "Bounty_requested" ) ) { requested = World.FindMobile( (int) childRow["Serial"] ); if( requested != null && !requested.Deleted && requested is PlayerMobile ) entry.Requested.Add( requested ); } foreach( DataRow childRow in bountyRow.GetChildRows( "Bounty_accepted" ) ) { accepted = World.FindMobile( (int) childRow["Serial"] ); if( accepted != null && !accepted.Deleted && accepted is PlayerMobile ) entry.Accepted.Add( accepted ); } if( !entry.Expired ) BountyBoard.AddEntry( entry ); else { NotifyBountyEnd( entry ); if ( !Banker.Deposit( entry.Owner, price ) ) entry.Owner.AddToBackpack( new Gold( price ) ); } if( Wanted == null || Wanted.Deleted || !(Wanted is PlayerMobile) ) BountyBoard.RemoveEntry( entry, true ); } }
public static BountyBoardEntry AddEntry( Mobile Owner, Mobile Wanted, int price, DateTime expireTime ) { foreach( BountyBoardEntry entry in m_Entries ) { if(entry.Owner == Owner && entry.Wanted == Wanted) { entry.Price += price; entry.ExpireTime = expireTime; return entry; } } BountyBoardEntry be = new BountyBoardEntry( Owner, Wanted, price, expireTime ); m_Entries.Add( be ); ArrayList instances = BountyBoard.Instances; for ( int i = 0; i < instances.Count; ++i ) ((BountyBoard)instances[i]).InvalidateProperties(); return be; }
public EditBountyGump(Mobile from, BountyBoardEntry entry) : this(from, entry, 0, null, null) { }
public static void RemoveEntry( BountyBoardEntry be, bool refund ) { m_Entries.Remove( be ); ArrayList instances = BountyBoard.Instances; for ( int i = 0; i < instances.Count; ++i ) ((BountyBoard)instances[i]).InvalidateProperties(); if( refund && be != null && be.Owner != null && be.Wanted != null) { string msg = String.Format( "Your bounty in the amount of {0} on {1}'s head has ended.", be.Price, be.Wanted.Name ); if( NetState.Instances.Contains( be.Owner.NetState ) ) { be.Owner.SendMessage( msg ); } else { ((PlayerMobile)be.Owner).ShowBountyUpdate = true; ((PlayerMobile)be.Owner).BountyUpdateList.Add( msg ); } if ( Banker.Deposit( be.Owner, be.Price ) ) be.Owner.SendLocalizedMessage( 1060397, be.Price.ToString() ); // ~1_AMOUNT~ gold has been deposited into your bank box. else { be.Owner.AddToBackpack( new Gold( be.Price ) ); be.Owner.SendMessage( "The bounty of {0} has been added to your backpack.", be.Price ); } } else if( be != null && be.Owner != null && be.Wanted != null) { string msg = String.Format( "Your bounty in the amount of {0} on {1}'s head has been claimed.", be.Price, be.Wanted.Name ); if( NetState.Instances.Contains( be.Owner.NetState ) ) { be.Owner.SendMessage( msg ); } else { ((PlayerMobile)be.Owner).ShowBountyUpdate = true; ((PlayerMobile)be.Owner).BountyUpdateList.Add( msg ); } } NotifyBountyEnd( be ); }
public EditBountyGump(Mobile from, BountyBoardEntry entry, int page, ArrayList requestList, ArrayList acceptList) : base(50, 50) { if (entry == null) { return; } m_From = from; m_Entry = entry; m_Page = page; if (requestList == null) { requestList = new ArrayList(entry.Requested.Count); for (int i = 0; i < entry.Requested.Count; ++i) { Mobile request = (Mobile)entry.Requested[i]; requestList.Add(request); } } m_Requested = requestList; if (acceptList == null) { acceptList = new ArrayList(entry.Accepted.Count); for (int i = 0; i < entry.Accepted.Count; ++i) { Mobile accept = (Mobile)entry.Accepted[i]; acceptList.Add(accept); } } m_Accepted = acceptList; int index = GetIndexForPage(page); int count = 5; int tableIndex = 0; Closable = true; Disposable = true; Dragable = true; Resizable = false; AddPage(0); AddBackground(0, 0, 440, 324, 9200); AddHtml(160, 5, 200, 32, Color("Edit Bounty", HtmlColor), false, false); AddHtml(10, 32, 200, 32, Color("Wanted", HtmlColor), false, false); AddHtml(175, 32, 200, 32, Color("Price", HtmlColor), false, false); AddHtml(260, 32, 200, 32, Color("Expires", HtmlColor), false, false); AddImageTiled(10, 50, 400, 2, 2624); AddHtml(10, 96, 200, 32, Color("Requested", HtmlColor), false, false); AddHtml(230, 96, 200, 32, Color("Approved", HtmlColor), false, false); AddImageTiled(10, 115, 400, 2, 2624); AddHtmlLocalized(370, 290, 200, 32, 1011441, HtmlColor, false, false); // exit AddButton(340, 290, 4017, 4018, 0, GumpButtonType.Reply, 0); // exit AddHtml(10, 64, 200, 32, Color(m_Entry.Wanted.Name, HtmlColor), false, false); AddHtml(175, 64, 200, 32, Color(m_Entry.Price.ToString(), HtmlColor), false, false); AddHtml(260, 64, 200, 32, Color(m_Entry.ExpireTime.ToString(), HtmlColor), false, false); if (page > 0) { AddHtmlLocalized(60, 290, 150, 20, 1011067, HtmlColor, false, false); // Previous page AddButton(30, 290, 4014, 4016, 1, GumpButtonType.Reply, 0); } if ((GetIndexForPage(page + 1) < m_Requested.Count) || (GetIndexForPage(page + 1) < m_Accepted.Count)) { AddHtmlLocalized(230, 290, 150, 20, 1011066, HtmlColor, false, false); // Next page AddButton(200, 290, 4005, 4007, 2, GumpButtonType.Reply, 0); } tableIndex = 0; for (int i = index; i < (index + count) && i >= 0 && i < m_Requested.Count; ++i) { Mobile request = (Mobile)m_Requested[i]; int y = 128 + (tableIndex++ *32); AddButton(10, y, 2117, 2118, 3 + (i * 1), GumpButtonType.Reply, 0); AddHtml(40, y, 200, 32, Color(request.Name, HtmlColor), false, false); } tableIndex = 0; for (int i = index; i < (index + count) && i >= 0 && i < m_Accepted.Count; ++i) { Mobile accept = (Mobile)m_Accepted[i]; int y = 128 + (tableIndex++ *32); AddHtml(230, y, 200, 32, Color(accept.Name, HtmlColor), false, false); } }
public static bool hasBounty( Mobile claimer, Mobile killer, out BountyBoardEntry bountyEntry, out bool canClaim) { bountyEntry = null; canClaim = false; DateTime expireTime = DateTime.MaxValue; bool hasBounty = false; foreach( BountyBoardEntry entry in m_Entries ) { if(entry.Wanted == killer ) { hasBounty = true; canClaim = entry.Accepted.Contains( claimer ); if( /*canClaim &&*/ entry.ExpireTime < expireTime ) // crash bugfix { bountyEntry = entry; expireTime = entry.ExpireTime; } } } return hasBounty; }
public static void saveGlobalList(WorldSaveEventArgs e) { if (!System.IO.File.Exists(xmlSchema)) { Console.WriteLine("Could not open {0}.", xmlSchema); Console.WriteLine("{0} must be in .\\Data\\Bounty System", xmlSchema); Console.WriteLine("Cannot save bounties."); return; } if (System.IO.File.Exists(xmlFileBackup)) { System.IO.File.Delete(xmlFileBackup); } if (System.IO.File.Exists(xmlFile)) { System.IO.File.Move(xmlFile, xmlFileBackup); } DataSet ds = new DataSet(); ds.ReadXmlSchema(xmlSchema); DataRow bountyRow, OwnerRow, WantedRow, requestedRow, acceptedRow; try { var entries = new BountyBoardEntry[m_Entries.Count]; m_Entries.CopyTo(entries); foreach (BountyBoardEntry entry in m_Entries) { if (entry == null) { continue; } if (entry.Owner == null || entry.Owner.Deleted) { continue; } if (entry.Wanted == null || entry.Wanted.Deleted) { BountyBoard.RemoveEntry(entry, true); continue; } bountyRow = ds.Tables["Bounty"].NewRow(); bountyRow["Price"] = entry.Price; bountyRow["ExpireTime"] = entry.ExpireTime; ds.Tables["Bounty"].Rows.Add(bountyRow); OwnerRow = ds.Tables["Owner"].NewRow(); OwnerRow["Name"] = entry.Owner.Name; OwnerRow["Serial"] = entry.Owner.Serial.Value; OwnerRow.SetParentRow(bountyRow, ds.Relations["Bounty_Owner"]); ds.Tables["Owner"].Rows.Add(OwnerRow); WantedRow = ds.Tables["Wanted"].NewRow(); WantedRow["Name"] = entry.Wanted.Name; WantedRow["Serial"] = entry.Wanted.Serial.Value; WantedRow.SetParentRow(bountyRow, ds.Relations["Bounty_Wanted"]); ds.Tables["Wanted"].Rows.Add(WantedRow); foreach (Mobile requested in entry.Requested) { if (requested == null || requested.Deleted) { continue; } requestedRow = ds.Tables["Requested"].NewRow(); requestedRow["Name"] = requested.Name; requestedRow["Serial"] = requested.Serial.Value; requestedRow.SetParentRow(bountyRow, ds.Relations["Bounty_Requested"]); ds.Tables["Requested"].Rows.Add(requestedRow); } foreach (Mobile accepted in entry.Accepted) { if (accepted == null || accepted.Deleted) { continue; } acceptedRow = ds.Tables["Accepted"].NewRow(); acceptedRow["Name"] = accepted.Name; acceptedRow["Serial"] = accepted.Serial.Value; acceptedRow.SetParentRow(bountyRow, ds.Relations["Bounty_Accepted"]); ds.Tables["Accepted"].Rows.Add(acceptedRow); } ds.WriteXml(xmlFile); } } catch (Exception exception) { Console.WriteLine(exception); } }