Codestyle/Cleanup

This commit is contained in:
Sarjuuk
2025-10-05 00:28:27 +02:00
parent eb95b03e31
commit baf4ba5b98
4 changed files with 55 additions and 88 deletions

View File

@@ -546,22 +546,17 @@ class StatsContainer implements \Countable
case ENCHANTMENT_TYPE_STAT: // ITEM_MOD_*
return [Stat::getIndexFrom(Stat::IDX_ITEM_MOD, $object)];
case ENCHANTMENT_TYPE_RESISTANCE:
if ($object == SPELL_SCHOOL_NORMAL)
return [Stat::ARMOR];
if ($object == SPELL_SCHOOL_HOLY)
return [Stat::HOLY_RESISTANCE];
if ($object == SPELL_SCHOOL_FIRE)
return [Stat::FIRE_RESISTANCE];
if ($object == SPELL_SCHOOL_NATURE)
return [Stat::NATURE_RESISTANCE];
if ($object == SPELL_SCHOOL_FROST)
return [Stat::FROST_RESISTANCE];
if ($object == SPELL_SCHOOL_SHADOW)
return [Stat::SHADOW_RESISTANCE];
if ($object == SPELL_SCHOOL_ARCANE)
return [Stat::ARCANE_RESISTANCE];
return [];
return match ($object)
{
SPELL_SCHOOL_NORMAL => [Stat::ARMOR],
SPELL_SCHOOL_HOLY => [Stat::HOLY_RESISTANCE],
SPELL_SCHOOL_FIRE => [Stat::FIRE_RESISTANCE],
SPELL_SCHOOL_NATURE => [Stat::NATURE_RESISTANCE],
SPELL_SCHOOL_FROST => [Stat::FROST_RESISTANCE],
SPELL_SCHOOL_SHADOW => [Stat::SHADOW_RESISTANCE],
SPELL_SCHOOL_ARCANE => [Stat::ARCANE_RESISTANCE],
default => []
};
case ENCHANTMENT_TYPE_EQUIP_SPELL: // handled one level up
case ENCHANTMENT_TYPE_COMBAT_SPELL: // we do not average effects, so skip
case ENCHANTMENT_TYPE_USE_SPELL:
@@ -602,20 +597,15 @@ class StatsContainer implements \Countable
switch ($auraId)
{
case SPELL_AURA_MOD_STAT:
if ($miscValue < 0) // all stats
return [Stat::AGILITY, Stat::STRENGTH, Stat::INTELLECT, Stat::SPIRIT, Stat::STAMINA];
if ($miscValue == STAT_STRENGTH) // one stat
return [Stat::STRENGTH];
if ($miscValue == STAT_AGILITY)
return [Stat::AGILITY];
if ($miscValue == STAT_STAMINA)
return [Stat::STAMINA];
if ($miscValue == STAT_INTELLECT)
return [Stat::INTELLECT];
if ($miscValue == STAT_SPIRIT)
return [Stat::SPIRIT];
return []; // one bullshit
return match ($miscValue)
{
STAT_STRENGTH => [Stat::STRENGTH],
STAT_AGILITY => [Stat::AGILITY],
STAT_STAMINA => [Stat::STAMINA],
STAT_INTELLECT => [Stat::INTELLECT],
STAT_SPIRIT => [Stat::SPIRIT],
default => $miscValue < 0 ? [Stat::AGILITY, Stat::STRENGTH, Stat::INTELLECT, Stat::SPIRIT, Stat::STAMINA] : []
};
case SPELL_AURA_MOD_INCREASE_HEALTH:
case SPELL_AURA_MOD_INCREASE_HEALTH_NONSTACK:
case SPELL_AURA_MOD_INCREASE_HEALTH_2:
@@ -629,27 +619,16 @@ class StatsContainer implements \Countable
if ($miscValue == SPELL_MAGIC_SCHOOLS)
return [Stat::DAMAGE_SPELL_POWER];
// HolySpellpower (deprecated; still used in randomproperties)
if ($miscValue & (1 << SPELL_SCHOOL_HOLY))
$stats[] = Stat::HOLY_SPELL_POWER;
// FireSpellpower (deprecated; still used in randomproperties)
if ($miscValue & (1 << SPELL_SCHOOL_FIRE))
$stats[] = Stat::FIRE_SPELL_POWER;
// NatureSpellpower (deprecated; still used in randomproperties)
if ($miscValue & (1 << SPELL_SCHOOL_NATURE))
$stats[] = Stat::NATURE_SPELL_POWER;
// FrostSpellpower (deprecated; still used in randomproperties)
if ($miscValue & (1 << SPELL_SCHOOL_FROST))
$stats[] = Stat::FROST_SPELL_POWER;
// ShadowSpellpower (deprecated; still used in randomproperties)
if ($miscValue & (1 << SPELL_SCHOOL_SHADOW))
$stats[] = Stat::SHADOW_SPELL_POWER;
// ArcaneSpellpower (deprecated; still used in randomproperties)
if ($miscValue & (1 << SPELL_SCHOOL_ARCANE))
$stats[] = Stat::ARCANE_SPELL_POWER;
@@ -657,16 +636,14 @@ class StatsContainer implements \Countable
case SPELL_AURA_MOD_HEALING_DONE: // not as a mask..
return [Stat::HEALING_SPELL_POWER];
case SPELL_AURA_MOD_INCREASE_ENERGY: // MiscVal:type see defined Powers only energy/mana in use
if ($miscValue == POWER_ENERGY)
return [Stat::ENERGY];
if ($miscValue == POWER_RAGE)
return [Stat::RAGE];
if ($miscValue == POWER_MANA)
return [Stat::MANA];
if ($miscValue == POWER_RUNIC_POWER)
return [Stat::RUNIC_POWER];
return [];
return match ($miscValue)
{
POWER_ENERGY => [Stat::ENERGY],
POWER_RAGE => [Stat::RAGE],
POWER_MANA => [Stat::MANA],
POWER_RUNIC_POWER => [Stat::RUNIC_POWER],
default => []
};
case SPELL_AURA_MOD_RATING:
case SPELL_AURA_MOD_RATING_FROM_STAT:
if ($stat = self::convertCombatRating($miscValue))

View File

@@ -8,15 +8,15 @@ if (!defined('AOWOW_REVISION'))
class Game
{
public static $resistanceFields = array(
public static array $resistanceFields = array(
null, 'resHoly', 'resFire', 'resNature', 'resFrost', 'resShadow', 'resArcane'
);
public static $rarityColorStings = array( // zero-indexed
public static array $rarityColorStings = array( // zero-indexed
'9d9d9d', 'ffffff', '1eff00', '0070dd', 'a335ee', 'ff8000', 'e5cc80', 'e6cc80'
);
public static $specIconStrings = array(
public static array $specIconStrings = array(
-1 => 'inv_misc_questionmark',
0 => 'spell_nature_elementalabsorption',
6 => ['spell_deathknight_bloodpresence', 'spell_deathknight_frostpresence', 'spell_deathknight_unholypresence' ],
@@ -48,7 +48,7 @@ class Game
// zoneorsort for quests need updating
// partially points non-instanced area with identical name for instance quests
public static $questSortFix = array(
public static array $questSortFix = array(
-221 => 440, // Treasure Map => Tanaris
-284 => 0, // Special => Misc (some quests get shuffled into seasonal)
151 => 0, // Designer Island => Misc
@@ -86,7 +86,7 @@ class Game
1417 => 1477 // Sunken Temple
);
public static $questSubCats = array(
public static array $questSubCats = array(
1 => [132], // Dun Morogh: Coldridge Valley
12 => [9], // Elwynn Forest: Northshire Valley
141 => [188], // Teldrassil: Shadowglen
@@ -113,7 +113,7 @@ class Game
Because this is more or less the only reaonable way to fit all that information into one database field, so..
.. the indizes of this array are bits of skillLine2OrMask in ?_spell if skillLineId1 is negative
*/
public static $skillLineMask = array( // idx => [familyId, skillLineId]
public static array $skillLineMask = array( // idx => [familyId, skillLineId]
-1 => array( // Pets (Hunter)
[ 1, 208], [ 2, 209], [ 3, 203], [ 4, 210], [ 5, 211], [ 6, 212], [ 7, 213], // Wolf, Cat, Spider, Bear, Boar, Crocolisk, Carrion Bird
[ 8, 214], [ 9, 215], [11, 217], [12, 218], [20, 236], [21, 251], [24, 653], // Crab, Gorilla, Raptor, Tallstrider, Scorpid, Turtle, Bat
@@ -129,31 +129,31 @@ class Game
)
);
public static $sockets = array( // jsStyle Strings
public static array $sockets = array( // jsStyle Strings
'meta', 'red', 'yellow', 'blue'
);
public static function getReputationLevelForPoints($pts)
public static function getReputationLevelForPoints(int $pts) : int
{
if ($pts >= 41999)
return REP_EXALTED;
else if ($pts >= 20999)
if ($pts >= 20999)
return REP_REVERED;
else if ($pts >= 8999)
if ($pts >= 8999)
return REP_HONORED;
else if ($pts >= 2999)
if ($pts >= 2999)
return REP_FRIENDLY;
else if ($pts >= 0)
if ($pts >= 0)
return REP_NEUTRAL;
else if ($pts >= -3000)
if ($pts >= -3000)
return REP_UNFRIENDLY;
else if ($pts >= -6000)
if ($pts >= -6000)
return REP_HOSTILE;
else
return REP_HATED;
}
public static function getTaughtSpells(&$spell)
public static function getTaughtSpells(mixed &$spell) : array
{
$extraIds = [-1]; // init with -1 to prevent empty-array errors
$lookup = [-1];

View File

@@ -152,24 +152,14 @@ abstract class CLI
if ($timestamp)
$msg = str_pad(date('H:i:s'), 10);
switch ($lvl)
$msg .= match ($lvl)
{
case self::LOG_ERROR: // red critical error
$msg .= '['.self::red('ERR').'] ';
break;
case self::LOG_WARN: // yellow notice
$msg .= '['.self::yellow('WARN').'] ';
break;
case self::LOG_OK: // green success
$msg .= '['.self::green('OK').'] ';
break;
case self::LOG_INFO: // blue info
$msg .= '['.self::blue('INFO').'] ';
break;
case self::LOG_BLANK:
$msg .= ' ';
break;
}
self::LOG_ERROR => '['.self::red('ERR').'] ', // red critical error
self::LOG_WARN => '['.self::yellow('WARN').'] ', // yellow notice
self::LOG_OK => '['.self::green('OK').'] ', // green success
self::LOG_INFO => '['.self::blue('INFO').'] ', // blue info
default => ' '
};
$msg .= $txt;
}

View File

@@ -8,9 +8,9 @@ if (!defined('AOWOW_REVISION'))
class Timer
{
private $t_cur = 0;
private $t_new = 0;
private $intv = 0;
private float $t_cur = 0;
private float $t_new = 0;
private float $intv = 0;
public function __construct(int $intervall)
{