Add math and classes to install
This commit is contained in:
parent
c689f37afc
commit
247d5dc461
|
@ -174,6 +174,35 @@ function second()
|
||||||
|
|
||||||
$page .= table_status_msg($query === true, 'Drops', 'populate');
|
$page .= table_status_msg($query === true, 'Drops', 'populate');
|
||||||
|
|
||||||
|
$query = db()->exec(<<<SQL
|
||||||
|
CREATE TABLE classes (
|
||||||
|
'id' INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
'name' TEXT NOT NULL,
|
||||||
|
'lore' TEXT NOT NULL,
|
||||||
|
'exp_rate' INTEGER NOT NULL DEFAULT 3,
|
||||||
|
'base_hp' INTEGER NOT NULL DEFAULT 15,
|
||||||
|
'base_mp' INTEGER NOT NULL DEFAULT 10,
|
||||||
|
'base_str' INTEGER NOT NULL DEFAULT 1,
|
||||||
|
'base_dex' INTEGER NOT NULL DEFAULT 1,
|
||||||
|
'hp_rate' INTEGER NOT NULL DEFAULT 2,
|
||||||
|
'mp_rate' INTEGER NOT NULL DEFAULT 2,
|
||||||
|
'str_rate' INTEGER NOT NULL DEFAULT 2,
|
||||||
|
'dex_rate' INTEGER NOT NULL DEFAULT 2,
|
||||||
|
);
|
||||||
|
SQL);
|
||||||
|
|
||||||
|
$page .= table_status_msg($query === true, 'Classes', 'create');
|
||||||
|
|
||||||
|
$query = db()->exec(<<<SQL
|
||||||
|
INSERT INTO classes VALUES
|
||||||
|
(1, 'Adventurer', '', 3, 15, 10, 4, 4, 2, 2, 2, 2),
|
||||||
|
(2, 'Mage', '', 1, 10, 15, 1, 7, 1, 3, 1, 2),
|
||||||
|
(2, 'Warrior', '', 2, 20, 5, 7, 1, 3, 1, 3, 1),
|
||||||
|
(3, 'Paladin', '', 5, 15, 15, 5, 5, 2, 2, 2, 2);
|
||||||
|
SQL);
|
||||||
|
|
||||||
|
$page .= table_status_msg($query === true, 'Classes', 'populate');
|
||||||
|
|
||||||
$query = db()->exec(<<<SQL
|
$query = db()->exec(<<<SQL
|
||||||
CREATE TABLE levels (
|
CREATE TABLE levels (
|
||||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
@ -576,6 +605,7 @@ function second()
|
||||||
`latitude` INTEGER NOT NULL default 0,
|
`latitude` INTEGER NOT NULL default 0,
|
||||||
`longitude` INTEGER NOT NULL default 0,
|
`longitude` INTEGER NOT NULL default 0,
|
||||||
`charclass` INTEGER NOT NULL default 0,
|
`charclass` INTEGER NOT NULL default 0,
|
||||||
|
'class_id' INTEGER NOT NULL DEFAULT 1,
|
||||||
`currentaction` TEXT NOT NULL default 'In Town',
|
`currentaction` TEXT NOT NULL default 'In Town',
|
||||||
`currentfight` INTEGER NOT NULL default 0,
|
`currentfight` INTEGER NOT NULL default 0,
|
||||||
`currentmonster` INTEGER NOT NULL default 0,
|
`currentmonster` INTEGER NOT NULL default 0,
|
||||||
|
|
18
src/math.php
18
src/math.php
|
@ -9,7 +9,7 @@ namespace Math;
|
||||||
/**
|
/**
|
||||||
* Calculates the ***total*** EXP required at a particular level in order to level up.
|
* Calculates the ***total*** EXP required at a particular level in order to level up.
|
||||||
*/
|
*/
|
||||||
function calculate_exp(int $level, int $growthRate): int
|
function calculate_exp(int $level, int $growth_rate): int
|
||||||
{
|
{
|
||||||
if ($level < 1) throw new \InvalidArgumentException("Level must be 1 or greater");
|
if ($level < 1) throw new \InvalidArgumentException("Level must be 1 or greater");
|
||||||
|
|
||||||
|
@ -21,9 +21,9 @@ function calculate_exp(int $level, int $growthRate): int
|
||||||
// 4 = Slow
|
// 4 = Slow
|
||||||
// 5 = Fluctuating
|
// 5 = Fluctuating
|
||||||
|
|
||||||
if ($growthRate < 0 || $growthRate > 5) throw new \InvalidArgumentException("Growth rate must be between 0 and 5");
|
if ($growth_rate < 0 || $growth_rate > 5) throw new \InvalidArgumentException("Growth rate must be between 0 and 5");
|
||||||
|
|
||||||
return match($growthRate) {
|
return match($growth_rate) {
|
||||||
0 => calculate_erratic_exp($level),
|
0 => calculate_erratic_exp($level),
|
||||||
1 => (4 * pow($level, 3)) / 5,
|
1 => (4 * pow($level, 3)) / 5,
|
||||||
2 => pow($level, 3),
|
2 => pow($level, 3),
|
||||||
|
@ -71,9 +71,9 @@ function calculate_points(int $base_points, int $level, int $mode = 2): int
|
||||||
if ($level < 1) throw new \InvalidArgumentException("Level must be 1 or greater");
|
if ($level < 1) throw new \InvalidArgumentException("Level must be 1 or greater");
|
||||||
|
|
||||||
$growth_multiplier = match($mode) {
|
$growth_multiplier = match($mode) {
|
||||||
1 => 0.75,
|
1 => 0.15,
|
||||||
2 => 1.0,
|
2 => 0.3,
|
||||||
3 => 1.5,
|
3 => 0.6,
|
||||||
default => throw new \InvalidArgumentException("Invalid mode. Use 1 (weak), 2 (normal), or 3 (strong)")
|
default => throw new \InvalidArgumentException("Invalid mode. Use 1 (weak), 2 (normal), or 3 (strong)")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -88,9 +88,9 @@ function calculate_stat(int $base_stat, int $level, int $mode = 2): int
|
||||||
if ($level < 1) throw new \InvalidArgumentException("Level must be 1 or greater");
|
if ($level < 1) throw new \InvalidArgumentException("Level must be 1 or greater");
|
||||||
|
|
||||||
$growth_multiplier = match($mode) {
|
$growth_multiplier = match($mode) {
|
||||||
1 => 0.75,
|
1 => 0.15,
|
||||||
2 => 1.0,
|
2 => 0.3,
|
||||||
3 => 1.5,
|
3 => 0.6,
|
||||||
default => throw new \InvalidArgumentException("Invalid mode. Use 1 (weak), 2 (normal), or 3 (strong)")
|
default => throw new \InvalidArgumentException("Invalid mode. Use 1 (weak), 2 (normal), or 3 (strong)")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user