Fixes code according to modern code style. Fixes a few expression bugs.

This commit is contained in:
Kamron Batman 2018-09-15 09:58:51 -07:00
parent 89eea25e5f
commit 970fd563b2
3324 changed files with 441118 additions and 433755 deletions

View file

@ -1,62 +1,62 @@
namespace Server.Engines.BulkOrders
{
public class BOBFilter
{
public bool IsDefault => ( Type == 0 && Quality == 0 && Material == 0 && Quantity == 0 );
public class BOBFilter
{
public BOBFilter()
{
}
public void Clear()
{
Type = 0;
Quality = 0;
Material = 0;
Quantity = 0;
}
public BOBFilter(GenericReader reader)
{
int version = reader.ReadEncodedInt();
public int Type { get; set; }
switch (version)
{
case 1:
{
Type = reader.ReadEncodedInt();
Quality = reader.ReadEncodedInt();
Material = reader.ReadEncodedInt();
Quantity = reader.ReadEncodedInt();
public int Quality { get; set; }
break;
}
}
}
public int Material { get; set; }
public bool IsDefault => Type == 0 && Quality == 0 && Material == 0 && Quantity == 0;
public int Quantity { get; set; }
public int Type{ get; set; }
public BOBFilter()
{
}
public int Quality{ get; set; }
public BOBFilter( GenericReader reader )
{
int version = reader.ReadEncodedInt();
public int Material{ get; set; }
switch ( version )
{
case 1:
{
Type = reader.ReadEncodedInt();
Quality = reader.ReadEncodedInt();
Material = reader.ReadEncodedInt();
Quantity = reader.ReadEncodedInt();
public int Quantity{ get; set; }
break;
}
}
}
public void Clear()
{
Type = 0;
Quality = 0;
Material = 0;
Quantity = 0;
}
public void Serialize( GenericWriter writer )
{
if ( IsDefault )
{
writer.WriteEncodedInt( 0 ); // version
}
else
{
writer.WriteEncodedInt( 1 ); // version
public void Serialize(GenericWriter writer)
{
if (IsDefault)
{
writer.WriteEncodedInt(0); // version
}
else
{
writer.WriteEncodedInt(1); // version
writer.WriteEncodedInt( Type );
writer.WriteEncodedInt( Quality );
writer.WriteEncodedInt( Material );
writer.WriteEncodedInt( Quantity );
}
}
}
writer.WriteEncodedInt(Type);
writer.WriteEncodedInt(Quality);
writer.WriteEncodedInt(Material);
writer.WriteEncodedInt(Quantity);
}
}
}
}

View file

@ -1,206 +1,224 @@
using Server.Gumps;
using Server.Mobiles;
using Server.Network;
namespace Server.Engines.BulkOrders
{
public class BOBFilterGump : Gump
{
private PlayerMobile m_From;
private BulkOrderBook m_Book;
public class BOBFilterGump : Gump
{
private const int LabelColor = 0x7FFF;
private const int LabelColor = 0x7FFF;
private static int[,] m_MaterialFilters =
{
{ 1044067, 1 }, // Blacksmithy
{ 1062226, 3 }, // Iron
{ 1018332, 4 }, // Dull Copper
{ 1018333, 5 }, // Shadow Iron
{ 1018334, 6 }, // Copper
{ 1018335, 7 }, // Bronze
private static int[,] m_MaterialFilters = {
{ 1044067, 1 }, // Blacksmithy
{ 1062226, 3 }, // Iron
{ 1018332, 4 }, // Dull Copper
{ 1018333, 5 }, // Shadow Iron
{ 1018334, 6 }, // Copper
{ 1018335, 7 }, // Bronze
{ 0, 0 }, // --Blank--
{ 1018336, 8 }, // Golden
{ 1018337, 9 }, // Agapite
{ 1018338, 10 }, // Verite
{ 1018339, 11 }, // Valorite
{ 0, 0 }, // --Blank--
{ 0, 0 }, // --Blank--
{ 1018336, 8 }, // Golden
{ 1018337, 9 }, // Agapite
{ 1018338, 10 }, // Verite
{ 1018339, 11 }, // Valorite
{ 0, 0 }, // --Blank--
{ 1044094, 2 }, // Tailoring
{ 1044286, 12 }, // Cloth
{ 1062235, 13 }, // Leather
{ 1062236, 14 }, // Spined
{ 1062237, 15 }, // Horned
{ 1062238, 16 } // Barbed
};
{ 1044094, 2 }, // Tailoring
{ 1044286, 12 }, // Cloth
{ 1062235, 13 }, // Leather
{ 1062236, 14 }, // Spined
{ 1062237, 15 }, // Horned
{ 1062238, 16 } // Barbed
};
private static int[,] m_TypeFilters =
{
{ 1062229, 0 }, // All
{ 1062224, 1 }, // Small
{ 1062225, 2 } // Large
};
private static int[,] m_TypeFilters = {
{ 1062229, 0 }, // All
{ 1062224, 1 }, // Small
{ 1062225, 2 } // Large
};
private static int[,] m_QualityFilters =
{
{ 1062229, 0 }, // All
{ 1011542, 1 }, // Normal
{ 1060636, 2 } // Exceptional
};
private static int[,] m_QualityFilters = {
{ 1062229, 0 }, // All
{ 1011542, 1 }, // Normal
{ 1060636, 2 } // Exceptional
};
private static int[,] m_AmountFilters =
{
{ 1062229, 0 }, // All
{ 1049706, 1 }, // 10
{ 1016007, 2 }, // 15
{ 1062239, 3 } // 20
};
private static int[,] m_AmountFilters = {
{ 1062229, 0 }, // All
{ 1049706, 1 }, // 10
{ 1016007, 2 }, // 15
{ 1062239, 3 } // 20
};
private static int[][,] m_Filters =
{
m_TypeFilters,
m_QualityFilters,
m_MaterialFilters,
m_AmountFilters
};
private static int[][,] m_Filters = {
m_TypeFilters,
m_QualityFilters,
m_MaterialFilters,
m_AmountFilters
};
private static int[] m_XOffsets_Type = { 0, 75, 170 };
private static int[] m_XOffsets_Quality = { 0, 75, 170 };
private static int[] m_XOffsets_Amount = { 0, 75, 180, 275 };
private static int[] m_XOffsets_Material = { 0, 105, 210, 305, 390, 485 };
private static int[] m_XOffsets_Type = { 0, 75, 170 };
private static int[] m_XOffsets_Quality = { 0, 75, 170 };
private static int[] m_XOffsets_Amount = { 0, 75, 180, 275 };
private static int[] m_XOffsets_Material = { 0, 105, 210, 305, 390, 485 };
private static int[] m_XWidths_Small = { 50, 50, 70, 50 };
private static int[] m_XWidths_Large = { 80, 50, 50, 50, 50, 50 };
private BulkOrderBook m_Book;
private PlayerMobile m_From;
private static int[] m_XWidths_Small = { 50, 50, 70, 50 };
private static int[] m_XWidths_Large = { 80, 50, 50, 50, 50, 50 };
public BOBFilterGump(PlayerMobile from, BulkOrderBook book) : base(12, 24)
{
from.CloseGump(typeof(BOBGump));
from.CloseGump(typeof(BOBFilterGump));
private void AddFilterList( int x, int y, int[] xOffsets, int yOffset, int[,] filters, int[] xWidths, int filterValue, int filterIndex )
{
for ( int i = 0; i < filters.GetLength( 0 ); ++i )
{
int number = filters[i, 0];
m_From = from;
m_Book = book;
if ( number == 0 )
continue;
BOBFilter f = from.UseOwnFilter ? from.BOBFilter : book.Filter;
bool isSelected = ( filters[i, 1] == filterValue );
AddPage(0);
if ( !isSelected && (i % xOffsets.Length) == 0 )
isSelected = ( filterValue == 0 );
AddBackground(10, 10, 600, 439, 5054);
AddHtmlLocalized( x + 35 + xOffsets[i % xOffsets.Length], y + ((i / xOffsets.Length) * yOffset), xWidths[i % xOffsets.Length], 32, number, isSelected ? 16927 : LabelColor, false, false );
AddButton( x + xOffsets[i % xOffsets.Length], y + ((i / xOffsets.Length) * yOffset), 4005, 4007, 4 + filterIndex + (i * 4), GumpButtonType.Reply, 0 );
}
}
AddImageTiled(18, 20, 583, 420, 2624);
AddAlphaRegion(18, 20, 583, 420);
public override void OnResponse( Network.NetState sender, RelayInfo info )
{
BOBFilter f = ( m_From.UseOwnFilter ? m_From.BOBFilter : m_Book.Filter );
AddImage(5, 5, 10460);
AddImage(585, 5, 10460);
AddImage(5, 424, 10460);
AddImage(585, 424, 10460);
int index = info.ButtonID;
AddHtmlLocalized(270, 32, 200, 32, 1062223, LabelColor, false, false); // Filter Preference
switch ( index )
{
case 0: // Apply
{
m_From.SendGump( new BOBGump( m_From, m_Book ) );
AddHtmlLocalized(26, 64, 120, 32, 1062228, LabelColor, false, false); // Bulk Order Type
AddFilterList(25, 96, m_XOffsets_Type, 40, m_TypeFilters, m_XWidths_Small, f.Type, 0);
break;
}
case 1: // Set Book Filter
{
m_From.UseOwnFilter = false;
m_From.SendGump( new BOBFilterGump( m_From, m_Book ) );
AddHtmlLocalized(320, 64, 50, 32, 1062215, LabelColor, false, false); // Quality
AddFilterList(320, 96, m_XOffsets_Quality, 40, m_QualityFilters, m_XWidths_Small, f.Quality, 1);
break;
}
case 2: // Set Your Filter
{
m_From.UseOwnFilter = true;
m_From.SendGump( new BOBFilterGump( m_From, m_Book ) );
AddHtmlLocalized(26, 160, 120, 32, 1062232, LabelColor, false, false); // Material Type
AddFilterList(25, 192, m_XOffsets_Material, 40, m_MaterialFilters, m_XWidths_Large, f.Material, 2);
break;
}
case 3: // Clear Filter
{
f.Clear();
m_From.SendGump( new BOBFilterGump( m_From, m_Book ) );
AddHtmlLocalized(26, 320, 120, 32, 1062217, LabelColor, false, false); // Amount
AddFilterList(25, 352, m_XOffsets_Amount, 40, m_AmountFilters, m_XWidths_Small, f.Quantity, 3);
break;
}
default:
{
index -= 4;
AddHtmlLocalized(75, 416, 120, 32, 1062477, from.UseOwnFilter ? LabelColor : 16927, false,
false); // Set Book Filter
AddButton(40, 416, 4005, 4007, 1, GumpButtonType.Reply, 0);
int type = index % 4;
index /= 4;
AddHtmlLocalized(235, 416, 120, 32, 1062478, from.UseOwnFilter ? 16927 : LabelColor, false,
false); // Set Your Filter
AddButton(200, 416, 4005, 4007, 2, GumpButtonType.Reply, 0);
if ( type >= 0 && type < m_Filters.Length )
{
int[,] filters = m_Filters[type];
AddHtmlLocalized(405, 416, 120, 32, 1062231, LabelColor, false, false); // Clear Filter
AddButton(370, 416, 4005, 4007, 3, GumpButtonType.Reply, 0);
if ( index >= 0 && index < filters.GetLength( 0 ) )
{
if ( filters[index, 0] == 0 )
break;
AddHtmlLocalized(540, 416, 50, 32, 1011046, LabelColor, false, false); // APPLY
AddButton(505, 416, 4017, 4018, 0, GumpButtonType.Reply, 0);
}
switch ( type )
{
case 0: f.Type = filters[index, 1]; break;
case 1: f.Quality = filters[index, 1]; break;
case 2: f.Material = filters[index, 1]; break;
case 3: f.Quantity = filters[index, 1]; break;
}
private void AddFilterList(int x, int y, int[] xOffsets, int yOffset, int[,] filters, int[] xWidths, int filterValue,
int filterIndex)
{
for (int i = 0; i < filters.GetLength(0); ++i)
{
int number = filters[i, 0];
m_From.SendGump( new BOBFilterGump( m_From, m_Book ) );
}
}
if (number == 0)
continue;
break;
}
}
}
bool isSelected = filters[i, 1] == filterValue;
public BOBFilterGump( PlayerMobile from, BulkOrderBook book ) : base( 12, 24 )
{
from.CloseGump( typeof( BOBGump ) );
from.CloseGump( typeof( BOBFilterGump ) );
if (!isSelected && i % xOffsets.Length == 0)
isSelected = filterValue == 0;
m_From = from;
m_Book = book;
AddHtmlLocalized(x + 35 + xOffsets[i % xOffsets.Length], y + i / xOffsets.Length * yOffset,
xWidths[i % xOffsets.Length], 32, number, isSelected ? 16927 : LabelColor, false, false);
AddButton(x + xOffsets[i % xOffsets.Length], y + i / xOffsets.Length * yOffset, 4005, 4007,
4 + filterIndex + i * 4, GumpButtonType.Reply, 0);
}
}
BOBFilter f = ( from.UseOwnFilter ? from.BOBFilter : book.Filter );
public override void OnResponse(NetState sender, RelayInfo info)
{
BOBFilter f = m_From.UseOwnFilter ? m_From.BOBFilter : m_Book.Filter;
AddPage( 0 );
int index = info.ButtonID;
AddBackground( 10, 10, 600, 439, 5054 );
switch (index)
{
case 0: // Apply
{
m_From.SendGump(new BOBGump(m_From, m_Book));
AddImageTiled( 18, 20, 583, 420, 2624 );
AddAlphaRegion( 18, 20, 583, 420 );
break;
}
case 1: // Set Book Filter
{
m_From.UseOwnFilter = false;
m_From.SendGump(new BOBFilterGump(m_From, m_Book));
AddImage( 5, 5, 10460 );
AddImage( 585, 5, 10460 );
AddImage( 5, 424, 10460 );
AddImage( 585, 424, 10460 );
break;
}
case 2: // Set Your Filter
{
m_From.UseOwnFilter = true;
m_From.SendGump(new BOBFilterGump(m_From, m_Book));
AddHtmlLocalized( 270, 32, 200, 32, 1062223, LabelColor, false, false ); // Filter Preference
break;
}
case 3: // Clear Filter
{
f.Clear();
m_From.SendGump(new BOBFilterGump(m_From, m_Book));
AddHtmlLocalized( 26, 64, 120, 32, 1062228, LabelColor, false, false ); // Bulk Order Type
AddFilterList( 25, 96, m_XOffsets_Type, 40, m_TypeFilters, m_XWidths_Small, f.Type, 0 );
break;
}
default:
{
index -= 4;
AddHtmlLocalized( 320, 64, 50, 32, 1062215, LabelColor, false, false ); // Quality
AddFilterList( 320, 96, m_XOffsets_Quality, 40, m_QualityFilters, m_XWidths_Small, f.Quality, 1 );
int type = index % 4;
index /= 4;
AddHtmlLocalized( 26, 160, 120, 32, 1062232, LabelColor, false, false ); // Material Type
AddFilterList( 25, 192, m_XOffsets_Material, 40, m_MaterialFilters, m_XWidths_Large, f.Material, 2 );
if (type >= 0 && type < m_Filters.Length)
{
int[,] filters = m_Filters[type];
AddHtmlLocalized( 26, 320, 120, 32, 1062217, LabelColor, false, false ); // Amount
AddFilterList( 25, 352, m_XOffsets_Amount, 40, m_AmountFilters, m_XWidths_Small, f.Quantity, 3 );
if (index >= 0 && index < filters.GetLength(0))
{
if (filters[index, 0] == 0)
break;
AddHtmlLocalized( 75, 416, 120, 32, 1062477, ( from.UseOwnFilter ? LabelColor : 16927 ), false, false ); // Set Book Filter
AddButton( 40, 416, 4005, 4007, 1, GumpButtonType.Reply, 0 );
switch (type)
{
case 0:
f.Type = filters[index, 1];
break;
case 1:
f.Quality = filters[index, 1];
break;
case 2:
f.Material = filters[index, 1];
break;
case 3:
f.Quantity = filters[index, 1];
break;
}
AddHtmlLocalized( 235, 416, 120, 32, 1062478, ( from.UseOwnFilter ? 16927 : LabelColor ), false, false ); // Set Your Filter
AddButton( 200, 416, 4005, 4007, 2, GumpButtonType.Reply, 0 );
m_From.SendGump(new BOBFilterGump(m_From, m_Book));
}
}
AddHtmlLocalized( 405, 416, 120, 32, 1062231, LabelColor, false, false ); // Clear Filter
AddButton( 370, 416, 4005, 4007, 3, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 540, 416, 50, 32, 1011046, LabelColor, false, false ); // APPLY
AddButton( 505, 416, 4017, 4018, 0, GumpButtonType.Reply, 0 );
}
}
break;
}
}
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,106 +1,107 @@
namespace Server.Engines.BulkOrders
{
public class BOBLargeEntry
{
public bool RequireExceptional { get; }
public class BOBLargeEntry
{
public BOBLargeEntry(LargeBOD bod)
{
RequireExceptional = bod.RequireExceptional;
public BODType DeedType { get; }
if (bod is LargeTailorBOD)
DeedType = BODType.Tailor;
else if (bod is LargeSmithBOD)
DeedType = BODType.Smith;
public BulkMaterialType Material { get; }
Material = bod.Material;
AmountMax = bod.AmountMax;
public int AmountMax { get; }
Entries = new BOBLargeSubEntry[bod.Entries.Length];
public int Price { get; set; }
for (int i = 0; i < Entries.Length; ++i)
Entries[i] = new BOBLargeSubEntry(bod.Entries[i]);
}
public BOBLargeSubEntry[] Entries { get; }
public BOBLargeEntry(GenericReader reader)
{
int version = reader.ReadEncodedInt();
public Item Reconstruct()
{
LargeBOD bod = null;
switch (version)
{
case 0:
{
RequireExceptional = reader.ReadBool();
if ( DeedType == BODType.Smith )
bod = new LargeSmithBOD( AmountMax, RequireExceptional, Material, ReconstructEntries() );
else if ( DeedType == BODType.Tailor )
bod = new LargeTailorBOD( AmountMax, RequireExceptional, Material, ReconstructEntries() );
DeedType = (BODType)reader.ReadEncodedInt();
for ( int i = 0; bod != null && i < bod.Entries.Length; ++i )
bod.Entries[i].Owner = bod;
Material = (BulkMaterialType)reader.ReadEncodedInt();
AmountMax = reader.ReadEncodedInt();
Price = reader.ReadEncodedInt();
return bod;
}
Entries = new BOBLargeSubEntry[reader.ReadEncodedInt()];
private LargeBulkEntry[] ReconstructEntries()
{
LargeBulkEntry[] entries = new LargeBulkEntry[Entries.Length];
for (int i = 0; i < Entries.Length; ++i)
Entries[i] = new BOBLargeSubEntry(reader);
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;
}
break;
}
}
}
return entries;
}
public bool RequireExceptional{ get; }
public BOBLargeEntry( LargeBOD bod )
{
RequireExceptional = bod.RequireExceptional;
public BODType DeedType{ get; }
if ( bod is LargeTailorBOD )
DeedType = BODType.Tailor;
else if ( bod is LargeSmithBOD )
DeedType = BODType.Smith;
public BulkMaterialType Material{ get; }
Material = bod.Material;
AmountMax = bod.AmountMax;
public int AmountMax{ get; }
Entries = new BOBLargeSubEntry[bod.Entries.Length];
public int Price{ get; set; }
for ( int i = 0; i < Entries.Length; ++i )
Entries[i] = new BOBLargeSubEntry( bod.Entries[i] );
}
public BOBLargeSubEntry[] Entries{ get; }
public BOBLargeEntry( GenericReader reader )
{
int version = reader.ReadEncodedInt();
public Item Reconstruct()
{
LargeBOD bod = null;
switch ( version )
{
case 0:
{
RequireExceptional = reader.ReadBool();
if (DeedType == BODType.Smith)
bod = new LargeSmithBOD(AmountMax, RequireExceptional, Material, ReconstructEntries());
else if (DeedType == BODType.Tailor)
bod = new LargeTailorBOD(AmountMax, RequireExceptional, Material, ReconstructEntries());
DeedType = (BODType)reader.ReadEncodedInt();
for (int i = 0; bod != null && i < bod.Entries.Length; ++i)
bod.Entries[i].Owner = bod;
Material = (BulkMaterialType)reader.ReadEncodedInt();
AmountMax = reader.ReadEncodedInt();
Price = reader.ReadEncodedInt();
return bod;
}
Entries = new BOBLargeSubEntry[reader.ReadEncodedInt()];
private LargeBulkEntry[] ReconstructEntries()
{
LargeBulkEntry[] entries = new LargeBulkEntry[Entries.Length];
for ( int i = 0; i < Entries.Length; ++i )
Entries[i] = new BOBLargeSubEntry( reader );
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;
}
break;
}
}
}
return entries;
}
public void Serialize( GenericWriter writer )
{
writer.WriteEncodedInt( 0 ); // version
public void Serialize(GenericWriter writer)
{
writer.WriteEncodedInt(0); // version
writer.Write( (bool) RequireExceptional );
writer.Write(RequireExceptional);
writer.WriteEncodedInt( (int) DeedType );
writer.WriteEncodedInt( (int) Material );
writer.WriteEncodedInt( (int) AmountMax );
writer.WriteEncodedInt( (int) Price );
writer.WriteEncodedInt((int)DeedType);
writer.WriteEncodedInt((int)Material);
writer.WriteEncodedInt(AmountMax);
writer.WriteEncodedInt(Price);
writer.WriteEncodedInt( (int) Entries.Length );
writer.WriteEncodedInt(Entries.Length);
for ( int i = 0; i < Entries.Length; ++i )
Entries[i].Serialize( writer );
}
}
for (int i = 0; i < Entries.Length; ++i)
Entries[i].Serialize(writer);
}
}
}

View file

@ -2,55 +2,55 @@ using System;
namespace Server.Engines.BulkOrders
{
public class BOBLargeSubEntry
{
public Type ItemType { get; }
public class BOBLargeSubEntry
{
public BOBLargeSubEntry(LargeBulkEntry lbe)
{
ItemType = lbe.Details.Type;
AmountCur = lbe.Amount;
Number = lbe.Details.Number;
Graphic = lbe.Details.Graphic;
}
public int AmountCur { get; }
public BOBLargeSubEntry(GenericReader reader)
{
int version = reader.ReadEncodedInt();
public int Number { get; }
switch (version)
{
case 0:
{
string type = reader.ReadString();
public int Graphic { get; }
if (type != null)
ItemType = ScriptCompiler.FindTypeByFullName(type);
public BOBLargeSubEntry( LargeBulkEntry lbe )
{
ItemType = lbe.Details.Type;
AmountCur = lbe.Amount;
Number = lbe.Details.Number;
Graphic = lbe.Details.Graphic;
}
AmountCur = reader.ReadEncodedInt();
Number = reader.ReadEncodedInt();
Graphic = reader.ReadEncodedInt();
public BOBLargeSubEntry( GenericReader reader )
{
int version = reader.ReadEncodedInt();
break;
}
}
}
switch ( version )
{
case 0:
{
string type = reader.ReadString();
public Type ItemType{ get; }
if ( type != null )
ItemType = ScriptCompiler.FindTypeByFullName( type );
public int AmountCur{ get; }
AmountCur = reader.ReadEncodedInt();
Number = reader.ReadEncodedInt();
Graphic = reader.ReadEncodedInt();
public int Number{ get; }
break;
}
}
}
public int Graphic{ get; }
public void Serialize( GenericWriter writer )
{
writer.WriteEncodedInt( 0 ); // version
public void Serialize(GenericWriter writer)
{
writer.WriteEncodedInt(0); // version
writer.Write( ItemType == null ? null : ItemType.FullName );
writer.Write(ItemType == null ? null : ItemType.FullName);
writer.WriteEncodedInt( (int) AmountCur );
writer.WriteEncodedInt( (int) Number );
writer.WriteEncodedInt( (int) Graphic );
}
}
writer.WriteEncodedInt(AmountCur);
writer.WriteEncodedInt(Number);
writer.WriteEncodedInt(Graphic);
}
}
}

View file

@ -2,99 +2,99 @@ using System;
namespace Server.Engines.BulkOrders
{
public class BOBSmallEntry
{
public Type ItemType { get; }
public class BOBSmallEntry
{
public BOBSmallEntry(SmallBOD bod)
{
ItemType = bod.Type;
RequireExceptional = bod.RequireExceptional;
public bool RequireExceptional { get; }
if (bod is SmallTailorBOD)
DeedType = BODType.Tailor;
else if (bod is SmallSmithBOD)
DeedType = BODType.Smith;
public BODType DeedType { get; }
Material = bod.Material;
AmountCur = bod.AmountCur;
AmountMax = bod.AmountMax;
Number = bod.Number;
Graphic = bod.Graphic;
}
public BulkMaterialType Material { get; }
public BOBSmallEntry(GenericReader reader)
{
int version = reader.ReadEncodedInt();
public int AmountCur { get; }
switch (version)
{
case 0:
{
string type = reader.ReadString();
public int AmountMax { get; }
if (type != null)
ItemType = ScriptCompiler.FindTypeByFullName(type);
public int Number { get; }
RequireExceptional = reader.ReadBool();
public int Graphic { get; }
DeedType = (BODType)reader.ReadEncodedInt();
public int Price { get; set; }
Material = (BulkMaterialType)reader.ReadEncodedInt();
AmountCur = reader.ReadEncodedInt();
AmountMax = reader.ReadEncodedInt();
Number = reader.ReadEncodedInt();
Graphic = reader.ReadEncodedInt();
Price = reader.ReadEncodedInt();
public Item Reconstruct()
{
SmallBOD bod = null;
break;
}
}
}
if ( DeedType == BODType.Smith )
bod = new SmallSmithBOD( AmountCur, AmountMax, ItemType, Number, Graphic, RequireExceptional, Material );
else if ( DeedType == BODType.Tailor )
bod = new SmallTailorBOD( AmountCur, AmountMax, ItemType, Number, Graphic, RequireExceptional, Material );
public Type ItemType{ get; }
return bod;
}
public bool RequireExceptional{ get; }
public BOBSmallEntry( SmallBOD bod )
{
ItemType = bod.Type;
RequireExceptional = bod.RequireExceptional;
public BODType DeedType{ get; }
if ( bod is SmallTailorBOD )
DeedType = BODType.Tailor;
else if ( bod is SmallSmithBOD )
DeedType = BODType.Smith;
public BulkMaterialType Material{ get; }
Material = bod.Material;
AmountCur = bod.AmountCur;
AmountMax = bod.AmountMax;
Number = bod.Number;
Graphic = bod.Graphic;
}
public int AmountCur{ get; }
public BOBSmallEntry( GenericReader reader )
{
int version = reader.ReadEncodedInt();
public int AmountMax{ get; }
switch ( version )
{
case 0:
{
string type = reader.ReadString();
public int Number{ get; }
if ( type != null )
ItemType = ScriptCompiler.FindTypeByFullName( type );
public int Graphic{ get; }
RequireExceptional = reader.ReadBool();
public int Price{ get; set; }
DeedType = (BODType)reader.ReadEncodedInt();
public Item Reconstruct()
{
SmallBOD bod = null;
Material = (BulkMaterialType)reader.ReadEncodedInt();
AmountCur = reader.ReadEncodedInt();
AmountMax = reader.ReadEncodedInt();
Number = reader.ReadEncodedInt();
Graphic = reader.ReadEncodedInt();
Price = reader.ReadEncodedInt();
if (DeedType == BODType.Smith)
bod = new SmallSmithBOD(AmountCur, AmountMax, ItemType, Number, Graphic, RequireExceptional, Material);
else if (DeedType == BODType.Tailor)
bod = new SmallTailorBOD(AmountCur, AmountMax, ItemType, Number, Graphic, RequireExceptional, Material);
break;
}
}
}
return bod;
}
public void Serialize( GenericWriter writer )
{
writer.WriteEncodedInt( 0 ); // version
public void Serialize(GenericWriter writer)
{
writer.WriteEncodedInt(0); // version
writer.Write( ItemType == null ? null : ItemType.FullName );
writer.Write(ItemType == null ? null : ItemType.FullName);
writer.Write( (bool) RequireExceptional );
writer.Write(RequireExceptional);
writer.WriteEncodedInt( (int) DeedType );
writer.WriteEncodedInt( (int) Material );
writer.WriteEncodedInt( (int) AmountCur );
writer.WriteEncodedInt( (int) AmountMax );
writer.WriteEncodedInt( (int) Number );
writer.WriteEncodedInt( (int) Graphic );
writer.WriteEncodedInt( (int) Price );
}
}
writer.WriteEncodedInt((int)DeedType);
writer.WriteEncodedInt((int)Material);
writer.WriteEncodedInt(AmountCur);
writer.WriteEncodedInt(AmountMax);
writer.WriteEncodedInt(Number);
writer.WriteEncodedInt(Graphic);
writer.WriteEncodedInt(Price);
}
}
}

View file

@ -1,136 +1,140 @@
using Server.Items;
using Server.Gumps;
using Server.Items;
using Server.Mobiles;
using Server.Network;
namespace Server.Engines.BulkOrders
{
public class BODBuyGump : Gump
{
private PlayerMobile m_From;
private BulkOrderBook m_Book;
private object m_Object;
private int m_Price;
private int m_Page;
public class BODBuyGump : Gump
{
private BulkOrderBook m_Book;
private PlayerMobile m_From;
private object m_Object;
private int m_Page;
private int m_Price;
public override void OnResponse( Network.NetState sender, RelayInfo info )
{
if ( info.ButtonID == 2 )
{
PlayerVendor pv = m_Book.RootParent as PlayerVendor;
public BODBuyGump(PlayerMobile from, BulkOrderBook book, object obj, int page, int price) : base(100, 200)
{
m_From = from;
m_Book = book;
m_Object = obj;
m_Price = price;
m_Page = page;
if ( m_Book.Entries.Contains( m_Object ) && pv != null )
{
int price = 0;
AddPage(0);
VendorItem vi = pv.GetVendorItem( m_Book );
AddBackground(100, 10, 300, 150, 5054);
if ( vi != null && !vi.IsForSale )
{
if ( m_Object is BOBLargeEntry entry )
price = entry.Price;
else
price = ((BOBSmallEntry)m_Object).Price;
}
AddHtmlLocalized(125, 20, 250, 24, 1019070, false, false); // You have agreed to purchase:
AddHtmlLocalized(125, 45, 250, 24, 1045151, false, false); // a bulk order deed
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;
AddHtmlLocalized(125, 70, 250, 24, 1019071, false, false); // for the amount of:
AddLabel(125, 95, 0, price.ToString());
if ( m_Object is BOBLargeEntry entry )
item = entry.Reconstruct();
else
item = ((BOBSmallEntry)m_Object).Reconstruct();
AddButton(250, 130, 4005, 4007, 1, GumpButtonType.Reply, 0);
AddHtmlLocalized(282, 130, 100, 24, 1011012, false, false); // CANCEL
if ( item == null )
{
m_From.SendMessage( "Internal error. The bulk order deed could not be reconstructed." );
}
else
{
pv.Say( m_From.Name );
AddButton(120, 130, 4005, 4007, 2, GumpButtonType.Reply, 0);
AddHtmlLocalized(152, 130, 100, 24, 1011036, false, false); // OKAY
}
Container pack = m_From.Backpack;
public override void OnResponse(NetState sender, RelayInfo info)
{
if (info.ButtonID == 2)
{
PlayerVendor pv = m_Book.RootParent as PlayerVendor;
if ( (pack == null) || ((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 != null && 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.
if (m_Book.Entries.Contains(m_Object) && pv != null)
{
int price = 0;
if ( m_Book.Entries.Count / 5 < m_Book.ItemCount )
{
m_Book.ItemCount--;
m_Book.InvalidateItems();
}
VendorItem vi = pv.GetVendorItem(m_Book);
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.
}
}
else
{
m_From.SendLocalizedMessage( 503207 ); // Cancelled purchase.
}
}
if (vi != null && !vi.IsForSale)
{
if (m_Object is BOBLargeEntry entry)
price = entry.Price;
else
price = ((BOBSmallEntry)m_Object).Price;
}
public BODBuyGump( PlayerMobile from, BulkOrderBook book, object obj, int page, int price ) : base( 100, 200 )
{
m_From = from;
m_Book = book;
m_Object = obj;
m_Price = price;
m_Page = page;
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;
AddPage( 0 );
if (m_Object is BOBLargeEntry entry)
item = entry.Reconstruct();
else
item = ((BOBSmallEntry)m_Object).Reconstruct();
AddBackground( 100, 10, 300, 150, 5054 );
if (item == null)
{
m_From.SendMessage("Internal error. The bulk order deed could not be reconstructed.");
}
else
{
pv.Say(m_From.Name);
AddHtmlLocalized( 125, 20, 250, 24, 1019070, false, false ); // You have agreed to purchase:
AddHtmlLocalized( 125, 45, 250, 24, 1045151, false, false ); // a bulk order deed
Container pack = m_From.Backpack;
AddHtmlLocalized( 125, 70, 250, 24, 1019071, false, false ); // for the amount of:
AddLabel( 125, 95, 0, price.ToString() );
if (pack == null || 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 != null && 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.
AddButton( 250, 130, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 282, 130, 100, 24, 1011012, false, false ); // CANCEL
if (m_Book.Entries.Count / 5 < m_Book.ItemCount)
{
m_Book.ItemCount--;
m_Book.InvalidateItems();
}
AddButton( 120, 130, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 152, 130, 100, 24, 1011036, false, false ); // OKAY
}
}
}
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.
}
}
else
{
m_From.SendLocalizedMessage(503207); // Cancelled purchase.
}
}
}
}

View file

@ -1,8 +1,8 @@
namespace Server.Engines.BulkOrders
{
public enum BODType
{
Smith,
Tailor
}
public enum BODType
{
Smith,
Tailor
}
}