Fertigkeiten: Praxispunkte (10 Kaestchen) und Wuergel je Fertigkeitsstufe in Bogen und PDF
This commit is contained in:
parent
3a5d366aba
commit
85fd24a0f0
10 changed files with 185 additions and 7 deletions
|
|
@ -344,7 +344,7 @@ function skills_catalog_delete(int $id): void
|
|||
function character_skills(int $characterId): array
|
||||
{
|
||||
$stmt = db()->prepare(
|
||||
"SELECT cs.id, cs.character_id, cs.skill_id, cs.name, cs.bonus, cs.note,
|
||||
"SELECT cs.id, cs.character_id, cs.skill_id, cs.name, cs.bonus, cs.note, cs.pp,
|
||||
COALESCE(NULLIF(cs.attribute, ''), s.attribute) AS attribute,
|
||||
s.category
|
||||
FROM character_skills cs
|
||||
|
|
@ -378,6 +378,35 @@ function character_skill_add(int $characterId, ?int $skillId, string $name, int
|
|||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Praxispunkte einer Fertigkeit setzen (0 … WS_SKILL_PRACTICE_SLOTS).
|
||||
*
|
||||
* Klick auf das zuletzt gefüllte Kästchen nimmt den Punkt wieder weg, deshalb
|
||||
* toggelt die Funktion bei gleichem Wert auf eins weniger.
|
||||
*
|
||||
* @return int gespeicherter Wert
|
||||
*/
|
||||
function character_skill_set_pp(int $characterId, int $id, int $pp): int
|
||||
{
|
||||
$current = character_skill_pp($characterId, $id);
|
||||
$pp = max(0, min(WS_SKILL_PRACTICE_SLOTS, $pp));
|
||||
if ($current !== null && $pp === $current) {
|
||||
$pp = max(0, $pp - 1);
|
||||
}
|
||||
db()->prepare('UPDATE character_skills SET pp = ? WHERE id = ? AND character_id = ?')
|
||||
->execute([$pp, $id, $characterId]);
|
||||
return $pp;
|
||||
}
|
||||
|
||||
/** Gespeicherte Praxispunkte einer Fertigkeit; null, wenn sie nicht existiert. */
|
||||
function character_skill_pp(int $characterId, int $id): ?int
|
||||
{
|
||||
$stmt = db()->prepare('SELECT pp FROM character_skills WHERE id = ? AND character_id = ? LIMIT 1');
|
||||
$stmt->execute([$id, $characterId]);
|
||||
$value = $stmt->fetchColumn();
|
||||
return $value === false ? null : (int) $value;
|
||||
}
|
||||
|
||||
function character_skill_delete(int $characterId, int $id): void
|
||||
{
|
||||
db()->prepare('DELETE FROM character_skills WHERE id = ? AND character_id = ?')->execute([$id, $characterId]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue