Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion db/queries/infractions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ WHERE id = $1;
SELECT id, game_id, game_card_id, accused, accuser, created, active, affirmed
FROM infractions
WHERE game_id = $1
ORDER BY created DESC;
ORDER BY created ASC;

-- name: InfractionsActiveCount :one
SELECT COUNT(*) FROM infractions
Expand Down
2 changes: 1 addition & 1 deletion db/sqlc/infractions.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions game.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,12 @@ func dataHandler(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNoContent)
return
}
activeCount := 0
for _, inf := range state.Infractions {
if inf.Active.Bool {
activeCount++
}
}
for _, inf := range state.Infractions {
if inf.Active.Bool {
log.Debug("serving infraction to host", "infraction_id", inf.ID)
Expand All @@ -334,9 +340,10 @@ func dataHandler(w http.ResponseWriter, r *http.Request) {
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(map[string]any{
"id": inf.ID,
"accused": accusedName,
"rule": ruleContent,
"id": inf.ID,
"accused": accusedName,
"rule": ruleContent,
"remaining": activeCount - 1,
})
return
}
Expand Down
7 changes: 7 additions & 0 deletions static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,13 @@ dialog::backdrop {
background: var(--color-backdrop);
}

.decide-remaining {
text-align: center;
font-size: 0.875em;
color: var(--color-dim);
margin: -0.5em 0 0;
}

.decide-info-rule {
font-family: var(--font-script);
}
Expand Down
1 change: 1 addition & 0 deletions static/html/tmpl.game.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ <h2>prompt challenge</h2>

<dialog id="decide-dialog">
<div class="dialog-body stack">
<p class="decide-remaining" hidden></p>
<h2>Verdict</h2>
<p class="decide-info-name"></p>
<p class="decide-info-rule"></p>
Expand Down
9 changes: 9 additions & 0 deletions static/js/accuse.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@
var infoRule = d.querySelector('.decide-info-rule');
if (infoName) infoName.textContent = 'did ' + data.accused + ' break the rule';
if (infoRule) infoRule.textContent = data.rule;
var remaining = d.querySelector('.decide-remaining');
if (remaining) {
if (data.remaining > 0) {
remaining.textContent = '+' + data.remaining + ' more';
remaining.hidden = false;
} else {
remaining.hidden = true;
}
}
if (!d.open) d.showModal();
}

Expand Down
Loading