Bearbeiten-Modus: Wuergel und Praxispunkte je Fertigkeit anzeigen und setzen
This commit is contained in:
parent
85fd24a0f0
commit
3795c517fb
2 changed files with 21 additions and 2 deletions
|
|
@ -136,6 +136,9 @@ function page_handle(string $method, string $path): void
|
|||
require_post();
|
||||
$character = character_require((int) $m[1], $user);
|
||||
$wantsJson = strtolower((string) ($_SERVER['HTTP_X_REQUESTED_WITH'] ?? '')) === 'fetch';
|
||||
$back = post_string('back') === 'edit'
|
||||
? '/characters/' . $character['id'] . '/edit#fertigkeiten'
|
||||
: '/characters/' . $character['id'] . '#fertigkeiten';
|
||||
if (!csrf_valid()) {
|
||||
if ($wantsJson) {
|
||||
http_response_code(419);
|
||||
|
|
@ -144,7 +147,7 @@ function page_handle(string $method, string $path): void
|
|||
return;
|
||||
}
|
||||
flash('error', 'Die Sitzung ist abgelaufen. Bitte erneut versuchen.');
|
||||
redirect('/characters/' . $character['id'] . '#fertigkeiten');
|
||||
redirect($back);
|
||||
}
|
||||
$pp = max(0, min(WS_SKILL_PRACTICE_SLOTS, post_int('pp', 0)));
|
||||
$pp = character_skill_set_pp((int) $character['id'], (int) $m[2], $pp);
|
||||
|
|
@ -153,7 +156,7 @@ function page_handle(string $method, string $path): void
|
|||
echo json_encode(['ok' => true, 'pp' => $pp], JSON_UNESCAPED_UNICODE);
|
||||
return;
|
||||
}
|
||||
redirect('/characters/' . $character['id'] . '#fertigkeiten');
|
||||
redirect($back);
|
||||
}
|
||||
if (preg_match('#^/characters/(\d+)/skills/(add|\d+/delete)$#', $path, $m) === 1) {
|
||||
require_post();
|
||||
|
|
|
|||
|
|
@ -111,6 +111,8 @@ $base = url('/characters/' . $cid);
|
|||
<th>Fertigkeit</th>
|
||||
<th>Attribut</th>
|
||||
<th class="num">MOD</th>
|
||||
<th class="num">Würfel</th>
|
||||
<th>PP</th>
|
||||
<th>Stufe / Notiz</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
|
@ -121,6 +123,20 @@ $base = url('/characters/' . $cid);
|
|||
<td class="skill-name"><?= e((string) $skill['name']) ?></td>
|
||||
<td class="muted"><?= e((string) ($skill['attribute'] ?? '')) ?></td>
|
||||
<td class="num <?= $mod === null ? 'muted' : bonus_class($mod) ?>"><?= $mod === null ? '–' : e(signed($mod)) ?></td>
|
||||
<td class="num die"><b><?= e(skill_die((int) $skill['bonus'])) ?></b></td>
|
||||
<td class="pp-cell">
|
||||
<?php $pp = max(0, min(WS_SKILL_PRACTICE_SLOTS, (int) ($skill['pp'] ?? 0))); ?>
|
||||
<form method="post" action="<?= e($base . '/skills/' . (int) $skill['id'] . '/pp') ?>" class="pp-slots" data-pp-form aria-label="Praxispunkte <?= e((string) $skill['name']) ?>">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="back" value="edit">
|
||||
<?php for ($slot = 1; $slot <= WS_SKILL_PRACTICE_SLOTS; $slot++): ?>
|
||||
<button type="submit" name="pp" value="<?= $slot ?>"
|
||||
class="pp-slot<?= $slot <= $pp ? ' is-filled' : '' ?>"
|
||||
title="<?= $slot ?> Praxispunkt<?= $slot === 1 ? '' : 'e' ?>"
|
||||
aria-pressed="<?= $slot <= $pp ? 'true' : 'false' ?>"></button>
|
||||
<?php endfor; ?>
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<div class="inline-form">
|
||||
<form method="post" action="<?= e($base . '/skills/' . (int) $skill['id']) ?>" class="inline-form">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue