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

View File

@@ -8,15 +8,15 @@ if (!defined('AOWOW_REVISION'))
class Game class Game
{ {
public static $resistanceFields = array( public static array $resistanceFields = array(
null, 'resHoly', 'resFire', 'resNature', 'resFrost', 'resShadow', 'resArcane' 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' '9d9d9d', 'ffffff', '1eff00', '0070dd', 'a335ee', 'ff8000', 'e5cc80', 'e6cc80'
); );
public static $specIconStrings = array( public static array $specIconStrings = array(
-1 => 'inv_misc_questionmark', -1 => 'inv_misc_questionmark',
0 => 'spell_nature_elementalabsorption', 0 => 'spell_nature_elementalabsorption',
6 => ['spell_deathknight_bloodpresence', 'spell_deathknight_frostpresence', 'spell_deathknight_unholypresence' ], 6 => ['spell_deathknight_bloodpresence', 'spell_deathknight_frostpresence', 'spell_deathknight_unholypresence' ],
@@ -48,7 +48,7 @@ class Game
// zoneorsort for quests need updating // zoneorsort for quests need updating
// partially points non-instanced area with identical name for instance quests // 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 -221 => 440, // Treasure Map => Tanaris
-284 => 0, // Special => Misc (some quests get shuffled into seasonal) -284 => 0, // Special => Misc (some quests get shuffled into seasonal)
151 => 0, // Designer Island => Misc 151 => 0, // Designer Island => Misc
@@ -86,7 +86,7 @@ class Game
1417 => 1477 // Sunken Temple 1417 => 1477 // Sunken Temple
); );
public static $questSubCats = array( public static array $questSubCats = array(
1 => [132], // Dun Morogh: Coldridge Valley 1 => [132], // Dun Morogh: Coldridge Valley
12 => [9], // Elwynn Forest: Northshire Valley 12 => [9], // Elwynn Forest: Northshire Valley
141 => [188], // Teldrassil: Shadowglen 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.. 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 .. 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 => 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 [ 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 [ 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' 'meta', 'red', 'yellow', 'blue'
); );
public static function getReputationLevelForPoints($pts) public static function getReputationLevelForPoints(int $pts) : int
{ {
if ($pts >= 41999) if ($pts >= 41999)
return REP_EXALTED; return REP_EXALTED;
else if ($pts >= 20999) if ($pts >= 20999)
return REP_REVERED; return REP_REVERED;
else if ($pts >= 8999) if ($pts >= 8999)
return REP_HONORED; return REP_HONORED;
else if ($pts >= 2999) if ($pts >= 2999)
return REP_FRIENDLY; return REP_FRIENDLY;
else if ($pts >= 0) if ($pts >= 0)
return REP_NEUTRAL; return REP_NEUTRAL;
else if ($pts >= -3000) if ($pts >= -3000)
return REP_UNFRIENDLY; return REP_UNFRIENDLY;
else if ($pts >= -6000) if ($pts >= -6000)
return REP_HOSTILE; return REP_HOSTILE;
else
return REP_HATED; 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 $extraIds = [-1]; // init with -1 to prevent empty-array errors
$lookup = [-1]; $lookup = [-1];

View File

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

View File

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