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

@ -4,227 +4,247 @@ using Server.Engines.Craft;
namespace Server.Engines.BulkOrders
{
public class SmallTailorBOD : SmallBOD
{
public static double[] m_TailoringMaterialChances = {
0.857421875, // None
0.125000000, // Spined
0.015625000, // Horned
0.001953125 // Barbed
};
public class SmallTailorBOD : SmallBOD
{
public static double[] m_TailoringMaterialChances =
{
0.857421875, // None
0.125000000, // Spined
0.015625000, // Horned
0.001953125 // Barbed
};
public override int ComputeFame()
{
return TailorRewardCalculator.Instance.ComputeFame( this );
}
private SmallTailorBOD(SmallBulkEntry entry, BulkMaterialType material, int amountMax, bool reqExceptional)
{
Hue = 0x483;
AmountMax = amountMax;
Type = entry.Type;
Number = entry.Number;
Graphic = entry.Graphic;
RequireExceptional = reqExceptional;
Material = material;
}
public override int ComputeGold()
{
return TailorRewardCalculator.Instance.ComputeGold( this );
}
[Constructible]
public SmallTailorBOD()
{
SmallBulkEntry[] entries;
bool useMaterials;
public override List<Item> ComputeRewards( bool full )
{
List<Item> list = new List<Item>();
if (useMaterials = Utility.RandomBool())
entries = SmallBulkEntry.TailorLeather;
else
entries = SmallBulkEntry.TailorCloth;
RewardGroup rewardGroup = TailorRewardCalculator.Instance.LookupRewards( TailorRewardCalculator.Instance.ComputePoints( this ) );
if (entries.Length > 0)
{
int hue = 0x483;
int amountMax = Utility.RandomList(10, 15, 20);
if ( rewardGroup != null )
{
if ( full )
{
for ( int i = 0; i < rewardGroup.Items.Length; ++i )
{
Item item = rewardGroup.Items[i].Construct();
BulkMaterialType material;
if ( item != null )
list.Add( item );
}
}
else
{
RewardItem rewardItem = rewardGroup.AcquireItem();
if (useMaterials)
material = GetRandomMaterial(BulkMaterialType.Spined, m_TailoringMaterialChances);
else
material = BulkMaterialType.None;
Item item = rewardItem?.Construct();
bool reqExceptional = Utility.RandomBool() || material == BulkMaterialType.None;
if ( item != null )
list.Add( item );
}
}
SmallBulkEntry entry = entries[Utility.Random(entries.Length)];
return list;
}
Hue = hue;
AmountMax = amountMax;
Type = entry.Type;
Number = entry.Number;
Graphic = entry.Graphic;
RequireExceptional = reqExceptional;
Material = material;
}
}
public static SmallTailorBOD CreateRandomFor( Mobile m )
{
SmallBulkEntry[] entries;
bool useMaterials = Utility.RandomBool();
public SmallTailorBOD(int amountCur, int amountMax, Type type, int number, int graphic, bool reqExceptional,
BulkMaterialType mat)
{
Hue = 0x483;
AmountMax = amountMax;
AmountCur = amountCur;
Type = type;
Number = number;
Graphic = graphic;
RequireExceptional = reqExceptional;
Material = mat;
}
double theirSkill = m.Skills[SkillName.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;
else
entries = SmallBulkEntry.TailorCloth;
public SmallTailorBOD(Serial serial) : base(serial)
{
}
if ( entries.Length > 0 )
{
int amountMax;
public override int ComputeFame()
{
return TailorRewardCalculator.Instance.ComputeFame(this);
}
if ( theirSkill >= 70.1 )
amountMax = Utility.RandomList( 10, 15, 20, 20 );
else if ( theirSkill >= 50.1 )
amountMax = Utility.RandomList( 10, 15, 15, 20 );
else
amountMax = Utility.RandomList( 10, 10, 15, 20 );
public override int ComputeGold()
{
return TailorRewardCalculator.Instance.ComputeGold(this);
}
BulkMaterialType material = BulkMaterialType.None;
public override List<Item> ComputeRewards(bool full)
{
List<Item> list = new List<Item>();
if ( useMaterials && theirSkill >= 70.1 )
{
for ( int i = 0; i < 20; ++i )
{
BulkMaterialType check = GetRandomMaterial( BulkMaterialType.Spined, m_TailoringMaterialChances );
double skillReq = 0.0;
RewardGroup rewardGroup =
TailorRewardCalculator.Instance.LookupRewards(TailorRewardCalculator.Instance.ComputePoints(this));
switch ( check )
{
case BulkMaterialType.DullCopper: skillReq = 65.0; break;
case BulkMaterialType.Bronze: skillReq = 80.0; break;
case BulkMaterialType.Gold: skillReq = 85.0; break;
case BulkMaterialType.Agapite: skillReq = 90.0; break;
case BulkMaterialType.Verite: skillReq = 95.0; break;
case BulkMaterialType.Valorite: skillReq = 100.0; break;
case BulkMaterialType.Spined: skillReq = 65.0; break;
case BulkMaterialType.Horned: skillReq = 80.0; break;
case BulkMaterialType.Barbed: skillReq = 99.0; break;
}
if (rewardGroup != null)
{
if (full)
{
for (int i = 0; i < rewardGroup.Items.Length; ++i)
{
Item item = rewardGroup.Items[i].Construct();
if ( theirSkill >= skillReq )
{
material = check;
break;
}
}
}
if (item != null)
list.Add(item);
}
}
else
{
RewardItem rewardItem = rewardGroup.AcquireItem();
double excChance = 0.0;
Item item = rewardItem?.Construct();
if ( theirSkill >= 70.1 )
excChance = (theirSkill + 80.0) / 200.0;
if (item != null)
list.Add(item);
}
}
bool reqExceptional = ( excChance > Utility.RandomDouble() );
return list;
}
public static SmallTailorBOD CreateRandomFor(Mobile m)
{
SmallBulkEntry[] entries;
bool useMaterials = Utility.RandomBool();
double theirSkill = m.Skills[SkillName.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;
else
entries = SmallBulkEntry.TailorCloth;
if (entries.Length > 0)
{
int amountMax;
if (theirSkill >= 70.1)
amountMax = Utility.RandomList(10, 15, 20, 20);
else if (theirSkill >= 50.1)
amountMax = Utility.RandomList(10, 15, 15, 20);
else
amountMax = Utility.RandomList(10, 10, 15, 20);
BulkMaterialType material = BulkMaterialType.None;
if (useMaterials && theirSkill >= 70.1)
for (int i = 0; i < 20; ++i)
{
BulkMaterialType check = GetRandomMaterial(BulkMaterialType.Spined, m_TailoringMaterialChances);
double skillReq = 0.0;
switch (check)
{
case BulkMaterialType.DullCopper:
skillReq = 65.0;
break;
case BulkMaterialType.Bronze:
skillReq = 80.0;
break;
case BulkMaterialType.Gold:
skillReq = 85.0;
break;
case BulkMaterialType.Agapite:
skillReq = 90.0;
break;
case BulkMaterialType.Verite:
skillReq = 95.0;
break;
case BulkMaterialType.Valorite:
skillReq = 100.0;
break;
case BulkMaterialType.Spined:
skillReq = 65.0;
break;
case BulkMaterialType.Horned:
skillReq = 80.0;
break;
case BulkMaterialType.Barbed:
skillReq = 99.0;
break;
}
if (theirSkill >= skillReq)
{
material = check;
break;
}
}
double excChance = 0.0;
if (theirSkill >= 70.1)
excChance = (theirSkill + 80.0) / 200.0;
bool reqExceptional = excChance > Utility.RandomDouble();
CraftSystem system = DefTailoring.CraftSystem;
CraftSystem system = DefTailoring.CraftSystem;
List<SmallBulkEntry> validEntries = new List<SmallBulkEntry>();
List<SmallBulkEntry> validEntries = new List<SmallBulkEntry>();
for ( int i = 0; i < entries.Length; ++i )
{
CraftItem item = system.CraftItems.SearchFor( entries[i].Type );
for (int i = 0; i < entries.Length; ++i)
{
CraftItem item = system.CraftItems.SearchFor(entries[i].Type);
if ( item != null )
{
bool allRequiredSkills = true;
double chance = item.GetSuccessChance( m, null, system, false, ref allRequiredSkills );
if (item != null)
{
bool allRequiredSkills = true;
double chance = item.GetSuccessChance(m, null, system, false, ref allRequiredSkills);
if ( allRequiredSkills && chance >= 0.0 )
{
if ( reqExceptional )
chance = item.GetExceptionalChance( system, chance, m );
if (allRequiredSkills && chance >= 0.0)
{
if (reqExceptional)
chance = item.GetExceptionalChance(system, chance, m);
if ( chance > 0.0 )
validEntries.Add( entries[i] );
}
}
}
if (chance > 0.0)
validEntries.Add(entries[i]);
}
}
}
if ( validEntries.Count > 0 )
{
SmallBulkEntry entry = validEntries[Utility.Random( validEntries.Count )];
return new SmallTailorBOD( entry, material, amountMax, reqExceptional );
}
}
if (validEntries.Count > 0)
{
SmallBulkEntry entry = validEntries[Utility.Random(validEntries.Count)];
return new SmallTailorBOD(entry, material, amountMax, reqExceptional);
}
}
return null;
}
return null;
}
private SmallTailorBOD( SmallBulkEntry entry, BulkMaterialType material, int amountMax, bool reqExceptional )
{
Hue = 0x483;
AmountMax = amountMax;
Type = entry.Type;
Number = entry.Number;
Graphic = entry.Graphic;
RequireExceptional = reqExceptional;
Material = material;
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
[Constructible]
public SmallTailorBOD()
{
SmallBulkEntry[] entries;
bool useMaterials;
writer.Write(0); // version
}
if ( useMaterials = Utility.RandomBool() )
entries = SmallBulkEntry.TailorLeather;
else
entries = SmallBulkEntry.TailorCloth;
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
if ( entries.Length > 0 )
{
int hue = 0x483;
int amountMax = Utility.RandomList( 10, 15, 20 );
BulkMaterialType material;
if ( useMaterials )
material = GetRandomMaterial( BulkMaterialType.Spined, m_TailoringMaterialChances );
else
material = BulkMaterialType.None;
bool reqExceptional = Utility.RandomBool() || (material == BulkMaterialType.None);
SmallBulkEntry entry = entries[Utility.Random( entries.Length )];
Hue = hue;
AmountMax = amountMax;
Type = entry.Type;
Number = entry.Number;
Graphic = entry.Graphic;
RequireExceptional = reqExceptional;
Material = material;
}
}
public SmallTailorBOD( int amountCur, int amountMax, Type type, int number, int graphic, bool reqExceptional, BulkMaterialType mat )
{
Hue = 0x483;
AmountMax = amountMax;
AmountCur = amountCur;
Type = type;
Number = number;
Graphic = graphic;
RequireExceptional = reqExceptional;
Material = mat;
}
public SmallTailorBOD( 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();
}
}
int version = reader.ReadInt();
}
}
}