Fixes implicit ternary expressions

This commit is contained in:
Kamron Batman 2018-09-14 14:56:48 -07:00
parent c85b0a740c
commit ff26dfa375
345 changed files with 1905 additions and 2336 deletions

View file

@ -152,7 +152,7 @@ namespace Server.Engines.Craft
string nameString = craftSystem.CraftSubRes2.NameString;
int nameNumber = craftSystem.CraftSubRes2.NameNumber;
int resIndex = ( context == null ? -1 : context.LastResourceIndex2 );
int resIndex = context?.LastResourceIndex2 ?? -1;
Type resourceType = craftSystem.CraftSubRes2.ResType;
@ -481,7 +481,7 @@ namespace Server.Engines.Craft
{
if ( m_Page == CraftPage.PickResource && index >= 0 && index < system.CraftSubRes.Count )
{
int groupIndex = ( context == null ? -1 : context.LastGroupIndex );
int groupIndex = context?.LastGroupIndex ?? -1;
CraftSubRes res = system.CraftSubRes.GetAt( index );
@ -499,7 +499,7 @@ namespace Server.Engines.Craft
}
else if ( m_Page == CraftPage.PickResource2 && index >= 0 && index < system.CraftSubRes2.Count )
{
int groupIndex = ( context == null ? -1 : context.LastGroupIndex );
int groupIndex = context?.LastGroupIndex ?? -1;
CraftSubRes res = system.CraftSubRes2.GetAt( index );

View file

@ -246,30 +246,24 @@ namespace Server.Engines.Craft
message = "You lack the required hit points to make that.";
return false;
}
else
{
consumHits = consume;
}
consumHits = consume;
if ( Mana > 0 && from.Mana < Mana )
{
message = "You lack the required mana to make that.";
return false;
}
else
{
consumMana = consume;
}
consumMana = consume;
if ( Stam > 0 && from.Stam < Stam )
{
message = "You lack the required stamina to make that.";
return false;
}
else
{
consumStam = consume;
}
consumStam = consume;
if ( consumMana )
from.Mana -= Mana;
@ -786,7 +780,7 @@ namespace Server.Engines.Craft
return true;
}
else
{
CraftRes res = m_arCraftRes.GetAt( index );

View file

@ -49,7 +49,7 @@ namespace Server.Engines.Craft
private int GetWeakenChance( Mobile mob, SkillName skill, int curHits, int maxHits )
{
// 40% - (1% per hp lost) - (1% per 10 craft skill)
return (40 + (maxHits - curHits)) - (int)(((m_Deed != null)? m_Deed.SkillLevel : mob.Skills[skill].Value) / 10);
return (40 + (maxHits - curHits)) - (int)((m_Deed?.SkillLevel ?? mob.Skills[skill].Value) / 10);
}
private bool CheckWeaken( Mobile mob, SkillName skill, int curHits, int maxHits )
@ -75,17 +75,15 @@ namespace Server.Engines.Craft
if ( value < minSkill )
return false; // Too difficult
else if ( value >= maxSkill )
if ( value >= maxSkill )
return true; // No challenge
double chance = (value - minSkill) / (maxSkill - minSkill);
return (chance >= Utility.RandomDouble());
}
else
{
return mob.CheckSkill( skill, difficulty - 25.0, difficulty + 25.0 );
}
return mob.CheckSkill( skill, difficulty - 25.0, difficulty + 25.0 );
}
private bool CheckDeed( Mobile from )
@ -126,39 +124,41 @@ namespace Server.Engines.Craft
|| ( weapon is ButcherKnife )
|| ( weapon is SkinningKnife );
}
else if ( m_CraftSystem is DefCarpentry )
if ( m_CraftSystem is DefCarpentry )
{
return ( weapon is Club )
|| ( weapon is BlackStaff )
|| ( weapon is MagicWand )
#region Temporary
// TODO: Make these items craftable
|| ( weapon is WildStaff );
|| ( weapon is BlackStaff )
|| ( weapon is MagicWand )
#region Temporary
// TODO: Make these items craftable
|| ( weapon is WildStaff );
#endregion
}
else if ( m_CraftSystem is DefBlacksmithy )
if ( m_CraftSystem is DefBlacksmithy )
{
return ( weapon is Pitchfork )
#region Temporary
// TODO: Make these items craftable
|| ( weapon is RadiantScimitar )
|| ( weapon is WarCleaver )
|| ( weapon is ElvenSpellblade )
|| ( weapon is AssassinSpike )
|| ( weapon is Leafblade )
|| ( weapon is RuneBlade )
|| ( weapon is ElvenMachete )
|| ( weapon is OrnateAxe )
|| ( weapon is DiamondMace );
#region Temporary
// TODO: Make these items craftable
|| ( weapon is RadiantScimitar )
|| ( weapon is WarCleaver )
|| ( weapon is ElvenSpellblade )
|| ( weapon is AssassinSpike )
|| ( weapon is Leafblade )
|| ( weapon is RuneBlade )
|| ( weapon is ElvenMachete )
|| ( weapon is OrnateAxe )
|| ( weapon is DiamondMace );
#endregion
}
#region Temporary
// TODO: Make these items craftable
else if ( m_CraftSystem is DefBowFletching )
if ( m_CraftSystem is DefBowFletching )
{
return ( weapon is ElvenCompositeLongbow )
|| ( weapon is MagicalShortbow );
|| ( weapon is MagicalShortbow );
}
#endregion
return false;
@ -184,23 +184,25 @@ namespace Server.Engines.Craft
|| ( armor is HidePants )
|| ( armor is HidePauldrons );
}
else if ( m_CraftSystem is DefCarpentry )
if ( m_CraftSystem is DefCarpentry )
{
return ( armor is WingedHelm )
|| ( armor is RavenHelm )
|| ( armor is VultureHelm )
|| ( armor is WoodlandArms )
|| ( armor is WoodlandChest )
|| ( armor is WoodlandGloves )
|| ( armor is WoodlandGorget )
|| ( armor is WoodlandLegs );
|| ( armor is RavenHelm )
|| ( armor is VultureHelm )
|| ( armor is WoodlandArms )
|| ( armor is WoodlandChest )
|| ( armor is WoodlandGloves )
|| ( armor is WoodlandGorget )
|| ( armor is WoodlandLegs );
}
else if ( m_CraftSystem is DefBlacksmithy )
if ( m_CraftSystem is DefBlacksmithy )
{
return ( armor is Circlet )
|| ( armor is RoyalCirclet )
|| ( armor is GemmedCirclet );
|| ( armor is RoyalCirclet )
|| ( armor is GemmedCirclet );
}
#endregion
return false;

View file

@ -35,7 +35,7 @@ namespace Server.Engines.Craft
{
if ( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
return 1044038; // You have worn out your tool!
else if ( !BaseTool.CheckAccessible( tool, from ) )
if ( !BaseTool.CheckAccessible( tool, from ) )
return 1044263; // The tool must be on your person to use.
return 0;
@ -65,27 +65,20 @@ namespace Server.Engines.Craft
from.AddToBackpack( new Bottle() );
return 500287; // You fail to create a useful potion.
}
else
{
return 1044043; // You failed to create the item, and some of your materials are lost.
}
}
else
{
from.PlaySound( 0x240 ); // Sound of a filling bottle
if ( IsPotion( item.ItemType ) )
{
if ( quality == -1 )
return 1048136; // You create the potion and pour it into a keg.
else
return 500279; // You pour the potion into a bottle...
}
else
{
return 1044154; // You create the item.
}
return 1044043; // You failed to create the item, and some of your materials are lost.
}
from.PlaySound( 0x240 ); // Sound of a filling bottle
if ( IsPotion( item.ItemType ) )
{
if ( quality == -1 )
return 1048136; // You create the potion and pour it into a keg.
return 500279; // You pour the potion into a bottle...
}
return 1044154; // You create the item.
}
public override void InitCraftList()

View file

@ -112,9 +112,9 @@ namespace Server.Engines.Craft
{
if ( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
return 1044038; // You have worn out your tool!
else if ( !BaseTool.CheckTool( tool, from ) )
if ( !BaseTool.CheckTool( tool, from ) )
return 1048146; // If you have a tool equipped, you must use that tool.
else if ( !BaseTool.CheckAccessible( tool, from ) )
if ( !BaseTool.CheckAccessible( tool, from ) )
return 1044263; // The tool must be on your person to use.
bool anvil, forge;
@ -161,20 +161,16 @@ namespace Server.Engines.Craft
{
if ( lostMaterial )
return 1044043; // You failed to create the item, and some of your materials are lost.
else
return 1044157; // You failed to create the item, but no materials were lost.
}
else
{
if ( quality == 0 )
return 502785; // You were barely able to make this item. It's quality is below average.
else if ( makersMark && quality == 2 )
return 1044156; // You create an exceptional quality item and affix your maker's mark.
else if ( quality == 2 )
return 1044155; // You create an exceptional quality item.
else
return 1044154; // You create the item.
return 1044157; // You failed to create the item, but no materials were lost.
}
if ( quality == 0 )
return 502785; // You were barely able to make this item. It's quality is below average.
if ( makersMark && quality == 2 )
return 1044156; // You create an exceptional quality item and affix your maker's mark.
if ( quality == 2 )
return 1044155; // You create an exceptional quality item.
return 1044154; // You create the item.
}
public override void InitCraftList()

View file

@ -35,7 +35,7 @@ namespace Server.Engines.Craft
{
if ( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
return 1044038; // You have worn out your tool!
else if ( !BaseTool.CheckAccessible( tool, from ) )
if ( !BaseTool.CheckAccessible( tool, from ) )
return 1044263; // The tool must be on your person to use.
return 0;
@ -59,20 +59,16 @@ namespace Server.Engines.Craft
{
if ( lostMaterial )
return 1044043; // You failed to create the item, and some of your materials are lost.
else
return 1044157; // You failed to create the item, but no materials were lost.
}
else
{
if ( quality == 0 )
return 502785; // You were barely able to make this item. It's quality is below average.
else if ( makersMark && quality == 2 )
return 1044156; // You create an exceptional quality item and affix your maker's mark.
else if ( quality == 2 )
return 1044155; // You create an exceptional quality item.
else
return 1044154; // You create the item.
return 1044157; // You failed to create the item, but no materials were lost.
}
if ( quality == 0 )
return 502785; // You were barely able to make this item. It's quality is below average.
if ( makersMark && quality == 2 )
return 1044156; // You create an exceptional quality item and affix your maker's mark.
if ( quality == 2 )
return 1044155; // You create an exceptional quality item.
return 1044154; // You create the item.
}
public override CraftECA ECA => CraftECA.FiftyPercentChanceMinusTenPercent;

View file

@ -35,7 +35,7 @@ namespace Server.Engines.Craft
{
if ( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
return 1044038; // You have worn out your tool!
else if ( !BaseTool.CheckAccessible( tool, from ) )
if ( !BaseTool.CheckAccessible( tool, from ) )
return 1044263; // The tool must be on your person to use.
return 0;
@ -59,20 +59,16 @@ namespace Server.Engines.Craft
{
if ( lostMaterial )
return 1044043; // You failed to create the item, and some of your materials are lost.
else
return 1044157; // You failed to create the item, but no materials were lost.
}
else
{
if ( quality == 0 )
return 502785; // You were barely able to make this item. It's quality is below average.
else if ( makersMark && quality == 2 )
return 1044156; // You create an exceptional quality item and affix your maker's mark.
else if ( quality == 2 )
return 1044155; // You create an exceptional quality item.
else
return 1044154; // You create the item.
return 1044157; // You failed to create the item, but no materials were lost.
}
if ( quality == 0 )
return 502785; // You were barely able to make this item. It's quality is below average.
if ( makersMark && quality == 2 )
return 1044156; // You create an exceptional quality item and affix your maker's mark.
if ( quality == 2 )
return 1044155; // You create an exceptional quality item.
return 1044154; // You create the item.
}
public override void InitCraftList()

View file

@ -35,7 +35,7 @@ namespace Server.Engines.Craft
{
if ( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
return 1044038; // You have worn out your tool!
else if ( !BaseTool.CheckAccessible( tool, from ) )
if ( !BaseTool.CheckAccessible( tool, from ) )
return 1044263; // The tool must be on your person to use.
return 0;
@ -55,20 +55,16 @@ namespace Server.Engines.Craft
{
if ( lostMaterial )
return 1044043; // You failed to create the item, and some of your materials are lost.
else
return 1044157; // You failed to create the item, but no materials were lost.
}
else
{
if ( quality == 0 )
return 502785; // You were barely able to make this item. It's quality is below average.
else if ( makersMark && quality == 2 )
return 1044156; // You create an exceptional quality item and affix your maker's mark.
else if ( quality == 2 )
return 1044155; // You create an exceptional quality item.
else
return 1044154; // You create the item.
return 1044157; // You failed to create the item, but no materials were lost.
}
if ( quality == 0 )
return 502785; // You were barely able to make this item. It's quality is below average.
if ( makersMark && quality == 2 )
return 1044156; // You create an exceptional quality item and affix your maker's mark.
if ( quality == 2 )
return 1044155; // You create an exceptional quality item.
return 1044154; // You create the item.
}
public override void InitCraftList()

View file

@ -37,7 +37,7 @@ namespace Server.Engines.Craft
{
if ( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
return 1044038; // You have worn out your tool!
else if ( !BaseTool.CheckAccessible( tool, from ) )
if ( !BaseTool.CheckAccessible( tool, from ) )
return 1044263; // The tool must be on your person to use.
return 0;
@ -56,20 +56,16 @@ namespace Server.Engines.Craft
{
if ( lostMaterial )
return 1044043; // You failed to create the item, and some of your materials are lost.
else
return 1044157; // You failed to create the item, but no materials were lost.
}
else
{
if ( quality == 0 )
return 502785; // You were barely able to make this item. It's quality is below average.
else if ( makersMark && quality == 2 )
return 1044156; // You create an exceptional quality item and affix your maker's mark.
else if ( quality == 2 )
return 1044155; // You create an exceptional quality item.
else
return 1044154; // You create the item.
return 1044157; // You failed to create the item, but no materials were lost.
}
if ( quality == 0 )
return 502785; // You were barely able to make this item. It's quality is below average.
if ( makersMark && quality == 2 )
return 1044156; // You create an exceptional quality item and affix your maker's mark.
if ( quality == 2 )
return 1044155; // You create an exceptional quality item.
return 1044154; // You create the item.
}
public override void InitCraftList()

View file

@ -91,22 +91,18 @@ namespace Server.Engines.Craft
{
if ( lostMaterial )
return 1044043; // You failed to create the item, and some of your materials are lost.
else
return 1044157; // You failed to create the item, but no materials were lost.
return 1044157; // You failed to create the item, but no materials were lost.
}
else
{
from.PlaySound( 0x41 ); // glass breaking
if ( quality == 0 )
return 502785; // You were barely able to make this item. It's quality is below average.
else if ( makersMark && quality == 2 )
return 1044156; // You create an exceptional quality item and affix your maker's mark.
else if ( quality == 2 )
return 1044155; // You create an exceptional quality item.
else
return 1044154; // You create the item.
}
from.PlaySound( 0x41 ); // glass breaking
if ( quality == 0 )
return 502785; // You were barely able to make this item. It's quality is below average.
if ( makersMark && quality == 2 )
return 1044156; // You create an exceptional quality item and affix your maker's mark.
if ( quality == 2 )
return 1044155; // You create an exceptional quality item.
return 1044154; // You create the item.
}
public override void InitCraftList()

View file

@ -82,28 +82,21 @@ namespace Server.Engines.Craft
{
if ( lostMaterial )
return 1044043; // You failed to create the item, and some of your materials are lost.
else
return 1044157; // You failed to create the item, but no materials were lost.
}
else
{
if ( quality == 0 )
return 502785; // You were barely able to make this item. It's quality is below average.
else if ( makersMark && quality == 2 )
return 1044156; // You create an exceptional quality item and affix your maker's mark.
else if ( quality == 2 )
return 1044155; // You create an exceptional quality item.
else
return 1044154; // You create the item.
return 1044157; // You failed to create the item, but no materials were lost.
}
if ( quality == 0 )
return 502785; // You were barely able to make this item. It's quality is below average.
if ( makersMark && quality == 2 )
return 1044156; // You create an exceptional quality item and affix your maker's mark.
if ( quality == 2 )
return 1044155; // You create an exceptional quality item.
return 1044154; // You create the item.
}
else
{
if ( failed )
return 501630; // You fail to inscribe the scroll, and the scroll is ruined.
else
return 501629; // You inscribe the spell and put the scroll in your backpack.
}
if ( failed )
return 501630; // You fail to inscribe the scroll, and the scroll is ruined.
return 501629; // You inscribe the spell and put the scroll in your backpack.
}
private int m_Circle, m_Mana;

View file

@ -84,20 +84,16 @@ namespace Server.Engines.Craft
{
if ( lostMaterial )
return 1044043; // You failed to create the item, and some of your materials are lost.
else
return 1044157; // You failed to create the item, but no materials were lost.
}
else
{
if ( quality == 0 )
return 502785; // You were barely able to make this item. It's quality is below average.
else if ( makersMark && quality == 2 )
return 1044156; // You create an exceptional quality item and affix your maker's mark.
else if ( quality == 2 )
return 1044155; // You create an exceptional quality item.
else
return 1044154; // You create the item.
return 1044157; // You failed to create the item, but no materials were lost.
}
if ( quality == 0 )
return 502785; // You were barely able to make this item. It's quality is below average.
if ( makersMark && quality == 2 )
return 1044156; // You create an exceptional quality item and affix your maker's mark.
if ( quality == 2 )
return 1044155; // You create an exceptional quality item.
return 1044154; // You create the item.
}
public override void InitCraftList()

View file

@ -37,7 +37,7 @@ namespace Server.Engines.Craft
{
if ( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
return 1044038; // You have worn out your tool!
else if ( !BaseTool.CheckAccessible( tool, from ) )
if ( !BaseTool.CheckAccessible( tool, from ) )
return 1044263; // The tool must be on your person to use.
return 0;
@ -79,20 +79,16 @@ namespace Server.Engines.Craft
{
if ( lostMaterial )
return 1044043; // You failed to create the item, and some of your materials are lost.
else
return 1044157; // You failed to create the item, but no materials were lost.
}
else
{
if ( quality == 0 )
return 502785; // You were barely able to make this item. It's quality is below average.
else if ( makersMark && quality == 2 )
return 1044156; // You create an exceptional quality item and affix your maker's mark.
else if ( quality == 2 )
return 1044155; // You create an exceptional quality item.
else
return 1044154; // You create the item.
return 1044157; // You failed to create the item, but no materials were lost.
}
if ( quality == 0 )
return 502785; // You were barely able to make this item. It's quality is below average.
if ( makersMark && quality == 2 )
return 1044156; // You create an exceptional quality item and affix your maker's mark.
if ( quality == 2 )
return 1044155; // You create an exceptional quality item.
return 1044154; // You create the item.
}
public override void InitCraftList()

View file

@ -40,9 +40,9 @@ namespace Server.Engines.Craft
{
if ( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
return 1044038; // You have worn out your tool!
else if ( !BaseTool.CheckAccessible( tool, from ) )
if ( !BaseTool.CheckAccessible( tool, from ) )
return 1044263; // The tool must be on your person to use.
else if ( itemType != null && ( itemType.IsSubclassOf( typeof( BaseFactionTrapDeed ) ) || itemType == typeof( FactionTrapRemovalKit ) ) && Faction.Find( from ) == null )
if ( itemType != null && ( itemType.IsSubclassOf( typeof( BaseFactionTrapDeed ) ) || itemType == typeof( FactionTrapRemovalKit ) ) && Faction.Find( from ) == null )
return 1044573; // You have to be in a faction to do that.
return 0;
@ -91,20 +91,16 @@ namespace Server.Engines.Craft
{
if ( lostMaterial )
return 1044043; // You failed to create the item, and some of your materials are lost.
else
return 1044157; // You failed to create the item, but no materials were lost.
}
else
{
if ( quality == 0 )
return 502785; // You were barely able to make this item. It's quality is below average.
else if ( makersMark && quality == 2 )
return 1044156; // You create an exceptional quality item and affix your maker's mark.
else if ( quality == 2 )
return 1044155; // You create an exceptional quality item.
else
return 1044154; // You create the item.
return 1044157; // You failed to create the item, but no materials were lost.
}
if ( quality == 0 )
return 502785; // You were barely able to make this item. It's quality is below average.
if ( makersMark && quality == 2 )
return 1044156; // You create an exceptional quality item and affix your maker's mark.
if ( quality == 2 )
return 1044155; // You create an exceptional quality item.
return 1044154; // You create the item.
}
public override bool ConsumeOnFailure( Mobile from, Type resourceType, CraftItem craftItem )
@ -417,11 +413,9 @@ namespace Server.Engines.Craft
{
return false;
}
else
{
m_Container = container;
return true;
}
m_Container = container;
return true;
}
public override void EndCraftAction()