Modernization Fixes & Updates to Default Values (#3)

This commit is contained in:
Kamron Batman 2018-10-28 00:33:16 -07:00 • committed by GitHub
parent 445eddff68
commit dcf64091b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
768 changed files with 10507 additions and 14196 deletions

View file

@ -74,8 +74,8 @@ namespace Server.Engines.BulkOrders
public BOBFilterGump(PlayerMobile from, BulkOrderBook book) : base(12, 24)
{
from.CloseGump(typeof(BOBGump));
from.CloseGump(typeof(BOBFilterGump));
from.CloseGump<BOBGump>();
from.CloseGump<BOBFilterGump>();
m_From = from;
m_Book = book;

View file

@ -1,5 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Gumps;
using Server.Items;
using Server.Mobiles;
@ -13,18 +13,14 @@ namespace Server.Engines.BulkOrders
private const int LabelColor = 0x7FFF;
private BulkOrderBook m_Book;
private PlayerMobile m_From;
private ArrayList m_List;
private List<IBOBEntry> m_List;
private int m_Page;
public BOBGump(PlayerMobile from, BulkOrderBook book) : this(from, book, 0, null)
public BOBGump(PlayerMobile from, BulkOrderBook book, int page = 0, List<IBOBEntry> list = null) : base(12, 24)
{
}
public BOBGump(PlayerMobile from, BulkOrderBook book, int page, ArrayList list) : base(12, 24)
{
from.CloseGump(typeof(BOBGump));
from.CloseGump(typeof(BOBFilterGump));
from.CloseGump<BOBGump>();
from.CloseGump<BOBFilterGump>();
m_From = from;
m_Book = book;
@ -32,14 +28,14 @@ namespace Server.Engines.BulkOrders
if (list == null)
{
list = new ArrayList(book.Entries.Count);
list = new List<IBOBEntry>(book.Entries.Count);
for (int i = 0; i < book.Entries.Count; ++i)
{
object obj = book.Entries[i];
IBOBEntry entry = book.Entries[i];
if (CheckFilter(obj))
list.Add(obj);
if (CheckFilter(entry))
list.Add(entry);
}
}
@ -92,17 +88,13 @@ namespace Server.Engines.BulkOrders
for (int i = index; i < index + count && i >= 0 && i < list.Count; ++i)
{
object obj = list[i];
IBOBEntry entry = list[i];
if (!CheckFilter(obj))
if (!CheckFilter(entry))
continue;
AddImageTiled(24, 94 + tableIndex * 32, canPrice ? 573 : 489, 2, 2624);
if (obj is BOBLargeEntry entry)
tableIndex += entry.Entries.Length;
else
++tableIndex;
tableIndex += entry is BOBLargeEntry largeEntry ? largeEntry.Entries.Length : 1;
}
AddAlphaRegion(18, 20, width - 17, 420);
@ -169,12 +161,12 @@ namespace Server.Engines.BulkOrders
for (int i = index; i < index + count && i >= 0 && i < list.Count; ++i)
{
object obj = list[i];
IBOBEntry entry = list[i];
if (!CheckFilter(obj))
if (!CheckFilter(entry))
continue;
if (obj is BOBLargeEntry entry)
if (entry is BOBLargeEntry largeEntry)
{
int y = 96 + tableIndex * 32;
@ -189,9 +181,9 @@ namespace Server.Engines.BulkOrders
AddHtmlLocalized(61, y, 50, 32, 1062225, LabelColor, false, false); // Large
for (int j = 0; j < entry.Entries.Length; ++j)
for (int j = 0; j < largeEntry.Entries.Length; ++j)
{
BOBLargeSubEntry sub = entry.Entries[j];
BOBLargeSubEntry sub = largeEntry.Entries[j];
AddHtmlLocalized(103, y, 130, 32, sub.Number, LabelColor, false, false);
@ -215,7 +207,7 @@ namespace Server.Engines.BulkOrders
}
else
{
BOBSmallEntry smallEntry = (BOBSmallEntry)obj;
BOBSmallEntry smallEntry = (BOBSmallEntry)entry;
int y = 96 + tableIndex++ * 32;
@ -249,26 +241,15 @@ namespace Server.Engines.BulkOrders
}
}
public Item Reconstruct(object obj)
{
Item item = null;
if (obj is BOBLargeEntry entry)
item = entry.Reconstruct();
else
item = ((BOBSmallEntry)obj).Reconstruct();
return item;
}
public bool CheckFilter(object obj)
{
if (obj is BOBLargeEntry entry)
public bool CheckFilter(IBOBEntry entry)
{
if (entry is BOBLargeEntry largeEntry)
return CheckFilter(entry.Material, entry.AmountMax, true, entry.RequireExceptional, entry.DeedType,
entry.Entries.Length > 0 ? entry.Entries[0].ItemType : null);
if (obj is BOBSmallEntry smallEntry)
return CheckFilter(smallEntry.Material, smallEntry.AmountMax, false, smallEntry.RequireExceptional,
smallEntry.DeedType, smallEntry.ItemType);
largeEntry.Entries.Length > 0 ? largeEntry.Entries[0].ItemType : null);
if (entry is BOBSmallEntry smallEntry)
return CheckFilter(entry.Material, entry.AmountMax, false, entry.RequireExceptional,
entry.DeedType, smallEntry.ItemType);
return false;
}
@ -344,20 +325,15 @@ namespace Server.Engines.BulkOrders
int slots = 0;
int count = 0;
ArrayList list = m_List;
List<IBOBEntry> list = m_List;
for (int i = index; i >= 0 && i < list.Count; ++i)
{
object obj = list[i];
IBOBEntry entry = list[i];
if (CheckFilter(obj))
if (CheckFilter(entry))
{
int add;
if (obj is BOBLargeEntry entry)
add = entry.Entries.Length;
else
add = 1;
int add = entry is BOBLargeEntry largeEntry ? largeEntry.Entries.Length : 1;
if (slots + add > 10)
break;
@ -377,52 +353,42 @@ namespace Server.Engines.BulkOrders
return 0;
int count = 0;
int add = 0;
int page = 0;
ArrayList list = m_List;
int i;
object obj;
List<IBOBEntry> list = m_List;
for (i = 0; i < index && i < list.Count; i++)
{
obj = list[i];
if (CheckFilter(obj))
IBOBEntry entry = list[i];
if (!CheckFilter(entry))
continue;
int add = entry is BOBLargeEntry largeEntry ? largeEntry.Entries.Length : 1;
count += add;
if (count > 10)
{
if (obj is BOBLargeEntry entry)
add = entry.Entries.Length;
else
add = 1;
count += add;
if (count > 10)
{
page++;
count = add;
}
page++;
count = add;
}
}
/* now we are on the page of the bod preceeding the dropped one.
/* now we are on the page of the bod preceding the dropped one.
* next step: checking whether we have to remain where we are.
* The counter i needs to be incremented as the bod to this very moment
* has not yet been removed from m_List */
i++;
/* if, for instance, a big bod of size 6 has been removed, smaller bods
* might fall back into this page. Depending on their sizes, the page eeds
* might fall back into this page. Depending on their sizes, the page needs
* to be adjusted accordingly. This is done now.
*/
if (count + sizeDropped > 10)
{
while (i < list.Count && count <= 10)
{
obj = list[i];
if (CheckFilter(obj))
{
if (obj is BOBLargeEntry entry)
count += entry.Entries.Length;
else
count += 1;
}
IBOBEntry entry = list[i];
if (CheckFilter(entry))
count += entry is BOBLargeEntry largeEntry ? largeEntry.Entries.Length : 1;
i++;
}
@ -521,9 +487,6 @@ namespace Server.Engines.BulkOrders
}
default:
{
bool canDrop = m_Book.IsChildOf(m_From.Backpack);
bool canPrice = canDrop || m_Book.RootParent is PlayerVendor;
index -= 5;
int type = index % 2;
@ -532,9 +495,9 @@ namespace Server.Engines.BulkOrders
if (index < 0 || index >= m_List.Count)
break;
object obj = m_List[index];
IBOBEntry bobEntry = m_List[index];
if (!m_Book.Entries.Contains(obj))
if (!m_Book.Entries.Contains(bobEntry))
{
m_From.SendLocalizedMessage(1062382); // The deed selected is not available.
break;
@ -544,54 +507,43 @@ namespace Server.Engines.BulkOrders
{
if (m_Book.IsChildOf(m_From.Backpack))
{
Item item = Reconstruct(obj);
Item item = bobEntry.Reconstruct();
if (item != null)
Container pack = m_From.Backpack;
if (pack == null || !pack.CheckHold(m_From, item, true, true, 0,
item.PileWeight + item.TotalWeight))
{
Container pack = m_From.Backpack;
if (pack == null || !pack.CheckHold(m_From, item, true, true, 0,
item.PileWeight + item.TotalWeight))
{
m_From.SendLocalizedMessage(503204); // You do not have room in your backpack for this
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page, null));
}
else
{
if (m_Book.IsChildOf(m_From.Backpack))
{
int sizeOfDroppedBod;
if (obj is BOBLargeEntry entry)
sizeOfDroppedBod = entry.Entries.Length;
else
sizeOfDroppedBod = 1;
m_From.AddToBackpack(item);
m_From.SendLocalizedMessage(
1045152); // The bulk order deed has been placed in your backpack.
m_Book.Entries.Remove(obj);
m_Book.InvalidateProperties();
if (m_Book.Entries.Count / 5 < m_Book.ItemCount)
{
m_Book.ItemCount--;
m_Book.InvalidateItems();
}
if (m_Book.Entries.Count > 0)
{
m_Page = GetPageForIndex(index, sizeOfDroppedBod);
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page, null));
}
else
{
m_From.SendLocalizedMessage(1062381); // The book is empty.
}
}
}
m_From.SendLocalizedMessage(503204); // You do not have room in your backpack for this
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page));
}
else
{
m_From.SendMessage("Internal error. The bulk order deed could not be reconstructed.");
if (m_Book.IsChildOf(m_From.Backpack))
{
int sizeOfDroppedBod = bobEntry is BOBLargeEntry entry ? entry.Entries.Length : 1;
m_From.AddToBackpack(item);
m_From.SendLocalizedMessage(
1045152); // The bulk order deed has been placed in your backpack.
m_Book.Entries.Remove(bobEntry);
m_Book.InvalidateProperties();
if (m_Book.Entries.Count / 5 < m_Book.ItemCount)
{
m_Book.ItemCount--;
m_Book.InvalidateItems();
}
if (m_Book.Entries.Count > 0)
{
m_Page = GetPageForIndex(index, sizeOfDroppedBod);
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page));
}
else
{
m_From.SendLocalizedMessage(1062381); // The book is empty.
}
}
}
}
}
@ -599,7 +551,7 @@ namespace Server.Engines.BulkOrders
{
if (m_Book.IsChildOf(m_From.Backpack))
{
m_From.Prompt = new SetPricePrompt(m_Book, obj, m_Page, m_List);
m_From.Prompt = new SetPricePrompt(m_Book, bobEntry, m_Page, m_List);
m_From.SendLocalizedMessage(1062383); // Type in a price for the deed:
}
else if (m_Book.RootParent is PlayerVendor pv)
@ -608,18 +560,8 @@ namespace Server.Engines.BulkOrders
if (vi != null && !vi.IsForSale)
{
int sizeOfDroppedBod;
int price = 0;
if (obj is BOBLargeEntry entry)
{
price = entry.Price;
sizeOfDroppedBod = entry.Entries.Length;
}
else
{
price = ((BOBSmallEntry)obj).Price;
sizeOfDroppedBod = 1;
}
int sizeOfDroppedBod = bobEntry is BOBLargeEntry largeEntry ? largeEntry.Entries.Length : 1;
int price = bobEntry.Price;
if (price == 0)
{
@ -630,7 +572,7 @@ namespace Server.Engines.BulkOrders
if (m_Book.Entries.Count > 0)
{
m_Page = GetPageForIndex(index, sizeOfDroppedBod);
m_From.SendGump(new BODBuyGump(m_From, m_Book, obj, m_Page, price));
m_From.SendGump(new BODBuyGump(m_From, m_Book, bobEntry, m_Page, price));
}
else
{
@ -649,21 +591,21 @@ namespace Server.Engines.BulkOrders
private class SetPricePrompt : Prompt
{
private BulkOrderBook m_Book;
private ArrayList m_List;
private object m_Object;
private List<IBOBEntry> m_List;
private IBOBEntry m_Entry;
private int m_Page;
public SetPricePrompt(BulkOrderBook book, object obj, int page, ArrayList list)
public SetPricePrompt(BulkOrderBook book, IBOBEntry entry, int page, List<IBOBEntry> list)
{
m_Book = book;
m_Object = obj;
m_Entry = entry;
m_Page = page;
m_List = list;
}
public override void OnResponse(Mobile from, string text)
{
if (m_Object != null && !m_Book.Entries.Contains(m_Object))
if (m_Entry != null && !m_Book.Entries.Contains(m_Entry))
{
from.SendLocalizedMessage(1062382); // The deed selected is not available.
return;
@ -675,19 +617,16 @@ namespace Server.Engines.BulkOrders
{
from.SendLocalizedMessage(1062390); // The price you requested is outrageous!
}
else if (m_Object == null)
else if (m_Entry == null)
{
for (int i = 0; i < m_List.Count; ++i)
{
object obj = m_List[i];
IBOBEntry entry = m_List[i];
if (!m_Book.Entries.Contains(obj))
if (!m_Book.Entries.Contains(entry))
continue;
if (obj is BOBLargeEntry entry)
entry.Price = price;
else
((BOBSmallEntry)obj).Price = price;
entry.Price = price;
}
from.SendMessage("Deed prices set.");
@ -695,21 +634,10 @@ namespace Server.Engines.BulkOrders
if (from is PlayerMobile mobile)
mobile.SendGump(new BOBGump(mobile, m_Book, m_Page, m_List));
}
else if (m_Object is BOBLargeEntry entry)
{
entry.Price = price;
from.SendLocalizedMessage(1062384); // Deed price set.
if (from is PlayerMobile mobile)
mobile.SendGump(new BOBGump(mobile, m_Book, m_Page, m_List));
}
else
{
((BOBSmallEntry)m_Object).Price = price;
m_Entry.Price = price;
from.SendLocalizedMessage(1062384); // Deed price set.
if (from is PlayerMobile mobile)
mobile.SendGump(new BOBGump(mobile, m_Book, m_Page, m_List));
}

View file

@ -1,6 +1,6 @@
namespace Server.Engines.BulkOrders
{
public class BOBLargeEntry
public class BOBLargeEntry: IBOBEntry
{
public BOBLargeEntry(LargeBOD bod)
{
@ -80,8 +80,7 @@ namespace Server.Engines.BulkOrders
for (int i = 0; i < Entries.Length; ++i)
{
entries[i] = new LargeBulkEntry(null,
new SmallBulkEntry(Entries[i].ItemType, Entries[i].Number, Entries[i].Graphic));
entries[i].Amount = Entries[i].AmountCur;
new SmallBulkEntry(Entries[i].ItemType, Entries[i].Number, Entries[i].Graphic)) { Amount = Entries[i].AmountCur };
}
return entries;

View file

@ -2,7 +2,7 @@ using System;
namespace Server.Engines.BulkOrders
{
public class BOBSmallEntry
public class BOBSmallEntry : IBOBEntry
{
public BOBSmallEntry(SmallBOD bod)
{

View file

@ -9,15 +9,15 @@ namespace Server.Engines.BulkOrders
{
private BulkOrderBook m_Book;
private PlayerMobile m_From;
private object m_Object;
private IBOBEntry m_Entry;
private int m_Page;
private int m_Price;
public BODBuyGump(PlayerMobile from, BulkOrderBook book, object obj, int page, int price) : base(100, 200)
public BODBuyGump(PlayerMobile from, BulkOrderBook book, IBOBEntry entry, int page, int price) : base(100, 200)
{
m_From = from;
m_Book = book;
m_Object = obj;
m_Entry = entry;
m_Price = price;
m_Page = page;
@ -40,100 +40,83 @@ namespace Server.Engines.BulkOrders
public override void OnResponse(NetState sender, RelayInfo info)
{
if (info.ButtonID == 2)
if (info.ButtonID != 2)
{
PlayerVendor pv = m_Book.RootParent as PlayerVendor;
m_From.SendLocalizedMessage(503207); // Cancelled purchase.
return;
}
if (m_Book.Entries.Contains(m_Object) && pv != null)
{
int price = 0;
if (!(m_Book.RootParent is PlayerVendor pv))
{
m_From.SendLocalizedMessage(1062382); // The deed selected is not available.
return;
}
VendorItem vi = pv.GetVendorItem(m_Book);
if (!m_Book.Entries.Contains(m_Entry))
{
pv.SayTo(m_From, 1062382); // The deed selected is not available.
return;
}
int price = 0;
if (vi != null && !vi.IsForSale)
{
if (m_Object is BOBLargeEntry entry)
price = entry.Price;
else
price = ((BOBSmallEntry)m_Object).Price;
}
VendorItem vi = pv.GetVendorItem(m_Book);
if (price != m_Price)
{
pv.SayTo(m_From,
"The price has been been changed. If you like, you may offer to purchase the item again.");
}
else if (price == 0)
{
pv.SayTo(m_From, 1062382); // The deed selected is not available.
}
else
{
Item item = null;
if (vi != null && !vi.IsForSale)
price = m_Entry.Price;
if (m_Object is BOBLargeEntry entry)
item = entry.Reconstruct();
else
item = ((BOBSmallEntry)m_Object).Reconstruct();
if (price != m_Price)
{
pv.SayTo(m_From,
"The price has been been changed. If you like, you may offer to purchase the item again.");
return;
}
if (item == null)
{
m_From.SendMessage("Internal error. The bulk order deed could not be reconstructed.");
}
else
{
pv.Say(m_From.Name);
if (price == 0)
{
pv.SayTo(m_From, 1062382); // The deed selected is not available.
return;
}
Container pack = m_From.Backpack;
Item item = m_Entry.Reconstruct();
pv.Say(m_From.Name);
if (pack == null || !pack.CheckHold(m_From, item, true, true, 0,
item.PileWeight + item.TotalWeight))
{
pv.SayTo(m_From, 503204); // You do not have room in your backpack for this
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page, null));
}
else
{
if (pack.ConsumeTotal(typeof(Gold), price) || Banker.Withdraw(m_From, price))
{
m_Book.Entries.Remove(m_Object);
m_Book.InvalidateProperties();
pv.HoldGold += price;
m_From.AddToBackpack(item);
m_From.SendLocalizedMessage(
1045152); // The bulk order deed has been placed in your backpack.
Container pack = m_From.Backpack;
if (m_Book.Entries.Count / 5 < m_Book.ItemCount)
{
m_Book.ItemCount--;
m_Book.InvalidateItems();
}
if (m_Book.Entries.Count > 0)
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page, null));
else
m_From.SendLocalizedMessage(1062381); // The book is empty.
}
else
{
pv.SayTo(m_From, 503205); // You cannot afford this item.
item.Delete();
}
}
}
}
}
else
{
if (pv == null)
m_From.SendLocalizedMessage(1062382); // The deed selected is not available.
else
pv.SayTo(m_From, 1062382); // The deed selected is not available.
}
if (pack == null || !pack.CheckHold(m_From, item, true, true, 0,
item.PileWeight + item.TotalWeight))
{
pv.SayTo(m_From, 503204); // You do not have room in your backpack for this
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page));
}
else
{
m_From.SendLocalizedMessage(503207); // Cancelled purchase.
if (pack.ConsumeTotal(typeof(Gold), price) || Banker.Withdraw(m_From, price))
{
m_Book.Entries.Remove(m_Entry);
m_Book.InvalidateProperties();
pv.HoldGold += price;
m_From.AddToBackpack(item);
m_From.SendLocalizedMessage(
1045152); // The bulk order deed has been placed in your backpack.
if (m_Book.Entries.Count / 5 < m_Book.ItemCount)
{
m_Book.ItemCount--;
m_Book.InvalidateItems();
}
if (m_Book.Entries.Count > 0)
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page));
else
m_From.SendLocalizedMessage(1062381); // The book is empty.
}
else
{
pv.SayTo(m_From, 503205); // You cannot afford this item.
item.Delete();
}
}
}
}

View file

@ -1,5 +1,3 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Gumps;
using Server.Multis;
@ -24,7 +22,7 @@ namespace Server.Engines.BulkOrders
[CommandProperty( AccessLevel.GameMaster )]
public SecureLevel Level { get; set; }
public ArrayList Entries { get; private set; }
public List<IBOBEntry> Entries { get; private set; }
public BOBFilter Filter { get; private set; }
@ -36,7 +34,7 @@ namespace Server.Engines.BulkOrders
Weight = 1.0;
LootType = LootType.Blessed;
Entries = new ArrayList();
Entries = new List<IBOBEntry>();
Filter = new BOBFilter();
Level = SecureLevel.CoOwners;
@ -73,9 +71,9 @@ namespace Server.Engines.BulkOrders
SecureTrade trade = cont.Trade;
if ( trade != null && trade.From.Mobile == from )
trade.To.Mobile.SendGump( new BOBGump( (PlayerMobile)(trade.To.Mobile), this ) );
trade.To.Mobile.SendGump( new BOBGump( (PlayerMobile)trade.To.Mobile, this ) );
else if ( trade != null && trade.To.Mobile == from )
trade.From.Mobile.SendGump( new BOBGump( (PlayerMobile)(trade.From.Mobile), this ) );
trade.From.Mobile.SendGump( new BOBGump( (PlayerMobile)trade.From.Mobile, this ) );
}
}
}
@ -216,7 +214,7 @@ namespace Server.Engines.BulkOrders
int count = reader.ReadEncodedInt();
Entries = new ArrayList( count );
Entries = new List<IBOBEntry>( count );
for ( int i = 0; i < count; ++i )
{
@ -240,7 +238,7 @@ namespace Server.Engines.BulkOrders
list.Add( 1062344, Entries.Count.ToString() ); // Deeds in book: ~1_val~
if ( m_BookName != null && m_BookName.Length > 0 )
if ( !string.IsNullOrEmpty(m_BookName) )
list.Add( 1062481, m_BookName ); // Book Name: ~1_val~
}

View file

@ -0,0 +1,12 @@
namespace Server.Engines.BulkOrders
{
public interface IBOBEntry
{
bool RequireExceptional{ get; }
BODType DeedType{ get; }
BulkMaterialType Material{ get; }
int AmountMax{ get; }
int Price{ get; set; }
Item Reconstruct();
}
}

View file

@ -13,8 +13,8 @@ namespace Server.Engines.BulkOrders
m_From = from;
m_Deed = deed;
m_From.CloseGump(typeof(LargeBODAcceptGump));
m_From.CloseGump(typeof(SmallBODAcceptGump));
m_From.CloseGump<LargeBODAcceptGump>();
m_From.CloseGump<SmallBODAcceptGump>();
LargeBulkEntry[] entries = deed.Entries;

View file

@ -13,8 +13,8 @@ namespace Server.Engines.BulkOrders
m_From = from;
m_Deed = deed;
m_From.CloseGump(typeof(LargeBODGump));
m_From.CloseGump(typeof(SmallBODGump));
m_From.CloseGump<LargeBODGump>();
m_From.CloseGump<SmallBODGump>();
LargeBulkEntry[] entries = deed.Entries;

View file

@ -691,7 +691,7 @@ namespace Server.Engines.BulkOrders
switch (Utility.Random(4))
{
default:
case 0: return new SmallStretchedHideEastDeed();
return new SmallStretchedHideEastDeed();
case 1: return new SmallStretchedHideSouthDeed();
case 2: return new MediumStretchedHideEastDeed();
case 3: return new MediumStretchedHideSouthDeed();
@ -703,7 +703,7 @@ namespace Server.Engines.BulkOrders
switch (Utility.Random(4))
{
default:
case 0: return new LightFlowerTapestryEastDeed();
return new LightFlowerTapestryEastDeed();
case 1: return new LightFlowerTapestrySouthDeed();
case 2: return new DarkFlowerTapestryEastDeed();
case 3: return new DarkFlowerTapestrySouthDeed();
@ -715,7 +715,7 @@ namespace Server.Engines.BulkOrders
switch (Utility.Random(4))
{
default:
case 0: return new BrownBearRugEastDeed();
return new BrownBearRugEastDeed();
case 1: return new BrownBearRugSouthDeed();
case 2: return new PolarBearRugEastDeed();
case 3: return new PolarBearRugSouthDeed();

View file

@ -13,8 +13,8 @@ namespace Server.Engines.BulkOrders
m_From = from;
m_Deed = deed;
m_From.CloseGump(typeof(LargeBODAcceptGump));
m_From.CloseGump(typeof(SmallBODAcceptGump));
m_From.CloseGump<LargeBODAcceptGump>();
m_From.CloseGump<SmallBODAcceptGump>();
AddPage(0);

View file

@ -13,8 +13,8 @@ namespace Server.Engines.BulkOrders
m_From = from;
m_Deed = deed;
m_From.CloseGump(typeof(LargeBODGump));
m_From.CloseGump(typeof(SmallBODGump));
m_From.CloseGump<LargeBODGump>();
m_From.CloseGump<SmallBODGump>();
AddPage(0);

View file

@ -141,7 +141,7 @@ namespace Server.Engines.BulkOrders
if (entries.Length > 0)
{
double theirSkill = m.Skills[SkillName.Blacksmith].Base;
double theirSkill = m.Skills.Blacksmith.Base;
int amountMax;
if (theirSkill >= 70.1)

View file

@ -127,7 +127,7 @@ namespace Server.Engines.BulkOrders
SmallBulkEntry[] entries;
bool useMaterials = Utility.RandomBool();
double theirSkill = m.Skills[SkillName.Tailoring].Base;
double theirSkill = m.Skills.Tailoring.Base;
if (useMaterials && theirSkill >= 6.2
) // Ugly, but the easiest leather BOD is Leather Cap which requires at least 6.2 skill.
entries = SmallBulkEntry.TailorLeather;

View file

@ -393,6 +393,7 @@ namespace Server.Engines.CannedEvil
}
catch
{
// ignored
}
}
}
@ -769,7 +770,6 @@ namespace Server.Engines.CannedEvil
switch (index)
{
default:
case 0:
x = -1;
y = -1;
break;

View file

@ -1,5 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Gumps;
using Server.Mobiles;
using Server.Network;
@ -11,7 +11,7 @@ namespace Server.Engines.ConPVP
private const int LabelColor32 = 0xFFFFFF;
private const int BlackColor32 = 0x000008;
private static Hashtable m_IgnoreLists = new Hashtable();
private static Dictionary<Mobile, List<IgnoreEntry>> m_IgnoreLists = new Dictionary<Mobile, List<IgnoreEntry>>();
private bool m_Active = true;
private Mobile m_Challenger, m_Challenged;
@ -28,7 +28,7 @@ namespace Server.Engines.ConPVP
m_Participant = p;
m_Slot = slot;
challenged.CloseGump(typeof(AcceptDuelGump));
challenged.CloseGump<AcceptDuelGump>();
Closable = false;
@ -109,7 +109,7 @@ namespace Server.Engines.ConPVP
m_Active = false;
m_Challenged.CloseGump(typeof(AcceptDuelGump));
m_Challenged.CloseGump<AcceptDuelGump>();
m_Challenger.SendMessage("{0} seems unresponsive.", m_Challenged.Name);
m_Challenged.SendMessage("You decline the challenge.");
@ -117,14 +117,14 @@ namespace Server.Engines.ConPVP
public static void BeginIgnore(Mobile source, Mobile toIgnore)
{
ArrayList list = (ArrayList)m_IgnoreLists[source];
List<IgnoreEntry> list = m_IgnoreLists[source];
if (list == null)
m_IgnoreLists[source] = list = new ArrayList();
m_IgnoreLists[source] = list = new List<IgnoreEntry>();
for (int i = 0; i < list.Count; ++i)
{
IgnoreEntry ie = (IgnoreEntry)list[i];
IgnoreEntry ie = list[i];
if (ie.Ignored == toIgnore)
{
@ -132,7 +132,8 @@ namespace Server.Engines.ConPVP
return;
}
if (ie.Expired) list.RemoveAt(i--);
if (ie.Expired)
list.RemoveAt(i--);
}
list.Add(new IgnoreEntry(toIgnore));
@ -140,14 +141,14 @@ namespace Server.Engines.ConPVP
public static bool IsIgnored(Mobile source, Mobile check)
{
ArrayList list = (ArrayList)m_IgnoreLists[source];
List<IgnoreEntry> list = m_IgnoreLists[source];
if (list == null)
return false;
for (int i = 0; i < list.Count; ++i)
{
IgnoreEntry ie = (IgnoreEntry)list[i];
IgnoreEntry ie = list[i];
if (ie.Expired)
list.RemoveAt(i--);

View file

@ -8,15 +8,13 @@ namespace Server.Engines.ConPVP
{
public class ArenaController : Item
{
private Arena m_Arena;
[Constructible]
public ArenaController() : base(0x1B7A)
{
Visible = false;
Movable = false;
m_Arena = new Arena();
Arena = new Arena();
Instances.Add(this);
}
@ -26,11 +24,7 @@ namespace Server.Engines.ConPVP
}
[CommandProperty(AccessLevel.GameMaster)]
public Arena Arena
{
get => m_Arena;
set { }
}
public Arena Arena{ get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public bool IsPrivate{ get; set; }
@ -44,13 +38,13 @@ namespace Server.Engines.ConPVP
base.OnDelete();
Instances.Remove(this);
m_Arena.Delete();
Arena.Delete();
}
public override void OnDoubleClick(Mobile from)
{
if (from.AccessLevel >= AccessLevel.GameMaster)
from.SendGump(new PropertiesGump(from, m_Arena));
from.SendGump(new PropertiesGump(from, Arena));
}
public override void Serialize(GenericWriter writer)
@ -61,7 +55,7 @@ namespace Server.Engines.ConPVP
writer.Write(IsPrivate);
m_Arena.Serialize(writer);
Arena.Serialize(writer);
}
public override void Deserialize(GenericReader reader)
@ -80,7 +74,7 @@ namespace Server.Engines.ConPVP
}
case 0:
{
m_Arena = new Arena(reader);
Arena = new Arena(reader);
break;
}
}
@ -191,7 +185,6 @@ namespace Server.Engines.ConPVP
private bool m_IsGuarded;
private string m_Name;
private ArenaStartPoints m_Points;
private SafeZone m_Region;
@ -200,7 +193,7 @@ namespace Server.Engines.ConPVP
public Arena()
{
m_Points = new ArenaStartPoints();
Points = new ArenaStartPoints();
Players = new List<Mobile>();
}
@ -269,7 +262,7 @@ namespace Server.Engines.ConPVP
}
m_Active = reader.ReadBool();
m_Points = new ArenaStartPoints(reader);
Points = new ArenaStartPoints(reader);
if (m_Active)
{
@ -425,11 +418,7 @@ namespace Server.Engines.ConPVP
public bool IsOccupied => Players.Count > 0;
[CommandProperty(AccessLevel.GameMaster)]
public ArenaStartPoints Points
{
get => m_Points;
set { }
}
public ArenaStartPoints Points{ get; private set; }
public Item Teleporter{ get; set; }
@ -514,7 +503,7 @@ namespace Server.Engines.ConPVP
if (index < 0)
index = 0;
return m_Points.Points[index % m_Points.Points.Length];
return Points.Points[index % Points.Points.Length];
}
public void MoveInside(DuelPlayer[] players, int index)
@ -522,7 +511,7 @@ namespace Server.Engines.ConPVP
if (index < 0)
index = 0;
else
index %= m_Points.Points.Length;
index %= Points.Points.Length;
Point3D start = GetBaseStartPoint(index);
@ -652,7 +641,7 @@ namespace Server.Engines.ConPVP
writer.Write(Wall);
writer.Write(m_Active);
m_Points.Serialize(writer);
Points.Serialize(writer);
}
public static Arena FindArena(List<Mobile> players)

View file

@ -33,19 +33,18 @@ namespace Server.Engines.ConPVP
private Timer m_Countdown;
private ArrayList m_Entered = new ArrayList();
public EventGame m_EventGame;
private Map m_GateFacet;
private Point3D m_GatePoint;
public TournyMatch m_Match;
public TourneyMatch m_Match;
public Arena m_OverrideArena;
private Timer m_SDWarnTimer, m_SDActivateTimer;
public Tournament m_Tournament;
private ArrayList m_Walls = new ArrayList();
private List<Item> m_Walls = new List<Item>();
private bool m_Yielding;
@ -56,7 +55,7 @@ namespace Server.Engines.ConPVP
public DuelContext(Mobile initiator, RulesetLayout layout, bool addNew)
{
Initiator = initiator;
Participants = new ArrayList();
Participants = new List<Participant>();
Ruleset = new Ruleset(layout);
Ruleset.ApplyDefault(layout.Defaults[0]);
@ -64,8 +63,7 @@ namespace Server.Engines.ConPVP
{
Participants.Add(new Participant(this, 1));
Participants.Add(new Participant(this, 1));
((Participant)Participants[0]).Add(initiator);
Participants[0].Add(initiator);
}
}
@ -83,7 +81,7 @@ namespace Server.Engines.ConPVP
public Mobile Initiator{ get; }
public ArrayList Participants{ get; }
public List<Participant> Participants{ get; }
public Ruleset Ruleset{ get; private set; }
@ -93,22 +91,8 @@ namespace Server.Engines.ConPVP
public bool IsSuddenDeath{ get; set; }
public bool IsOneVsOne
{
get
{
if (Participants.Count != 2)
return false;
if (((Participant)Participants[0]).Players.Length != 1)
return false;
if (((Participant)Participants[1]).Players.Length != 1)
return false;
return true;
}
}
public bool IsOneVsOne => Participants.Count == 2 && Participants[0].Players.Length == 1 &&
Participants[1].Players.Length == 1;
public bool StartedBeginCountdown{ get; private set; }
@ -134,7 +118,7 @@ namespace Server.Engines.ConPVP
public void DelayBounce(TimeSpan ts, Mobile mob, Container corpse)
{
Timer.DelayCall(ts, new TimerStateCallback(DelayBounce_Callback), new object[] { mob, corpse });
Timer.DelayCall(ts, () => DelayBounce_Callback(mob, corpse));
}
public static bool AllowSpecialMove(Mobile from, string name, SpecialMove move)
@ -183,7 +167,7 @@ namespace Server.Engines.ConPVP
DuelPlayer pl = Find(from);
if (pl == null || pl.Eliminated)
if (pl?.Eliminated != false)
return true;
if (CantDoAnything(from))
@ -192,7 +176,8 @@ namespace Server.Engines.ConPVP
if (spell is RecallSpell)
from.SendMessage("You may not cast this spell.");
string title = null, option = null;
string title = null;
string option;
if (spell is ArcanistSpell)
{
@ -492,12 +477,8 @@ namespace Server.Engines.ConPVP
return false;
}
private void DelayBounce_Callback(object state)
private void DelayBounce_Callback(Mobile mob, Container corpse)
{
object[] states = (object[])state;
Mobile mob = (Mobile)states[0];
Container corpse = (Container)states[1];
RemoveAggressions(mob);
SendOutside(mob);
Refresh(mob, corpse);
@ -698,11 +679,11 @@ namespace Server.Engines.ConPVP
winner.Players.Length == 1 ? "{0} has won the duel." : "{0} and {1} team have won the duel.",
winner.Players.Length == 1 ? "You have won the duel." : "Your team has won the duel.");
if (m_Tournament != null && winner.TournyPart != null)
if (m_Tournament != null && winner.TourneyPart != null)
{
m_Match.Winner = winner.TournyPart;
winner.TournyPart.WonMatch(m_Match);
m_Tournament.HandleWon(Arena, m_Match, winner.TournyPart);
m_Match.Winner = winner.TourneyPart;
winner.TourneyPart.WonMatch(m_Match);
m_Tournament.HandleWon(Arena, m_Match, winner.TourneyPart);
}
for (int i = 0; i < Participants.Count; ++i)
@ -716,7 +697,7 @@ namespace Server.Engines.ConPVP
loser.Players.Length == 1 ? "You have lost the duel." : "Your team has lost the duel.");
if (m_Tournament != null)
loser.TournyPart?.LostMatch(m_Match);
loser.TourneyPart?.LostMatch(m_Match);
}
for (int j = 0; j < loser.Players.Length; ++j)
@ -724,7 +705,7 @@ namespace Server.Engines.ConPVP
{
RemoveAggressions(loser.Players[j].Mobile);
loser.Players[j].Mobile.Delta(MobileDelta.Noto);
loser.Players[j].Mobile.CloseGump(typeof(BeginGump));
loser.Players[j].Mobile.CloseGump<BeginGump>();
if (m_Tournament != null)
loser.Players[j].Mobile.SendEverything();
@ -814,12 +795,6 @@ namespace Server.Engines.ConPVP
StopSDTimers();
Type[] types =
{
typeof(BeginGump), typeof(DuelContextGump), typeof(ParticipantGump), typeof(PickRulesetGump),
typeof(ReadyGump), typeof(ReadyUpGump), typeof(RulesetGump)
};
for (int i = 0; i < Participants.Count; ++i)
{
Participant p = (Participant)Participants[i];
@ -834,8 +809,7 @@ namespace Server.Engines.ConPVP
if (pl.Mobile is PlayerMobile mobile)
mobile.DuelPlayer = null;
for (int k = 0; k < types.Length; ++k)
pl.Mobile.CloseGump(types[k]);
CloseAllGumps(pl);
}
}
@ -936,33 +910,21 @@ namespace Server.Engines.ConPVP
{
cb(count);
m_Countdown = Timer.DelayCall(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0), count,
new TimerStateCallback(Countdown_Callback), new object[] { count - 1, cb });
() => Countdown_Callback(--count, cb));
}
public void StopCountdown()
{
m_Countdown?.Stop();
m_Countdown = null;
}
private void Countdown_Callback(object state)
private void Countdown_Callback(int count, CountdownCallback cb)
{
object[] states = (object[])state;
int count = (int)states[0];
CountdownCallback cb = (CountdownCallback)states[1];
if (count == 0)
{
m_Countdown?.Stop();
m_Countdown = null;
}
StopCountdown();
cb(count);
states[0] = count - 1;
}
public void StopSDTimers()
@ -1051,7 +1013,7 @@ namespace Server.Engines.ConPVP
{
m_AutoTieTimer?.Stop();
TimeSpan ts = m_Tournament == null || m_Tournament.TournyType == TournyType.Standard
TimeSpan ts = m_Tournament == null || m_Tournament.TourneyType == TourneyType.Standard
? AutoTieDelay
: TimeSpan.FromMinutes(90.0);
@ -1077,11 +1039,11 @@ namespace Server.Engines.ConPVP
StopSDTimers();
ArrayList remaining = new ArrayList();
List<TourneyParticipant> remaining = new List<TourneyParticipant>();
for (int i = 0; i < Participants.Count; ++i)
{
Participant p = (Participant)Participants[i];
Participant p = Participants[i];
if (p.Eliminated)
{
@ -1107,8 +1069,8 @@ namespace Server.Engines.ConPVP
DelayBounce(TimeSpan.FromSeconds(8.0), pl.Mobile, null);
}
if (p.TournyPart != null)
remaining.Add(p.TournyPart);
if (p.TourneyPart != null)
remaining.Add(p.TourneyPart);
}
for (int j = 0; j < p.Players.Length; ++j)
@ -1204,12 +1166,10 @@ namespace Server.Engines.ConPVP
}
}
private static void ViewLadder_OnTarget(Mobile from, object obj, object state)
private static void ViewLadder_OnTarget(Mobile from, object obj, Ladder ladder)
{
if (obj is PlayerMobile pm)
{
Ladder ladder = (Ladder)state;
LadderEntry entry = ladder.Find(pm);
if (entry == null)
@ -1249,7 +1209,7 @@ namespace Server.Engines.ConPVP
if (!pm.CheckAlive())
{
}
else if (pm.Region.IsPartOf(typeof(Jail)))
else if (pm.Region.IsPartOf<Jail>())
{
}
else if (CheckCombat(pm))
@ -1285,7 +1245,7 @@ namespace Server.Engines.ConPVP
if (prefs != null)
{
e.Mobile.CloseGump(typeof(PreferencesGump));
e.Mobile.CloseGump<PreferencesGump>();
e.Mobile.SendGump(new PreferencesGump(e.Mobile, prefs));
}
}
@ -1341,7 +1301,7 @@ namespace Server.Engines.ConPVP
else
{
pm.SendMessage("Target a player to view their ranking and level.");
pm.BeginTarget(16, false, TargetFlags.None, new TargetStateCallback(ViewLadder_OnTarget), instance);
pm.BeginTarget(16, false, TargetFlags.None, ViewLadder_OnTarget, instance);
}
}
}
@ -1551,12 +1511,20 @@ namespace Server.Engines.ConPVP
}
}
}
public void CloseAllGumps(DuelPlayer pl)
{
pl.Mobile.CloseGump<BeginGump>();
pl.Mobile.CloseGump<DuelContextGump>();
pl.Mobile.CloseGump<ParticipantGump>();
pl.Mobile.CloseGump<PickRulesetGump>();
pl.Mobile.CloseGump<ReadyGump>();
pl.Mobile.CloseGump<ReadyUpGump>();
pl.Mobile.CloseGump<RulesetGump>();
}
public void CloseAllGumps()
{
Type[] types = { typeof(DuelContextGump), typeof(ParticipantGump), typeof(RulesetGump) };
int[] defs = { -1, -1, -1 };
for (int i = 0; i < Participants.Count; ++i)
{
Participant p = (Participant)Participants[i];
@ -1565,14 +1533,8 @@ namespace Server.Engines.ConPVP
{
DuelPlayer pl = p.Players[j];
if (pl == null)
continue;
Mobile mob = pl.Mobile;
for (int k = 0; k < types.Length; ++k)
mob.CloseGump(types[k]);
//mob.CloseGump( types[k], defs[k] );
if (pl != null)
CloseAllGumps(pl);
}
}
}
@ -1582,9 +1544,6 @@ namespace Server.Engines.ConPVP
if (StartedReadyCountdown)
return; // sanity
Type[] types = { typeof(DuelContextGump), typeof(ReadyUpGump), typeof(ReadyGump) };
int[] defs = { -1, -1, -1 };
for (int i = 0; i < Participants.Count; ++i)
{
Participant p = (Participant)Participants[i];
@ -1612,10 +1571,11 @@ namespace Server.Engines.ConPVP
else
mob.SendMessage(0x22, "{0} has rejected the {1}.", rejector.Name, Rematch ? "rematch" : page);
}
for (int k = 0; k < types.Length; ++k)
mob.CloseGump(types[k]);
//mob.CloseGump( types[k], defs[k] );
// Close all of them?
mob.CloseGump<DuelContextGump>();
mob.CloseGump<ReadyUpGump>();
mob.CloseGump<ReadyGump>();
}
}
@ -1655,7 +1615,7 @@ namespace Server.Engines.ConPVP
ArchProtectionSpell.RemoveEntry(mob);
mob.EndAction(typeof(DefensiveSpell));
mob.EndAction<DefensiveSpell>();
}
TransformationSpellHelper.RemoveContext(mob, true);
@ -1664,11 +1624,11 @@ namespace Server.Engines.ConPVP
if (DisguiseTimers.IsDisguised(mob))
DisguiseTimers.StopTimer(mob);
if (!mob.CanBeginAction(typeof(PolymorphSpell)))
if (!mob.CanBeginAction<PolymorphSpell>())
{
mob.BodyMod = 0;
mob.HueMod = -1;
mob.EndAction(typeof(PolymorphSpell));
mob.EndAction<PolymorphSpell>();
}
BaseArmor.ValidateMobile(mob);
@ -1692,7 +1652,7 @@ namespace Server.Engines.ConPVP
public void DestroyWall()
{
for (int i = 0; i < m_Walls.Count; ++i)
((Item)m_Walls[i]).Delete();
m_Walls[i].Delete();
m_Walls.Clear();
}
@ -1739,11 +1699,11 @@ namespace Server.Engines.ConPVP
{
for (int i = 0; i < Participants.Count; ++i)
{
Participant p = (Participant)Participants[i];
Participant p = Participants[i];
if (p.Players.Length > 1)
{
ArrayList players = new ArrayList();
List<Mobile> players = new List<Mobile>();
for (int j = 0; j < p.Players.Length; ++j)
{
@ -1758,7 +1718,7 @@ namespace Server.Engines.ConPVP
if (players.Count > 1)
for (int leaderIndex = 0; leaderIndex + 1 < players.Count; leaderIndex += Party.Capacity)
{
Mobile leader = (Mobile)players[leaderIndex];
Mobile leader = players[leaderIndex];
Party party = Party.Get(leader);
if (party == null)
@ -1774,7 +1734,7 @@ namespace Server.Engines.ConPVP
for (int j = leaderIndex + 1; j < players.Count && j < leaderIndex + Party.Capacity; ++j)
{
Mobile player = (Mobile)players[j];
Mobile player = players[j];
Party existing = Party.Get(player);
if (existing == party)
@ -1807,7 +1767,7 @@ namespace Server.Engines.ConPVP
{
for (int i = 0; i < Participants.Count; ++i)
{
Participant p = (Participant)Participants[i];
Participant p = Participants[i];
for (int j = 0; j < p.Players.Length; ++j)
{
@ -1945,11 +1905,9 @@ namespace Server.Engines.ConPVP
BeginAutoTie();
}
Type[] types = { typeof(ReadyGump), typeof(ReadyUpGump), typeof(BeginGump) };
for (int i = 0; i < Participants.Count; ++i)
{
Participant p = (Participant)Participants[i];
Participant p = Participants[i];
for (int j = 0; j < p.Players.Length; ++j)
{
@ -1963,13 +1921,18 @@ namespace Server.Engines.ConPVP
if (count > 0)
{
if (count == 10)
CloseAndSendGump(mob, new BeginGump(count), types);
{
mob.CloseGump<ReadyGump>();
mob.CloseGump<ReadyUpGump>();
mob.CloseGump<BeginGump>();
mob.SendGump(new BeginGump(count));
}
mob.Frozen = true;
}
else
{
mob.CloseGump(typeof(BeginGump));
mob.CloseGump<BeginGump>();
mob.Frozen = false;
}
}
@ -1980,7 +1943,7 @@ namespace Server.Engines.ConPVP
{
for (int i = 0; i < Participants.Count; ++i)
{
Participant p = (Participant)Participants[i];
Participant p = Participants[i];
for (int j = 0; j < p.Players.Length; ++j)
{
@ -2005,11 +1968,9 @@ namespace Server.Engines.ConPVP
ReadyWait = true;
ReadyCount = -1;
Type[] types = { typeof(ReadyUpGump) };
for (int i = 0; i < Participants.Count; ++i)
{
Participant p = (Participant)Participants[i];
Participant p = Participants[i];
for (int j = 0; j < p.Players.Length; ++j)
{
@ -2017,9 +1978,11 @@ namespace Server.Engines.ConPVP
Mobile mob = pl?.Mobile;
if (mob != null)
if (m_Tournament == null)
CloseAndSendGump(mob, new ReadyUpGump(mob, this), types);
if (mob != null && m_Tournament == null)
{
mob.CloseGump<ReadyUpGump>();
mob.SendGump(new ReadyUpGump(mob, this));
}
}
}
}
@ -2031,7 +1994,7 @@ namespace Server.Engines.ConPVP
for (int i = 0; i < Participants.Count; ++i)
{
Participant p = (Participant)Participants[i];
Participant p = Participants[i];
for (int j = 0; j < p.Players.Length; ++j)
{
@ -2040,7 +2003,7 @@ namespace Server.Engines.ConPVP
if (dp == null)
return "a slot is empty";
if (dp.Mobile.Region.IsPartOf(typeof(Jail)))
if (dp.Mobile.Region.IsPartOf<Jail>())
return $"{dp.Mobile.Name} is in jail";
if (Sigil.ExistsOn(dp.Mobile))
@ -2089,7 +2052,7 @@ namespace Server.Engines.ConPVP
{
for (int i = 0; i < Participants.Count; ++i)
{
Participant p = (Participant)Participants[i];
Participant p = Participants[i];
for (int j = 0; j < p.Players.Length; ++j)
{
@ -2110,7 +2073,7 @@ namespace Server.Engines.ConPVP
for (int i = 0; i < Participants.Count; ++i)
{
Participant p = (Participant)Participants[i];
Participant p = Participants[i];
for (int j = 0; j < p.Players.Length; ++j)
{
@ -2130,7 +2093,7 @@ namespace Server.Engines.ConPVP
{
for (int i = 0; i < Participants.Count; ++i)
{
Participant p = (Participant)Participants[i];
Participant p = Participants[i];
for (int j = 0; j < p.Players.Length; ++j)
{
@ -2173,7 +2136,7 @@ namespace Server.Engines.ConPVP
for (int i = 0; i < Participants.Count; ++i)
{
Participant p = (Participant)Participants[i];
Participant p = Participants[i];
for (int j = 0; j < p.Players.Length; ++j)
{
@ -2206,7 +2169,7 @@ namespace Server.Engines.ConPVP
{
for (int i = 0; i < Participants.Count; ++i)
{
Participant p = (Participant)Participants[i];
Participant p = Participants[i];
for (int j = 0; j < p.Players.Length; ++j)
{
@ -2227,11 +2190,9 @@ namespace Server.Engines.ConPVP
bool isAllReady = true;
Type[] types = { typeof(ReadyGump) };
for (int i = 0; i < Participants.Count; ++i)
{
Participant p = (Participant)Participants[i];
Participant p = Participants[i];
for (int j = 0; j < p.Players.Length; ++j)
{
@ -2245,7 +2206,10 @@ namespace Server.Engines.ConPVP
if (pl.Ready)
{
if (m_Tournament == null)
CloseAndSendGump(mob, new ReadyGump(mob, this, count), types);
{
mob.CloseGump<ReadyGump>();
mob.SendGump(new ReadyGump(mob, this, count));
}
}
else
{
@ -2258,45 +2222,6 @@ namespace Server.Engines.ConPVP
StartCountdown(3, SendReadyGump);
}
public static void CloseAndSendGump(Mobile mob, Gump g, params Type[] types)
{
CloseAndSendGump(mob.NetState, g, types);
}
public static void CloseAndSendGump(NetState ns, Gump g, params Type[] types)
{
Mobile mob = ns?.Mobile;
if (mob != null)
{
foreach (Type type in types) mob.CloseGump(type);
mob.SendGump(g);
}
/*if ( ns == null )
return;
for ( int i = 0; i < types.Length; ++i )
ns.Send( new CloseGump( Gump.GetTypeID( types[i] ), 0 ) );
g.SendTo( ns );
ns.AddGump( g );
Packet[] packets = new Packet[types.Length + 1];
for ( int i = 0; i < types.Length; ++i )
packets[i] = new CloseGump( Gump.GetTypeID( types[i] ), 0 );
packets[types.Length] = (Packet) typeof( Gump ).InvokeMember( "Compile", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, g, null, null );
bool compress = ns.CompressionEnabled;
ns.CompressionEnabled = false;
ns.Send( BindPackets( compress, packets ) );
ns.CompressionEnabled = compress;*/
}
private class InternalWall : Item
{
public InternalWall() : base(0x80)
@ -2395,11 +2320,11 @@ namespace Server.Engines.ConPVP
private class ExitTeleporter : Item
{
private ArrayList m_Entries;
private List<ReturnEntry> m_Entries;
public ExitTeleporter() : base(0x1822)
{
m_Entries = new ArrayList();
m_Entries = new List<ReturnEntry>();
Hue = 0x482;
Movable = false;
@ -2428,7 +2353,7 @@ namespace Server.Engines.ConPVP
{
for (int i = 0; i < m_Entries.Count; ++i)
{
ReturnEntry entry = (ReturnEntry)m_Entries[i];
ReturnEntry entry = m_Entries[i];
if (entry.Mobile == mob)
return entry;
@ -2472,7 +2397,7 @@ namespace Server.Engines.ConPVP
for (int i = 0; i < m_Entries.Count; ++i)
{
ReturnEntry entry = (ReturnEntry)m_Entries[i];
ReturnEntry entry = m_Entries[i];
writer.Write(entry.Mobile);
writer.Write(entry.Location);
@ -2495,7 +2420,7 @@ namespace Server.Engines.ConPVP
{
int count = reader.ReadEncodedInt();
m_Entries = new ArrayList(count);
m_Entries = new List<ReturnEntry>(count);
for (int i = 0; i < count; ++i)
{
@ -2586,35 +2511,5 @@ namespace Server.Engines.ConPVP
Delete();
}
}
/*public static Packet BindPackets( bool compress, params Packet[] packets )
{
if ( packets.Length == 0 )
throw new ArgumentException( "No packets to bind", "packets" );
byte[][] compiled = new byte[packets.Length][];
int[] lengths = new int[packets.Length];
int length = 0;
for ( int i = 0; i < packets.Length; ++i )
{
compiled[i] = packets[i].Compile( compress, out lengths[i] );
length += lengths[i];
}
return new BoundPackets( length, compiled, lengths );
}
private class BoundPackets : Packet
{
public BoundPackets( int length, byte[][] compiled, int[] lengths ) : base( 0, length )
{
m_Stream.Seek( 0, System.IO.SeekOrigin.Begin );
for ( int i = 0; i < compiled.Length; ++i )
m_Stream.Write( compiled[i], 0, lengths[i] );
}
}*/
}
}

View file

@ -1,5 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Server.Gumps;
using Server.Items;
@ -15,7 +16,7 @@ namespace Server.Engines.ConPVP
private BRGame m_Game;
private ArrayList m_Helpers;
private List<Mobile> m_Helpers;
private Point3DList m_Path = new Point3DList();
private int m_PathIdx;
@ -29,7 +30,7 @@ namespace Server.Engines.ConPVP
m_Game = game;
m_Helpers = new ArrayList();
m_Helpers = new List<Mobile>();
m_Timer = new EffectTimer(this);
m_Timer.Start();
@ -230,7 +231,7 @@ namespace Server.Engines.ConPVP
private void DoAnim(Point3D start, Point3D end, Map map)
{
Effects.SendMovingEffect(new Entity(Serial.Zero, start, map), new Entity(Serial.Zero, end, map),
ItemID, 15, 0, false, false, Hue, 0);
ItemID, 15, 0, false, false, Hue);
}
private void DoCatch(Mobile m)
@ -270,29 +271,21 @@ namespace Server.Engines.ConPVP
dest = swap;
}*/
ArrayList list = new ArrayList();
double rise, run, zslp;
double dist3d, dist2d;
double x, y, z;
int xd, yd, zd;
Point3D p;
List<Point3D> list = new List<Point3D>();
xd = dest.X - org.X;
yd = dest.Y - org.Y;
zd = dest.Z - org.Z;
dist2d = Math.Sqrt(xd * xd + yd * yd);
if (zd != 0)
dist3d = Math.Sqrt(dist2d * dist2d + zd * zd);
else
dist3d = dist2d;
int xd = dest.X - org.X;
int yd = dest.Y - org.Y;
int zd = dest.Z - org.Z;
double dist2d = Math.Sqrt(xd * xd + yd * yd);
double dist3d = zd == 0 ? dist2d : Math.Sqrt(dist2d * dist2d + zd * zd);
rise = yd / dist3d;
run = xd / dist3d;
zslp = zd / dist3d;
double rise = yd / dist3d;
double run = xd / dist3d;
double zslp = zd / dist3d;
x = org.X;
y = org.Y;
z = org.Z;
double x = org.X;
double y = org.Y;
double z = org.Z;
while (Utility.NumberBetween(x, dest.X, org.X, 0.5) && Utility.NumberBetween(y, dest.Y, org.Y, 0.5) &&
Utility.NumberBetween(z, dest.Z, org.Z, 0.5))
{
@ -302,7 +295,7 @@ namespace Server.Engines.ConPVP
if (list.Count > 0)
{
p = (Point3D)list[list.Count - 1];
Point3D p = list[list.Count - 1];
if (p.X != ix || p.Y != iy || p.Z != iz)
list.Add(new Point3D(ix, iy, iz));
@ -317,9 +310,8 @@ namespace Server.Engines.ConPVP
z += zslp;
}
if (list.Count > 0)
if ((Point3D)list[list.Count - 1] != dest)
list.Add(dest);
if (list.Count > 0 && list[list.Count - 1] != dest)
list.Add(dest);
/*if ( dist3d > 4 && ( dest.X != org.X || dest.Y != org.Y ) )
{
@ -359,7 +351,7 @@ namespace Server.Engines.ConPVP
for (int i = 0; i < count; i++)
{
p = (Point3D)list[i];
Point3D p = list[i];
int xp = i - count / 2;
@ -371,7 +363,7 @@ namespace Server.Engines.ConPVP
m_Path.Clear();
for (int i = 0; i < list.Count; i++)
m_Path.Add((Point3D)list[i]);
m_Path.Add(list[i]);
m_PathIdx = 0;
@ -616,7 +608,7 @@ namespace Server.Engines.ConPVP
for (int i = m_Helpers.Count - 1; i >= 0; i--)
{
Mobile mob = (Mobile)m_Helpers[i];
Mobile mob = m_Helpers[i];
BRPlayerInfo pi = team[mob];
if (pi != null)
@ -661,7 +653,7 @@ namespace Server.Engines.ConPVP
if (m_Helpers.Count > 0)
{
Mobile last = (Mobile)m_Helpers[0];
Mobile last = m_Helpers[0];
if (m_Game.GetTeamInfo(last) != team)
m_Helpers.Clear();
@ -951,7 +943,7 @@ namespace Server.Engines.ConPVP
{
if (m_TeamInfo?.Game != null)
{
from.CloseGump(typeof(BRBoardGump));
from.CloseGump<BRBoardGump>();
from.SendGump(new BRBoardGump(from, m_TeamInfo.Game));
}
}
@ -983,16 +975,17 @@ namespace Server.Engines.ConPVP
{
}
public BRBoardGump(Mobile mob, BRGame game, BRTeamInfo section)
: base(60, 60)
public BRBoardGump(Mobile mob, BRGame game, BRTeamInfo section) : base(60, 60)
{
m_Game = game;
BRTeamInfo ourTeam = game.GetTeamInfo(mob);
ArrayList entries = new ArrayList();
List<BRTeamInfo> entries = new List<BRTeamInfo>();
int total = 0;
if (section == null)
{
for (int i = 0; i < game.Context.Participants.Count; ++i)
{
BRTeamInfo teamInfo = game.Controller.TeamInfo[i % game.Controller.TeamInfo.Length];
@ -1002,17 +995,15 @@ namespace Server.Engines.ConPVP
entries.Add(teamInfo);
}
total = entries.Count;
}
else
foreach (BRPlayerInfo player in section.Players.Values)
if (player.Score > 0)
entries.Add(player);
total++;
entries.Sort();
/*
delegate( IRankedCTF a, IRankedCTF b )
{
return b.Score - a.Score;
} );*/
int height = 0;
@ -1027,7 +1018,7 @@ namespace Server.Engines.ConPVP
AddImageTiled(16, 15, 369, height - 29, 3604);
for (int i = 0; i < entries.Count; i += 1)
for (int i = 0; i < total; i += 1)
AddImageTiled(22, 58 + i * 75, 357, 70, 0x2430);
AddAlphaRegion(16, 15, 369, height - 29);
@ -1043,7 +1034,7 @@ namespace Server.Engines.ConPVP
if (section == null)
for (int i = 0; i < entries.Count; ++i)
{
BRTeamInfo teamInfo = entries[i] as BRTeamInfo;
BRTeamInfo teamInfo = entries[i];
AddImage(30, 70 + i * 75, 10152);
AddImage(30, 85 + i * 75, 10151);
@ -1208,20 +1199,20 @@ namespace Server.Engines.ConPVP
}
[PropertyObject]
public sealed class BRTeamInfo : IRankedCTF, IComparable
public sealed class BRTeamInfo : IRankedCTF, IComparable<BRTeamInfo>
{
private BRGoal m_Goal;
public BRTeamInfo(int teamID)
{
TeamID = teamID;
Players = new Hashtable();
Players = new Dictionary<Mobile, BRPlayerInfo>();
}
public BRTeamInfo(int teamID, GenericReader ip)
{
TeamID = teamID;
Players = new Hashtable();
Players = new Dictionary<Mobile, BRPlayerInfo>();
int version = ip.ReadEncodedInt();
@ -1247,7 +1238,7 @@ namespace Server.Engines.ConPVP
[CommandProperty(AccessLevel.GameMaster)]
public BRBoard Board{ get; set; }
public Hashtable Players{ get; }
public Dictionary<Mobile, BRPlayerInfo> Players{ get; }
public BRPlayerInfo this[Mobile mob]
{
@ -1281,9 +1272,8 @@ namespace Server.Engines.ConPVP
}
}
public int CompareTo(object obj)
public int CompareTo(BRTeamInfo ti)
{
BRTeamInfo ti = (BRTeamInfo)obj;
int res = ti.Captures.CompareTo(Captures);
if (res == 0)
{
@ -1367,32 +1357,16 @@ namespace Server.Engines.ConPVP
public BRTeamInfo[] TeamInfo{ get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public BRTeamInfo Team1
{
get => TeamInfo[0];
set { }
}
public BRTeamInfo Team1 => TeamInfo[0];
[CommandProperty(AccessLevel.GameMaster)]
public BRTeamInfo Team2
{
get => TeamInfo[1];
set { }
}
public BRTeamInfo Team2 => TeamInfo[1];
[CommandProperty(AccessLevel.GameMaster)]
public BRTeamInfo Team3
{
get => TeamInfo[2];
set { }
}
public BRTeamInfo Team3 => TeamInfo[2];
[CommandProperty(AccessLevel.GameMaster)]
public BRTeamInfo Team4
{
get => TeamInfo[3];
set { }
}
public BRTeamInfo Team4 => TeamInfo[3];
[CommandProperty(AccessLevel.GameMaster)]
public TimeSpan Duration{ get; set; }
@ -1515,7 +1489,7 @@ namespace Server.Engines.ConPVP
for (int i = 0; i < m_Context.Participants.Count; ++i)
{
Participant p = m_Context.Participants[i] as Participant;
Participant p = m_Context.Participants[i];
for (int j = 0; j < p.Players.Length; ++j)
if (p.Players[j] != null)
@ -1566,19 +1540,12 @@ namespace Server.Engines.ConPVP
public void DelayBounce(TimeSpan ts, Mobile mob, Container corpse)
{
Timer.DelayCall(ts, new TimerStateCallback(DelayBounce_Callback), new object[] { mob, corpse });
Timer.DelayCall(ts, () => DelayBounce_Callback(mob, corpse));
}
private void DelayBounce_Callback(object state)
private void DelayBounce_Callback(Mobile mob, Container corpse)
{
object[] states = (object[])state;
Mobile mob = (Mobile)states[0];
Container corpse = (Container)states[1];
DuelPlayer dp = null;
if (mob is PlayerMobile mobile)
dp = mobile.DuelPlayer;
DuelPlayer dp = mob is PlayerMobile mobile ? mobile.DuelPlayer : null;
m_Context.RemoveAggressions(mob);
@ -1631,7 +1598,7 @@ namespace Server.Engines.ConPVP
}
}
mob.CloseGump(typeof(BRBoardGump));
mob.CloseGump<BRBoardGump>();
mob.SendGump(new BRBoardGump(mob, this));
m_Context.Requip(mob, corpse);
@ -1651,7 +1618,7 @@ namespace Server.Engines.ConPVP
}
for (int i = 0; i < m_Context.Participants.Count; ++i)
ApplyHues(m_Context.Participants[i] as Participant,
ApplyHues(m_Context.Participants[i],
Controller.TeamInfo[i % Controller.TeamInfo.Length].Color);
m_FinishTimer?.Stop();
@ -1664,51 +1631,49 @@ namespace Server.Engines.ConPVP
private void Finish_Callback()
{
ArrayList teams = new ArrayList();
List<BRTeamInfo> teams = new List<BRTeamInfo>();
for (int i = 0; i < m_Context.Participants.Count; ++i)
{
BRTeamInfo teamInfo = Controller.TeamInfo[i % Controller.TeamInfo.Length];
if (teamInfo == null)
continue;
teams.Add(teamInfo);
if (teamInfo != null)
teams.Add(teamInfo);
}
teams.Sort();
Tournament tourny = m_Context.m_Tournament;
Tournament tourney = m_Context.m_Tournament;
StringBuilder sb = new StringBuilder();
if (tourny != null && tourny.TournyType == TournyType.FreeForAll)
if (tourney != null && tourney.TourneyType == TourneyType.FreeForAll)
{
sb.Append(m_Context.Participants.Count * tourny.PlayersPerParticipant);
sb.Append(m_Context.Participants.Count * tourney.PlayersPerParticipant);
sb.Append("-man FFA");
}
else if (tourny != null && tourny.TournyType == TournyType.RandomTeam)
else if (tourney != null && tourney.TourneyType == TourneyType.RandomTeam)
{
sb.Append(tourny.ParticipantsPerMatch);
sb.Append(tourney.ParticipantsPerMatch);
sb.Append("-team");
}
else if (tourny != null && tourny.TournyType == TournyType.RedVsBlue)
else if (tourney != null && tourney.TourneyType == TourneyType.RedVsBlue)
{
sb.Append("Red v Blue");
}
else if (tourny != null && tourny.TournyType == TournyType.Faction)
else if (tourney != null && tourney.TourneyType == TourneyType.Faction)
{
sb.Append(tourny.ParticipantsPerMatch);
sb.Append(tourney.ParticipantsPerMatch);
sb.Append("-team Faction");
}
else if (tourny != null)
else if (tourney != null)
{
for (int i = 0; i < tourny.ParticipantsPerMatch; ++i)
for (int i = 0; i < tourney.ParticipantsPerMatch; ++i)
{
if (sb.Length > 0)
sb.Append('v');
sb.Append(tourny.PlayersPerParticipant);
sb.Append(tourney.PlayersPerParticipant);
}
}
@ -1717,7 +1682,7 @@ namespace Server.Engines.ConPVP
string title = sb.ToString();
BRTeamInfo winner = (BRTeamInfo)(teams.Count > 0 ? teams[0] : null);
BRTeamInfo winner = teams.Count > 0 ? teams[0] : null;
for (int i = 0; i < teams.Count; ++i)
{
@ -1728,9 +1693,9 @@ namespace Server.Engines.ConPVP
else if (i == 1)
rank = TrophyRank.Silver;
BRPlayerInfo leader = ((BRTeamInfo)teams[i]).Leader;
BRPlayerInfo leader = teams[i].Leader;
foreach (BRPlayerInfo pl in ((BRTeamInfo)teams[i]).Players.Values)
foreach (BRPlayerInfo pl in teams[i].Players.Values)
{
Mobile mob = pl.Player;
@ -1767,7 +1732,7 @@ namespace Server.Engines.ConPVP
if (pl == leader)
item.ItemID = 4810;
item.Name = $"{item.Name}, {((BRTeamInfo)teams[i]).Name.ToLower()} team";
item.Name = $"{item.Name}, {teams[i].Name.ToLower()} team";
if (!mob.PlaceInBackpack(item))
mob.BankBox.DropItem(item);
@ -1804,7 +1769,7 @@ namespace Server.Engines.ConPVP
if (dp?.Mobile != null)
{
dp.Mobile.CloseGump(typeof(BRBoardGump));
dp.Mobile.CloseGump<BRBoardGump>();
dp.Mobile.SendGump(new BRBoardGump(dp.Mobile, this));
}
}
@ -1818,7 +1783,7 @@ namespace Server.Engines.ConPVP
p.Players[j].Eliminated = true;
}
m_Context.Finish(m_Context.Participants[winner.TeamID] as Participant);
m_Context.Finish(m_Context.Participants[winner.TeamID]);
}
public override void OnStop()
@ -1838,10 +1803,10 @@ namespace Server.Engines.ConPVP
m_Bomb?.Delete();
for (int i = 0; i < m_Context.Participants.Count; ++i)
ApplyHues(m_Context.Participants[i] as Participant, -1);
ApplyHues(m_Context.Participants[i], -1);
m_FinishTimer?.Stop();
m_FinishTimer = null;
}
}
}
}

View file

@ -31,7 +31,7 @@ namespace Server.Engines.ConPVP
{
if (m_TeamInfo?.Game != null)
{
from.CloseGump(typeof(CTFBoardGump));
from.CloseGump<CTFBoardGump>();
from.SendGump(new CTFBoardGump(from, m_TeamInfo.Game));
}
}
@ -58,12 +58,7 @@ namespace Server.Engines.ConPVP
private CTFGame m_Game;
public CTFBoardGump(Mobile mob, CTFGame game)
: this(mob, game, null)
{
}
public CTFBoardGump(Mobile mob, CTFGame game, CTFTeamInfo section)
public CTFBoardGump(Mobile mob, CTFGame game, CTFTeamInfo section = null)
: base(60, 60)
{
m_Game = game;
@ -719,60 +714,28 @@ namespace Server.Engines.ConPVP
public CTFTeamInfo[] TeamInfo{ get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public CTFTeamInfo Team1
{
get => TeamInfo[0];
set { }
}
public CTFTeamInfo Team1 => TeamInfo[0];
[CommandProperty(AccessLevel.GameMaster)]
public CTFTeamInfo Team2
{
get => TeamInfo[1];
set { }
}
public CTFTeamInfo Team2 => TeamInfo[1];
[CommandProperty(AccessLevel.GameMaster)]
public CTFTeamInfo Team3
{
get => TeamInfo[2];
set { }
}
public CTFTeamInfo Team3 => TeamInfo[2];
[CommandProperty(AccessLevel.GameMaster)]
public CTFTeamInfo Team4
{
get => TeamInfo[3];
set { }
}
public CTFTeamInfo Team4 => TeamInfo[3];
[CommandProperty(AccessLevel.GameMaster)]
public CTFTeamInfo Team5
{
get => TeamInfo[4];
set { }
}
public CTFTeamInfo Team5 => TeamInfo[4];
[CommandProperty(AccessLevel.GameMaster)]
public CTFTeamInfo Team6
{
get => TeamInfo[5];
set { }
}
public CTFTeamInfo Team6 => TeamInfo[5];
[CommandProperty(AccessLevel.GameMaster)]
public CTFTeamInfo Team7
{
get => TeamInfo[6];
set { }
}
public CTFTeamInfo Team7 => TeamInfo[6];
[CommandProperty(AccessLevel.GameMaster)]
public CTFTeamInfo Team8
{
get => TeamInfo[7];
set { }
}
public CTFTeamInfo Team8 => TeamInfo[7];
[CommandProperty(AccessLevel.GameMaster)]
public TimeSpan Duration{ get; set; }
@ -876,7 +839,7 @@ namespace Server.Engines.ConPVP
for (int i = 0; i < m_Context.Participants.Count; ++i)
{
Participant p = m_Context.Participants[i] as Participant;
Participant p = m_Context.Participants[i];
for (int j = 0; j < p.Players.Length; ++j)
if (p.Players[j] != null)
@ -932,19 +895,12 @@ namespace Server.Engines.ConPVP
public void DelayBounce(TimeSpan ts, Mobile mob, Container corpse)
{
Timer.DelayCall(ts, new TimerStateCallback(DelayBounce_Callback), new object[] { mob, corpse });
Timer.DelayCall(ts, () => DelayBounce_Callback(mob, corpse));
}
private void DelayBounce_Callback(object state)
private void DelayBounce_Callback(Mobile mob, Container corpse)
{
object[] states = (object[])state;
Mobile mob = (Mobile)states[0];
Container corpse = (Container)states[1];
DuelPlayer dp = null;
if (mob is PlayerMobile mobile)
dp = mobile.DuelPlayer;
DuelPlayer dp = mob is PlayerMobile mobile ? mobile.DuelPlayer : null;
m_Context.RemoveAggressions(mob);
@ -1027,7 +983,7 @@ namespace Server.Engines.ConPVP
}
}
mob.CloseGump(typeof(CTFBoardGump));
mob.CloseGump<CTFBoardGump>();
mob.SendGump(new CTFBoardGump(mob, this));
m_Context.Requip(mob, corpse);
@ -1047,7 +1003,7 @@ namespace Server.Engines.ConPVP
}
for (int i = 0; i < m_Context.Participants.Count; ++i)
ApplyHues(m_Context.Participants[i] as Participant, Controller.TeamInfo[i % 8].Color);
ApplyHues(m_Context.Participants[i], Controller.TeamInfo[i % 8].Color);
m_FinishTimer?.Stop();
@ -1070,37 +1026,37 @@ namespace Server.Engines.ConPVP
teams.Sort(delegate(CTFTeamInfo a, CTFTeamInfo b) { return b.Score - a.Score; });
Tournament tourny = m_Context.m_Tournament;
Tournament tourney = m_Context.m_Tournament;
StringBuilder sb = new StringBuilder();
if (tourny != null && tourny.TournyType == TournyType.FreeForAll)
if (tourney != null && tourney.TourneyType == TourneyType.FreeForAll)
{
sb.Append(m_Context.Participants.Count * tourny.PlayersPerParticipant);
sb.Append(m_Context.Participants.Count * tourney.PlayersPerParticipant);
sb.Append("-man FFA");
}
else if (tourny != null && tourny.TournyType == TournyType.RandomTeam)
else if (tourney != null && tourney.TourneyType == TourneyType.RandomTeam)
{
sb.Append(tourny.ParticipantsPerMatch);
sb.Append(tourney.ParticipantsPerMatch);
sb.Append("-team");
}
else if (tourny != null && tourny.TournyType == TournyType.RedVsBlue)
else if (tourney != null && tourney.TourneyType == TourneyType.RedVsBlue)
{
sb.Append("Red v Blue");
}
else if (tourny != null && tourny.TournyType == TournyType.Faction)
else if (tourney != null && tourney.TourneyType == TourneyType.Faction)
{
sb.Append(tourny.ParticipantsPerMatch);
sb.Append(tourney.ParticipantsPerMatch);
sb.Append("-team Faction");
}
else if (tourny != null)
else if (tourney != null)
{
for (int i = 0; i < tourny.ParticipantsPerMatch; ++i)
for (int i = 0; i < tourney.ParticipantsPerMatch; ++i)
{
if (sb.Length > 0)
sb.Append('v');
sb.Append(tourny.PlayersPerParticipant);
sb.Append(tourney.PlayersPerParticipant);
}
}
@ -1193,7 +1149,7 @@ namespace Server.Engines.ConPVP
for (int i = 0; i < m_Context.Participants.Count; ++i)
{
Participant p = m_Context.Participants[i] as Participant;
Participant p = m_Context.Participants[i];
for (int j = 0; j < p.Players.Length; ++j)
{
@ -1201,7 +1157,7 @@ namespace Server.Engines.ConPVP
if (dp?.Mobile != null)
{
dp.Mobile.CloseGump(typeof(CTFBoardGump));
dp.Mobile.CloseGump<CTFBoardGump>();
dp.Mobile.SendGump(new CTFBoardGump(dp.Mobile, this));
}
}
@ -1214,7 +1170,7 @@ namespace Server.Engines.ConPVP
p.Players[j].Eliminated = true;
}
m_Context.Finish(m_Context.Participants[winner.TeamID] as Participant);
m_Context.Finish(m_Context.Participants[winner.TeamID]);
}
public override void OnStop()
@ -1236,7 +1192,7 @@ namespace Server.Engines.ConPVP
}
for (int i = 0; i < m_Context.Participants.Count; ++i)
ApplyHues(m_Context.Participants[i] as Participant, -1);
ApplyHues(m_Context.Participants[i], -1);
m_FinishTimer?.Stop();

View file

@ -29,7 +29,7 @@ namespace Server.Engines.ConPVP
{
if (m_TeamInfo?.Game != null)
{
from.CloseGump(typeof(DDBoardGump));
from.CloseGump<DDBoardGump>();
from.SendGump(new DDBoardGump(from, m_TeamInfo.Game));
}
}
@ -389,18 +389,10 @@ namespace Server.Engines.ConPVP
public DDTeamInfo[] TeamInfo{ get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public DDTeamInfo Team1
{
get => TeamInfo[0];
set { }
}
public DDTeamInfo Team1 => TeamInfo[0];
[CommandProperty(AccessLevel.GameMaster)]
public DDTeamInfo Team2
{
get => TeamInfo[1];
set { }
}
public DDTeamInfo Team2 => TeamInfo[1];
[CommandProperty(AccessLevel.GameMaster)]
public DDWayPoint PointA{ get; set; }
@ -501,7 +493,7 @@ namespace Server.Engines.ConPVP
for (int i = 0; i < m_Context.Participants.Count; ++i)
{
Participant p = m_Context.Participants[i] as Participant;
Participant p = m_Context.Participants[i];
for (int j = 0; j < p.Players.Length; ++j)
if (p.Players[j] != null)
@ -552,19 +544,12 @@ namespace Server.Engines.ConPVP
public void DelayBounce(TimeSpan ts, Mobile mob, Container corpse)
{
Timer.DelayCall(ts, new TimerStateCallback(DelayBounce_Callback), new object[] { mob, corpse });
Timer.DelayCall(ts, () => DelayBounce_Callback(mob, corpse));
}
private void DelayBounce_Callback(object state)
private void DelayBounce_Callback(Mobile mob, Container corpse)
{
object[] states = (object[])state;
Mobile mob = (Mobile)states[0];
Container corpse = (Container)states[1];
DuelPlayer dp = null;
if (mob is PlayerMobile mobile)
dp = mobile.DuelPlayer;
DuelPlayer dp = mob is PlayerMobile mobile ? mobile.DuelPlayer : null;
m_Context.RemoveAggressions(mob);
@ -613,7 +598,7 @@ namespace Server.Engines.ConPVP
}
}
mob.CloseGump(typeof(DDBoardGump));
mob.CloseGump<DDBoardGump>();
mob.SendGump(new DDBoardGump(mob, this));
m_Context.Requip(mob, corpse);
@ -653,7 +638,7 @@ namespace Server.Engines.ConPVP
Controller.PointB.Game = this;
for (int i = 0; i < m_Context.Participants.Count; ++i)
ApplyHues(m_Context.Participants[i] as Participant,
ApplyHues(m_Context.Participants[i],
Controller.TeamInfo[i % Controller.TeamInfo.Length].Color);
m_FinishTimer?.Stop();
@ -674,37 +659,37 @@ namespace Server.Engines.ConPVP
teams.Sort((a, b) => b.Score - a.Score);
Tournament tourny = m_Context.m_Tournament;
Tournament tourney = m_Context.m_Tournament;
StringBuilder sb = new StringBuilder();
if (tourny != null && tourny.TournyType == TournyType.FreeForAll)
if (tourney != null && tourney.TourneyType == TourneyType.FreeForAll)
{
sb.Append(m_Context.Participants.Count * tourny.PlayersPerParticipant);
sb.Append(m_Context.Participants.Count * tourney.PlayersPerParticipant);
sb.Append("-man FFA");
}
else if (tourny != null && tourny.TournyType == TournyType.RandomTeam)
else if (tourney != null && tourney.TourneyType == TourneyType.RandomTeam)
{
sb.Append(tourny.ParticipantsPerMatch);
sb.Append(tourney.ParticipantsPerMatch);
sb.Append("-team");
}
else if (tourny != null && tourny.TournyType == TournyType.RedVsBlue)
else if (tourney != null && tourney.TourneyType == TourneyType.RedVsBlue)
{
sb.Append("Red v Blue");
}
else if (tourny != null && tourny.TournyType == TournyType.Faction)
else if (tourney != null && tourney.TourneyType == TourneyType.Faction)
{
sb.Append(tourny.ParticipantsPerMatch);
sb.Append(tourney.ParticipantsPerMatch);
sb.Append("-team Faction");
}
else if (tourny != null)
else if (tourney != null)
{
for (int i = 0; i < tourny.ParticipantsPerMatch; ++i)
for (int i = 0; i < tourney.ParticipantsPerMatch; ++i)
{
if (sb.Length > 0)
sb.Append('v');
sb.Append(tourny.PlayersPerParticipant);
sb.Append(tourney.PlayersPerParticipant);
}
}
@ -797,7 +782,7 @@ namespace Server.Engines.ConPVP
for (int i = 0; i < m_Context.Participants.Count; ++i)
{
Participant p = m_Context.Participants[i] as Participant;
Participant p = m_Context.Participants[i];
for (int j = 0; j < p.Players.Length; ++j)
{
@ -805,7 +790,7 @@ namespace Server.Engines.ConPVP
if (dp?.Mobile != null)
{
dp.Mobile.CloseGump(typeof(DDBoardGump));
dp.Mobile.CloseGump<DDBoardGump>();
dp.Mobile.SendGump(new DDBoardGump(dp.Mobile, this));
}
}
@ -818,7 +803,7 @@ namespace Server.Engines.ConPVP
p.Players[j].Eliminated = true;
}
m_Context.Finish(m_Context.Participants[winner.TeamID] as Participant);
m_Context.Finish(m_Context.Participants[winner.TeamID]);
}
public override void OnStop()
@ -854,7 +839,7 @@ namespace Server.Engines.ConPVP
}
for (int i = 0; i < m_Context.Participants.Count; ++i)
ApplyHues(m_Context.Participants[i] as Participant, -1);
ApplyHues(m_Context.Participants[i], -1);
m_FinishTimer?.Stop();
m_FinishTimer = null;

View file

@ -1,5 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Server.Gumps;
using Server.Items;
@ -170,12 +171,10 @@ namespace Server.Engines.ConPVP
private void ReKingify(Mobile m)
{
KHTeamInfo ti = null;
if (m_Game == null || m == null)
return;
ti = m_Game.GetTeamInfo(m);
if (ti == null)
if (m_Game.GetTeamInfo(m) == null)
return;
King = m;
@ -216,7 +215,6 @@ namespace Server.Engines.ConPVP
protected override void OnTick()
{
KHTeamInfo ti = null;
KHPlayerInfo pi = null;
if (m_Hill == null || m_Hill.Deleted || m_Hill.Game == null)
@ -232,7 +230,7 @@ namespace Server.Engines.ConPVP
return;
}
ti = m_Hill.Game.GetTeamInfo(m_Hill.King);
KHTeamInfo ti = m_Hill.Game.GetTeamInfo(m_Hill.King);
if (ti != null)
pi = ti[m_Hill.King];
@ -251,11 +249,9 @@ namespace Server.Engines.ConPVP
if (m_Counter >= m_Hill.ScoreInterval)
{
string hill = m_Hill.Name;
string king = m_Hill.King.Name;
if (king == null)
king = "";
string king = m_Hill.King.Name ?? "";
if (hill == null || hill == "")
if (string.IsNullOrEmpty(hill))
hill = "the hill";
m_Hill.Game.Alert("{0} ({1}) is king of {2}!", king, ti.Name, hill);
@ -315,7 +311,7 @@ namespace Server.Engines.ConPVP
{
if (m_Game != null)
{
from.CloseGump(typeof(KHBoardGump));
from.CloseGump<KHBoardGump>();
from.SendGump(new KHBoardGump(from, m_Game));
}
else
@ -364,16 +360,14 @@ namespace Server.Engines.ConPVP
KHTeamInfo ourTeam = game.GetTeamInfo(mob);
ArrayList entries = new ArrayList();
List<KHTeamInfo> entries = new List<KHTeamInfo>();
for (int i = 0; i < game.Context.Participants.Count; ++i)
{
KHTeamInfo teamInfo = game.Controller.TeamInfo[i % game.Controller.TeamInfo.Length];
if (teamInfo == null)
continue;
entries.Add(teamInfo);
if (teamInfo != null)
entries.Add(teamInfo);
}
entries.Sort();
@ -408,7 +402,7 @@ namespace Server.Engines.ConPVP
for (int i = 0; i < entries.Count; ++i)
{
KHTeamInfo teamInfo = entries[i] as KHTeamInfo;
KHTeamInfo teamInfo = entries[i];
AddImage(30, 70 + i * 75, 10152);
AddImage(30, 85 + i * 75, 10151);
@ -505,7 +499,7 @@ namespace Server.Engines.ConPVP
}
}
public sealed class KHPlayerInfo : IRankedCTF, IComparable
public sealed class KHPlayerInfo : IRankedCTF, IComparable<KHPlayerInfo>
{
private int m_Captures;
@ -521,30 +515,18 @@ namespace Server.Engines.ConPVP
public Mobile Player{ get; }
public int CompareTo(object obj)
public int CompareTo(KHPlayerInfo pi)
{
KHPlayerInfo pi = (KHPlayerInfo)obj;
int res = pi.Score.CompareTo(Score);
if (res == 0)
{
res = pi.Captures.CompareTo(Captures);
if (res != 0)
return res;
if (res == 0)
res = pi.Kills.CompareTo(Kills);
}
res = pi.Captures.CompareTo(Captures);
return res;
return res != 0 ? res : pi.Kills.CompareTo(Kills);
}
public string Name
{
get
{
if (Player?.Name == null)
return "";
return Player.Name;
}
}
public string Name => Player.Name ?? "";
public int Kills
{
@ -586,13 +568,13 @@ namespace Server.Engines.ConPVP
public KHTeamInfo(int teamID)
{
TeamID = teamID;
Players = new Hashtable();
Players = new Dictionary<Mobile, KHPlayerInfo>();
}
public KHTeamInfo(int teamID, GenericReader ip)
{
TeamID = teamID;
Players = new Hashtable();
Players = new Dictionary<Mobile, KHPlayerInfo>();
int version = ip.ReadEncodedInt();
@ -613,7 +595,7 @@ namespace Server.Engines.ConPVP
public KHPlayerInfo Leader{ get; set; }
public Hashtable Players{ get; }
public Dictionary<Mobile, KHPlayerInfo> Players{ get; }
public KHPlayerInfo this[Mobile mob]
{
@ -706,7 +688,7 @@ namespace Server.Engines.ConPVP
Name = "King of the Hill Controller";
Duration = TimeSpan.FromMinutes(30.0);
Boards = new ArrayList();
Boards = new List<KHBoard>();
Hills = new HillOfTheKing[4];
TeamInfo = new KHTeamInfo[8];
@ -722,60 +704,28 @@ namespace Server.Engines.ConPVP
public KHTeamInfo[] TeamInfo{ get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public KHTeamInfo Team1_W
{
get => TeamInfo[0];
set { }
}
public KHTeamInfo Team1_W => TeamInfo[0];
[CommandProperty(AccessLevel.GameMaster)]
public KHTeamInfo Team2_E
{
get => TeamInfo[1];
set { }
}
public KHTeamInfo Team2_E => TeamInfo[1];
[CommandProperty(AccessLevel.GameMaster)]
public KHTeamInfo Team3_N
{
get => TeamInfo[2];
set { }
}
public KHTeamInfo Team3_N => TeamInfo[2];
[CommandProperty(AccessLevel.GameMaster)]
public KHTeamInfo Team4_S
{
get => TeamInfo[3];
set { }
}
public KHTeamInfo Team4_S => TeamInfo[3];
[CommandProperty(AccessLevel.GameMaster)]
public KHTeamInfo Team5_NW
{
get => TeamInfo[4];
set { }
}
public KHTeamInfo Team5_NW => TeamInfo[4];
[CommandProperty(AccessLevel.GameMaster)]
public KHTeamInfo Team6_SE
{
get => TeamInfo[5];
set { }
}
public KHTeamInfo Team6_SE => TeamInfo[5];
[CommandProperty(AccessLevel.GameMaster)]
public KHTeamInfo Team7_SW
{
get => TeamInfo[6];
set { }
}
public KHTeamInfo Team7_SW => TeamInfo[6];
[CommandProperty(AccessLevel.GameMaster)]
public KHTeamInfo Team8_NE
{
get => TeamInfo[7];
set { }
}
public KHTeamInfo Team8_NE => TeamInfo[7];
public HillOfTheKing[] Hills{ get; private set; }
@ -807,7 +757,7 @@ namespace Server.Engines.ConPVP
set => Hills[3] = value;
}
public ArrayList Boards{ get; private set; }
public List<KHBoard> Boards{ get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public TimeSpan Duration{ get; set; }
@ -873,7 +823,7 @@ namespace Server.Engines.ConPVP
Duration = reader.ReadTimeSpan();
Boards = reader.ReadItemList();
Boards = reader.ReadStrongItemList<KHBoard>();
Hills = new HillOfTheKing[reader.ReadEncodedInt()];
for (int i = 0; i < Hills.Length; ++i)
@ -893,8 +843,7 @@ namespace Server.Engines.ConPVP
{
private Timer m_FinishTimer;
public KHGame(KHController controller, DuelContext context)
: base(context)
public KHGame(KHController controller, DuelContext context) : base(context)
{
Controller = controller;
}
@ -928,7 +877,7 @@ namespace Server.Engines.ConPVP
for (int i = 0; i < m_Context.Participants.Count; ++i)
{
Participant p = m_Context.Participants[i] as Participant;
Participant p = m_Context.Participants[i];
for (int j = 0; j < p.Players.Length; ++j)
if (p.Players[j] != null)
@ -979,19 +928,12 @@ namespace Server.Engines.ConPVP
public void DelayBounce(TimeSpan ts, Mobile mob, Container corpse)
{
Timer.DelayCall(ts, new TimerStateCallback(DelayBounce_Callback), new object[] { mob, corpse });
Timer.DelayCall(ts, () => DelayBounce_Callback(mob, corpse));
}
private void DelayBounce_Callback(object state)
private void DelayBounce_Callback(Mobile mob, Container corpse)
{
object[] states = (object[])state;
Mobile mob = (Mobile)states[0];
Container corpse = (Container)states[1];
DuelPlayer dp = null;
if (mob is PlayerMobile mobile)
dp = mobile.DuelPlayer;
DuelPlayer dp = mob is PlayerMobile mobile ? mobile.DuelPlayer : null;
m_Context.RemoveAggressions(mob);
@ -1045,7 +987,7 @@ namespace Server.Engines.ConPVP
}
}
mob.CloseGump(typeof(KHBoardGump));
mob.CloseGump<KHBoardGump>();
mob.SendGump(new KHBoardGump(mob, this));
m_Context.Requip(mob, corpse);
@ -1065,7 +1007,7 @@ namespace Server.Engines.ConPVP
}
for (int i = 0; i < m_Context.Participants.Count; ++i)
ApplyHues(m_Context.Participants[i] as Participant,
ApplyHues(m_Context.Participants[i],
Controller.TeamInfo[i % Controller.TeamInfo.Length].Color);
m_FinishTimer?.Stop();
@ -1083,46 +1025,44 @@ namespace Server.Engines.ConPVP
private void Finish_Callback()
{
ArrayList teams = new ArrayList();
List<KHTeamInfo> teams = new List<KHTeamInfo>();
for (int i = 0; i < m_Context.Participants.Count; ++i)
{
KHTeamInfo teamInfo = Controller.TeamInfo[i % Controller.TeamInfo.Length];
if (teamInfo == null)
continue;
teams.Add(teamInfo);
if (teamInfo != null)
teams.Add(teamInfo);
}
teams.Sort();
Tournament tourny = m_Context.m_Tournament;
Tournament tourney = m_Context.m_Tournament;
StringBuilder sb = new StringBuilder();
if (tourny != null && tourny.TournyType == TournyType.FreeForAll)
if (tourney != null && tourney.TourneyType == TourneyType.FreeForAll)
{
sb.Append(m_Context.Participants.Count * tourny.PlayersPerParticipant);
sb.Append(m_Context.Participants.Count * tourney.PlayersPerParticipant);
sb.Append("-man FFA");
}
else if (tourny != null && tourny.TournyType == TournyType.RandomTeam)
else if (tourney != null && tourney.TourneyType == TourneyType.RandomTeam)
{
sb.Append(tourny.ParticipantsPerMatch);
sb.Append(tourney.ParticipantsPerMatch);
sb.Append("-team");
}
else if (tourny != null && tourny.TournyType == TournyType.RedVsBlue)
else if (tourney != null && tourney.TourneyType == TourneyType.RedVsBlue)
{
sb.Append("Red v Blue");
}
else if (tourny != null)
else if (tourney != null)
{
for (int i = 0; i < tourny.ParticipantsPerMatch; ++i)
for (int i = 0; i < tourney.ParticipantsPerMatch; ++i)
{
if (sb.Length > 0)
sb.Append('v');
sb.Append(tourny.PlayersPerParticipant);
sb.Append(tourney.PlayersPerParticipant);
}
}
@ -1131,7 +1071,7 @@ namespace Server.Engines.ConPVP
string title = sb.ToString();
KHTeamInfo winner = (KHTeamInfo)(teams.Count > 0 ? teams[0] : null);
KHTeamInfo winner = teams.Count > 0 ? teams[0] : null;
for (int i = 0; i < teams.Count; ++i)
{
@ -1142,9 +1082,9 @@ namespace Server.Engines.ConPVP
else if (i == 1)
rank = TrophyRank.Silver;
KHPlayerInfo leader = ((KHTeamInfo)teams[i]).Leader;
KHPlayerInfo leader = teams[i].Leader;
foreach (KHPlayerInfo pl in ((KHTeamInfo)teams[i]).Players.Values)
foreach (KHPlayerInfo pl in teams[i].Players.Values)
{
Mobile mob = pl.Player;
@ -1182,7 +1122,7 @@ namespace Server.Engines.ConPVP
if (pl == leader)
item.ItemID = 4810;
item.Name = $"{item.Name}, {((KHTeamInfo)teams[i]).Name.ToLower()}";
item.Name = $"{item.Name}, {teams[i].Name.ToLower()}";
if (!mob.PlaceInBackpack(item))
mob.BankBox.DropItem(item);
@ -1219,21 +1159,22 @@ namespace Server.Engines.ConPVP
if (dp?.Mobile != null)
{
dp.Mobile.CloseGump(typeof(KHBoardGump));
dp.Mobile.CloseGump<KHBoardGump>();
dp.Mobile.SendGump(new KHBoardGump(dp.Mobile, this));
}
}
if (i == winner.TeamID)
if (i == winner?.TeamID)
continue;
if (p?.Players != null)
if (p.Players != null)
for (int j = 0; j < p.Players.Length; ++j)
if (p.Players[j] != null)
p.Players[j].Eliminated = true;
}
m_Context.Finish(m_Context.Participants[winner.TeamID] as Participant);
if (winner != null)
m_Context.Finish(m_Context.Participants[winner.TeamID]);
}
public override void OnStop()
@ -1250,10 +1191,10 @@ namespace Server.Engines.ConPVP
board.m_Game = null;
for (int i = 0; i < m_Context.Participants.Count; ++i)
ApplyHues(m_Context.Participants[i] as Participant, -1);
ApplyHues(m_Context.Participants[i], -1);
m_FinishTimer?.Stop();
m_FinishTimer = null;
}
}
}
}

View file

@ -0,0 +1,123 @@
using System;
using System.Collections.Generic;
using System.Text;
using Server.Network;
namespace Server.Engines.ConPVP
{
public class TourneyMatch
{
public TourneyMatch(List<TourneyParticipant> participants)
{
Participants = participants;
for (int i = 0; i < participants.Count; ++i)
{
TourneyParticipant part = participants[i];
StringBuilder sb = new StringBuilder();
sb.Append("Matched in a duel against ");
if (participants.Count > 2)
sb.AppendFormat("{0} other {1}: ", participants.Count - 1,
part.Players.Count == 1 ? "players" : "teams");
bool hasAppended = false;
for (int j = 0; j < participants.Count; ++j)
{
if (i == j)
continue;
if (hasAppended)
sb.Append(", ");
sb.Append(participants[j].NameList);
hasAppended = true;
}
sb.Append(".");
part.AddLog(sb.ToString());
}
}
public List<TourneyParticipant> Participants{ get; set; }
public TourneyParticipant Winner{ get; set; }
public DuelContext Context{ get; set; }
public bool InProgress => Context != null && Context.Registered;
public void Start(Arena arena, Tournament tourney)
{
TourneyParticipant first = Participants[0];
DuelContext dc = new DuelContext(first.Players[0], tourney.Ruleset.Layout, false);
dc.Ruleset.Options.SetAll(false);
dc.Ruleset.Options.Or(tourney.Ruleset.Options);
for (int i = 0; i < Participants.Count; ++i)
{
TourneyParticipant tourneyPart = Participants[i];
Participant duelPart = new Participant(dc, tourneyPart.Players.Count)
{
TourneyPart = tourneyPart
};
for (int j = 0; j < tourneyPart.Players.Count; ++j)
duelPart.Add(tourneyPart.Players[j]);
for (int j = 0; j < duelPart.Players.Length; ++j)
if (duelPart.Players[j] != null)
duelPart.Players[j].Ready = true;
dc.Participants.Add(duelPart);
}
if (tourney.EventController != null)
dc.m_EventGame = tourney.EventController.Construct(dc);
dc.m_Tournament = tourney;
dc.m_Match = this;
dc.m_OverrideArena = arena;
if (tourney.SuddenDeath > TimeSpan.Zero &&
(tourney.SuddenDeathRounds == 0 || tourney.Pyramid.Levels.Count <= tourney.SuddenDeathRounds))
dc.StartSuddenDeath(tourney.SuddenDeath);
dc.SendReadyGump(0);
if (dc.StartedBeginCountdown)
{
Context = dc;
for (int i = 0; i < Participants.Count; ++i)
{
TourneyParticipant p = Participants[i];
for (int j = 0; j < p.Players.Count; ++j)
{
Mobile mob = p.Players[j];
foreach (Mobile view in mob.GetMobilesInRange(18))
if (!mob.CanSee(view))
mob.Send(view.RemovePacket);
mob.LocalOverheadMessage(MessageType.Emote, 0x3B2, false,
"* Your mind focuses intently on the fight and all other distractions fade away *");
}
}
}
else
{
dc.Unregister();
dc.StopCountdown();
}
}
}
}

View file

@ -0,0 +1,382 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Server.Gumps;
using Server.Mobiles;
using Server.Network;
namespace Server.Engines.ConPVP
{
public class AcceptTeamGump : Gump
{
private const int BlackColor32 = 0x000008;
private const int LabelColor32 = 0xFFFFFF;
private bool m_Active;
private Mobile m_From;
private List<Mobile> m_Players;
private Mobile m_Registrar;
private Mobile m_Requested;
private Tournament m_Tournament;
public AcceptTeamGump(Mobile from, Mobile requested, Tournament tourney, Mobile registrar, List<Mobile> players) :
base(50, 50)
{
m_From = from;
m_Requested = requested;
m_Tournament = tourney;
m_Registrar = registrar;
m_Players = players;
m_Active = true;
#region Rules
Ruleset ruleset = tourney.Ruleset;
Ruleset basedef = ruleset.Base;
int height = 185 + 35 + 60 + 12;
int changes = 0;
BitArray defs;
if (ruleset.Flavors.Count > 0)
{
defs = new BitArray(basedef.Options);
for (int i = 0; i < ruleset.Flavors.Count; ++i)
defs.Or(((Ruleset)ruleset.Flavors[i]).Options);
height += ruleset.Flavors.Count * 18;
}
else
{
defs = basedef.Options;
}
BitArray opts = ruleset.Options;
for (int i = 0; i < opts.Length; ++i)
if (defs[i] != opts[i])
++changes;
height += changes * 22;
height += 10 + 22 + 25 + 25;
#endregion
Closable = false;
AddPage(0);
AddBackground(1, 1, 398, height, 3600);
AddImageTiled(16, 15, 369, height - 29, 3604);
AddAlphaRegion(16, 15, 369, height - 29);
AddImage(215, -43, 0xEE40);
StringBuilder sb = new StringBuilder();
if (tourney.TourneyType == TourneyType.FreeForAll)
{
sb.Append("FFA");
}
else if (tourney.TourneyType == TourneyType.RandomTeam)
{
sb.Append(tourney.ParticipantsPerMatch);
sb.Append("-Team");
}
else if (tourney.TourneyType == TourneyType.Faction)
{
sb.Append(tourney.ParticipantsPerMatch);
sb.Append("-Team Faction");
}
else if (tourney.TourneyType == TourneyType.RedVsBlue)
{
sb.Append("Red v Blue");
}
else
{
for (int i = 0; i < tourney.ParticipantsPerMatch; ++i)
{
if (sb.Length > 0)
sb.Append('v');
sb.Append(tourney.PlayersPerParticipant);
}
}
if (tourney.EventController != null)
sb.Append(' ').Append(tourney.EventController.Title);
sb.Append(" Tournament Invitation");
AddBorderedText(22, 22, 294, 20, Center(sb.ToString()), LabelColor32, BlackColor32);
AddBorderedText(22, 50, 294, 40,
$"You have been asked to partner with {from.Name} in a tournament. Do you accept?",
0xB0C868, BlackColor32);
AddImageTiled(32, 88, 264, 1, 9107);
AddImageTiled(42, 90, 264, 1, 9157);
#region Rules
int y = 100;
string groupText = null;
switch (tourney.GroupType)
{
case GroupingType.HighVsLow:
groupText = "High vs Low";
break;
case GroupingType.Nearest:
groupText = "Closest opponent";
break;
case GroupingType.Random:
groupText = "Random";
break;
}
AddBorderedText(35, y, 190, 20, $"Grouping: {groupText}", LabelColor32, BlackColor32);
y += 20;
string tieText = null;
switch (tourney.TieType)
{
case TieType.Random:
tieText = "Random";
break;
case TieType.Highest:
tieText = "Highest advances";
break;
case TieType.Lowest:
tieText = "Lowest advances";
break;
case TieType.FullAdvancement:
tieText = tourney.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances";
break;
case TieType.FullElimination:
tieText = tourney.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated";
break;
}
AddBorderedText(35, y, 190, 20, $"Tiebreaker: {tieText}", LabelColor32, BlackColor32);
y += 20;
string sdText = "Off";
if (tourney.SuddenDeath > TimeSpan.Zero)
{
sdText = $"{(int)tourney.SuddenDeath.TotalMinutes}:{tourney.SuddenDeath.Seconds:D2}";
if (tourney.SuddenDeathRounds > 0)
sdText = $"{sdText} (first {tourney.SuddenDeathRounds} rounds)";
else
sdText = $"{sdText} (all rounds)";
}
AddBorderedText(35, y, 240, 20, $"Sudden Death: {sdText}", LabelColor32, BlackColor32);
y += 20;
y += 6;
AddImageTiled(32, y - 1, 264, 1, 9107);
AddImageTiled(42, y + 1, 264, 1, 9157);
y += 6;
AddBorderedText(35, y, 190, 20, $"Ruleset: {basedef.Title}", LabelColor32, BlackColor32);
y += 20;
for (int i = 0; i < ruleset.Flavors.Count; ++i, y += 18)
AddBorderedText(35, y, 190, 20, $" + {((Ruleset)ruleset.Flavors[i]).Title}", LabelColor32, BlackColor32);
y += 4;
if (changes > 0)
{
AddBorderedText(35, y, 190, 20, "Modifications:", LabelColor32, BlackColor32);
y += 20;
for (int i = 0; i < opts.Length; ++i)
if (defs[i] != opts[i])
{
string name = ruleset.Layout.FindByIndex(i);
if (name != null) // sanity
{
AddImage(35, y, opts[i] ? 0xD3 : 0xD2);
AddBorderedText(60, y, 165, 22, name, LabelColor32, BlackColor32);
}
y += 22;
}
}
else
{
AddBorderedText(35, y, 190, 20, "Modifications: None", LabelColor32, BlackColor32);
y += 20;
}
#endregion
y += 8;
AddImageTiled(32, y - 1, 264, 1, 9107);
AddImageTiled(42, y + 1, 264, 1, 9157);
y += 8;
AddRadio(24, y, 9727, 9730, true, 1);
AddBorderedText(60, y + 5, 250, 20, "Yes, I will join them.", LabelColor32, BlackColor32);
y += 35;
AddRadio(24, y, 9727, 9730, false, 2);
AddBorderedText(60, y + 5, 250, 20, "No, I do not wish to fight.", LabelColor32, BlackColor32);
y += 35;
AddRadio(24, y, 9727, 9730, false, 3);
AddBorderedText(60, y + 5, 270, 20, "No, most certainly not. Do not ask again.", LabelColor32, BlackColor32);
y += 35;
y -= 3;
AddButton(314, y, 247, 248, 1, GumpButtonType.Reply, 0);
Timer.DelayCall(TimeSpan.FromSeconds(15.0), AutoReject);
}
public string Center(string text)
{
return $"<CENTER>{text}</CENTER>";
}
public string Color(string text, int color)
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor)
{
AddColoredText(x - 1, y - 1, width, height, text, borderColor);
AddColoredText(x - 1, y + 1, width, height, text, borderColor);
AddColoredText(x + 1, y - 1, width, height, text, borderColor);
AddColoredText(x + 1, y + 1, width, height, text, borderColor);
AddColoredText(x, y, width, height, text, color);
}
private void AddColoredText(int x, int y, int width, int height, string text, int color)
{
if (color == 0)
AddHtml(x, y, width, height, text, false, false);
else
AddHtml(x, y, width, height, Color(text, color), false, false);
}
public void AutoReject()
{
if (!m_Active)
return;
m_Active = false;
m_Requested.CloseGump<AcceptTeamGump>();
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
if (m_Registrar != null)
{
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x22, false, $"{m_Requested.Name} seems unresponsive.", m_From.NetState);
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x22, false, $"You have declined the partnership with {m_From.Name}.", m_Requested.NetState);
}
}
public override void OnResponse(NetState sender, RelayInfo info)
{
Mobile from = m_From;
Mobile mob = m_Requested;
if (info.ButtonID != 1 || !m_Active)
return;
m_Active = false;
if (info.IsSwitched(1))
{
if (!(mob is PlayerMobile pm))
return;
if (AcceptDuelGump.IsIgnored(mob, from) || mob.Blessed)
{
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "They ignore your invitation.", from.NetState);
}
else if (pm.DuelContext != null)
{
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "They are already assigned to another duel.", from.NetState);
}
else if (m_Players.Contains(mob))
{
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "You have already named them as a team member.", from.NetState);
}
else if (m_Tournament.HasParticipant(mob))
{
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "They have already entered this tournament.", from.NetState);
}
else if (m_Players.Count >= m_Tournament.PlayersPerParticipant)
{
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "Your team is full.", from.NetState);
}
else
{
m_Players.Add(mob);
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
if (m_Registrar != null)
{
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x59, false, $"{mob.Name} has accepted your offer of partnership.", from.NetState);
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x59, false, $"You have accepted the partnership with {from.Name}.", mob.NetState);
}
}
}
else
{
if (info.IsSwitched(3))
AcceptDuelGump.BeginIgnore(m_Requested, m_From);
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
if (m_Registrar != null)
{
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x22, false, $"{mob.Name} has declined your offer of partnership.", from.NetState);
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x22, false, $"You have declined the partnership with {from.Name}.", mob.NetState);
}
}
}
}
}

View file

@ -50,7 +50,7 @@ namespace Server.Engines.ConPVP
return false;
}
from.CloseGump(typeof(ArenaGump));
from.CloseGump<ArenaGump>();
from.SendGump(new ArenaGump(from, this));
if (!from.Hidden || from.AccessLevel == AccessLevel.Player)

View file

@ -0,0 +1,566 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Server.Factions;
using Server.Gumps;
using Server.Mobiles;
using Server.Network;
using Server.Targeting;
namespace Server.Engines.ConPVP
{
public class ConfirmSignupGump : Gump
{
private const int BlackColor32 = 0x000008;
private const int LabelColor32 = 0xFFFFFF;
private Mobile m_From;
private List<Mobile> m_Players;
private Mobile m_Registrar;
private Tournament m_Tournament;
public ConfirmSignupGump(Mobile from, Mobile registrar, Tournament tourney, List<Mobile> players) : base(50, 50)
{
m_From = from;
m_Registrar = registrar;
m_Tournament = tourney;
m_Players = players;
m_From.CloseGump<AcceptTeamGump>();
m_From.CloseGump<AcceptDuelGump>();
m_From.CloseGump<DuelContextGump>();
m_From.CloseGump<ConfirmSignupGump>();
#region Rules
Ruleset ruleset = tourney.Ruleset;
Ruleset basedef = ruleset.Base;
int height = 185 + 60 + 12;
int changes = 0;
BitArray defs;
if (ruleset.Flavors.Count > 0)
{
defs = new BitArray(basedef.Options);
for (int i = 0; i < ruleset.Flavors.Count; ++i)
defs.Or(((Ruleset)ruleset.Flavors[i]).Options);
height += ruleset.Flavors.Count * 18;
}
else
{
defs = basedef.Options;
}
BitArray opts = ruleset.Options;
for (int i = 0; i < opts.Length; ++i)
if (defs[i] != opts[i])
++changes;
height += changes * 22;
height += 10 + 22 + 25 + 25;
if (tourney.PlayersPerParticipant > 1)
height += 36 + tourney.PlayersPerParticipant * 20;
#endregion
Closable = false;
AddPage(0);
//AddBackground( 0, 0, 400, 220, 9150 );
AddBackground(1, 1, 398, height, 3600);
//AddBackground( 16, 15, 369, 189, 9100 );
AddImageTiled(16, 15, 369, height - 29, 3604);
AddAlphaRegion(16, 15, 369, height - 29);
AddImage(215, -43, 0xEE40);
//AddImage( 330, 141, 0x8BA );
StringBuilder sb = new StringBuilder();
if (tourney.TourneyType == TourneyType.FreeForAll)
{
sb.Append("FFA");
}
else if (tourney.TourneyType == TourneyType.RandomTeam)
{
sb.Append(tourney.ParticipantsPerMatch);
sb.Append("-Team");
}
else if (tourney.TourneyType == TourneyType.Faction)
{
sb.Append(tourney.ParticipantsPerMatch);
sb.Append("-Team Faction");
}
else if (tourney.TourneyType == TourneyType.RedVsBlue)
{
sb.Append("Red v Blue");
}
else
{
for (int i = 0; i < tourney.ParticipantsPerMatch; ++i)
{
if (sb.Length > 0)
sb.Append('v');
sb.Append(tourney.PlayersPerParticipant);
}
}
if (tourney.EventController != null)
sb.Append(' ').Append(tourney.EventController.Title);
sb.Append(" Tournament Signup");
AddBorderedText(22, 22, 294, 20, Center(sb.ToString()), LabelColor32, BlackColor32);
AddBorderedText(22, 50, 294, 40, "You have requested to join the tournament. Do you accept the rules?", 0xB0C868,
BlackColor32);
AddImageTiled(32, 88, 264, 1, 9107);
AddImageTiled(42, 90, 264, 1, 9157);
#region Rules
int y = 100;
string groupText = null;
switch (tourney.GroupType)
{
case GroupingType.HighVsLow:
groupText = "High vs Low";
break;
case GroupingType.Nearest:
groupText = "Closest opponent";
break;
case GroupingType.Random:
groupText = "Random";
break;
}
AddBorderedText(35, y, 190, 20, $"Grouping: {groupText}", LabelColor32, BlackColor32);
y += 20;
string tieText = null;
switch (tourney.TieType)
{
case TieType.Random:
tieText = "Random";
break;
case TieType.Highest:
tieText = "Highest advances";
break;
case TieType.Lowest:
tieText = "Lowest advances";
break;
case TieType.FullAdvancement:
tieText = tourney.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances";
break;
case TieType.FullElimination:
tieText = tourney.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated";
break;
}
AddBorderedText(35, y, 190, 20, $"Tiebreaker: {tieText}", LabelColor32, BlackColor32);
y += 20;
string sdText = "Off";
if (tourney.SuddenDeath > TimeSpan.Zero)
{
sdText = $"{(int)tourney.SuddenDeath.TotalMinutes}:{tourney.SuddenDeath.Seconds:D2}";
if (tourney.SuddenDeathRounds > 0)
sdText = $"{sdText} (first {tourney.SuddenDeathRounds} rounds)";
else
sdText = $"{sdText} (all rounds)";
}
AddBorderedText(35, y, 240, 20, $"Sudden Death: {sdText}", LabelColor32, BlackColor32);
y += 20;
y += 6;
AddImageTiled(32, y - 1, 264, 1, 9107);
AddImageTiled(42, y + 1, 264, 1, 9157);
y += 6;
AddBorderedText(35, y, 190, 20, $"Ruleset: {basedef.Title}", LabelColor32, BlackColor32);
y += 20;
for (int i = 0; i < ruleset.Flavors.Count; ++i, y += 18)
AddBorderedText(35, y, 190, 20, $" + {((Ruleset)ruleset.Flavors[i]).Title}", LabelColor32, BlackColor32);
y += 4;
if (changes > 0)
{
AddBorderedText(35, y, 190, 20, "Modifications:", LabelColor32, BlackColor32);
y += 20;
for (int i = 0; i < opts.Length; ++i)
if (defs[i] != opts[i])
{
string name = ruleset.Layout.FindByIndex(i);
if (name != null) // sanity
{
AddImage(35, y, opts[i] ? 0xD3 : 0xD2);
AddBorderedText(60, y, 165, 22, name, LabelColor32, BlackColor32);
}
y += 22;
}
}
else
{
AddBorderedText(35, y, 190, 20, "Modifications: None", LabelColor32, BlackColor32);
y += 20;
}
#endregion
#region Team
if (tourney.PlayersPerParticipant > 1)
{
y += 8;
AddImageTiled(32, y - 1, 264, 1, 9107);
AddImageTiled(42, y + 1, 264, 1, 9157);
y += 8;
AddBorderedText(35, y, 190, 20, "Your Team", LabelColor32, BlackColor32);
y += 20;
for (int i = 0; i < players.Count; ++i, y += 20)
{
if (i == 0)
AddImage(35, y, 0xD2);
else
AddGoldenButton(35, y, 1 + i);
AddBorderedText(60, y, 200, 20, players[i].Name, LabelColor32, BlackColor32);
}
for (int i = players.Count; i < tourney.PlayersPerParticipant; ++i, y += 20)
{
if (i == 0)
AddImage(35, y, 0xD2);
else
AddGoldenButton(35, y, 1 + i);
AddBorderedText(60, y, 200, 20, "(Empty)", LabelColor32, BlackColor32);
}
}
#endregion
y += 8;
AddImageTiled(32, y - 1, 264, 1, 9107);
AddImageTiled(42, y + 1, 264, 1, 9157);
y += 8;
AddRadio(24, y, 9727, 9730, true, 1);
AddBorderedText(60, y + 5, 250, 20, "Yes, I wish to join the tournament.", LabelColor32, BlackColor32);
y += 35;
AddRadio(24, y, 9727, 9730, false, 2);
AddBorderedText(60, y + 5, 250, 20, "No, I do not wish to join.", LabelColor32, BlackColor32);
y += 35;
y -= 3;
AddButton(314, y, 247, 248, 1, GumpButtonType.Reply, 0);
}
public string Center(string text)
{
return $"<CENTER>{text}</CENTER>";
}
public string Color(string text, int color)
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor)
{
AddColoredText(x - 1, y - 1, width, height, text, borderColor);
AddColoredText(x - 1, y + 1, width, height, text, borderColor);
AddColoredText(x + 1, y - 1, width, height, text, borderColor);
AddColoredText(x + 1, y + 1, width, height, text, borderColor);
AddColoredText(x, y, width, height, text, color);
}
private void AddColoredText(int x, int y, int width, int height, string text, int color)
{
if (color == 0)
AddHtml(x, y, width, height, text, false, false);
else
AddHtml(x, y, width, height, Color(text, color), false, false);
}
public void AddGoldenButton(int x, int y, int bid)
{
AddButton(x, y, 0xD2, 0xD2, bid, GumpButtonType.Reply, 0);
AddButton(x + 3, y + 3, 0xD8, 0xD8, bid, GumpButtonType.Reply, 0);
}
public override void OnResponse(NetState sender, RelayInfo info)
{
if (info.ButtonID == 1 && info.IsSwitched(1))
{
Tournament tourney = m_Tournament;
Mobile from = m_From;
switch (tourney.Stage)
{
case TournamentStage.Fighting:
{
if (m_Registrar != null)
{
if (m_Tournament.HasParticipant(from))
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "Excuse me? You are already signed up.", from.NetState);
else
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "The tournament has already begun. You are too late to signup now.",
from.NetState);
}
break;
}
case TournamentStage.Inactive:
{
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "The tournament is closed.", from.NetState);
break;
}
case TournamentStage.Signup:
{
if (m_Players.Count != tourney.PlayersPerParticipant)
{
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "You have not yet chosen your team.", from.NetState);
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
break;
}
Ladder ladder = Ladder.Instance;
for (int i = 0; i < m_Players.Count; ++i)
{
Mobile mob = m_Players[i];
LadderEntry entry = ladder?.Find(mob);
if (entry != null && Ladder.GetLevel(entry.Experience) < tourney.LevelRequirement)
{
if (m_Registrar != null)
{
if (mob == from)
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "You have not yet proven yourself a worthy dueler.", from.NetState);
else
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, $"{mob.Name} has not yet proven themselves a worthy dueler.",
from.NetState);
}
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
return;
}
if (tourney.IsFactionRestricted && Faction.Find(mob) == null)
{
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "Only those who have declared their faction allegiance may participate.",
from.NetState);
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
return;
}
if (tourney.HasParticipant(mob))
{
if (m_Registrar != null)
{
if (mob == from)
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "You have already entered this tournament.", from.NetState);
else
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, $"{mob.Name} has already entered this tournament.", from.NetState);
}
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
return;
}
if (mob is PlayerMobile mobile && mobile.DuelContext != null)
{
if (mob == from)
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false,
"You are already assigned to a duel. You must yield it before joining this tournament.",
from.NetState);
else
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false,
$"{mobile.Name} is already assigned to a duel. They must yield it before joining this tournament.",
from.NetState);
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
return;
}
}
if (m_Registrar != null)
{
string fmt;
if (tourney.PlayersPerParticipant == 1)
fmt =
"As you say m'{0}. I've written your name to the bracket. The tournament will begin {1}.";
else if (tourney.PlayersPerParticipant == 2)
fmt =
"As you wish m'{0}. The tournament will begin {1}, but first you must name your partner.";
else
fmt = "As you wish m'{0}. The tournament will begin {1}, but first you must name your team.";
string timeUntil;
int minutesUntil = (int)Math.Round((tourney.SignupStart + tourney.SignupPeriod - DateTime.UtcNow)
.TotalMinutes);
if (minutesUntil == 0)
timeUntil = "momentarily";
else
timeUntil = $"in {minutesUntil} minute{(minutesUntil == 1 ? "" : "s")}";
m_Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, string.Format(fmt, from.Female ? "Lady" : "Lord", timeUntil), from.NetState);
}
TourneyParticipant part = new TourneyParticipant(from);
part.Players.Clear();
part.Players.AddRange(m_Players);
tourney.Participants.Add(part);
break;
}
}
}
else if (info.ButtonID > 1)
{
int index = info.ButtonID - 1;
if (index > 0 && index < m_Players.Count)
{
m_Players.RemoveAt(index);
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
}
else if (m_Players.Count < m_Tournament.PlayersPerParticipant)
{
m_From.BeginTarget(12, false, TargetFlags.None, AddPlayer_OnTarget);
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
}
}
}
private void AddPlayer_OnTarget(Mobile from, object obj)
{
if (!(obj is Mobile mob) || mob == from)
{
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "Excuse me?", from.NetState);
}
else if (!mob.Player)
{
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
if (mob.Body.IsHuman)
mob.SayTo(from, 1005443); // Nay, I would rather stay here and watch a nail rust.
else
mob.SayTo(from, 1005444); // The creature ignores your offer.
}
else if (AcceptDuelGump.IsIgnored(mob, from) || mob.Blessed)
{
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "They ignore your invitation.", from.NetState);
}
else
{
if (!(mob is PlayerMobile pm))
return;
if (pm.DuelContext != null)
{
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "They are already assigned to another duel.", from.NetState);
}
else if (mob.HasGump<AcceptTeamGump>())
{
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "They have already been offered a partnership.", from.NetState);
}
else if (mob.HasGump<ConfirmSignupGump>())
{
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "They are already trying to join this tournament.", from.NetState);
}
else if (m_Players.Contains(mob))
{
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "You have already named them as a team member.", from.NetState);
}
else if (m_Tournament.HasParticipant(mob))
{
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "They have already entered this tournament.", from.NetState);
}
else if (m_Players.Count >= m_Tournament.PlayersPerParticipant)
{
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "Your team is full.", from.NetState);
}
else
{
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
mob.SendGump(new AcceptTeamGump(from, mob, m_Tournament, m_Registrar, m_Players));
m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x59, false,
$"As you command m'{(from.Female ? "Lady" : "Lord")}. I've given your offer to {mob.Name}.",
from.NetState);
}
}
}
}
}

View file

@ -10,9 +10,9 @@ namespace Server.Engines.ConPVP
From = from;
Context = context;
from.CloseGump(typeof(RulesetGump));
from.CloseGump(typeof(DuelContextGump));
from.CloseGump(typeof(ParticipantGump));
from.CloseGump<RulesetGump>();
from.CloseGump<DuelContextGump>();
from.CloseGump<ParticipantGump>();
int count = context.Participants.Count;

View file

@ -1,5 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Gumps;
using Server.Network;
@ -41,7 +41,7 @@ namespace Server.Engines.ConPVP
{
case 1:
{
Ladder = reader.ReadItem() as LadderController;
Ladder = reader.ReadItem<LadderController>();
break;
}
}
@ -51,15 +51,12 @@ namespace Server.Engines.ConPVP
{
if (from.InRange(GetWorldLocation(), 2))
{
Ladder ladder = ConPVP.Ladder.Instance;
if (Ladder != null)
ladder = Ladder.Ladder;
Ladder ladder = ConPVP.Ladder.Instance ?? Ladder.Ladder;
if (ladder != null)
{
from.CloseGump(typeof(LadderGump));
from.SendGump(new LadderGump(ladder, 0));
from.CloseGump<LadderGump>();
from.SendGump(new LadderGump(ladder));
}
}
else
@ -74,24 +71,19 @@ namespace Server.Engines.ConPVP
private int m_ColumnX = 12;
private Ladder m_Ladder;
private ArrayList m_List;
private List<LadderEntry> m_List;
private int m_Page;
public LadderGump(Ladder ladder) : this(ladder, 0)
{
}
public LadderGump(Ladder ladder, int page) : base(50, 50)
public LadderGump(Ladder ladder, int page = 0) : base(50, 50)
{
m_Ladder = ladder;
m_Page = page;
AddPage(0);
ArrayList list = ladder.ToArrayList();
m_List = list;
m_List = new List<LadderEntry>(ladder.Entries);
int lc = Math.Min(list.Count, 150);
int lc = Math.Min(m_List.Count, 150);
int start = page * 15;
int end = start + 15;
@ -121,7 +113,7 @@ namespace Server.Engines.ConPVP
AddImage(466, height - 12 - 2 - 16, 0x2622);
AddHtml(16, height - 12 - 2 - 18, 400, 20,
Color(string.Format("Top {3} of {0:N0} duelists, page {1} of {2}", list.Count, page + 1, (lc + 14) / 15, lc),
Color(string.Format("Top {3} of {0:N0} duelists, page {1} of {2}", m_List.Count, page + 1, (lc + 14) / 15, lc),
0xFFC000), false, false);
AddColumnHeader(75, "Rank");
@ -133,7 +125,7 @@ namespace Server.Engines.ConPVP
for (int i = start; i < end && i < lc; ++i)
{
LadderEntry entry = (LadderEntry)list[i];
LadderEntry entry = m_List[i];
int y = 32 + (i - start) * 20;
int x = 12;
@ -153,8 +145,7 @@ namespace Server.Engines.ConPVP
int xp = entry.Experience;
int level = Ladder.GetLevel(xp);
int xpBase, xpAdvance;
Ladder.GetLevelInfo(level, out xpBase, out xpAdvance);
Ladder.GetLevelInfo(level, out int xpBase, out int xpAdvance);
int width;

View file

@ -13,9 +13,9 @@ namespace Server.Engines.ConPVP
Context = context;
Participant = p;
from.CloseGump(typeof(RulesetGump));
from.CloseGump(typeof(DuelContextGump));
from.CloseGump(typeof(ParticipantGump));
from.CloseGump<RulesetGump>();
from.CloseGump<DuelContextGump>();
from.CloseGump<ParticipantGump>();
int count = p.Players.Length;
@ -231,7 +231,7 @@ namespace Server.Engines.ConPVP
from.SendMessage("{0} cannot fight because they have recently been in combat with another player.",
pm.Name);
}
else if (mob.HasGump(typeof(AcceptDuelGump)))
else if (mob.HasGump<AcceptDuelGump>())
{
from.SendMessage("{0} has already been offered a duel.");
}

View file

@ -1,4 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using Server.Gumps;
using Server.Network;
@ -16,7 +16,7 @@ namespace Server.Engines.ConPVP
m_Context = context;
m_Count = count;
ArrayList parts = context.Participants;
List<Participant> parts = context.Participants;
int height = 25 + 20;
@ -35,7 +35,7 @@ namespace Server.Engines.ConPVP
height += 25;
Closable = false;
Dragable = false;
Draggable = false;
AddPage(0);

View file

@ -1,4 +1,5 @@
using System.Collections;
using System.Collections.Generic;
using Server.Gumps;
using Server.Mobiles;
using Server.Network;
@ -36,13 +37,13 @@ namespace Server.Engines.ConPVP
AddPage(1);
ArrayList parts = context.Participants;
List<Participant> parts = context.Participants;
int height = 25 + 20;
for (int i = 0; i < parts.Count; ++i)
{
Participant p = (Participant)parts[i];
Participant p = parts[i];
height += 4;
@ -63,7 +64,7 @@ namespace Server.Engines.ConPVP
for (int i = 0; i < parts.Count; ++i)
{
Participant p = (Participant)parts[i];
Participant p = parts[i];
y += 4;

View file

@ -12,13 +12,8 @@ namespace Server.Engines.ConPVP
private bool m_ReadOnly;
private Ruleset m_Ruleset;
public RulesetGump(Mobile from, Ruleset ruleset, RulesetLayout page, DuelContext duelContext) : this(from, ruleset,
page, duelContext, false)
{
}
public RulesetGump(Mobile from, Ruleset ruleset, RulesetLayout page, DuelContext duelContext, bool readOnly) : base(
readOnly ? 310 : 50, 50)
public RulesetGump(Mobile from, Ruleset ruleset, RulesetLayout page, DuelContext duelContext, bool readOnly = false)
: base(readOnly ? 310 : 50, 50)
{
m_From = from;
m_Ruleset = ruleset;
@ -26,11 +21,11 @@ namespace Server.Engines.ConPVP
m_DuelContext = duelContext;
m_ReadOnly = readOnly;
Dragable = !readOnly;
Draggable = !readOnly;
from.CloseGump(typeof(RulesetGump));
from.CloseGump(typeof(DuelContextGump));
from.CloseGump(typeof(ParticipantGump));
from.CloseGump<RulesetGump>();
from.CloseGump<DuelContextGump>();
from.CloseGump<ParticipantGump>();
RulesetLayout depthCounter = page;
int depth = 0;

View file

@ -0,0 +1,862 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Server.Gumps;
using Server.Mobiles;
using Server.Network;
namespace Server.Engines.ConPVP
{
public enum TourneyBracketGumpType
{
Index,
Rules_Info,
Participant_List,
Participant_Info,
Round_List,
Round_Info,
Match_Info,
Player_Info
}
public class TournamentBracketGump : Gump
{
private const int BlackColor32 = 0x000008;
private const int LabelColor32 = 0xFFFFFF;
private Mobile m_From;
private List<object> m_List;
private object m_Object;
private int m_Page;
private int m_PerPage;
private Tournament m_Tournament;
private TourneyBracketGumpType m_Type;
public TournamentBracketGump(Mobile from, Tournament tourney, TourneyBracketGumpType type,
List<object> list = null, int page = 0, object obj = null) : base(50, 50)
{
m_From = from;
m_Tournament = tourney;
m_Type = type;
m_List = list;
m_Page = page;
m_Object = obj;
m_PerPage = 12;
switch (type)
{
case TourneyBracketGumpType.Index:
{
AddPage(0);
AddBackground(0, 0, 300, 300, 9380);
StringBuilder sb = new StringBuilder();
if (tourney.TourneyType == TourneyType.FreeForAll)
{
sb.Append("FFA");
}
else if (tourney.TourneyType == TourneyType.RandomTeam)
{
sb.Append(tourney.ParticipantsPerMatch);
sb.Append("-Team");
}
else if (tourney.TourneyType == TourneyType.RedVsBlue)
{
sb.Append("Red v Blue");
}
else if (tourney.TourneyType == TourneyType.Faction)
{
sb.Append(tourney.ParticipantsPerMatch);
sb.Append("-Team Faction");
}
else
{
for (int i = 0; i < tourney.ParticipantsPerMatch; ++i)
{
if (sb.Length > 0)
sb.Append('v');
sb.Append(tourney.PlayersPerParticipant);
}
}
if (tourney.EventController != null)
sb.Append(' ').Append(tourney.EventController.Title);
sb.Append(" Tournament Bracket");
AddHtml(25, 35, 250, 20, Center(sb.ToString()), false, false);
AddRightArrow(25, 53, ToButtonID(0, 4), "Rules");
AddRightArrow(25, 71, ToButtonID(0, 1), "Participants");
if (m_Tournament.Stage == TournamentStage.Signup)
{
TimeSpan until = m_Tournament.SignupStart + m_Tournament.SignupPeriod - DateTime.UtcNow;
string text;
int secs = (int)until.TotalSeconds;
if (secs > 0)
{
int mins = secs / 60;
secs %= 60;
if (mins > 0 && secs > 0)
text =
$"The tournament will begin in {mins} minute{(mins == 1 ? "" : "s")} and {secs} second{(secs == 1 ? "" : "s")}.";
else if (mins > 0)
text = $"The tournament will begin in {mins} minute{(mins == 1 ? "" : "s")}.";
else if (secs > 0)
text = $"The tournament will begin in {secs} second{(secs == 1 ? "" : "s")}.";
else
text = "The tournament will begin shortly.";
}
else
{
text = "The tournament will begin shortly.";
}
AddHtml(25, 92, 250, 40, text, false, false);
}
else
{
AddRightArrow(25, 89, ToButtonID(0, 2), "Rounds");
}
break;
}
case TourneyBracketGumpType.Rules_Info:
{
Ruleset ruleset = tourney.Ruleset;
Ruleset basedef = ruleset.Base;
BitArray defs;
if (ruleset.Flavors.Count > 0)
{
defs = new BitArray(basedef.Options);
for (int i = 0; i < ruleset.Flavors.Count; ++i)
defs.Or(((Ruleset)ruleset.Flavors[i]).Options);
}
else
{
defs = basedef.Options;
}
int changes = 0;
BitArray opts = ruleset.Options;
for (int i = 0; i < opts.Length; ++i)
if (defs[i] != opts[i])
++changes;
AddPage(0);
AddBackground(0, 0, 300,
60 + 18 + 20 + 20 + 20 + 8 + 20 + ruleset.Flavors.Count * 18 + 4 + 20 + changes * 22 + 6, 9380);
AddLeftArrow(25, 11, ToButtonID(0, 0));
AddHtml(25, 35, 250, 20, Center("Rules"), false, false);
int y = 53;
string groupText = null;
switch (tourney.GroupType)
{
case GroupingType.HighVsLow:
groupText = "High vs Low";
break;
case GroupingType.Nearest:
groupText = "Closest opponent";
break;
case GroupingType.Random:
groupText = "Random";
break;
}
AddHtml(35, y, 190, 20, $"Grouping: {groupText}", false, false);
y += 20;
string tieText = null;
switch (tourney.TieType)
{
case TieType.Random:
tieText = "Random";
break;
case TieType.Highest:
tieText = "Highest advances";
break;
case TieType.Lowest:
tieText = "Lowest advances";
break;
case TieType.FullAdvancement:
tieText = tourney.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances";
break;
case TieType.FullElimination:
tieText = tourney.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated";
break;
}
AddHtml(35, y, 190, 20, $"Tiebreaker: {tieText}", false, false);
y += 20;
string sdText = "Off";
if (tourney.SuddenDeath > TimeSpan.Zero)
{
sdText = $"{(int)tourney.SuddenDeath.TotalMinutes}:{tourney.SuddenDeath.Seconds:D2}";
if (tourney.SuddenDeathRounds > 0)
sdText = $"{sdText} (first {tourney.SuddenDeathRounds} rounds)";
else
sdText = $"{sdText} (all rounds)";
}
AddHtml(35, y, 240, 20, $"Sudden Death: {sdText}", false, false);
y += 20;
y += 8;
AddHtml(35, y, 190, 20, $"Ruleset: {basedef.Title}", false, false);
y += 20;
for (int i = 0; i < ruleset.Flavors.Count; ++i, y += 18)
AddHtml(35, y, 190, 20, $" + {((Ruleset)ruleset.Flavors[i]).Title}", false, false);
y += 4;
if (changes > 0)
{
AddHtml(35, y, 190, 20, "Modifications:", false, false);
y += 20;
for (int i = 0; i < opts.Length; ++i)
if (defs[i] != opts[i])
{
string name = ruleset.Layout.FindByIndex(i);
if (name != null) // sanity
{
AddImage(35, y, opts[i] ? 0xD3 : 0xD2);
AddHtml(60, y, 165, 22, name, false, false);
}
y += 22;
}
}
else
{
AddHtml(35, y, 190, 20, "Modifications: None", false, false);
}
break;
}
case TourneyBracketGumpType.Participant_List:
{
AddPage(0);
AddBackground(0, 0, 300, 300, 9380);
List<TourneyParticipant> pList = m_List != null
? Utility.CastListCovariant<object, TourneyParticipant>(m_List)
: new List<TourneyParticipant>(tourney.Participants);
AddLeftArrow(25, 11, ToButtonID(0, 0));
AddHtml(25, 35, 250, 20, Center($"{pList.Count} Participant{(pList.Count == 1 ? "" : "s")}"), false,
false);
StartPage(out int index, out int count, out int y, 12);
for (int i = 0; i < count; ++i, y += 18)
{
TourneyParticipant part = pList[index + i];
string name = part.NameList;
if (m_Tournament.TourneyType != TourneyType.Standard && part.Players.Count == 1)
if (part.Players[0] is PlayerMobile pm && pm.DuelPlayer != null)
name = Color(name, pm.DuelPlayer.Eliminated ? 0x6633333 : 0x336666);
AddRightArrow(25, y, ToButtonID(2, index + i), name);
}
break;
}
case TourneyBracketGumpType.Participant_Info:
{
if (!(obj is TourneyParticipant part))
break;
AddPage(0);
AddBackground(0, 0, 300, 60 + 18 + 20 + part.Players.Count * 18 + 20 + 20 + 160, 9380);
AddLeftArrow(25, 11, ToButtonID(0, 1));
AddHtml(25, 35, 250, 20, Center("Participants"), false, false);
int y = 53;
AddHtml(25, y, 200, 20, part.Players.Count == 1 ? "Players" : "Team", false, false);
y += 20;
for (int i = 0; i < part.Players.Count; ++i)
{
Mobile mob = part.Players[i];
string name = mob.Name;
if (m_Tournament.TourneyType != TourneyType.Standard)
if (mob is PlayerMobile pm && pm.DuelPlayer != null)
name = Color(name, pm.DuelPlayer.Eliminated ? 0x6633333 : 0x336666);
AddRightArrow(35, y, ToButtonID(4, i), name);
y += 18;
}
AddHtml(25, y, 200, 20,
$"Free Advances: {(part.FreeAdvances == 0 ? "None" : part.FreeAdvances.ToString())}", false, false);
y += 20;
AddHtml(25, y, 200, 20, "Log:", false, false);
y += 20;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < part.Log.Count; ++i)
{
if (sb.Length > 0)
sb.Append("<br>");
sb.Append(part.Log[i]);
}
if (sb.Length == 0)
sb.Append("Nothing logged yet.");
AddHtml(25, y, 250, 150, Color(sb.ToString(), BlackColor32), false, true);
break;
}
case TourneyBracketGumpType.Player_Info:
{
AddPage(0);
AddBackground(0, 0, 300, 300, 9380);
AddLeftArrow(25, 11, ToButtonID(0, 3));
AddHtml(25, 35, 250, 20, Center("Participants"), false, false);
if (!(obj is Mobile mob))
break;
Ladder ladder = Ladder.Instance;
LadderEntry entry = ladder?.Find(mob);
AddHtml(25, 53, 250, 20, $"Name: {mob.Name}", false, false);
AddHtml(25, 73, 250, 20,
$"Guild: {(mob.Guild == null ? "None" : mob.Guild.Name + " [" + mob.Guild.Abbreviation + "]")}",
false, false);
AddHtml(25, 93, 250, 20, $"Rank: {(entry == null ? "N/A" : LadderGump.Rank(entry.Index + 1))}", false,
false);
AddHtml(25, 113, 250, 20, $"Level: {(entry == null ? 0 : Ladder.GetLevel(entry.Experience))}", false,
false);
AddHtml(25, 133, 250, 20, $"Wins: {entry?.Wins ?? 0:N0}", false, false);
AddHtml(25, 153, 250, 20, $"Losses: {entry?.Losses ?? 0:N0}", false, false);
break;
}
case TourneyBracketGumpType.Round_List:
{
AddPage(0);
AddBackground(0, 0, 300, 300, 9380);
AddLeftArrow(25, 11, ToButtonID(0, 0));
AddHtml(25, 35, 250, 20, Center("Rounds"), false, false);
// List<PyramidLevel> levelsList = m_List != null
// ? Utility.CastListCovariant<object, PyramidLevel>(m_List)
// : new List<PyramidLevel>(tourney.Pyramid.Levels);
StartPage(out int index, out int count, out int y, 12);
for (int i = 0; i < count; ++i, y += 18)
AddRightArrow(25, y, ToButtonID(3, index + i), "Round #" + (index + i + 1));
break;
}
case TourneyBracketGumpType.Round_Info:
{
AddPage(0);
AddBackground(0, 0, 300, 300, 9380);
AddLeftArrow(25, 11, ToButtonID(0, 2));
AddHtml(25, 35, 250, 20, Center("Rounds"), false, false);
if (!(m_Object is PyramidLevel level))
break;
List<TourneyMatch> matchesList = m_List != null
? Utility.CastListCovariant<object, TourneyMatch>(m_List)
: new List<TourneyMatch>(level.Matches);
AddRightArrow(25, 53, ToButtonID(5, 0),
$"Free Advance: {(level.FreeAdvance == null ? "None" : level.FreeAdvance.NameList)}");
AddHtml(25, 73, 200, 20, $"{matchesList.Count} Match{(matchesList.Count == 1 ? "" : "es")}", false, false);
StartPage(out int index, out int count, out int y, 10);
for (int i = 0; i < count; ++i, y += 18)
{
TourneyMatch match = matchesList[index + i];
int color = -1;
if (match.InProgress)
color = 0x336666;
else if (match.Context != null && match.Winner == null)
color = 0x666666;
StringBuilder sb = new StringBuilder();
if (m_Tournament.TourneyType == TourneyType.Standard)
for (int j = 0; j < match.Participants.Count; ++j)
{
if (sb.Length > 0)
sb.Append(" vs ");
TourneyParticipant part = match.Participants[j];
string txt = part.NameList;
if (color == -1 && match.Context != null && match.Winner == part)
txt = Color(txt, 0x336633);
else if (color == -1 && match.Context != null)
txt = Color(txt, 0x663333);
sb.Append(txt);
}
else if (m_Tournament.EventController != null || m_Tournament.TourneyType == TourneyType.RandomTeam ||
m_Tournament.TourneyType == TourneyType.RedVsBlue ||
m_Tournament.TourneyType == TourneyType.Faction)
for (int j = 0; j < match.Participants.Count; ++j)
{
if (sb.Length > 0)
sb.Append(" vs ");
TourneyParticipant part = match.Participants[j];
string txt;
if (m_Tournament.EventController != null)
{
txt = $"Team {m_Tournament.EventController.GetTeamName(j)} ({part.Players.Count})";
}
else if (m_Tournament.TourneyType == TourneyType.RandomTeam)
{
txt = $"Team {j + 1} ({part.Players.Count})";
}
else if (m_Tournament.TourneyType == TourneyType.Faction)
{
if (m_Tournament.ParticipantsPerMatch == 4)
{
string name = "(null)";
switch (j)
{
case 0:
{
name = "Minax";
break;
}
case 1:
{
name = "Council of Mages";
break;
}
case 2:
{
name = "True Britannians";
break;
}
case 3:
{
name = "Shadowlords";
break;
}
}
txt = $"{name} ({part.Players.Count})";
}
else if (m_Tournament.ParticipantsPerMatch == 2)
{
txt = $"{(j == 0 ? "Evil" : "Hero")} Team ({part.Players.Count})";
}
else
{
txt = $"Team {j + 1} ({part.Players.Count})";
}
}
else
{
txt = $"Team {(j == 0 ? "Red" : "Blue")} ({part.Players.Count})";
}
if (color == -1 && match.Context != null && match.Winner == part)
txt = Color(txt, 0x336633);
else if (color == -1 && match.Context != null)
txt = Color(txt, 0x663333);
sb.Append(txt);
}
else if (m_Tournament.TourneyType == TourneyType.FreeForAll) sb.Append("Free For All");
string str = sb.ToString();
if (color >= 0)
str = Color(str, color);
AddRightArrow(25, y, ToButtonID(5, index + i + 1), str);
}
break;
}
case TourneyBracketGumpType.Match_Info:
{
if (!(obj is TourneyMatch match))
break;
int ct = m_Tournament.TourneyType == TourneyType.FreeForAll ? 2 : match.Participants.Count;
AddPage(0);
AddBackground(0, 0, 300, 60 + 18 + 20 + 20 + 20 + ct * 18 + 6, 9380);
AddLeftArrow(25, 11, ToButtonID(0, 5));
AddHtml(25, 35, 250, 20, Center("Rounds"), false, false);
AddHtml(25, 53, 250, 20, $"Winner: {(match.Winner == null ? "N/A" : match.Winner.NameList)}", false,
false);
AddHtml(25, 73, 250, 20,
$"State: {(match.InProgress ? "In progress" : match.Context != null ? "Complete" : "Waiting")}",
false, false);
AddHtml(25, 93, 250, 20, "Participants:", false, false);
if (m_Tournament.TourneyType == TourneyType.Standard)
for (int i = 0; i < match.Participants.Count; ++i)
{
TourneyParticipant part = match.Participants[i];
AddRightArrow(25, 113 + i * 18, ToButtonID(6, i), part.NameList);
}
else if (m_Tournament.EventController != null || m_Tournament.TourneyType == TourneyType.RandomTeam ||
m_Tournament.TourneyType == TourneyType.RedVsBlue ||
m_Tournament.TourneyType == TourneyType.Faction)
for (int i = 0; i < match.Participants.Count; ++i)
{
TourneyParticipant part = match.Participants[i];
if (m_Tournament.EventController != null)
{
AddRightArrow(25, 113 + i * 18, ToButtonID(6, i),
$"Team {m_Tournament.EventController.GetTeamName(i)} ({part.Players.Count})");
}
else if (m_Tournament.TourneyType == TourneyType.RandomTeam)
{
AddRightArrow(25, 113 + i * 18, ToButtonID(6, i),
$"Team {i + 1} ({part.Players.Count})");
}
else if (m_Tournament.TourneyType == TourneyType.Faction)
{
if (m_Tournament.ParticipantsPerMatch == 4)
{
string name = "(null)";
switch (i)
{
case 0:
{
name = "Minax";
break;
}
case 1:
{
name = "Council of Mages";
break;
}
case 2:
{
name = "True Britannians";
break;
}
case 3:
{
name = "Shadowlords";
break;
}
}
AddRightArrow(25, 113 + i * 18, ToButtonID(6, i),
$"{name} ({part.Players.Count})");
}
else if (m_Tournament.ParticipantsPerMatch == 2)
{
AddRightArrow(25, 113 + i * 18, ToButtonID(6, i),
$"{(i == 0 ? "Evil" : "Hero")} Team ({part.Players.Count})");
}
else
{
AddRightArrow(25, 113 + i * 18, ToButtonID(6, i),
$"Team {i + 1} ({part.Players.Count})");
}
}
else
{
AddRightArrow(25, 113 + i * 18, ToButtonID(6, i),
$"Team {(i == 0 ? "Red" : "Blue")} ({part.Players.Count})");
}
}
else if (m_Tournament.TourneyType == TourneyType.FreeForAll)
AddHtml(25, 113, 250, 20, "Free For All", false, false);
break;
}
}
}
public string Center(string text)
{
return $"<CENTER>{text}</CENTER>";
}
public string Color(string text, int color)
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor)
{
AddColoredText(x - 1, y - 1, width, height, text, borderColor);
AddColoredText(x - 1, y + 1, width, height, text, borderColor);
AddColoredText(x + 1, y - 1, width, height, text, borderColor);
AddColoredText(x + 1, y + 1, width, height, text, borderColor);
AddColoredText(x, y, width, height, text, color);
}
private void AddColoredText(int x, int y, int width, int height, string text, int color)
{
if (color == 0)
AddHtml(x, y, width, height, text, false, false);
else
AddHtml(x, y, width, height, Color(text, color), false, false);
}
public void AddRightArrow(int x, int y, int bid, string text)
{
AddButton(x, y, 0x15E1, 0x15E5, bid, GumpButtonType.Reply, 0);
if (text != null)
AddHtml(x + 20, y - 1, 230, 20, text, false, false);
}
public void AddRightArrow(int x, int y, int bid)
{
AddRightArrow(x, y, bid, null);
}
public void AddLeftArrow(int x, int y, int bid, string text)
{
AddButton(x, y, 0x15E3, 0x15E7, bid, GumpButtonType.Reply, 0);
if (text != null)
AddHtml(x + 20, y - 1, 230, 20, text, false, false);
}
public void AddLeftArrow(int x, int y, int bid)
{
AddLeftArrow(x, y, bid, null);
}
public int ToButtonID(int type, int index)
{
return 1 + index * 7 + type;
}
public bool FromButtonID(int bid, out int type, out int index)
{
type = (bid - 1) % 7;
index = (bid - 1) / 7;
return bid >= 1;
}
public void StartPage(out int index, out int count, out int y, int perPage)
{
m_PerPage = perPage;
index = Math.Max(m_Page * perPage, 0);
count = Math.Max(Math.Min(m_List.Count - index, perPage), 0);
y = 53 + (12 - perPage) * 18;
if (m_Page > 0)
AddLeftArrow(242, 35, ToButtonID(1, 0));
if ((m_Page + 1) * perPage < m_List.Count)
AddRightArrow(260, 35, ToButtonID(1, 1));
}
public override void OnResponse(NetState sender, RelayInfo info)
{
if (!FromButtonID(info.ButtonID, out int type, out int index))
return;
switch (type)
{
case 0:
{
switch (index)
{
case 0:
m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, TourneyBracketGumpType.Index));
break;
case 1:
m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament,
TourneyBracketGumpType.Participant_List));
break;
case 2:
m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, TourneyBracketGumpType.Round_List));
break;
case 4:
m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, TourneyBracketGumpType.Rules_Info));
break;
case 3:
{
Mobile mob = m_Object as Mobile;
for (int i = 0; i < m_Tournament.Participants.Count; ++i)
{
TourneyParticipant part = m_Tournament.Participants[i];
if (part.Players.Contains(mob))
{
m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament,
TourneyBracketGumpType.Participant_Info, null, 0, part));
break;
}
}
break;
}
case 5:
{
if (!(m_Object is TourneyMatch match))
break;
for (int i = 0; i < m_Tournament.Pyramid.Levels.Count; ++i)
{
PyramidLevel level = m_Tournament.Pyramid.Levels[i];
if (level.Matches.Contains(match))
m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament,
TourneyBracketGumpType.Round_Info, null, 0, level));
}
break;
}
}
break;
}
case 1:
{
switch (index)
{
case 0:
{
if (m_List != null && m_Page > 0)
m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, m_Type, m_List, m_Page - 1,
m_Object));
break;
}
case 1:
{
if (m_List != null && (m_Page + 1) * m_PerPage < m_List.Count)
m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, m_Type, m_List, m_Page + 1,
m_Object));
break;
}
}
break;
}
case 2:
{
if (m_Type != TourneyBracketGumpType.Participant_List)
break;
if (index >= 0 && index < m_List.Count)
m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament,
TourneyBracketGumpType.Participant_Info, null, 0, m_List[index]));
break;
}
case 3:
{
if (m_Type != TourneyBracketGumpType.Round_List)
break;
if (index >= 0 && index < m_List.Count)
m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, TourneyBracketGumpType.Round_Info,
null, 0, m_List[index]));
break;
}
case 4:
{
if (m_Type != TourneyBracketGumpType.Participant_Info)
break;
if (m_Object is TourneyParticipant part && index >= 0 && index < part.Players.Count)
m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, TourneyBracketGumpType.Player_Info,
null, 0, part.Players[index]));
break;
}
case 5:
{
if (m_Type != TourneyBracketGumpType.Round_Info)
break;
if (!(m_Object is PyramidLevel level))
break;
if (index == 0)
{
if (level.FreeAdvance != null)
m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament,
TourneyBracketGumpType.Participant_Info, null, 0, level.FreeAdvance));
else
m_From.SendGump(
new TournamentBracketGump(m_From, m_Tournament, m_Type, m_List, m_Page, m_Object));
}
else if (index >= 1 && index <= level.Matches.Count)
{
m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, TourneyBracketGumpType.Match_Info,
null, 0, level.Matches[index - 1]));
}
break;
}
case 6:
{
if (m_Type != TourneyBracketGumpType.Match_Info)
break;
if (m_Object is TourneyMatch match && index >= 0 && index < match.Participants.Count)
m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament,
TourneyBracketGumpType.Participant_Info, null, 0, match.Participants[index]));
break;
}
}
}
}
}

View file

@ -1,40 +1,34 @@
using System;
using System.Collections;
using System.Collections.Generic;
namespace Server.Engines.ConPVP
{
public class LadderController : Item
{
private Ladder m_Ladder;
[Constructible]
public LadderController() : base(0x1B7A)
{
Visible = false;
Movable = false;
m_Ladder = new Ladder();
Ladder = new Ladder();
if (Ladder.Instance == null)
Ladder.Instance = m_Ladder;
Ladder.Instance = Ladder;
}
public LadderController(Serial serial) : base(serial)
{
}
//[CommandProperty( AccessLevel.GameMaster )]
public Ladder Ladder
{
get => m_Ladder;
set { }
}
[CommandProperty( AccessLevel.Administrator )]
public Ladder Ladder{ get; private set; }
public override string DefaultName => "ladder controller";
public override void Delete()
{
if (Ladder.Instance == m_Ladder)
if (Ladder.Instance == Ladder)
Ladder.Instance = null;
base.Delete();
@ -46,9 +40,9 @@ namespace Server.Engines.ConPVP
writer.Write(1);
m_Ladder.Serialize(writer);
Ladder.Serialize(writer);
writer.Write(Ladder.Instance == m_Ladder);
writer.Write(Ladder.Instance == Ladder);
}
public override void Deserialize(GenericReader reader)
@ -62,10 +56,10 @@ namespace Server.Engines.ConPVP
case 1:
case 0:
{
m_Ladder = new Ladder(reader);
Ladder = new Ladder(reader);
if (version < 1 || reader.ReadBool())
Ladder.Instance = m_Ladder;
Ladder.Instance = Ladder;
break;
}
@ -120,14 +114,13 @@ namespace Server.Engines.ConPVP
/* +6 */ { 40, 160 }
};
private ArrayList m_Entries;
public List<LadderEntry> Entries{ get; } = new List<LadderEntry>();
private Hashtable m_Table;
private Dictionary<Mobile, LadderEntry> m_Table;
public Ladder()
{
m_Table = new Hashtable();
m_Entries = new ArrayList();
m_Table = new Dictionary<Mobile, LadderEntry>();
}
public Ladder(GenericReader reader)
@ -141,8 +134,8 @@ namespace Server.Engines.ConPVP
{
int count = reader.ReadEncodedInt();
m_Table = new Hashtable(count);
m_Entries = new ArrayList(count);
m_Table = new Dictionary<Mobile, LadderEntry>(count);
Entries = new List<LadderEntry>(count);
for (int i = 0; i < count; ++i)
{
@ -151,18 +144,18 @@ namespace Server.Engines.ConPVP
if (entry.Mobile != null)
{
m_Table[entry.Mobile] = entry;
entry.Index = m_Entries.Count;
m_Entries.Add(entry);
entry.Index = Entries.Count;
Entries.Add(entry);
}
}
if (version == 0)
{
m_Entries.Sort();
Entries.Sort();
for (int i = 0; i < m_Entries.Count; ++i)
for (int i = 0; i < Entries.Count; ++i)
{
LadderEntry entry = (LadderEntry)m_Entries[i];
LadderEntry entry = Entries[i];
entry.Index = i;
}
@ -247,20 +240,15 @@ namespace Server.Engines.ConPVP
return xp * (weWon ? 1 : -1);
}
public ArrayList ToArrayList()
{
return m_Entries;
}
private int Swap(int idx, int newIdx)
{
object hold = m_Entries[idx];
LadderEntry hold = Entries[idx];
m_Entries[idx] = m_Entries[newIdx];
m_Entries[newIdx] = hold;
Entries[idx] = Entries[newIdx];
Entries[newIdx] = hold;
((LadderEntry)m_Entries[idx]).Index = idx;
((LadderEntry)m_Entries[newIdx]).Index = newIdx;
Entries[idx].Index = idx;
Entries[newIdx].Index = newIdx;
return newIdx;
}
@ -269,29 +257,25 @@ namespace Server.Engines.ConPVP
{
int index = entry.Index;
if (index >= 0 && index < m_Entries.Count)
if (index >= 0 && index < Entries.Count)
{
// sanity
int c;
while (index - 1 >= 0 && (c = entry.CompareTo(m_Entries[index - 1])) < 0)
while (index - 1 >= 0 && (entry.CompareTo(Entries[index - 1])) < 0)
index = Swap(index, index - 1);
while (index + 1 < m_Entries.Count && (c = entry.CompareTo(m_Entries[index + 1])) > 0)
while (index + 1 < Entries.Count && (entry.CompareTo(Entries[index + 1])) > 0)
index = Swap(index, index + 1);
}
}
public LadderEntry Find(Mobile mob)
{
LadderEntry entry = (LadderEntry)m_Table[mob];
LadderEntry entry = m_Table[mob];
if (entry == null)
{
m_Table[mob] = entry = new LadderEntry(mob, this);
entry.Index = m_Entries.Count;
m_Entries.Add(entry);
entry.Index = Entries.Count;
Entries.Add(entry);
}
return entry;
@ -299,17 +283,17 @@ namespace Server.Engines.ConPVP
public LadderEntry FindNoCreate(Mobile mob)
{
return m_Table[mob] as LadderEntry;
return m_Table[mob];
}
public void Serialize(GenericWriter writer)
{
writer.WriteEncodedInt(1); // version;
writer.WriteEncodedInt(m_Entries.Count);
writer.WriteEncodedInt(Entries.Count);
for (int i = 0; i < m_Entries.Count; ++i)
((LadderEntry)m_Entries[i]).Serialize(writer);
for (int i = 0; i < Entries.Count; ++i)
Entries[i].Serialize(writer);
}
}

View file

@ -19,7 +19,7 @@ namespace Server.Engines.ConPVP
public DuelContext Context{ get; }
public TournyParticipant TournyPart{ get; set; }
public TourneyParticipant TourneyPart{ get; set; }
public int FilledSlots
{

View file

@ -1,4 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using Server.Gumps;
using Server.Network;
@ -7,18 +6,16 @@ namespace Server.Engines.ConPVP
{
public class PreferencesController : Item
{
private Preferences m_Preferences;
[Constructible]
public PreferencesController() : base(0x1B7A)
{
Visible = false;
Movable = false;
m_Preferences = new Preferences();
Preferences = new Preferences();
if (Preferences.Instance == null)
Preferences.Instance = m_Preferences;
Preferences.Instance = Preferences;
else
Delete();
}
@ -27,18 +24,14 @@ namespace Server.Engines.ConPVP
{
}
//[CommandProperty( AccessLevel.GameMaster )]
public Preferences Preferences
{
get => m_Preferences;
set { }
}
[CommandProperty( AccessLevel.Administrator )]
public Preferences Preferences{ get; private set; }
public override string DefaultName => "preferences controller";
public override void Delete()
{
if (Preferences.Instance != m_Preferences)
if (Preferences.Instance != Preferences)
base.Delete();
}
@ -48,7 +41,7 @@ namespace Server.Engines.ConPVP
writer.Write(0);
m_Preferences.Serialize(writer);
Preferences.Serialize(writer);
}
public override void Deserialize(GenericReader reader)
@ -61,8 +54,8 @@ namespace Server.Engines.ConPVP
{
case 0:
{
m_Preferences = new Preferences(reader);
Preferences.Instance = m_Preferences;
Preferences = new Preferences(reader);
Preferences.Instance = Preferences;
break;
}
}
@ -71,12 +64,12 @@ namespace Server.Engines.ConPVP
public class Preferences
{
private Hashtable m_Table;
private Dictionary<Mobile, PreferencesEntry> m_Table;
public Preferences()
{
m_Table = new Hashtable();
Entries = new ArrayList();
m_Table = new Dictionary<Mobile, PreferencesEntry>();
Entries = new List<PreferencesEntry>();
}
public Preferences(GenericReader reader)
@ -89,12 +82,12 @@ namespace Server.Engines.ConPVP
{
int count = reader.ReadEncodedInt();
m_Table = new Hashtable(count);
Entries = new ArrayList(count);
m_Table = new Dictionary<Mobile, PreferencesEntry>(count);
Entries = new List<PreferencesEntry>(count);
for (int i = 0; i < count; ++i)
{
PreferencesEntry entry = new PreferencesEntry(reader, this, version);
PreferencesEntry entry = new PreferencesEntry(reader, version);
if (entry.Mobile != null)
{
@ -108,17 +101,17 @@ namespace Server.Engines.ConPVP
}
}
public ArrayList Entries{ get; }
public List<PreferencesEntry> Entries{ get; }
public static Preferences Instance{ get; set; }
public PreferencesEntry Find(Mobile mob)
{
PreferencesEntry entry = (PreferencesEntry)m_Table[mob];
PreferencesEntry entry = m_Table[mob];
if (entry == null)
{
m_Table[mob] = entry = new PreferencesEntry(mob, this);
m_Table[mob] = entry = new PreferencesEntry(mob);
Entries.Add(entry);
}
@ -132,25 +125,20 @@ namespace Server.Engines.ConPVP
writer.WriteEncodedInt(Entries.Count);
for (int i = 0; i < Entries.Count; ++i)
((PreferencesEntry)Entries[i]).Serialize(writer);
Entries[i].Serialize(writer);
}
}
public class PreferencesEntry
{
private Preferences m_Preferences;
public PreferencesEntry(Mobile mob, Preferences prefs)
public PreferencesEntry(Mobile mob)
{
m_Preferences = prefs;
Mobile = mob;
Disliked = new ArrayList();
Disliked = new List<string>();
}
public PreferencesEntry(GenericReader reader, Preferences prefs, int version)
public PreferencesEntry(GenericReader reader, int version)
{
m_Preferences = prefs;
switch (version)
{
case 0:
@ -159,7 +147,7 @@ namespace Server.Engines.ConPVP
int count = reader.ReadEncodedInt();
Disliked = new ArrayList(count);
Disliked = new List<string>(count);
for (int i = 0; i < count; ++i)
Disliked.Add(reader.ReadString());
@ -171,7 +159,7 @@ namespace Server.Engines.ConPVP
public Mobile Mobile{ get; }
public ArrayList Disliked{ get; }
public List<string> Disliked{ get; }
public void Serialize(GenericWriter writer)
{
@ -180,7 +168,7 @@ namespace Server.Engines.ConPVP
writer.WriteEncodedInt(Disliked.Count);
for (int i = 0; i < Disliked.Count; ++i)
writer.Write((string)Disliked[i]);
writer.Write(Disliked[i]);
}
}
@ -188,11 +176,9 @@ namespace Server.Engines.ConPVP
{
private int m_ColumnX = 12;
private PreferencesEntry m_Entry;
private Mobile m_From;
public PreferencesGump(Mobile from, Preferences prefs) : base(50, 50)
{
m_From = from;
m_Entry = prefs.Find(from);
if (m_Entry == null)
@ -221,10 +207,7 @@ namespace Server.Engines.ConPVP
{
Arena ar = arenas[i];
string name = ar.Name;
if (name == null)
name = "(no name)";
string name = ar.Name ?? "(no name)";
int x = 12;
int y = 32 + i * 31;
@ -235,7 +218,6 @@ namespace Server.Engines.ConPVP
x += 35;
AddBorderedText(x + 5, y + 5, 115 - 5, name, color, 0);
x += 115;
}
}
@ -272,12 +254,6 @@ namespace Server.Engines.ConPVP
private void AddBorderedText(int x, int y, int width, string text, int color, int borderColor)
{
/*AddColoredText( x - 1, y, width, text, borderColor );
AddColoredText( x + 1, y, width, text, borderColor );
AddColoredText( x, y - 1, width, text, borderColor );
AddColoredText( x, y + 1, width, text, borderColor );*/
/*AddColoredText( x - 1, y - 1, width, text, borderColor );
AddColoredText( x + 1, y + 1, width, text, borderColor );*/
AddColoredText(x, y, width, text, color);
}

View file

@ -1,4 +1,5 @@
using System.Collections;
using System.Collections.Generic;
namespace Server.Engines.ConPVP
{
@ -18,7 +19,7 @@ namespace Server.Engines.ConPVP
public Ruleset Base{ get; private set; }
public ArrayList Flavors{ get; } = new ArrayList();
public List<Ruleset> Flavors{ get; } = new List<Ruleset>();
public bool Changed{ get; set; }
@ -36,7 +37,7 @@ namespace Server.Engines.ConPVP
{
for (int i = 0; i < Flavors.Count; ++i)
{
Ruleset flavor = (Ruleset)Flavors[i];
Ruleset flavor = Flavors[i];
Options.Or(flavor.Options);
}

File diff suppressed because it is too large Load diff

View file

@ -1,121 +0,0 @@
namespace Server.Engines.ConPVP
{
#if false
[Flippable( 0x9A8, 0xE80 )]
public class StakesContainer : LockableContainer
{
private Mobile m_Initiator;
private Participant m_Participant;
private Hashtable m_Owners;
public override bool CheckItemUse( Mobile from, Item item )
{
Mobile owner = (Mobile)m_Owners[item];
if ( owner != null && owner != from )
return false;
return base.CheckItemUse( from, item );
}
public override bool CheckTarget( Mobile from, Server.Targeting.Target targ, object targeted )
{
Mobile owner = (Mobile)m_Owners[targeted];
if ( owner != null && owner != from )
return false;
return base.CheckTarget( from, targ, targeted );
}
public override bool CheckLift(Mobile from, Item item)
{
Mobile owner = (Mobile)m_Owners[item];
if ( owner != null && owner != from )
return false;
return base.CheckLift( from, item );
}
public void ReturnItems()
{
ArrayList items = new ArrayList( this.Items );
for ( int i = 0; i < items.Count; ++i )
{
Item item = (Item)items[i];
Mobile owner = (Mobile)m_Owners[item];
if ( owner == null || owner.Deleted )
owner = m_Initiator;
if ( owner == null || owner.Deleted )
return;
if ( item.LootType != LootType.Blessed || !owner.PlaceInBackpack( item ) )
owner.BankBox.DropItem( item );
}
}
public override bool TryDropItem( Mobile from, Item dropped, bool sendFullMessage )
{
if ( m_Participant == null || !m_Participant.Contains( from ) )
{
if ( sendFullMessage )
from.SendMessage( "You are not allowed to place items here." );
return false;
}
if ( dropped is Container || dropped.Stackable )
{
if ( sendFullMessage )
from.SendMessage( "That item cannot be used as stakes." );
return false;
}
if ( !base.TryDropItem( from, dropped, sendFullMessage ) )
return false;
if ( from != null )
m_Owners[dropped] = from;
return true;
}
public override void RemoveItem( Item item )
{
base.RemoveItem( item );
m_Owners.Remove( item );
}
public StakesContainer( DuelContext context, Participant participant ) : base( 0x9A8 )
{
Movable = false;
m_Initiator = context.Initiator;
m_Participant = participant;
m_Owners = new Hashtable();
}
public StakesContainer( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
}
#endif
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,65 @@
using Server.Network;
namespace Server.Engines.ConPVP
{
public class TournamentBracketItem : Item
{
[Constructible]
public TournamentBracketItem() : base(3774)
{
Movable = false;
}
public TournamentBracketItem(Serial serial) : base(serial)
{
}
[CommandProperty(AccessLevel.GameMaster)]
public TournamentController Tournament{ get; set; }
public override string DefaultName => "tournament bracket";
public override void OnDoubleClick(Mobile from)
{
if (!from.InRange(GetWorldLocation(), 2))
{
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that
}
else
{
Tournament tourney = Tournament?.Tournament;
if (tourney != null)
{
from.CloseGump<TournamentBracketGump>();
from.SendGump(new TournamentBracketGump(from, tourney, TourneyBracketGumpType.Index));
}
}
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0);
writer.Write(Tournament);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
switch (version)
{
case 0:
{
Tournament = reader.ReadItem() as TournamentController;
break;
}
}
}
}
}

View file

@ -0,0 +1,143 @@
using System;
using System.Collections.Generic;
using Server.ContextMenus;
using Server.Gumps;
namespace Server.Engines.ConPVP
{
public class TournamentController : Item
{
private static List<TournamentController> m_Instances = new List<TournamentController>();
[Constructible]
public TournamentController() : base(0x1B7A)
{
Visible = false;
Movable = false;
Tournament = new Tournament();
m_Instances.Add(this);
}
public TournamentController(Serial serial) : base(serial)
{
}
[CommandProperty(AccessLevel.GameMaster)]
public Tournament Tournament{ get; private set; }
public static bool IsActive
{
get
{
for (int i = 0; i < m_Instances.Count; ++i)
{
TournamentController controller = m_Instances[i];
if (controller != null && !controller.Deleted && controller.Tournament != null &&
controller.Tournament.Stage != TournamentStage.Inactive)
return true;
}
return false;
}
}
public override string DefaultName => "tournament controller";
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
{
base.GetContextMenuEntries(from, list);
if (from.AccessLevel >= AccessLevel.GameMaster && Tournament != null)
{
list.Add(new EditEntry(Tournament));
if (Tournament.CurrentStage == TournamentStage.Inactive)
list.Add(new StartEntry(Tournament));
}
}
public override void OnDoubleClick(Mobile from)
{
if (from.AccessLevel >= AccessLevel.GameMaster && Tournament != null)
{
from.CloseGump<PickRulesetGump>();
from.CloseGump<RulesetGump>();
from.SendGump(new PickRulesetGump(from, null, Tournament.Ruleset));
}
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0);
Tournament.Serialize(writer);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
switch (version)
{
case 0:
{
Tournament = new Tournament(reader);
break;
}
}
m_Instances.Add(this);
}
public override void OnDelete()
{
base.OnDelete();
m_Instances.Remove(this);
}
private class EditEntry : ContextMenuEntry
{
private Tournament m_Tournament;
public EditEntry(Tournament tourney) : base(5101)
{
m_Tournament = tourney;
}
public override void OnClick()
{
Owner.From.SendGump(new PropertiesGump(Owner.From, m_Tournament));
}
}
private class StartEntry : ContextMenuEntry
{
private Tournament m_Tournament;
public StartEntry(Tournament tourney) : base(5113)
{
m_Tournament = tourney;
}
public override void OnClick()
{
if (m_Tournament.Stage == TournamentStage.Inactive)
{
m_Tournament.SignupStart = DateTime.UtcNow;
m_Tournament.Stage = TournamentStage.Signup;
m_Tournament.Participants.Clear();
m_Tournament.Pyramid.Levels.Clear();
m_Tournament.Alert("Hear ye! Hear ye!",
"Tournament signup has opened. You can enter by signing up with the registrar.");
}
}
}
}
}

View file

@ -0,0 +1,189 @@
using System.Collections.Generic;
using Server.Ethics;
using Server.Factions;
namespace Server.Engines.ConPVP
{
public class TourneyPyramid
{
public TourneyPyramid()
{
Levels = new List<PyramidLevel>();
}
public List<PyramidLevel> Levels{ get; set; }
public void AddLevel(int partsPerMatch, List<TourneyParticipant> participants, GroupingType groupType, TourneyType tourneyType)
{
List<TourneyParticipant> copy = new List<TourneyParticipant>(participants);
if (groupType == GroupingType.Nearest || groupType == GroupingType.HighVsLow)
copy.Sort();
PyramidLevel level = new PyramidLevel();
switch (tourneyType)
{
case TourneyType.RedVsBlue:
{
TourneyParticipant[] parts = new TourneyParticipant[2];
for (int i = 0; i < parts.Length; ++i)
parts[i] = new TourneyParticipant(new List<Mobile>());
for (int i = 0; i < copy.Count; ++i)
{
List<Mobile> players = copy[i].Players;
for (int j = 0; j < players.Count; ++j)
{
Mobile mob = players[j];
if (mob.Kills >= 5)
parts[0].Players.Add(mob);
else
parts[1].Players.Add(mob);
}
}
level.Matches.Add(new TourneyMatch(new List<TourneyParticipant>(parts)));
break;
}
case TourneyType.Faction:
{
TourneyParticipant[] parts = new TourneyParticipant[partsPerMatch];
for (int i = 0; i < parts.Length; ++i)
parts[i] = new TourneyParticipant(new List<Mobile>());
for (int i = 0; i < copy.Count; ++i)
{
List<Mobile> players = copy[i].Players;
for (int j = 0; j < players.Count; ++j)
{
Mobile mob = players[j];
int index = -1;
if (partsPerMatch == 4)
{
Faction fac = Faction.Find(mob);
if (fac != null) index = fac.Definition.Sort;
}
else if (partsPerMatch == 2)
{
if (Ethic.Evil.IsEligible(mob))
index = 0;
else if (Ethic.Hero.IsEligible(mob)) index = 1;
}
if (index < 0 || index >= partsPerMatch) index = i % partsPerMatch;
parts[index].Players.Add(mob);
}
}
level.Matches.Add(new TourneyMatch(new List<TourneyParticipant>(parts)));
break;
}
case TourneyType.RandomTeam:
{
TourneyParticipant[] parts = new TourneyParticipant[partsPerMatch];
for (int i = 0; i < partsPerMatch; ++i)
parts[i] = new TourneyParticipant(new List<Mobile>());
for (int i = 0; i < copy.Count; ++i)
parts[i % parts.Length].Players.AddRange(copy[i].Players);
level.Matches.Add(new TourneyMatch(new List<TourneyParticipant>(parts)));
break;
}
case TourneyType.FreeForAll:
{
level.Matches.Add(new TourneyMatch(copy));
break;
}
case TourneyType.Standard:
{
if (partsPerMatch >= 2 && participants.Count % partsPerMatch == 1)
{
int lowAdvances = int.MaxValue;
for (int i = 0; i < participants.Count; ++i)
{
TourneyParticipant p = participants[i];
if (p.FreeAdvances < lowAdvances)
lowAdvances = p.FreeAdvances;
}
List<TourneyParticipant> toAdvance = new List<TourneyParticipant>();
for (int i = 0; i < participants.Count; ++i)
{
TourneyParticipant p = participants[i];
if (p.FreeAdvances == lowAdvances)
toAdvance.Add(p);
}
if (toAdvance.Count == 0)
toAdvance = copy; // sanity
int idx = Utility.Random(toAdvance.Count);
toAdvance[idx].AddLog(
"Advanced automatically due to an odd number of challengers.");
level.FreeAdvance = toAdvance[idx];
++level.FreeAdvance.FreeAdvances;
copy.Remove(toAdvance[idx]);
}
while (copy.Count >= partsPerMatch)
{
List<TourneyParticipant> thisMatch = new List<TourneyParticipant>();
for (int i = 0; i < partsPerMatch; ++i)
{
int idx = 0;
switch (groupType)
{
case GroupingType.HighVsLow:
idx = i * (copy.Count - 1) / (partsPerMatch - 1);
break;
case GroupingType.Nearest:
idx = 0;
break;
case GroupingType.Random:
idx = Utility.Random(copy.Count);
break;
}
thisMatch.Add(copy[idx]);
copy.RemoveAt(idx);
}
level.Matches.Add(new TourneyMatch(thisMatch));
}
if (copy.Count > 1)
level.Matches.Add(new TourneyMatch(copy));
break;
}
}
Levels.Add(level);
}
}
public class PyramidLevel
{
public List<TourneyMatch> Matches{ get; set; } = new List<TourneyMatch>();
public TourneyParticipant FreeAdvance{ get; set; }
}
}

View file

@ -0,0 +1,93 @@
using System;
using Server.Factions;
using Server.Mobiles;
using Server.Network;
namespace Server.Engines.ConPVP
{
public class TournamentRegistrar : Banker
{
[Constructible]
public TournamentRegistrar()
{
Timer.DelayCall(TimeSpan.FromSeconds(30.0), TimeSpan.FromSeconds(30.0), Announce_Callback);
}
public TournamentRegistrar(Serial serial) : base(serial)
{
}
[CommandProperty(AccessLevel.GameMaster)]
public TournamentController Tournament{ get; set; }
private void Announce_Callback()
{
Tournament tourney = Tournament?.Tournament;
if (tourney?.Stage == TournamentStage.Signup)
PublicOverheadMessage(MessageType.Regular, 0x35, false,
"Come one, come all! Do you aspire to be a fighter of great renown? Join this tournament and show the world your abilities.");
}
public override void OnMovement(Mobile m, Point3D oldLocation)
{
base.OnMovement(m, oldLocation);
Tournament tourney = Tournament?.Tournament;
if (InRange(m, 4) && !InRange(oldLocation, 4) && tourney != null && tourney.Stage == TournamentStage.Signup &&
m.CanBeginAction(this))
{
Ladder ladder = Ladder.Instance;
LadderEntry entry = ladder?.Find(m);
if (entry != null && Ladder.GetLevel(entry.Experience) < tourney.LevelRequirement)
return;
if (tourney.IsFactionRestricted && Faction.Find(m) == null) return;
if (tourney.HasParticipant(m))
return;
PrivateOverheadMessage(MessageType.Regular, 0x35, false,
$"Hello m'{(m.Female ? "Lady" : "Lord")}. Dost thou wish to enter this tournament? You need only to write your name in this book.",
m.NetState);
m.BeginAction(this);
Timer.DelayCall(TimeSpan.FromSeconds(10.0), ReleaseLock_Callback, m);
}
}
public void ReleaseLock_Callback(Mobile m)
{
m.EndAction(this);
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0);
writer.Write(Tournament);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
switch (version)
{
case 0:
{
Tournament = reader.ReadItem() as TournamentController;
break;
}
}
Timer.DelayCall(TimeSpan.FromSeconds(30.0), TimeSpan.FromSeconds(30.0), Announce_Callback);
}
}
}

View file

@ -0,0 +1,149 @@
using System.Collections.Generic;
using Server.Factions;
using Server.Mobiles;
using Server.Network;
namespace Server.Engines.ConPVP
{
public class TournamentSignupItem : Item
{
[Constructible]
public TournamentSignupItem() : base(4029)
{
Movable = false;
}
public TournamentSignupItem(Serial serial) : base(serial)
{
}
[CommandProperty(AccessLevel.GameMaster)]
public TournamentController Tournament{ get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public Mobile Registrar{ get; set; }
public override string DefaultName => "tournament signup book";
public override void OnDoubleClick(Mobile from)
{
if (!from.InRange(GetWorldLocation(), 2))
{
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that
}
else
{
Tournament tourney = Tournament?.Tournament;
if (tourney == null)
return;
if (Registrar != null)
Registrar.Direction = Registrar.GetDirectionTo(this);
switch (tourney.Stage)
{
case TournamentStage.Fighting:
{
if (Registrar != null)
{
if (tourney.HasParticipant(from))
Registrar.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "Excuse me? You are already signed up.", from.NetState);
else
Registrar.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "The tournament has already begun. You are too late to signup now.",
from.NetState);
}
break;
}
case TournamentStage.Inactive:
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "The tournament is closed.", from.NetState);
break;
}
case TournamentStage.Signup:
{
Ladder ladder = Ladder.Instance;
LadderEntry entry = ladder?.Find(from);
if (entry != null && Ladder.GetLevel(entry.Experience) < tourney.LevelRequirement)
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "You have not yet proven yourself a worthy dueler.", from.NetState);
break;
}
if (tourney.IsFactionRestricted && Faction.Find(from) == null)
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "Only those who have declared their faction allegiance may participate.",
from.NetState);
break;
}
if (from.HasGump<AcceptTeamGump>())
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "You must first respond to the offer I've given you.", from.NetState);
}
else if (from.HasGump<AcceptDuelGump>())
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "You must first cancel your duel offer.", from.NetState);
}
else if (from is PlayerMobile mobile && mobile.DuelContext != null)
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x22, false, "You are already participating in a duel.", mobile.NetState);
}
else if (!tourney.HasParticipant(from))
{
from.CloseGump<ConfirmSignupGump>();
from.SendGump(new ConfirmSignupGump(from, Registrar, tourney, new List<Mobile> { from }));
}
else
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
0x35, false, "You have already entered this tournament.", from.NetState);
}
break;
}
}
}
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0);
writer.Write(Tournament);
writer.Write(Registrar);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
switch (version)
{
case 0:
{
Tournament = reader.ReadItem() as TournamentController;
Registrar = reader.ReadMobile();
break;
}
}
}
}
}

View file

@ -0,0 +1,109 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Server.Engines.ConPVP
{
public class TourneyParticipant : IComparable<TourneyParticipant>
{
public TourneyParticipant(Mobile owner)
{
Log = new List<string>();
Players = new List<Mobile> { owner };
}
public TourneyParticipant(List<Mobile> players)
{
Log = new List<string>();
Players = players;
}
public List<Mobile> Players{ get; set; }
public List<string> Log{ get; set; }
public int FreeAdvances{ get; set; }
public int TotalLadderXP
{
get
{
Ladder ladder = Ladder.Instance;
if (ladder == null)
return 0;
int total = 0;
for (int i = 0; i < Players.Count; ++i)
{
Mobile mob = Players[i];
LadderEntry entry = ladder.Find(mob);
if (entry != null)
total += entry.Experience;
}
return total;
}
}
public string NameList
{
get
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < Players.Count; ++i)
{
if (Players[i] == null)
continue;
Mobile mob = Players[i];
if (sb.Length > 0)
{
if (Players.Count == 2)
sb.Append(" and ");
else if (i + 1 < Players.Count)
sb.Append(", ");
else
sb.Append(", and ");
}
sb.Append(mob.Name);
}
if (sb.Length == 0)
return "Empty";
return sb.ToString();
}
}
public int CompareTo(TourneyParticipant p)
{
return p.TotalLadderXP - TotalLadderXP;
}
public void AddLog(string text)
{
Log.Add(text);
}
public void AddLog(string format, params object[] args)
{
AddLog(string.Format(format, args));
}
public void WonMatch(TourneyMatch match)
{
AddLog("Match won.");
}
public void LostMatch(TourneyMatch match)
{
AddLog("Match lost.");
}
}
}

View file

@ -35,8 +35,8 @@ namespace Server.Engines.Craft
CraftContext context = craftSystem.GetContext(from);
from.CloseGump(typeof(CraftGump));
from.CloseGump(typeof(CraftGumpItem));
from.CloseGump<CraftGump>();
from.CloseGump<CraftGumpItem>();
AddPage(0);
@ -125,7 +125,7 @@ namespace Server.Engines.Craft
if (from.Backpack != null)
{
Item[] items = from.Backpack.FindItemsByType(resourceType, true);
Item[] items = from.Backpack.FindItemsByType(resourceType);
for (int i = 0; i < items.Length; ++i)
resourceCount += items[i].Amount;
@ -163,7 +163,7 @@ namespace Server.Engines.Craft
if (from.Backpack != null)
{
Item[] items = from.Backpack.FindItemsByType(resourceType, true);
Item[] items = from.Backpack.FindItemsByType(resourceType);
for (int i = 0; i < items.Length; ++i)
resourceCount += items[i].Amount;
@ -219,7 +219,7 @@ namespace Server.Engines.Craft
if (from.Backpack != null)
{
Item[] items = from.Backpack.FindItemsByType(subResource.ItemType, true);
Item[] items = from.Backpack.FindItemsByType(subResource.ItemType);
for (int j = 0; j < items.Length; ++j)
resourceCount += items[j].Amount;
@ -471,8 +471,6 @@ namespace Server.Engines.Craft
{
if (m_Page == CraftPage.PickResource && index >= 0 && index < system.CraftSubRes.Count)
{
int groupIndex = context?.LastGroupIndex ?? -1;
CraftSubRes res = system.CraftSubRes.GetAt(index);
if (m_From.Skills[system.MainSkill].Base < res.RequiredSkill)
@ -489,8 +487,6 @@ namespace Server.Engines.Craft
}
else if (m_Page == CraftPage.PickResource2 && index >= 0 && index < system.CraftSubRes2.Count)
{
int groupIndex = context?.LastGroupIndex ?? -1;
CraftSubRes res = system.CraftSubRes2.GetAt(index);
if (m_From.Skills[system.MainSkill].Base < res.RequiredSkill)

View file

@ -34,8 +34,8 @@ namespace Server.Engines.Craft
m_CraftItem = craftItem;
m_Tool = tool;
from.CloseGump(typeof(CraftGump));
from.CloseGump(typeof(CraftGumpItem));
from.CloseGump<CraftGump>();
from.CloseGump<CraftGumpItem>();
AddPage(0);
AddBackground(0, 0, 530, 417, 5054);
@ -143,7 +143,7 @@ namespace Server.Engines.Craft
for (int i = 0; i < m_CraftItem.Skills.Count; i++)
{
CraftSkill skill = m_CraftItem.Skills.GetAt(i);
double minSkill = skill.MinSkill, maxSkill = skill.MaxSkill;
double minSkill = skill.MinSkill;
if (minSkill < 0)
minSkill = 0;

View file

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Server.Commands;
using Server.Factions;
using Server.Items;
@ -142,6 +141,7 @@ namespace Server.Engines.Craft
}
catch
{
// ignored
}
if (item != null)
@ -177,9 +177,9 @@ namespace Server.Engines.Craft
public bool ConsumeAttributes(Mobile from, ref object message, bool consume)
{
bool consumMana = false;
bool consumHits = false;
bool consumStam = false;
bool consumMana;
bool consumHits;
bool consumStam;
if (Hits > 0 && from.Hits < Hits)
{
@ -755,7 +755,7 @@ namespace Server.Engines.Craft
public void Craft(Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool)
{
if (from.BeginAction(typeof(CraftSystem)))
if (from.BeginAction<CraftSystem>())
{
if (RequiredExpansion == Expansion.None ||
from.NetState != null && from.NetState.SupportsExpansion(RequiredExpansion))
@ -794,39 +794,39 @@ namespace Server.Engines.Craft
}
else
{
from.EndAction(typeof(CraftSystem));
from.EndAction<CraftSystem>();
from.SendGump(new CraftGump(from, craftSystem, tool, message));
}
}
else
{
from.EndAction(typeof(CraftSystem));
from.EndAction<CraftSystem>();
from.SendGump(new CraftGump(from, craftSystem, tool, message));
}
}
else
{
from.EndAction(typeof(CraftSystem));
from.EndAction<CraftSystem>();
from.SendGump(new CraftGump(from, craftSystem, tool, badCraft));
}
}
else
{
from.EndAction(typeof(CraftSystem));
from.EndAction<CraftSystem>();
from.SendGump(new CraftGump(from, craftSystem, tool,
1072847)); // You must learn that recipe from a scroll.
}
}
else
{
from.EndAction(typeof(CraftSystem));
from.EndAction<CraftSystem>();
from.SendGump(new CraftGump(from, craftSystem, tool,
1044153)); // You don't have the required skills to attempt this item.
}
}
else
{
from.EndAction(typeof(CraftSystem));
from.EndAction<CraftSystem>();
from.SendGump(new CraftGump(from, craftSystem, tool,
RequiredExpansionMessage(RequiredExpansion))); //The {0} expansion is required to attempt this item.
}
@ -1098,7 +1098,7 @@ namespace Server.Engines.Craft
}
else
{
m_From.EndAction(typeof(CraftSystem));
m_From.EndAction<CraftSystem>();
int badCraft = m_CraftSystem.CanCraft(m_From, m_Tool, m_CraftItem.ItemType);

View file

@ -80,18 +80,18 @@ namespace Server.Engines.Craft
}
int phys = 0, fire = 0, cold = 0, pois = 0, nrgy = 0;
int dura = 0, luck = 0, lreq = 0, dinc = 0;
int baseChance = 0;
int dura, luck, lreq, dinc = 0;
int baseChance;
bool physBonus = false;
bool fireBonus = false;
bool coldBonus = false;
bool nrgyBonus = false;
bool poisBonus = false;
bool duraBonus = false;
bool luckBonus = false;
bool lreqBonus = false;
bool dincBonus = false;
bool fireBonus;
bool coldBonus;
bool nrgyBonus;
bool poisBonus;
bool duraBonus;
bool luckBonus;
bool lreqBonus;
bool dincBonus;
if (item is BaseWeapon weapon)
{

View file

@ -17,7 +17,7 @@ namespace Server.Engines.Craft
public QueryMakersMarkGump(int quality, Mobile from, CraftItem craftItem, CraftSystem craftSystem, Type typeRes,
BaseTool tool) : base(100, 200)
{
from.CloseGump(typeof(QueryMakersMarkGump));
from.CloseGump<QueryMakersMarkGump>();
m_Quality = quality;
m_From = from;

View file

@ -56,7 +56,7 @@ namespace Server.Engines.Craft
private static void LearnAllRecipes_OnCommand(CommandEventArgs e)
{
Mobile m = e.Mobile;
m.SendMessage("Target a player to teach them all of the recipies.");
m.SendMessage("Target a player to teach them all of the recipes.");
m.BeginTarget(-1, false, TargetFlags.None, delegate(Mobile from, object targeted)
{
@ -65,7 +65,7 @@ namespace Server.Engines.Craft
foreach (KeyValuePair<int, Recipe> kvp in Recipes)
mobile.AcquireRecipe(kvp.Key);
m.SendMessage("You teach them all of the recipies.");
m.SendMessage("You teach them all of the recipes.");
}
else
{
@ -75,11 +75,11 @@ namespace Server.Engines.Craft
}
[Usage("ForgetAllRecipes")]
[Description("Makes a player forget all the recipies they've learned.")]
[Description("Makes a player forget all the recipes they've learned.")]
private static void ForgetAllRecipes_OnCommand(CommandEventArgs e)
{
Mobile m = e.Mobile;
m.SendMessage("Target a player to have them forget all of the recipies they've learned.");
m.SendMessage("Target a player to have them forget all of the recipes they've learned.");
m.BeginTarget(-1, false, TargetFlags.None, delegate(Mobile from, object targeted)
{
@ -87,7 +87,7 @@ namespace Server.Engines.Craft
{
mobile.ResetRecipes();
m.SendMessage("They forget all their recipies.");
m.SendMessage("They forget all their recipes.");
}
else
{

View file

@ -37,11 +37,6 @@ namespace Server.Engines.Craft
m_Deed = deed;
}
private static void EndGolemRepair(object state)
{
((Mobile)state).EndAction(typeof(Golem));
}
private int GetWeakenChance(Mobile mob, SkillName skill, int curHits, int maxHits)
{
// 40% - (1% per hp lost) - (1% per 10 craft skill)
@ -229,14 +224,14 @@ namespace Server.Engines.Craft
}
else
{
double skillValue = usingDeed ? m_Deed.SkillLevel : from.Skills[SkillName.Tinkering].Value;
double skillValue = usingDeed ? m_Deed.SkillLevel : from.Skills.Tinkering.Value;
if (skillValue < 60.0)
{
number =
1044153; // You don't have the required skills to attempt this item. //TODO: How does OSI handle this with deeds with golems?
}
else if (!from.CanBeginAction(typeof(Golem)))
else if (!from.CanBeginAction<Golem>())
{
number = 501789; // You must wait before trying again.
}
@ -263,9 +258,8 @@ namespace Server.Engines.Craft
number = 1044279; // You repair the item.
toDelete = true;
from.BeginAction(typeof(Golem));
Timer.DelayCall(TimeSpan.FromSeconds(12.0), new TimerStateCallback(EndGolemRepair),
from);
from.BeginAction<Golem>();
Timer.DelayCall(TimeSpan.FromSeconds(12.0), from.EndAction<Golem>);
}
else
{

View file

@ -95,7 +95,7 @@ namespace Server.Engines.Craft
break;
}
if (difficulty > from.Skills[SkillName.Mining].Value)
if (difficulty > from.Skills.Mining.Value)
return SmeltResult.NoSkill;
Type resourceType = info.ResourceTypes[0];
@ -130,9 +130,7 @@ namespace Server.Engines.Craft
{
if (num == 1044267)
{
bool anvil, forge;
DefBlacksmithy.CheckAnvilAndForge(from, 2, out anvil, out forge);
DefBlacksmithy.CheckAnvilAndForge(from, 2, out bool anvil, out bool forge);
if (!anvil)
num = 1044266; // You must be near an anvil

View file

@ -84,7 +84,7 @@ namespace Server.Engines.Craft
public override void InitCraftList()
{
int index = -1;
int index;
// Refresh Potion
index = AddCraft(typeof(RefreshPotion), 1044530, 1044538, -25, 25.0, typeof(BlackPearl), 1044353, 1, 1044361);

View file

@ -118,8 +118,7 @@ namespace Server.Engines.Craft
if (!BaseTool.CheckAccessible(tool, from))
return 1044263; // The tool must be on your person to use.
bool anvil, forge;
CheckAnvilAndForge(from, 2, out anvil, out forge);
CheckAnvilAndForge(from, 2, out bool anvil, out bool forge);
if (anvil && forge)
return 0;

View file

@ -76,7 +76,7 @@ namespace Server.Engines.Craft
public override void InitCraftList()
{
int index = -1;
int index;
// Materials
AddCraft(typeof(Kindling), 1044457, 1023553, 0.0, 00.0, typeof(Log), 1044041, 1, 1044351);

View file

@ -71,7 +71,7 @@ namespace Server.Engines.Craft
public override void InitCraftList()
{
int index = -1;
int index;
/* Begin Ingredients */
index = AddCraft(typeof(SackFlour), 1044495, 1024153, 0.0, 100.0, typeof(WheatSheaf), 1044489, 2, 1044490);

View file

@ -41,14 +41,12 @@ namespace Server.Engines.Craft
return 1044038; // You have worn out your tool!
if (!BaseTool.CheckTool(tool, from))
return 1048146; // If you have a tool equipped, you must use that tool.
if (!(from is PlayerMobile mobile && mobile.Glassblowing && mobile.Skills[SkillName.Alchemy].Base >= 100.0))
if (!(from is PlayerMobile mobile && mobile.Glassblowing && mobile.Skills.Alchemy.Base >= 100.0))
return 1044634; // You havent learned glassblowing.
if (!BaseTool.CheckAccessible(tool, from))
return 1044263; // The tool must be on your person to use.
bool anvil, forge;
DefBlacksmithy.CheckAnvilAndForge(from, 2, out anvil, out forge);
DefBlacksmithy.CheckAnvilAndForge(from, 2, out _, out bool forge);
if (forge)
return 0;

View file

@ -43,7 +43,7 @@ namespace Server.Engines.Craft
return 1044038; // You have worn out your tool!
if (!BaseTool.CheckTool(tool, from))
return 1048146; // If you have a tool equipped, you must use that tool.
if (!(from is PlayerMobile mobile && mobile.Masonry && mobile.Skills[SkillName.Carpentry].Base >= 100.0))
if (!(from is PlayerMobile mobile && mobile.Masonry && mobile.Skills.Carpentry.Base >= 100.0))
return 1044633; // You havent learned stonecraft.
if (!BaseTool.CheckAccessible(tool, from))
return 1044263; // The tool must be on your person to use.

View file

@ -95,7 +95,7 @@ namespace Server.Engines.Craft
public override void InitCraftList()
{
int index = -1;
int index;
#region Hats

View file

@ -146,7 +146,7 @@ namespace Server.Engines.Craft
public override void InitCraftList()
{
int index = -1;
int index;
#region Wooden Items
@ -489,9 +489,7 @@ namespace Server.Engines.Craft
protected override void OnTarget(Mobile from, object targeted)
{
int message;
if (m_TrapCraft.Acquire(targeted, out message))
if (m_TrapCraft.Acquire(targeted, out int message))
m_TrapCraft.CraftItem.CompleteCraft(m_TrapCraft.Quality, false, m_TrapCraft.From,
m_TrapCraft.CraftSystem, m_TrapCraft.TypeRes, m_TrapCraft.Tool, m_TrapCraft);
else

View file

@ -205,7 +205,7 @@ namespace Server.Engines.Doom
if (map == null)
return;
BaseTrap trap = null;
BaseTrap trap;
int random = Utility.Random(100);
@ -324,6 +324,7 @@ namespace Server.Engines.Doom
}
catch
{
// ignored
}
}
@ -409,9 +410,7 @@ namespace Server.Engines.Doom
TypeName = reader.ReadString();
Door = reader.ReadItem<BaseDoor>();
;
Addon = reader.ReadItem<BaseAddon>();
;
Sequence = reader.ReadItem<GauntletSpawner>();
State = (GauntletSpawnerState)reader.ReadInt();

View file

@ -521,7 +521,7 @@ namespace Server.Engines.Doom
protected override void OnTick()
{
if (m_Player == null || !(m_Player.Map == Map.Malas))
if (m_Player == null || m_Player.Map != Map.Malas)
{
Stop();
}

View file

@ -128,7 +128,7 @@ namespace Server.Engines.Doom
}
else
{
m.SendLocalizedMessage(1060001); // You throw the switch, but the mechanism cannot be engaged again so soon.
m?.SendLocalizedMessage(1060001); // You throw the switch, but the mechanism cannot be engaged again so soon.
}
}

View file

@ -19,14 +19,12 @@ namespace Server.Ethics.Evil
public override void BeginInvoke(Player from)
{
from.Mobile.BeginTarget(12, true, TargetFlags.None, new TargetStateCallback(Power_OnTarget), from);
from.Mobile.BeginTarget(12, true, TargetFlags.None, Power_OnTarget, from);
from.Mobile.SendMessage("Where do you wish to blight?");
}
private void Power_OnTarget(Mobile fromMobile, object obj, object state)
private void Power_OnTarget(Mobile fromMobile, object obj, Player from)
{
Player from = state as Player;
if (!(obj is IPoint3D p))
return;

View file

@ -18,15 +18,12 @@ namespace Server.Ethics.Evil
public override void BeginInvoke(Player from)
{
from.Mobile.BeginTarget(12, false, TargetFlags.None, new TargetStateCallback(Power_OnTarget), from);
from.Mobile.BeginTarget(12, false, TargetFlags.None, Power_OnTarget, from);
from.Mobile.SendMessage("Which item do you wish to imbue?");
}
private void Power_OnTarget(Mobile fromMobile, object obj, object state)
private void Power_OnTarget(Mobile fromMobile, object obj, Player from)
{
if (!(state is Player from))
return;
if (!(obj is Item item))
{
from.Mobile.LocalOverheadMessage(MessageType.Regular, 0x3B2, false, "You may not imbue that.");

View file

@ -19,15 +19,12 @@ namespace Server.Ethics.Hero
public override void BeginInvoke(Player from)
{
from.Mobile.BeginTarget(12, true, TargetFlags.None, new TargetStateCallback(Power_OnTarget), from);
from.Mobile.BeginTarget(12, true, TargetFlags.None, Power_OnTarget, from);
from.Mobile.SendMessage("Where do you wish to bless?");
}
private void Power_OnTarget(Mobile fromMobile, object obj, object state)
private void Power_OnTarget(Mobile fromMobile, object obj, Player from)
{
if (!(state is Player from))
return;
if (!(obj is IPoint3D p))
return;

View file

@ -18,15 +18,12 @@ namespace Server.Ethics.Hero
public override void BeginInvoke(Player from)
{
from.Mobile.BeginTarget(12, false, TargetFlags.None, new TargetStateCallback(Power_OnTarget), from);
from.Mobile.BeginTarget(12, false, TargetFlags.None, Power_OnTarget, from);
from.Mobile.SendMessage("Which item do you wish to imbue?");
}
private void Power_OnTarget(Mobile fromMobile, object obj, object state)
private void Power_OnTarget(Mobile fromMobile, object obj, Player from)
{
if (!(state is Player from))
return;
if (!(obj is Item item))
{
from.Mobile.LocalOverheadMessage(MessageType.Regular, 0x3B2, false, "You may not imbue that.");

View file

@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Accounting;
using Server.Commands;
@ -677,11 +676,11 @@ namespace Server.Factions
public static void FactionItemReset_OnCommand(CommandEventArgs e)
{
ArrayList pots = new ArrayList();
List<Item> items = new List<Item>();
foreach (Item item in World.Items.Values)
if (item is IFactionItem && !(item is HoodedShroudOfShadows))
pots.Add(item);
items.Add(item);
int[] hues = new int[Factions.Count * 2];
@ -693,9 +692,9 @@ namespace Server.Factions
int count = 0;
for (int i = 0; i < pots.Count; ++i)
for (int i = 0; i < items.Count; ++i)
{
Item item = (Item)pots[i];
Item item = items[i];
IFactionItem fci = (IFactionItem)item;
if (fci.FactionItemState != null || item.LootType != LootType.Blessed)
@ -918,7 +917,7 @@ namespace Server.Factions
if (smallest == null)
return true; // sanity
if (StabilityFactor > 0 && (Members.Count + influx) * 100 / StabilityFactor > smallest.Members.Count)
if ((Members.Count + influx) * 100 / StabilityFactor > smallest.Members.Count)
return false;
return true;
@ -939,7 +938,7 @@ namespace Server.Factions
return;
}
if (killer.GetDistanceToSqrt(victim) > 64)
if (killer?.GetDistanceToSqrt(victim) > 64)
{
sigil.ReturnHome();
killer.SendLocalizedMessage(1042230); // The sigil has gone back to its home location.
@ -947,13 +946,13 @@ namespace Server.Factions
else if (Sigil.ExistsOn(killer))
{
sigil.ReturnHome();
killer.SendLocalizedMessage(
killer?.SendLocalizedMessage(
1010258); // The sigil has gone back to its home location because you already have a sigil.
}
else if (!killerPack.TryDropItem(killer, sigil, false))
{
sigil.ReturnHome();
killer.SendLocalizedMessage(1010259); // The sigil has gone home because your backpack is full.
killer?.SendLocalizedMessage(1010259); // The sigil has gone home because your backpack is full.
}
});
@ -998,7 +997,7 @@ namespace Server.Factions
#region Dueling
if (victim.Region.IsPartOf(typeof(SafeZone)))
if (victim.Region.IsPartOf<SafeZone>())
return;
#endregion
@ -1231,12 +1230,7 @@ namespace Server.Factions
}
}
context.m_Timer = Timer.DelayCall(SkillLossPeriod, new TimerStateCallback(ClearSkillLoss_Callback), mob);
}
private static void ClearSkillLoss_Callback(object state)
{
ClearSkillLoss((Mobile)state);
context.m_Timer = Timer.DelayCall(SkillLossPeriod, () => ClearSkillLoss(mob));
}
public static bool ClearSkillLoss(Mobile mob)

View file

@ -11,10 +11,8 @@ namespace Server.Factions
EventSink.Speech += EventSink_Speech;
}
private static void ShowScore_Sandbox(object state)
private static void ShowScore_Sandbox(PlayerState pl)
{
PlayerState pl = (PlayerState)state;
pl?.Mobile.PublicOverheadMessage(MessageType.Regular, pl.Mobile.SpeechHue, true,
pl.KillPoints.ToString("N0")); // NOTE: Added 'N0'
}
@ -141,16 +139,13 @@ namespace Server.Factions
PlayerState pl = PlayerState.Find(from);
if (pl != null)
Timer.DelayCall(TimeSpan.Zero, new TimerStateCallback(ShowScore_Sandbox), pl);
Timer.DelayCall(TimeSpan.Zero, ShowScore_Sandbox, pl);
break;
}
case 0x0178: // i honor your leadership
{
Faction faction = Faction.Find(from);
faction?.BeginHonorLeadership(from);
Faction.Find(from)?.BeginHonorLeadership(from);
break;
}
}

View file

@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Commands;
using Server.Targeting;
@ -7,7 +6,7 @@ using Server.Targeting;
namespace Server.Factions
{
[CustomEnum(new[] { "Britain", "Magincia", "Minoc", "Moonglow", "Skara Brae", "Trinsic", "Vesper", "Yew" })]
public abstract class Town : IComparable
public abstract class Town : IComparable, IComparable<Town>
{
public const int SilverCaptureBonus = 10000;
@ -133,6 +132,11 @@ namespace Server.Factions
public static List<Town> Towns => Reflector.Towns;
public int CompareTo(Town other)
{
return Definition.Sort - other.Definition.Sort;
}
public int CompareTo(object obj)
{
return Definition.Sort - ((Town)obj).Definition.Sort;
@ -225,12 +229,12 @@ namespace Server.Factions
if (Silver + flow < 0)
{
ArrayList toDelete = BuildFinanceList();
List<Mobile> toDelete = BuildFinanceList();
while (Silver + flow < 0 && toDelete.Count > 0)
{
int index = Utility.Random(toDelete.Count);
Mobile mob = (Mobile)toDelete[index];
Mobile mob = toDelete[index];
mob.Delete();
@ -242,19 +246,15 @@ namespace Server.Factions
Silver += flow;
}
public ArrayList BuildFinanceList()
public List<Mobile> BuildFinanceList()
{
ArrayList list = new ArrayList();
List<Mobile> list = new List<Mobile>();
List<VendorList> vendorLists = VendorLists;
for (int i = 0; i < VendorLists.Count; ++i)
list.AddRange(VendorLists[i].Vendors);
for (int i = 0; i < vendorLists.Count; ++i)
list.AddRange(vendorLists[i].Vendors);
List<GuardList> guardLists = GuardLists;
for (int i = 0; i < guardLists.Count; ++i)
list.AddRange(guardLists[i].Guards);
for (int i = 0; i < GuardLists.Count; ++i)
list.AddRange(GuardLists[i].Guards);
return list;
}

View file

@ -32,7 +32,7 @@ namespace Server.Factions
public static bool Exists(Mobile mob)
{
return mob.FindGump(typeof(FactionGump)) != null;
return mob.HasGump<FactionGump>();
}
public void AddHtmlText(int x, int y, int width, int height, TextDefinition text, bool back, bool scroll)

View file

@ -14,7 +14,6 @@ namespace Server.Factions
private Item m_Item;
private Mobile m_Mobile;
private object m_Notice;
private int m_Quality;
private BaseTool m_Tool;
public FactionImbueGump(int quality, Item item, Mobile from, CraftSystem craftSystem, BaseTool tool, object notice,
@ -26,7 +25,6 @@ namespace Server.Factions
m_CraftSystem = craftSystem;
m_Tool = tool;
m_Notice = notice;
m_Quality = quality;
m_Definition = def;
AddPage(0);
@ -38,7 +36,7 @@ namespace Server.Factions
AddHtmlLocalized(20, 60, 170, 25, 1018302, false, false); // Item quality:
AddHtmlLocalized(175, 60, 100, 25, 1018305 - m_Quality, false, false); // Exceptional, Average, Low
AddHtmlLocalized(175, 60, 100, 25, 1018305 - quality, false, false); // Exceptional, Average, Low
AddHtmlLocalized(20, 80, 170, 25, 1011572, false, false); // Item Cost :
AddLabel(175, 80, 0x34, def.SilverCost.ToString("N0")); // NOTE: Added 'N0'

View file

@ -267,9 +267,7 @@ namespace Server.Factions
public override void OnResponse(NetState sender, RelayInfo info)
{
int type, index;
if (!FromButtonID(info.ButtonID, out type, out index))
if (!FromButtonID(info.ButtonID, out int type, out int index))
return;
switch (type)

View file

@ -190,9 +190,7 @@ namespace Server.Factions
return;
}
int type, index;
if (!FromButtonID(info.ButtonID, out type, out index))
if (!FromButtonID(info.ButtonID, out int type, out int index))
return;
switch (type)
@ -259,8 +257,6 @@ namespace Server.Factions
{
VendorList vendorList = vendorLists[index];
Town town = Town.FromRegion(m_From.Region);
if (Town.FromRegion(m_From.Region) != m_Town)
{
m_From.SendLocalizedMessage(1010305); // You must be in your controlled city to buy Items

View file

@ -153,7 +153,6 @@ namespace Server.Factions
if (index >= 0 && index < m_Town.GuardLists.Count)
{
GuardList guardList = m_Town.GuardLists[index];
Town town = Town.FromRegion(m_From.Region);
if (Town.FromRegion(m_From.Region) != m_Town)
{

View file

@ -19,7 +19,7 @@ namespace Server
public override bool Use(Mobile from)
{
if (from.BeginAction(typeof(ClarityPotion)))
if (from.BeginAction<ClarityPotion>())
{
int amount = Utility.Dice(3, 3, 3);
int time = Utility.RandomMinMax(5, 30);
@ -42,7 +42,7 @@ namespace Server
from.PlaySound(0x1EE);
from.AddStatMod(new StatMod(StatType.Int, "clarity-potion", amount, TimeSpan.FromMinutes(time)));
Timer.DelayCall(TimeSpan.FromMinutes(time), delegate { from.EndAction(typeof(ClarityPotion)); });
Timer.DelayCall(TimeSpan.FromMinutes(time), delegate { from.EndAction<ClarityPotion>(); });
return true;
}

View file

@ -72,6 +72,7 @@ namespace Server
}
catch
{
// ignored
}
}

View file

@ -34,13 +34,13 @@ namespace Server
Point3D origin = new Point3D(pt);
Map facet = from.Map;
if (facet != null && facet.CanFit(pt.X, pt.Y, pt.Z, 16, false, false, true))
if (facet != null && facet.CanFit(pt.X, pt.Y, pt.Z, 16, false, false))
{
Movable = false;
Effects.SendMovingEffect(
from, new Entity(Serial.Zero, origin, facet),
ItemID & 0x3FFF, 7, 0, false, false, Hue - 1, 0
ItemID & 0x3FFF, 7, 0, false, false, Hue - 1
);
Timer.DelayCall(TimeSpan.FromSeconds(0.5), delegate
@ -80,11 +80,11 @@ namespace Server
from.DoHarmful(mob);
SpellHelper.Damage(TimeSpan.FromSeconds(0.50), mob, from, damage / 3, 0, 0, 0, 0,
SpellHelper.Damage(TimeSpan.FromSeconds(0.50), mob, from, damage / 3.0, 0, 0, 0, 0,
100);
SpellHelper.Damage(TimeSpan.FromSeconds(0.70), mob, from, damage / 3, 0, 0, 0, 0,
SpellHelper.Damage(TimeSpan.FromSeconds(0.70), mob, from, damage / 3.0, 0, 0, 0, 0,
100);
SpellHelper.Damage(TimeSpan.FromSeconds(1.00), mob, from, damage / 3, 0, 0, 0, 0,
SpellHelper.Damage(TimeSpan.FromSeconds(1.00), mob, from, damage / 3.0, 0, 0, 0, 0,
100);
Timer.DelayCall(TimeSpan.FromSeconds(0.50), delegate { mob.PlaySound(0x1FB); });

View file

@ -124,7 +124,7 @@ namespace Server.Factions
{
case AllowedPlacing.FactionStronghold:
{
StrongholdRegion region = (StrongholdRegion)Region.Find(p, m).GetRegion(typeof(StrongholdRegion));
StrongholdRegion region = Region.Find(p, m).GetRegion<StrongholdRegion>();
if (region != null && region.Faction == Faction)
return 0;
@ -160,7 +160,7 @@ namespace Server.Factions
if (!CheckDecay() && CheckRange(m.Location, oldLocation, 6))
if (Faction.Find(m) != null &&
(m.Skills[SkillName.DetectHidden].Value - 80.0) / 20.0 > Utility.RandomDouble())
(m.Skills.DetectHidden.Value - 80.0) / 20.0 > Utility.RandomDouble())
PrivateOverheadLocalizedMessage(m, 1010154, MessageHue, "", ""); // [Faction Trap]
}

View file

@ -418,7 +418,7 @@ namespace Server.Factions
public virtual void GenerateBody(bool isFemale, bool randomHair)
{
Hue = Utility.RandomSkinHue();
Hue = Race.Human.RandomSkinHue();
if (isFemale)
{
@ -472,7 +472,7 @@ namespace Server.Factions
m_Item = item;
}
public Mobile Rider
Mobile IMount.Rider
{
get => m_Item.Rider;
set { }

View file

@ -15,6 +15,7 @@ using Server.Targeting;
namespace Server.Factions
{
[Flags]
public enum GuardAI
{
Bless = 0x01, // heal, cure, +stats
@ -588,7 +589,7 @@ namespace Server.Factions
m_Guard.Mana >= 11)
{
spell = new RecallSpell(m_Guard, null,
new RunebookEntry(m_Guard.Home, m_Guard.Map, "Guard's Home", null), null);
new RunebookEntry(m_Guard.Home, m_Guard.Map, "Guard's Home", null));
}
else if (IsAllowed(GuardAI.Bless))
{
@ -598,7 +599,7 @@ namespace Server.Factions
(m_Guard.Mana < 11 || m_Guard.NextCombatTime - Core.TickCount > 2000))
spell = new HealSpell(m_Guard, null);
}
else if (m_Guard.CanBeginAction(typeof(BaseHealPotion)))
else if (m_Guard.CanBeginAction<BaseHealPotion>())
{
UseItemByType(typeof(BaseHealPotion));
}

View file

@ -96,11 +96,7 @@ namespace Server.Engines.Harvest
if (!CheckHarvest(from, tool))
return;
int tileID;
Map map;
Point3D loc;
if (!GetHarvestDetails(from, tool, toHarvest, out tileID, out map, out loc))
if (!GetHarvestDetails(from, tool, toHarvest, out int tileID, out Map map, out Point3D loc))
{
OnBadHarvestTarget(from, tool, toHarvest);
return;
@ -340,11 +336,7 @@ namespace Server.Engines.Harvest
return false;
}
int tileID;
Map map;
Point3D loc;
if (!GetHarvestDetails(from, tool, toHarvest, out tileID, out map, out loc))
if (!GetHarvestDetails(from, tool, toHarvest, out int tileID, out Map map, out Point3D loc))
{
from.EndAction(locked);
OnBadHarvestTarget(from, tool, toHarvest);
@ -417,11 +409,7 @@ namespace Server.Engines.Harvest
if (!CheckHarvest(from, tool))
return;
int tileID;
Map map;
Point3D loc;
if (!GetHarvestDetails(from, tool, toHarvest, out tileID, out map, out loc))
if (!GetHarvestDetails(from, tool, toHarvest, out int tileID, out Map map, out Point3D loc))
{
OnBadHarvestTarget(from, tool, toHarvest);
return;

View file

@ -31,10 +31,12 @@ namespace Server.Engines.Harvest
if (from is PlayerMobile player)
{
QuestSystem qs = player.Quest;
if (!(qs is WitchApprenticeQuest))
return;
if (qs is WitchApprenticeQuest &&
qs.FindObjective(typeof(FindIngredientObjective)) is FindIngredientObjective obj &&
!obj.Completed && obj.Ingredient == Ingredient.Bones)
FindIngredientObjective obj = qs.FindObjective<FindIngredientObjective>();
if (obj?.Completed == false && obj.Ingredient == Ingredient.Bones)
{
player.SendLocalizedMessage(
1055037); // You finish your grim work, finding some of the specific bones listed in the Hag's recipe.

View file

@ -137,9 +137,9 @@ namespace Server.Engines.Harvest
if (qs is CollectorQuest)
{
QuestObjective obj = qs.FindObjective(typeof(FishPearlsObjective));
QuestObjective obj = qs.FindObjective<FishPearlsObjective>();
if (obj != null && !obj.Completed)
if (obj?.Completed == false)
{
if (Utility.RandomDouble() < 0.5)
{
@ -167,8 +167,8 @@ namespace Server.Engines.Harvest
{
bool deepWater = SpecialFishingNet.FullValidation(map, loc.X, loc.Y);
double skillBase = from.Skills[SkillName.Fishing].Base;
double skillValue = from.Skills[SkillName.Fishing].Value;
double skillBase = from.Skills.Fishing.Base;
double skillValue = from.Skills.Fishing.Value;
for (int i = 0; i < m_MutateTable.Length; ++i)
{
@ -468,11 +468,7 @@ namespace Server.Engines.Harvest
{
base.OnHarvestStarted(from, tool, def, toHarvest);
int tileID;
Map map;
Point3D loc;
if (GetHarvestDetails(from, tool, toHarvest, out tileID, out map, out loc))
if (GetHarvestDetails(from, tool, toHarvest, out _, out Map map, out Point3D loc))
Timer.DelayCall(TimeSpan.FromSeconds(1.5),
delegate
{

View file

@ -209,7 +209,7 @@ namespace Server.Engines.Harvest
if (def == OreAndStone)
{
if (from is PlayerMobile pm && pm.StoneMining && pm.ToggleMiningStone &&
from.Skills[SkillName.Mining].Base >= 100.0 && 0.1 > Utility.RandomDouble())
from.Skills.Mining.Base >= 100.0 && 0.1 > Utility.RandomDouble())
return resource.Types[1];
return resource.Types[0];
@ -251,7 +251,7 @@ namespace Server.Engines.Harvest
if (!base.CheckHarvest(from, tool, def, toHarvest))
return false;
if (def == Sand && !(from is PlayerMobile mobile && mobile.Skills[SkillName.Mining].Base >= 100.0 &&
if (def == Sand && !(from is PlayerMobile mobile && mobile.Skills.Mining.Base >= 100.0 &&
mobile.SandMining))
{
OnBadHarvestTarget(from, tool, toHarvest);

View file

@ -54,7 +54,7 @@ namespace Server.Engines.Help
{
public HelpGump(Mobile from) : base(0, 0)
{
from.CloseGump(typeof(HelpGump));
from.CloseGump<HelpGump>();
bool isYoung = IsYoung(from);
@ -252,11 +252,11 @@ namespace Server.Engines.Help
{
BaseHouse house = BaseHouse.FindHouseAt(from);
if (house != null && house.IsAosRules && !from.Region.IsPartOf(typeof(SafeZone))) // Dueling
if (house != null && house.IsAosRules && !from.Region.IsPartOf<SafeZone>()) // Dueling
{
from.Location = house.BanLocation;
}
else if (from.Region.IsPartOf(typeof(Jail)))
else if (from.Region.IsPartOf<Jail>())
{
from.SendLocalizedMessage(1114345, "", 0x35); // You'll need a better jailbreak plan than that!
}
@ -315,7 +315,7 @@ namespace Server.Engines.Help
{
if (IsYoung(from))
{
if (from.Region.IsPartOf(typeof(Jail)))
if (from.Region.IsPartOf<Jail>())
from.SendLocalizedMessage(1114345, "", 0x35); // You'll need a better jailbreak plan than that!
else if (from.Region.IsPartOf("Haven Island"))
from.SendLocalizedMessage(1041529); // You're already in Haven

View file

@ -13,7 +13,7 @@ namespace Server.Engines.Help
m_From = from;
m_Type = type;
from.CloseGump(typeof(PagePromptGump));
from.CloseGump<PagePromptGump>();
AddBackground(50, 50, 540, 350, 2600);

View file

@ -146,10 +146,10 @@ namespace Server.Engines.Help
public class PageQueue
{
private static Hashtable m_KeyedByHandler = new Hashtable();
private static Hashtable m_KeyedBySender = new Hashtable();
private static Dictionary<Mobile, PageEntry> m_KeyedByHandler = new Dictionary<Mobile, PageEntry>();
private static Dictionary<Mobile, PageEntry> m_KeyedBySender = new Dictionary<Mobile, PageEntry>();
public static ArrayList List{ get; } = new ArrayList();
public static List<PageEntry> List{ get; } = new List<PageEntry>();
public static void Initialize()
{
@ -326,4 +326,4 @@ namespace Server.Engines.Help
Email.AsyncSend(mail);
}
}
}
}

View file

@ -1,5 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using Server.Gumps;
using Server.Network;
@ -54,11 +54,11 @@ namespace Server.Engines.Help
Add(new GumpLabel(180, 12, 2100, "Page Queue"));
ArrayList list = PageQueue.List;
for (int i = 0; i < list.Count;)
List<PageEntry> list = PageQueue.List;
for (int i = 0;i < list.Count;)
{
PageEntry e = (PageEntry)list[i];
PageEntry e = list[i];
if (e.Sender.Deleted || e.Sender.NetState == null)
{
@ -66,42 +66,39 @@ namespace Server.Engines.Help
PageQueue.Remove(e);
}
else
{
++i;
}
}
m_List = (PageEntry[])list.ToArray(typeof(PageEntry));
m_List = list.ToArray();
if (m_List.Length > 0)
{
Add(new GumpPage(1));
for (int i = 0; i < m_List.Length; ++i)
{
PageEntry e = m_List[i];
if (i >= 5 && i % 5 == 0)
{
Add(new GumpButton(368, 12, 0xFA5, 0xFA7, 0, GumpButtonType.Page, i / 5 + 1));
Add(new GumpLabel(298, 12, 2100, "Next Page"));
Add(new GumpPage(i / 5 + 1));
Add(new GumpButton(12, 12, 0xFAE, 0xFB0, 0, GumpButtonType.Page, i / 5));
Add(new GumpLabel(48, 12, 2100, "Previous Page"));
}
string typeString = PageQueue.GetPageTypeName(e.Type);
string html =
$"[{typeString}] {e.Message} <basefont color=#{(e.Handler == null ? 0xFF0000 : 0xFF):X6}>[<u>{(e.Handler == null ? "Unhandled" : "Handling")}</u>]</basefont>";
Add(new GumpHtml(12, 44 + i % 5 * 80, 350, 70, html, true, true));
Add(new GumpButton(370, 44 + i % 5 * 80 + 24, 0xFA5, 0xFA7, i + 1, GumpButtonType.Reply, 0));
}
}
else
if (m_List.Length <= 0)
{
Add(new GumpLabel(12, 44, 2100, "The page queue is empty."));
return;
}
Add(new GumpPage(1));
for (int i = 0; i < m_List.Length; ++i)
{
PageEntry e = m_List[i];
if (i >= 5 && i % 5 == 0)
{
Add(new GumpButton(368, 12, 0xFA5, 0xFA7, 0, GumpButtonType.Page, i / 5 + 1));
Add(new GumpLabel(298, 12, 2100, "Next Page"));
Add(new GumpPage(i / 5 + 1));
Add(new GumpButton(12, 12, 0xFAE, 0xFB0, 0, GumpButtonType.Page, i / 5));
Add(new GumpLabel(48, 12, 2100, "Previous Page"));
}
string typeString = PageQueue.GetPageTypeName(e.Type);
string html =
$"[{typeString}] {e.Message} <basefont color=#{(e.Handler == null ? 0xFF0000 : 0xFF):X6}>[<u>{(e.Handler == null ? "Unhandled" : "Handling")}</u>]</basefont>";
Add(new GumpHtml(12, 44 + i % 5 * 80, 350, 70, html, true, true));
Add(new GumpButton(370, 44 + i % 5 * 80 + 24, 0xFA5, 0xFA7, i + 1, GumpButtonType.Reply, 0));
}
}
@ -126,8 +123,6 @@ namespace Server.Engines.Help
public class PredefinedResponse
{
private static ArrayList m_List;
public PredefinedResponse(string title, string message)
{
Title = title;
@ -138,25 +133,13 @@ namespace Server.Engines.Help
public string Message{ get; set; }
public static ArrayList List
{
get
{
if (m_List == null)
m_List = Load();
return m_List;
}
}
public static List<PredefinedResponse> List{ get; private set; } = Load();
public static PredefinedResponse Add(string title, string message)
{
if (m_List == null)
m_List = Load();
PredefinedResponse resp = new PredefinedResponse(title, message);
m_List.Add(resp);
List.Add(resp);
Save();
return resp;
@ -164,8 +147,8 @@ namespace Server.Engines.Help
public static void Save()
{
if (m_List == null)
m_List = Load();
if (List == null)
List = Load();
try
{
@ -173,9 +156,9 @@ namespace Server.Engines.Help
using (StreamWriter op = new StreamWriter(path))
{
for (int i = 0; i < m_List.Count; ++i)
for (int i = 0; i < List.Count; ++i)
{
PredefinedResponse resp = (PredefinedResponse)m_List[i];
PredefinedResponse resp = List[i];
op.WriteLine("{0}\t{1}", resp.Title, resp.Message);
}
@ -187,41 +170,37 @@ namespace Server.Engines.Help
}
}
public static ArrayList Load()
public static List<PredefinedResponse> Load()
{
ArrayList list = new ArrayList();
string path = Path.Combine(Core.BaseDirectory, "Data/pageresponse.cfg");
if (File.Exists(path))
try
if (!File.Exists(path))
return new List<PredefinedResponse>();
List<PredefinedResponse> list = new List<PredefinedResponse>();
try
{
using (StreamReader ip = new StreamReader(path))
{
using (StreamReader ip = new StreamReader(path))
string line;
while ((line = ip.ReadLine()?.Trim()) != null)
{
string line;
if (line.Length == 0 || line.StartsWith("#"))
continue;
while ((line = ip.ReadLine()) != null)
try
{
line = line.Trim();
string[] split = line.Split('\t');
if (line.Length == 0 || line.StartsWith("#"))
continue;
string[] split = line.Split('\t');
if (split.Length == 2)
list.Add(new PredefinedResponse(split[0], split[1]));
}
catch
{
}
if (split.Length == 2)
list.Add(new PredefinedResponse(split[0], split[1]));
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
return list;
}
@ -239,7 +218,7 @@ namespace Server.Engines.Help
m_From = from;
m_Response = response;
from.CloseGump(typeof(PredefGump));
from.CloseGump<PredefGump>();
bool canEdit = from.AccessLevel >= AccessLevel.GameMaster;
@ -252,7 +231,7 @@ namespace Server.Engines.Help
AddHtml(10, 10, 390, 20, Color(Center("Predefined Responses"), LabelColor32), false, false);
ArrayList list = PredefinedResponse.List;
List<PredefinedResponse> list = PredefinedResponse.List;
AddPage(1);
@ -269,7 +248,7 @@ namespace Server.Engines.Help
AddLabel(48, 10, 2100, "Previous Page");
}
PredefinedResponse resp = (PredefinedResponse)list[i];
PredefinedResponse resp = list[i];
string html = $"<u>{resp.Title}</u><br>{resp.Message}";
@ -357,7 +336,7 @@ namespace Server.Engines.Help
{
PredefinedResponse resp = new PredefinedResponse("", "");
ArrayList list = PredefinedResponse.List;
List<PredefinedResponse> list = PredefinedResponse.List;
list.Add(resp);
m_From.SendGump(new PredefGump(m_From, resp));
@ -369,11 +348,11 @@ namespace Server.Engines.Help
int type = index % 3;
index /= 3;
ArrayList list = PredefinedResponse.List;
List<PredefinedResponse> list = PredefinedResponse.List;
if (index >= 0 && index < list.Count)
{
PredefinedResponse resp = (PredefinedResponse)list[index];
PredefinedResponse resp = list[index];
switch (type)
{
@ -414,7 +393,7 @@ namespace Server.Engines.Help
}
else
{
ArrayList list = PredefinedResponse.List;
List<PredefinedResponse> list = PredefinedResponse.List;
switch (info.ButtonID)
{
@ -473,117 +452,110 @@ namespace Server.Engines.Help
public PageEntryGump(Mobile m, PageEntry entry) : base(30, 30)
{
try
m_Mobile = m;
m_Entry = entry;
int buttons = 0;
int bottom = 356;
AddPage(0);
AddImageTiled(0, 0, 410, 456, 0xA40);
AddAlphaRegion(1, 1, 408, 454);
AddPage(1);
AddLabel(18, 18, 2100, "Sent:");
AddLabelCropped(128, 18, 264, 20, 2100, entry.Sent.ToString());
AddLabel(18, 38, 2100, "Sender:");
AddLabelCropped(128, 38, 264, 20, 2100,
$"{entry.Sender.RawName} {entry.Sender.Location} [{entry.Sender.Map}]");
AddButton(18, bottom - buttons * 22, 0xFAB, 0xFAD, 8, GumpButtonType.Reply, 0);
AddImageTiled(52, bottom - buttons * 22 + 1, 340, 80, 0xA40 /*0xBBC*/ /*0x2458*/);
AddImageTiled(53, bottom - buttons * 22 + 2, 338, 78, 0xBBC /*0x2426*/);
AddTextEntry(55, bottom - buttons++ * 22 + 2, 336, 78, 0x480, 0, "");
AddButton(18, bottom - buttons * 22, 0xFA5, 0xFA7, 0, GumpButtonType.Page, 2);
AddLabel(52, bottom - buttons++ * 22, 2100, "Predefined Response");
if (entry.Sender != m)
{
m_Mobile = m;
m_Entry = entry;
AddButton(18, bottom - buttons * 22, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0);
AddLabel(52, bottom - buttons++ * 22, 2100, "Go to Sender");
}
int buttons = 0;
AddLabel(18, 58, 2100, "Handler:");
int bottom = 356;
if (entry.Handler == null)
{
AddLabelCropped(128, 58, 264, 20, 2100, "Unhandled");
AddPage(0);
AddButton(18, bottom - buttons * 22, 0xFB1, 0xFB3, 5, GumpButtonType.Reply, 0);
AddLabel(52, bottom - buttons++ * 22, 2100, "Delete Page");
AddImageTiled(0, 0, 410, 456, 0xA40);
AddAlphaRegion(1, 1, 408, 454);
AddButton(18, bottom - buttons * 22, 0xFB7, 0xFB9, 4, GumpButtonType.Reply, 0);
AddLabel(52, bottom - buttons++ * 22, 2100, "Handle Page");
}
else
{
AddLabelCropped(128, 58, 264, 20, m_AccessLevelHues[(int)entry.Handler.AccessLevel], entry.Handler.Name);
AddPage(1);
AddLabel(18, 18, 2100, "Sent:");
AddLabelCropped(128, 18, 264, 20, 2100, entry.Sent.ToString());
AddLabel(18, 38, 2100, "Sender:");
AddLabelCropped(128, 38, 264, 20, 2100,
$"{entry.Sender.RawName} {entry.Sender.Location} [{entry.Sender.Map}]");
AddButton(18, bottom - buttons * 22, 0xFAB, 0xFAD, 8, GumpButtonType.Reply, 0);
AddImageTiled(52, bottom - buttons * 22 + 1, 340, 80, 0xA40 /*0xBBC*/ /*0x2458*/);
AddImageTiled(53, bottom - buttons * 22 + 2, 338, 78, 0xBBC /*0x2426*/);
AddTextEntry(55, bottom - buttons++ * 22 + 2, 336, 78, 0x480, 0, "");
AddButton(18, bottom - buttons * 22, 0xFA5, 0xFA7, 0, GumpButtonType.Page, 2);
AddLabel(52, bottom - buttons++ * 22, 2100, "Predefined Response");
if (entry.Sender != m)
if (entry.Handler != m)
{
AddButton(18, bottom - buttons * 22, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0);
AddLabel(52, bottom - buttons++ * 22, 2100, "Go to Sender");
}
AddLabel(18, 58, 2100, "Handler:");
if (entry.Handler == null)
{
AddLabelCropped(128, 58, 264, 20, 2100, "Unhandled");
AddButton(18, bottom - buttons * 22, 0xFB1, 0xFB3, 5, GumpButtonType.Reply, 0);
AddLabel(52, bottom - buttons++ * 22, 2100, "Delete Page");
AddButton(18, bottom - buttons * 22, 0xFB7, 0xFB9, 4, GumpButtonType.Reply, 0);
AddLabel(52, bottom - buttons++ * 22, 2100, "Handle Page");
AddButton(18, bottom - buttons * 22, 0xFA5, 0xFA7, 2, GumpButtonType.Reply, 0);
AddLabel(52, bottom - buttons++ * 22, 2100, "Go to Handler");
}
else
{
AddLabelCropped(128, 58, 264, 20, m_AccessLevelHues[(int)entry.Handler.AccessLevel], entry.Handler.Name);
AddButton(18, bottom - buttons * 22, 0xFA2, 0xFA4, 6, GumpButtonType.Reply, 0);
AddLabel(52, bottom - buttons++ * 22, 2100, "Abandon Page");
if (entry.Handler != m)
{
AddButton(18, bottom - buttons * 22, 0xFA5, 0xFA7, 2, GumpButtonType.Reply, 0);
AddLabel(52, bottom - buttons++ * 22, 2100, "Go to Handler");
}
else
{
AddButton(18, bottom - buttons * 22, 0xFA2, 0xFA4, 6, GumpButtonType.Reply, 0);
AddLabel(52, bottom - buttons++ * 22, 2100, "Abandon Page");
AddButton(18, bottom - buttons * 22, 0xFB7, 0xFB9, 7, GumpButtonType.Reply, 0);
AddLabel(52, bottom - buttons++ * 22, 2100, "Page Handled");
}
}
AddLabel(18, 78, 2100, "Page Location:");
AddLabelCropped(128, 78, 264, 20, 2100, $"{entry.PageLocation} [{entry.PageMap}]");
AddButton(18, bottom - buttons * 22, 0xFA5, 0xFA7, 3, GumpButtonType.Reply, 0);
AddLabel(52, bottom - buttons++ * 22, 2100, "Go to Page Location");
if (entry.SpeechLog != null)
{
AddButton(18, bottom - buttons * 22, 0xFA5, 0xFA7, 10, GumpButtonType.Reply, 0);
AddLabel(52, bottom - buttons++ * 22, 2100, "View Speech Log");
}
AddLabel(18, 98, 2100, "Page Type:");
AddLabelCropped(128, 98, 264, 20, 2100, PageQueue.GetPageTypeName(entry.Type));
AddLabel(18, 118, 2100, "Message:");
AddHtml(128, 118, 250, 100, entry.Message, true, true);
AddPage(2);
ArrayList preresp = PredefinedResponse.List;
AddButton(18, 18, 0xFAE, 0xFB0, 0, GumpButtonType.Page, 1);
AddButton(410 - 18 - 32, 18, 0xFAB, 0xFAC, 9, GumpButtonType.Reply, 0);
if (preresp.Count == 0)
{
AddLabel(52, 18, 2100, "There are no predefined responses.");
}
else
{
AddLabel(52, 18, 2100, "Back");
for (int i = 0; i < preresp.Count; ++i)
{
AddButton(18, 40 + i * 22, 0xFA5, 0xFA7, 100 + i, GumpButtonType.Reply, 0);
AddLabel(52, 40 + i * 22, 2100, ((PredefinedResponse)preresp[i]).Title);
}
AddButton(18, bottom - buttons * 22, 0xFB7, 0xFB9, 7, GumpButtonType.Reply, 0);
AddLabel(52, bottom - buttons++ * 22, 2100, "Page Handled");
}
}
catch (Exception e)
AddLabel(18, 78, 2100, "Page Location:");
AddLabelCropped(128, 78, 264, 20, 2100, $"{entry.PageLocation} [{entry.PageMap}]");
AddButton(18, bottom - buttons * 22, 0xFA5, 0xFA7, 3, GumpButtonType.Reply, 0);
AddLabel(52, bottom - buttons++ * 22, 2100, "Go to Page Location");
if (entry.SpeechLog != null)
{
Console.WriteLine(e);
AddButton(18, bottom - buttons * 22, 0xFA5, 0xFA7, 10, GumpButtonType.Reply, 0);
AddLabel(52, bottom - buttons * 22, 2100, "View Speech Log");
}
AddLabel(18, 98, 2100, "Page Type:");
AddLabelCropped(128, 98, 264, 20, 2100, PageQueue.GetPageTypeName(entry.Type));
AddLabel(18, 118, 2100, "Message:");
AddHtml(128, 118, 250, 100, entry.Message, true, true);
AddPage(2);
List<PredefinedResponse> preresp = PredefinedResponse.List;
AddButton(18, 18, 0xFAE, 0xFB0, 0, GumpButtonType.Page, 1);
AddButton(410 - 18 - 32, 18, 0xFAB, 0xFAC, 9, GumpButtonType.Reply, 0);
if (preresp.Count == 0)
{
AddLabel(52, 18, 2100, "There are no predefined responses.");
}
else
{
AddLabel(52, 18, 2100, "Back");
for (int i = 0; i < preresp.Count; ++i)
{
AddButton(18, 40 + i * 22, 0xFA5, 0xFA7, 100 + i, GumpButtonType.Reply, 0);
AddLabel(52, 40 + i * 22, 2100, preresp[i].Title);
}
}
}
@ -803,8 +775,7 @@ namespace Server.Engines.Help
if (m_Entry.SpeechLog != null)
{
Gump gump = new SpeechLogGump(m_Entry.Sender, m_Entry.SpeechLog);
state.Mobile.SendGump(gump);
state.Mobile.SendGump(new SpeechLogGump(m_Entry.Sender, m_Entry.SpeechLog));
}
break;
@ -812,13 +783,13 @@ namespace Server.Engines.Help
default:
{
int index = info.ButtonID - 100;
ArrayList preresp = PredefinedResponse.List;
List<PredefinedResponse> preresp = PredefinedResponse.List;
if (index >= 0 && index < preresp.Count)
{
m_Entry.AddResponse(state.Mobile, "[PreDef] " + ((PredefinedResponse)preresp[index]).Title);
m_Entry.AddResponse(state.Mobile, "[PreDef] " + preresp[index].Title);
m_Entry.Sender.SendGump(new MessageSentGump(m_Entry.Sender, state.Mobile.Name,
((PredefinedResponse)preresp[index]).Message));
preresp[index].Message));
}
Resend(state);

View file

@ -120,7 +120,7 @@ namespace Server.Menus.Questions
m_MarkUse = markUse;
Closable = false;
Dragable = false;
Draggable = false;
Disposable = false;
AddBackground(0, 0, 270, 320, 2600);
@ -228,7 +228,7 @@ namespace Server.Menus.Questions
if (m_Mobile.NetState == null || DateTime.UtcNow > m_End)
{
m_Mobile.Frozen = false;
m_Mobile.CloseGump(typeof(StuckMenu));
m_Mobile.CloseGump<StuckMenu>();
Stop();
}

View file

@ -43,11 +43,11 @@ namespace Server.Commands
return false;
}
public static Item TryCreateItem(int x, int y, int z, Item srcItem)
public static T TryCreateItem<T>(int x, int y, int z, T srcItem) where T : Item
{
IPooledEnumerable<Item> eable = Map.Felucca.GetItemsInBounds(new Rectangle2D(x, y, 1, 1));
IPooledEnumerable<T> eable = Map.Felucca.GetItemsInBounds<T>(new Rectangle2D(x, y, 1, 1));
foreach (Item item in eable)
foreach (T item in eable)
if (item.GetType() == srcItem.GetType())
{
eable.Free();
@ -191,15 +191,13 @@ namespace Server.Commands
// Generate Central Khaldun entrance
DisappearingRaiseSwitch sw =
TryCreateItem(5459, 1426, 10, new DisappearingRaiseSwitch()) as DisappearingRaiseSwitch;
RaiseSwitch lv = TryCreateItem(5403, 1359, 0, new RaiseSwitch()) as RaiseSwitch;
TryCreateItem(5459, 1426, 10, new DisappearingRaiseSwitch());
RaiseSwitch lv = TryCreateItem(5403, 1359, 0, new RaiseSwitch());
RaisableItem stone =
TryCreateItem(5403, 1360, 0, new RaisableItem(0x788, 10, 0x477, 0x475, TimeSpan.FromMinutes(1.5))) as
RaisableItem;
TryCreateItem(5403, 1360, 0, new RaisableItem(0x788, 10, 0x477, 0x475, TimeSpan.FromMinutes(1.5)));
RaisableItem door =
TryCreateItem(5524, 1367, 0, new RaisableItem(0x1D0, 20, 0x477, 0x475, TimeSpan.FromMinutes(5.0))) as
RaisableItem;
TryCreateItem(5524, 1367, 0, new RaisableItem(0x1D0, 20, 0x477, 0x475, TimeSpan.FromMinutes(5.0)));
sw.RaisableItem = stone;
lv.RaisableItem = door;

View file

@ -259,8 +259,8 @@ namespace Server.Items
solution = new PuzzleChestSolution(PuzzleChestCylinder.None, PuzzleChestCylinder.None,
PuzzleChestCylinder.None, PuzzleChestCylinder.None, PuzzleChestCylinder.None);
from.CloseGump(typeof(PuzzleGump));
from.CloseGump(typeof(StatusGump));
from.CloseGump<PuzzleGump>();
from.CloseGump<StatusGump>();
from.SendGump(new PuzzleGump(from, this, solution, 0));
return true;
@ -277,9 +277,7 @@ namespace Server.Items
public void SubmitSolution(Mobile m, PuzzleChestSolution solution)
{
int correctCylinders, correctColors;
if (solution.Matches(Solution, out correctCylinders, out correctColors))
if (solution.Matches(Solution, out int correctCylinders, out int correctColors))
{
LockPick(m);
@ -553,7 +551,7 @@ namespace Server.Items
m_Chest = chest;
m_Solution = solution;
Dragable = false;
Draggable = false;
AddBackground(25, 0, 500, 410, 0x53);

View file

@ -148,7 +148,7 @@ namespace Server.Engines.MLQuests.Definitions
// The ability is awarded regardless of blacksmithy skill
pm.AcquireRecipe(32);
if (pm.Skills[SkillName.Blacksmith].Base < 45.0) // TODO: Verify threshold
if (pm.Skills.Blacksmith.Base < 45.0) // TODO: Verify threshold
pm.SendLocalizedMessage(
1075005); // You observe carefully but you can't grasp the complexities of smithing a bone handled machete.
else

View file

@ -161,7 +161,7 @@ namespace Server.Engines.MLQuests.Definitions
SetDex(70, 80);
SetInt(80, 90);
Hue = Utility.RandomSkinHue();
Hue = Race.Human.RandomSkinHue();
Female = true;
Body = 401;

View file

@ -284,12 +284,12 @@ namespace Server.Engines.MLQuests.Gumps
*/
public static void CloseOtherGumps(PlayerMobile pm)
{
pm.CloseGump(typeof(InfoNPCGump));
pm.CloseGump(typeof(QuestRewardGump));
pm.CloseGump(typeof(QuestConversationGump));
pm.CloseGump(typeof(QuestReportBackGump));
pm.CloseGump<InfoNPCGump>();
pm.CloseGump<QuestRewardGump>();
pm.CloseGump<QuestConversationGump>();
pm.CloseGump<QuestReportBackGump>();
//pm.CloseGump( typeof( UnknownGump807 ) );
pm.CloseGump(typeof(QuestCancelConfirmGump));
pm.CloseGump<QuestCancelConfirmGump>();
}
}
}

View file

@ -26,7 +26,7 @@ namespace Server.Engines.MLQuests.Gumps
if (closeGumps)
{
CloseOtherGumps(pm);
pm.CloseGump(typeof(QuestLogDetailedGump));
pm.CloseGump<QuestLogDetailedGump>();
}
SetTitle(quest.Title);

Some files were not shown because too many files have changed in this diff Show more