feat: rally point tabs, map village popups, report filters, beginner protection bar, keyboard shortcuts
Ideas taken from how Die Stämme works, in our own look: the rally point splits into
commands, troops and simulator; hovering a village on the map shows its owner, points
and distance, a click offers send troops and centre; reports filter by attacks,
defence and support; a dismissible bar counts down beginner protection; one key per
screen (V, H, T, P, W, M, R); resources in the village bar lead to the workforce.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 00:00:13 +00:00
|
|
|
import type { Report, ReportPage, ReportType } from '~/types/game'
|
feat: rally point, troop movements, support, reports, scouts, battle simulator and village rename
Send attacks and support from the rally point with a live travel-time preview, see own
commands and spotted incoming attacks with countdowns and call-back, send support home
or withdraw it, read battle and support reports with an unread badge, run the battle
simulator, rename villages, and send troops straight from the map. The watchtower gets
a diorama model; the mock server answers every new intent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 23:16:06 +00:00
|
|
|
|
|
|
|
|
/** Unread reports on the current world, for the header badge; every village state and report page updates it. */
|
|
|
|
|
export const useUnreadReports = () => useState<number>('reports.unread', () => 0)
|
|
|
|
|
|
|
|
|
|
/** The player's reports on one world: a page of the list, one report, delete and mark read. */
|
|
|
|
|
export function useReports(worldId: number) {
|
|
|
|
|
const page = ref<ReportPage | null>(null)
|
feat: rally point tabs, map village popups, report filters, beginner protection bar, keyboard shortcuts
Ideas taken from how Die Stämme works, in our own look: the rally point splits into
commands, troops and simulator; hovering a village on the map shows its owner, points
and distance, a click offers send troops and centre; reports filter by attacks,
defence and support; a dismissible bar counts down beginner protection; one key per
screen (V, H, T, P, W, M, R); resources in the village bar lead to the workforce.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 00:00:13 +00:00
|
|
|
/** The kind of reports listed; null for all. */
|
|
|
|
|
const type = ref<ReportType | null>(null)
|
feat: rally point, troop movements, support, reports, scouts, battle simulator and village rename
Send attacks and support from the rally point with a live travel-time preview, see own
commands and spotted incoming attacks with countdowns and call-back, send support home
or withdraw it, read battle and support reports with an unread badge, run the battle
simulator, rename villages, and send troops straight from the map. The watchtower gets
a diorama model; the mock server answers every new intent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 23:16:06 +00:00
|
|
|
const error = ref<string | null>(null)
|
|
|
|
|
const busy = ref(false)
|
|
|
|
|
const unread = useUnreadReports()
|
|
|
|
|
const errorText = useErrorText()
|
|
|
|
|
|
|
|
|
|
async function call<T>(event: string, data: object): Promise<T | null> {
|
|
|
|
|
busy.value = true
|
|
|
|
|
error.value = null
|
|
|
|
|
try {
|
|
|
|
|
return await ws.send<T>(event, data)
|
|
|
|
|
} catch (e) {
|
|
|
|
|
error.value = errorText(e)
|
|
|
|
|
return null
|
|
|
|
|
} finally {
|
|
|
|
|
busy.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function list(event: string, data: object) {
|
feat: rally point tabs, map village popups, report filters, beginner protection bar, keyboard shortcuts
Ideas taken from how Die Stämme works, in our own look: the rally point splits into
commands, troops and simulator; hovering a village on the map shows its owner, points
and distance, a click offers send troops and centre; reports filter by attacks,
defence and support; a dismissible bar counts down beginner protection; one key per
screen (V, H, T, P, W, M, R); resources in the village bar lead to the workforce.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 00:00:13 +00:00
|
|
|
const result = await call<ReportPage>(event, { world_id: worldId, type: type.value, ...data })
|
feat: rally point, troop movements, support, reports, scouts, battle simulator and village rename
Send attacks and support from the rally point with a live travel-time preview, see own
commands and spotted incoming attacks with countdowns and call-back, send support home
or withdraw it, read battle and support reports with an unread badge, run the battle
simulator, rename villages, and send troops straight from the map. The watchtower gets
a diorama model; the mock server answers every new intent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 23:16:06 +00:00
|
|
|
if (result) {
|
|
|
|
|
page.value = result
|
|
|
|
|
unread.value = result.unread
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
page,
|
feat: rally point tabs, map village popups, report filters, beginner protection bar, keyboard shortcuts
Ideas taken from how Die Stämme works, in our own look: the rally point splits into
commands, troops and simulator; hovering a village on the map shows its owner, points
and distance, a click offers send troops and centre; reports filter by attacks,
defence and support; a dismissible bar counts down beginner protection; one key per
screen (V, H, T, P, W, M, R); resources in the village bar lead to the workforce.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 00:00:13 +00:00
|
|
|
type,
|
feat: rally point, troop movements, support, reports, scouts, battle simulator and village rename
Send attacks and support from the rally point with a live travel-time preview, see own
commands and spotted incoming attacks with countdowns and call-back, send support home
or withdraw it, read battle and support reports with an unread badge, run the battle
simulator, rename villages, and send troops straight from the map. The watchtower gets
a diorama model; the mock server answers every new intent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 23:16:06 +00:00
|
|
|
error,
|
|
|
|
|
busy,
|
|
|
|
|
load: (n = 1) => list('report.index', { page: n }),
|
feat: rally point tabs, map village popups, report filters, beginner protection bar, keyboard shortcuts
Ideas taken from how Die Stämme works, in our own look: the rally point splits into
commands, troops and simulator; hovering a village on the map shows its owner, points
and distance, a click offers send troops and centre; reports filter by attacks,
defence and support; a dismissible bar counts down beginner protection; one key per
screen (V, H, T, P, W, M, R); resources in the village bar lead to the workforce.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 00:00:13 +00:00
|
|
|
// Both answer with every kind; a filtered list loads its kind again.
|
|
|
|
|
remove: async (ids: number[]) => {
|
|
|
|
|
await list('report.delete', { ids })
|
|
|
|
|
if (type.value) await list('report.index', { page: 1 })
|
|
|
|
|
},
|
|
|
|
|
readAll: async () => {
|
|
|
|
|
await list('report.readAll', {})
|
|
|
|
|
if (type.value) await list('report.index', { page: 1 })
|
|
|
|
|
},
|
feat: rally point, troop movements, support, reports, scouts, battle simulator and village rename
Send attacks and support from the rally point with a live travel-time preview, see own
commands and spotted incoming attacks with countdowns and call-back, send support home
or withdraw it, read battle and support reports with an unread badge, run the battle
simulator, rename villages, and send troops straight from the map. The watchtower gets
a diorama model; the mock server answers every new intent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 23:16:06 +00:00
|
|
|
/** One report; opening an unread one marks it read. */
|
|
|
|
|
show: async (id: number) => {
|
|
|
|
|
const report = await call<Report>('report.show', { id })
|
|
|
|
|
// Opening it may have read the last unread one; the list knows the new count.
|
|
|
|
|
if (report) ws.send<ReportPage>('report.index', { world_id: worldId, page: 1 }).then((p) => (unread.value = p.unread), () => {})
|
|
|
|
|
return report
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|