Charaktere: Geschlecht (Default maennlich) plus weibliche Platzhalterportraets
Spalte characters.gender mit Migration, Auswahl im Formular, Anzeige auf Bogen und im PDF-Export. 12 neue Platzhalterbilder assets/portraits/<klasse>-weiblich.webp (fal.ai nano-banana-pro/edit) werden von portrait_placeholder_rel() nach Geschlecht gewaehlt.
This commit is contained in:
parent
0cbaeeafcd
commit
9388d04e98
23 changed files with 62 additions and 13 deletions
|
|
@ -61,16 +61,17 @@ function character_create(int $userId, array $data): int
|
|||
$data = array_merge($data, saving_throws_for((string) ($data['class_name'] ?? 'Kämpfer'), (int) $data['level']));
|
||||
|
||||
$stmt = db()->prepare(
|
||||
'INSERT INTO characters (user_id, name, title, class_name, level, xp, hp_max, hp_current, ac, attack_bonus,
|
||||
'INSERT INTO characters (user_id, name, title, gender, class_name, level, xp, hp_max, hp_current, ac, attack_bonus,
|
||||
attr_str, attr_dex, attr_con, attr_int, attr_wis, attr_cha,
|
||||
save_death, save_wand, save_paralysis, save_breath, save_spell,
|
||||
alignment, created_at, updated_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'
|
||||
);
|
||||
$stmt->execute([
|
||||
$userId,
|
||||
$data['name'],
|
||||
$data['title'] ?? '',
|
||||
character_gender($data['gender'] ?? null),
|
||||
$data['class_name'] ?? 'Kämpfer',
|
||||
$data['level'] ?? 1,
|
||||
$data['xp'] ?? 0,
|
||||
|
|
@ -205,7 +206,7 @@ function character_update(int $id, array $d): void
|
|||
}
|
||||
|
||||
$stmt = db()->prepare(
|
||||
'UPDATE characters SET name = ?, title = ?, class_name = ?, level = ?, xp = ?, hp_max = ?, hp_current = ?,
|
||||
'UPDATE characters SET name = ?, title = ?, gender = ?, class_name = ?, level = ?, xp = ?, hp_max = ?, hp_current = ?,
|
||||
ac = ?, attack_bonus = ?, attr_str = ?, attr_dex = ?, attr_con = ?, attr_int = ?, attr_wis = ?, attr_cha = ?,
|
||||
save_death = ?, save_wand = ?, save_paralysis = ?, save_breath = ?, save_spell = ?,
|
||||
alignment = ?, deity = ?, age = ?, height = ?, weight = ?, gold_coins = ?,
|
||||
|
|
@ -215,6 +216,7 @@ function character_update(int $id, array $d): void
|
|||
$stmt->execute([
|
||||
$d['name'],
|
||||
$d['title'] ?? '',
|
||||
character_gender($d['gender'] ?? null),
|
||||
$d['class_name'] ?? 'Kämpfer',
|
||||
$d['level'] ?? 1,
|
||||
$d['xp'] ?? 0,
|
||||
|
|
@ -274,6 +276,13 @@ function character_ac_value(mixed $value): ?int
|
|||
return $int > 0 ? $int : null;
|
||||
}
|
||||
|
||||
/** Geschlecht auf einen gültigen Wert aus WS_GENDERS begrenzen. */
|
||||
function character_gender(mixed $value): string
|
||||
{
|
||||
$gender = is_string($value) ? trim($value) : '';
|
||||
return in_array($gender, WS_GENDERS, true) ? $gender : WS_DEFAULT_GENDER;
|
||||
}
|
||||
|
||||
function character_delete(int $id): void
|
||||
{
|
||||
db()->prepare('DELETE FROM characters WHERE id = ?')->execute([$id]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue