Динамический рассчёт стоимости товара в инвентаре. #40.
This commit is contained in:
parent
326d93f259
commit
7c7ac67ddb
@ -101,6 +101,28 @@ class Item
|
|||||||
default:
|
default:
|
||||||
$this->typename = 'Хлам';
|
$this->typename = 'Хлам';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$sum_stats =
|
||||||
|
$this->add_strength +
|
||||||
|
$this->add_dexterity +
|
||||||
|
$this->add_intuition +
|
||||||
|
$this->add_endurance +
|
||||||
|
$this->add_intelligence +
|
||||||
|
$this->add_wisdom;
|
||||||
|
$sum_mods =
|
||||||
|
$this->add_accuracy +
|
||||||
|
$this->add_evasion +
|
||||||
|
$this->add_criticals;
|
||||||
|
$sum_damage =
|
||||||
|
$this->add_min_physical_damage +
|
||||||
|
$this->add_max_physical_damage;
|
||||||
|
// За каждые N параметров повышаем множитель на 1 чтобы цена пропрорционально росла.
|
||||||
|
$stats_cost_modifier = 5 + floor($sum_stats / 10);
|
||||||
|
$mods_cost_modifier = 2 + floor($sum_mods / 50);
|
||||||
|
$damage_cost_modifier = 1 + floor($sum_damage / 100);
|
||||||
|
$result = intval($sum_stats * $stats_cost_modifier + $sum_mods * $mods_cost_modifier + $sum_damage * $damage_cost_modifier);
|
||||||
|
|
||||||
|
$this->item_cost = $result < 1 ? 1 : $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function wrap(int $number): string
|
protected function wrap(int $number): string
|
||||||
@ -134,6 +156,7 @@ class Item
|
|||||||
"Шанс крита" => $this->add_criticals,
|
"Шанс крита" => $this->add_criticals,
|
||||||
];
|
];
|
||||||
echo "<b>$this->name</b> (Масса: $this->weight)";
|
echo "<b>$this->name</b> (Масса: $this->weight)";
|
||||||
|
echo "<br> Стоимость: " . $this->item_cost;
|
||||||
echo "<br> Долговечность: " . $this->durability;
|
echo "<br> Долговечность: " . $this->durability;
|
||||||
echo "<br><em>$this->typename</em><br>";
|
echo "<br><em>$this->typename</em><br>";
|
||||||
foreach ($needsLines as $stat => $value) {
|
foreach ($needsLines as $stat => $value) {
|
||||||
|
Loading…
Reference in New Issue
Block a user