StatWeights/Fixup
* move weightable stats from Util to Stat * align what stats can be saved in weightscales to match javascript
This commit is contained in:
parent
00f048d3ae
commit
9d187e8d4c
5 changed files with 19 additions and 25 deletions
|
|
@ -88,7 +88,7 @@ class AccountWeightscalesResponse extends TextResponse
|
|||
return false;
|
||||
|
||||
foreach ($this->_post['scale'] as [$k, $v])
|
||||
if (in_array($k, Util::$weightScales)) // $v is known to be a positive int due to regex check
|
||||
if (Stat::getWeightJson($k)) // $v is known to be a positive int due to regex check
|
||||
if (!is_int(DB::Aowow()->query('INSERT INTO ?_account_weightscale_data VALUES (?d, ?, ?d)', $scaleId, $k, $v)))
|
||||
return false;
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class AdminWeightpresetsActionSaveResponse extends TextResponse
|
|||
{
|
||||
[$k, $v] = explode(':', $s);
|
||||
|
||||
if (!in_array($k, Util::$weightScales) || $v < 1)
|
||||
if (!Stat::getWeightJson($k) || $v < 1)
|
||||
continue;
|
||||
|
||||
if (DB::Aowow()->query('INSERT INTO ?_account_weightscale_data VALUES (?d, ?, ?d)', $this->_post['id'], $k, $v) === null)
|
||||
|
|
|
|||
|
|
@ -2018,9 +2018,8 @@ class ItemListFilter extends Filter
|
|||
|
||||
foreach ($this->values['wt'] as $k => $v)
|
||||
{
|
||||
if ($idx = Stat::getIndexFrom(Stat::IDX_FILTER_CR_ID, $v))
|
||||
if ($str = Stat::getWeightJson($v))
|
||||
{
|
||||
$str = Stat::getJsonString($idx);
|
||||
$qty = intVal($this->values['wtv'][$k]);
|
||||
|
||||
$select[] = '(IFNULL(`is`.`'.$str.'`, 0) * '.$qty.')';
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ abstract class Stat // based on g_statTo
|
|||
public const FLAG_PROFILER = 0x04; // stat used in profiler only
|
||||
public const FLAG_LVL_SCALING = 0x08; // rating effectivenes scales with level
|
||||
public const FLAG_FLOAT_VALUE = 0x10; // not an int
|
||||
public const FLAG_NO_WEIGHT = 0x20; // for item summary and filter .. basically any fi_filters.items of type: num thats not excluded by noweights: 1 is weightable
|
||||
|
||||
public const IDX_JSON_STR = 0;
|
||||
public const IDX_ITEM_MOD = 1; // granted by items
|
||||
|
|
@ -123,7 +124,7 @@ abstract class Stat // based on g_statTo
|
|||
public const IDX_FILTER_CR_ID = 3; // also references listview cols
|
||||
public const IDX_FLAGS = 4;
|
||||
|
||||
private static /* array */ $data = array(
|
||||
private static array $data = array(
|
||||
self::HEALTH => ['health', ITEM_MOD_HEALTH, null, 115, self::FLAG_ITEM],
|
||||
self::MANA => ['mana', ITEM_MOD_MANA, null, 116, self::FLAG_ITEM],
|
||||
self::AGILITY => ['agi', ITEM_MOD_AGILITY, null, 21, self::FLAG_ITEM],
|
||||
|
|
@ -188,7 +189,7 @@ abstract class Stat // based on g_statTo
|
|||
self::ARCANE_SPELL_POWER => ['arcsplpwr', null, null, 52, self::FLAG_ITEM],
|
||||
// v not part of g_statToJson v
|
||||
self::WEAPON_DAMAGE => ['dmg', null, null, null, self::FLAG_SERVERSIDE | self::FLAG_FLOAT_VALUE],
|
||||
self::WEAPON_DAMAGE_TYPE => ['damagetype', null, null, 35, self::FLAG_SERVERSIDE],
|
||||
self::WEAPON_DAMAGE_TYPE => ['damagetype', null, null, 35, self::FLAG_SERVERSIDE | self::FLAG_NO_WEIGHT],
|
||||
self::WEAPON_DAMAGE_MIN => ['dmgmin1', null, null, 33, self::FLAG_SERVERSIDE],
|
||||
self::WEAPON_DAMAGE_MAX => ['dmgmax1', null, null, 34, self::FLAG_SERVERSIDE],
|
||||
self::WEAPON_SPEED => ['speed', null, null, 36, self::FLAG_SERVERSIDE | self::FLAG_FLOAT_VALUE],
|
||||
|
|
@ -201,7 +202,7 @@ abstract class Stat // based on g_statTo
|
|||
self::RANGED_DAMAGE_MAX => ['rgddmgmax', null, null, 140, self::FLAG_SERVERSIDE],
|
||||
self::RANGED_SPEED => ['rgdspeed', null, null, 141, self::FLAG_SERVERSIDE | self::FLAG_FLOAT_VALUE],
|
||||
self::RANGED_DPS => ['rgddps', null, null, 138, self::FLAG_SERVERSIDE | self::FLAG_FLOAT_VALUE | self::FLAG_PROFILER],
|
||||
self::EXTRA_SOCKETS => ['nsockets', null, null, 100, self::FLAG_SERVERSIDE],
|
||||
self::EXTRA_SOCKETS => ['nsockets', null, null, 100, self::FLAG_SERVERSIDE | self::FLAG_NO_WEIGHT],
|
||||
self::ARMOR_BONUS => ['armorbonus', null, null, 109, self::FLAG_SERVERSIDE],
|
||||
self::MELEE_ATTACK_POWER => ['mleatkpwr', null, null, 37, self::FLAG_SERVERSIDE | self::FLAG_PROFILER],
|
||||
// v Profiler only v
|
||||
|
|
@ -248,6 +249,16 @@ abstract class Stat // based on g_statTo
|
|||
return !(self::$data[$stat][self::IDX_FLAGS] & self::FLAG_LVL_SCALING);
|
||||
}
|
||||
|
||||
public static function getWeightJson(string|int $jsonOrCriteriaId) : string
|
||||
{
|
||||
if (is_numeric($jsonOrCriteriaId))
|
||||
$row = array_find(self::$data, fn($x) => $x[self::IDX_FILTER_CR_ID] == $jsonOrCriteriaId);
|
||||
else
|
||||
$row = array_find(self::$data, fn($x) => $x[self::IDX_JSON_STR] == $jsonOrCriteriaId);
|
||||
|
||||
return $row && $row[self::IDX_FILTER_CR_ID] && !($row[self::IDX_FLAGS] & self::FLAG_NO_WEIGHT) ? $row[self::IDX_JSON_STR] : '';
|
||||
}
|
||||
|
||||
public static function getRatingPctFactor(int $stat) : float
|
||||
{
|
||||
// Note: this makes the weapon skill related combat ratings inaccessible. Is this relevant..?
|
||||
|
|
@ -315,13 +326,9 @@ abstract class Stat // based on g_statTo
|
|||
return $x;
|
||||
}
|
||||
|
||||
public static function getIndexFrom(int $idx, string $match) : int
|
||||
public static function getIndexFrom(int $idx, string $search) : int
|
||||
{
|
||||
$i = array_search($match, array_column(self::$data, $idx));
|
||||
if ($i === false)
|
||||
return 0;
|
||||
|
||||
return array_keys(self::$data)[$i];
|
||||
return array_find_key(self::$data, fn($x) => $x[$idx] == $search) ?: 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -69,18 +69,6 @@ abstract class Util
|
|||
'clothChestArmor', 'leatherChestArmor', 'mailChestArmor', 'plateChestArmor'
|
||||
);
|
||||
|
||||
public static $weightScales = array(
|
||||
'agi', 'int', 'sta', 'spi', 'str', 'health', 'mana', 'healthrgn', 'manargn',
|
||||
'armor', 'blockrtng', 'block', 'defrtng', 'dodgertng', 'parryrtng', 'resirtng',
|
||||
'atkpwr', 'feratkpwr', 'armorpenrtng', 'critstrkrtng', 'exprtng', 'hastertng', 'hitrtng', 'splpen',
|
||||
'splpwr', 'arcsplpwr', 'firsplpwr', 'frosplpwr', 'holsplpwr', 'natsplpwr', 'shasplpwr',
|
||||
'dmg', 'mledps', 'rgddps', 'mledmgmin', 'rgddmgmin', 'mledmgmax', 'rgddmgmax', 'mlespeed', 'rgdspeed',
|
||||
'arcres', 'firres', 'frores', 'holres', 'natres', 'shares',
|
||||
'mleatkpwr', 'mlecritstrkrtng', 'mlehastertng', 'mlehitrtng', 'rgdatkpwr', 'rgdcritstrkrtng', 'rgdhastertng', 'rgdhitrtng',
|
||||
'splcritstrkrtng', 'splhastertng', 'splhitrtng', 'spldmg', 'splheal',
|
||||
'nsockets'
|
||||
);
|
||||
|
||||
public static $dateFormatInternal = "Y/m/d H:i:s";
|
||||
|
||||
public static $changeLevelString = '<a href="javascript:;" onmousedown="return false" class="tip" style="color: white; cursor: pointer" onclick="$WH.g_staticTooltipLevelClick(this, null, 0)" onmouseover="$WH.Tooltip.showAtCursor(event, \'<span class=\\\'q2\\\'>\' + LANG.tooltip_changelevel + \'</span>\')" onmousemove="$WH.Tooltip.cursorUpdate(event)" onmouseout="$WH.Tooltip.hide()"><!--lvl-->%s</a>';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue