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,25 +1,25 @@
using Server.Mobiles;
using Server.Gumps;
using System.Collections.Generic;
using Server.Gumps;
using Server.Mobiles;
namespace Server.Engines.MLQuests.Rewards
{
public abstract class BaseReward
{
public TextDefinition Name { get; set; }
public abstract class BaseReward
{
public BaseReward(TextDefinition name)
{
Name = name;
}
public BaseReward( TextDefinition name )
{
Name = name;
}
public TextDefinition Name{ get; set; }
protected virtual int LabelHeight => 16;
protected virtual int LabelHeight => 16;
public void WriteToGump( Gump g, int x, ref int y )
{
TextDefinition.AddHtmlText( g, x, y, 280, LabelHeight, Name, false, false, 0x15F90, 0xBDE784 );
}
public void WriteToGump(Gump g, int x, ref int y)
{
TextDefinition.AddHtmlText(g, x, y, 280, LabelHeight, Name, false, false, 0x15F90, 0xBDE784);
}
public abstract void AddRewardItems( PlayerMobile pm, List<Item> rewards );
}
}
public abstract void AddRewardItems(PlayerMobile pm, List<Item> rewards);
}
}

View file

@ -1,19 +1,19 @@
using Server.Mobiles;
using System.Collections.Generic;
using Server.Mobiles;
namespace Server.Engines.MLQuests.Rewards
{
public class DummyReward : BaseReward
{
public DummyReward( TextDefinition name )
: base( name )
{
}
public class DummyReward : BaseReward
{
public DummyReward(TextDefinition name)
: base(name)
{
}
protected override int LabelHeight => 180;
protected override int LabelHeight => 180;
public override void AddRewardItems( PlayerMobile pm, List<Item> rewards )
{
}
}
}
public override void AddRewardItems(PlayerMobile pm, List<Item> rewards)
{
}
}
}

View file

@ -5,86 +5,104 @@ using Server.Mobiles;
namespace Server.Engines.MLQuests.Rewards
{
public class ItemReward : BaseReward
{
public static readonly ItemReward SmallBagOfTrinkets = new ItemReward( 1072268, typeof( SmallBagOfTrinkets ) ); // A small bag of trinkets.
public static readonly ItemReward BagOfTrinkets = new ItemReward( 1072341, typeof( BagOfTrinkets ) ); // A bag of trinkets.
public static readonly ItemReward BagOfTreasure = new ItemReward( 1072583, typeof( BagOfTreasure ) ); // A bag of treasure.
public static readonly ItemReward LargeBagOfTreasure = new ItemReward( 1072706, typeof( LargeBagOfTreasure ) ); // A large bag of treasure.
public static readonly ItemReward Strongbox = new ItemReward( 1072584, typeof( RewardStrongbox ) ); // A strongbox.
public class ItemReward : BaseReward
{
public static readonly ItemReward
SmallBagOfTrinkets = new ItemReward(1072268, typeof(SmallBagOfTrinkets)); // A small bag of trinkets.
public static readonly ItemReward TailorSatchel = new ItemReward( 1074282, typeof( TailorSatchel ) ); // Craftsman's Satchel
public static readonly ItemReward BlacksmithSatchel = new ItemReward( 1074282, typeof( BlacksmithSatchel ) ); // Craftsman's Satchel
public static readonly ItemReward FletchingSatchel = new ItemReward( 1074282, typeof( FletchingSatchel ) ); // Craftsman's Satchel
public static readonly ItemReward CarpentrySatchel = new ItemReward( 1074282, typeof( CarpentrySatchel ) ); // Craftsman's Satchel
public static readonly ItemReward TinkerSatchel = new ItemReward( 1074282, typeof( TinkerSatchel ) ); // Craftsman's Satchel
public static readonly ItemReward
BagOfTrinkets = new ItemReward(1072341, typeof(BagOfTrinkets)); // A bag of trinkets.
private Type m_Type;
private int m_Amount;
public static readonly ItemReward
BagOfTreasure = new ItemReward(1072583, typeof(BagOfTreasure)); // A bag of treasure.
public ItemReward()
: this( null, null )
{
}
public static readonly ItemReward
LargeBagOfTreasure = new ItemReward(1072706, typeof(LargeBagOfTreasure)); // A large bag of treasure.
public ItemReward( TextDefinition name, Type type )
: this( name, type, 1 )
{
}
public static readonly ItemReward Strongbox = new ItemReward(1072584, typeof(RewardStrongbox)); // A strongbox.
public ItemReward( TextDefinition name, Type type, int amount )
: base( name )
{
m_Type = type;
m_Amount = amount;
}
public static readonly ItemReward
TailorSatchel = new ItemReward(1074282, typeof(TailorSatchel)); // Craftsman's Satchel
public virtual Item CreateItem()
{
Item spawnedItem = null;
public static readonly ItemReward
BlacksmithSatchel = new ItemReward(1074282, typeof(BlacksmithSatchel)); // Craftsman's Satchel
try
{
spawnedItem = Activator.CreateInstance( m_Type ) as Item;
}
catch ( Exception e )
{
if ( MLQuestSystem.Debug )
Console.WriteLine( "WARNING: ItemReward.CreateItem failed for {0}: {1}", m_Type, e );
}
public static readonly ItemReward
FletchingSatchel = new ItemReward(1074282, typeof(FletchingSatchel)); // Craftsman's Satchel
return spawnedItem;
}
public static readonly ItemReward
CarpentrySatchel = new ItemReward(1074282, typeof(CarpentrySatchel)); // Craftsman's Satchel
public override void AddRewardItems( PlayerMobile pm, List<Item> rewards )
{
Item reward = CreateItem();
public static readonly ItemReward
TinkerSatchel = new ItemReward(1074282, typeof(TinkerSatchel)); // Craftsman's Satchel
if ( reward == null )
return;
private int m_Amount;
if ( reward.Stackable )
{
if ( m_Amount > 1 )
reward.Amount = m_Amount;
private Type m_Type;
rewards.Add( reward );
}
else
{
for ( int i = 0; i < m_Amount; ++i )
{
rewards.Add( reward );
public ItemReward()
: this(null, null)
{
}
if ( i < m_Amount - 1 )
{
reward = CreateItem();
public ItemReward(TextDefinition name, Type type)
: this(name, type, 1)
{
}
if ( reward == null )
return;
}
}
}
}
}
}
public ItemReward(TextDefinition name, Type type, int amount)
: base(name)
{
m_Type = type;
m_Amount = amount;
}
public virtual Item CreateItem()
{
Item spawnedItem = null;
try
{
spawnedItem = Activator.CreateInstance(m_Type) as Item;
}
catch (Exception e)
{
if (MLQuestSystem.Debug)
Console.WriteLine("WARNING: ItemReward.CreateItem failed for {0}: {1}", m_Type, e);
}
return spawnedItem;
}
public override void AddRewardItems(PlayerMobile pm, List<Item> rewards)
{
Item reward = CreateItem();
if (reward == null)
return;
if (reward.Stackable)
{
if (m_Amount > 1)
reward.Amount = m_Amount;
rewards.Add(reward);
}
else
{
for (int i = 0; i < m_Amount; ++i)
{
rewards.Add(reward);
if (i < m_Amount - 1)
{
reward = CreateItem();
if (reward == null)
return;
}
}
}
}
}
}