feat(events): four event recipes for the New event page #53
@@ -217,6 +217,15 @@ jobs:
|
||||
tar -C module --exclude=.git --exclude=node_modules -cf - . | tar -C core/modules/uo -xf -
|
||||
npm ci --omit=dev --prefix core/modules/uo/server
|
||||
|
||||
# The server-tests job runs the recipes against a fake core, which can say
|
||||
# they build the spec they mean to and not that core accepts it. This is the
|
||||
# only place core's own registry and spec validator see them: the module is
|
||||
# loaded through the real loader and every recipe is filled in through the
|
||||
# path the New event page takes. It works from its own temp copy of the
|
||||
# module, so the copy installed above is not the one it reads.
|
||||
- name: Build every event template through core's real registry
|
||||
run: node module/server/scripts/templateBuild.js --core core --module module
|
||||
|
||||
- name: Generate core's manifest with this module
|
||||
run: |
|
||||
npm run routes:manifest --prefix core/server
|
||||
|
||||
@@ -105,7 +105,8 @@ server/utils/ sidecar client, visibility, ingest, town crier, cliloc,
|
||||
server/config/ the push stream catalog, the engagement triggers and audiences
|
||||
server/db/schema.sql idempotent fragment, replayed by core's ensureSchema()
|
||||
server/db/purge.sql destructive; only ever run by an explicit purge
|
||||
server/scripts/ the three checks: imports, the fragment, the frozen manifest
|
||||
server/eventTemplates.js the four event recipes (announcement, boss raid, seasonal event, gathering giveaway)
|
||||
server/scripts/ the checks: imports, the fragment, the frozen manifest, the recipes through core
|
||||
server/test/ node --test, with a fake ctx standing in for core
|
||||
client/src/entry.jsx the chunk's entry — registers routes, nav, slots, feature provider
|
||||
client/src/shim/ react, react-dom, react-router-dom, jsx-runtime, from window.__rg
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
"core.js",
|
||||
"data",
|
||||
"db",
|
||||
"eventTemplates.js",
|
||||
"index.js",
|
||||
"model",
|
||||
"package.json",
|
||||
|
||||
@@ -2303,6 +2303,7 @@ module.exports = {
|
||||
MAX_GRANT_STACK,
|
||||
GRANTABLE,
|
||||
SEASONAL_EVENTS,
|
||||
SEASONAL_LABELS,
|
||||
SPAWNER_OPTIONS,
|
||||
PERMANENT_STATUSES,
|
||||
webUserId,
|
||||
|
||||
593
server/eventTemplates.js
Normal file
593
server/eventTemplates.js
Normal file
@@ -0,0 +1,593 @@
|
||||
// ── Event templates ("recipes") ─────────────────────────────────────────────
|
||||
//
|
||||
// Four named starting points for a new event, through core's
|
||||
// `api.registerEventTemplates` (MODULE_API 1.13.0). The author fills in a few
|
||||
// inputs; `build()` turns them into an ordinary draft — phases, steps, params —
|
||||
// which the editor opens unsaved. Core validates the plan as a spec and keeps
|
||||
// nothing about the template, so this file can change without touching a single
|
||||
// event it was ever used for.
|
||||
//
|
||||
// uo.template.announce tell everyone, and optionally leave a news item up
|
||||
// uo.template.boss_raid a named boss at a landmark for a while
|
||||
// uo.template.seasonal one of ServUO's seasonal events, on for a few hours
|
||||
// uo.template.gathering_giveaway a gift for everyone who turned up
|
||||
//
|
||||
// **`build()` makes no sidecar or shard call, and reads no database.** A recipe
|
||||
// has to fill in while the shard is down — the dry run is what checks the live
|
||||
// world — so everything checked here is what the inputs alone can say: formats,
|
||||
// ranges, and rules between two inputs. Whether the landmark exists or the
|
||||
// creature can be built is the actions' own business, at the dry run.
|
||||
//
|
||||
// **There is no teardown step in any of these, and that is on purpose.** What a
|
||||
// run made with a `reversible: 'ledger'` action (a boss, a news article, a
|
||||
// participation slot) or a `core.lease` is put back by core when the run ends.
|
||||
// A phase with `advance.after` is what keeps it alive until then: the hold IS
|
||||
// the length of the event.
|
||||
//
|
||||
// **No `default` on an input** — core drops the key — so every default lives in
|
||||
// `build()`, and an input left empty arrives as absent.
|
||||
|
||||
const {
|
||||
MAX_BROADCAST_LEN,
|
||||
MAX_NEWS_TITLE,
|
||||
MAX_NEWS_BODY,
|
||||
MAX_AREA_RADIUS,
|
||||
MAX_BOSSES,
|
||||
MAX_BOSS_MULTIPLIER,
|
||||
MAX_GRANT_STACK,
|
||||
MAX_PROP_LEASE_MS,
|
||||
GRANTABLE,
|
||||
SEASONAL_EVENTS,
|
||||
SEASONAL_LABELS,
|
||||
} = require('./config/uoEventActions')
|
||||
|
||||
/** How long a Town Cryer news item stays up when the author gives a title and no length: a day. */
|
||||
const DEFAULT_NEWS_MINUTES = 1440
|
||||
|
||||
/** The default area a giveaway counts around its place, in tiles. */
|
||||
const DEFAULT_RADIUS = 40
|
||||
|
||||
/**
|
||||
* The longest a phase may be held: thirty days, core's own paste guard on
|
||||
* `advance.after` (`MAX_AFTER_SECONDS` in the spec validator). Not a policy of
|
||||
* ours — a hold longer than any event this is for is a typo, and core would
|
||||
* refuse it anyway, but in its words rather than the author's.
|
||||
*/
|
||||
const MAX_HOLD_MINUTES = 30 * 24 * 60
|
||||
|
||||
/** What a seasonal lease may be held for, in minutes. The lease declares 12 hours. */
|
||||
const MAX_SEASONAL_MINUTES = Math.floor(MAX_PROP_LEASE_MS / 60_000)
|
||||
|
||||
// ── Small readers ───────────────────────────────────────────────────────────
|
||||
|
||||
/** An optional input is absent, null or empty. */
|
||||
const isBlank = (v) => v === undefined || v === null || (typeof v === 'string' && v.trim() === '')
|
||||
|
||||
/** A string input, trimmed and collapsed to one line — or '' when absent. */
|
||||
const oneLine = (v) => (isBlank(v) ? '' : String(v).replace(/\s+/g, ' ').trim())
|
||||
|
||||
/** "30 minutes", "1 hour", "3 hours", "90 minutes". */
|
||||
function minutesWords(n) {
|
||||
if (n >= 60 && n % 60 === 0) {
|
||||
const hours = n / 60
|
||||
return `${hours} hour${hours === 1 ? '' : 's'}`
|
||||
}
|
||||
return `${n} minute${n === 1 ? '' : 's'}`
|
||||
}
|
||||
|
||||
/** "OrcCaptain" → "Orc Captain". A name that is not plain CamelCase is left as the shard spells it. */
|
||||
function creatureWords(type) {
|
||||
return /^[A-Za-z]+$/.test(type) ? type.replace(/([a-z])([A-Z])/g, '$1 $2') : type
|
||||
}
|
||||
|
||||
/** A place as the author picked it, `facet/name` or `facet/group/name`, or null. */
|
||||
function readPlace(raw) {
|
||||
const place = oneLine(raw)
|
||||
const parts = place.split('/')
|
||||
if (parts.length < 2 || parts.some((p) => p.trim() === '')) return null
|
||||
return { value: place, name: parts[parts.length - 1].trim() }
|
||||
}
|
||||
|
||||
const placeRefusal = (raw) => `"${raw}" is not a place — pick one from the list, as facet/name`
|
||||
|
||||
/**
|
||||
* A whole number of minutes in 1..max, or a refusal in the author's words.
|
||||
* `what` finishes "<what> lasts 1 to N minutes": "the raid", "the event".
|
||||
*/
|
||||
function readMinutes(raw, max, what) {
|
||||
const minutes = Number(raw)
|
||||
if (isBlank(raw) || !Number.isInteger(minutes) || minutes < 1 || minutes > max) {
|
||||
return { ok: false, error: `${what} lasts 1 to ${max} minutes, and "${raw}" is not that` }
|
||||
}
|
||||
return { ok: true, minutes }
|
||||
}
|
||||
|
||||
/** A broadcast line: one line of at most `MAX_BROADCAST_LEN` characters. */
|
||||
function readMessage(raw, what) {
|
||||
const text = oneLine(raw)
|
||||
if (text.length > MAX_BROADCAST_LEN) {
|
||||
return {
|
||||
ok: false,
|
||||
error: `${what} is sent as one broadcast, which is capped at ${MAX_BROADCAST_LEN} characters, and this is ${text.length}`,
|
||||
}
|
||||
}
|
||||
return { ok: true, text }
|
||||
}
|
||||
|
||||
// ── 1. Announcement ─────────────────────────────────────────────────────────
|
||||
|
||||
const announce = {
|
||||
id: 'uo.template.announce',
|
||||
label: 'Announcement',
|
||||
description:
|
||||
'Tells everyone who is online a message, once. Add a news title and the same text is also posted in the in-game Town Cryer news window, and stays there for the length you choose. Nothing in the world changes; you can change every part of the plan before saving it.',
|
||||
inputs: [
|
||||
{
|
||||
name: 'text',
|
||||
type: 'string',
|
||||
required: true,
|
||||
example: 'The gates of Britain open at dusk. Gather at the bank.',
|
||||
description: `What to tell everyone online, up to ${MAX_BROADCAST_LEN} characters. It goes out once.`,
|
||||
},
|
||||
{
|
||||
name: 'hue',
|
||||
type: 'int',
|
||||
required: false,
|
||||
example: 1153,
|
||||
description: 'The colour of the message, as an Ultima Online colour number. Left empty, the shard uses its usual system colour.',
|
||||
},
|
||||
{
|
||||
name: 'newsTitle',
|
||||
type: 'string',
|
||||
required: false,
|
||||
example: 'The Britannian Midsummer Fair',
|
||||
description: `A heading for a Town Cryer news article carrying the same text, up to ${MAX_NEWS_TITLE} characters. Leave it empty to post no article.`,
|
||||
},
|
||||
{
|
||||
name: 'newsMinutes',
|
||||
type: 'int',
|
||||
required: false,
|
||||
example: 1440,
|
||||
duration: 'minutes',
|
||||
description: `How long the news article stays up, in minutes. Only with a news title. Left empty, it stays ${DEFAULT_NEWS_MINUTES} minutes (a day).`,
|
||||
},
|
||||
],
|
||||
|
||||
build({ inputs }) {
|
||||
const message = readMessage(inputs.text, 'the announcement')
|
||||
if (!message.ok) return message
|
||||
if (!message.text) return { ok: false, error: 'the announcement has no text to send' }
|
||||
|
||||
let hue
|
||||
if (!isBlank(inputs.hue)) {
|
||||
hue = Number(inputs.hue)
|
||||
if (!Number.isInteger(hue) || hue < 0) {
|
||||
return { ok: false, error: `"${inputs.hue}" is not a colour this shard will take; use a whole number, 0 or more` }
|
||||
}
|
||||
}
|
||||
|
||||
const newsTitle = oneLine(inputs.newsTitle)
|
||||
if (!newsTitle && !isBlank(inputs.newsMinutes)) {
|
||||
return { ok: false, error: 'a news length needs a news title; give the article a title, or clear the length' }
|
||||
}
|
||||
|
||||
const steps = [
|
||||
{
|
||||
actionId: 'uo.broadcast',
|
||||
label: 'Tell everyone online',
|
||||
params: { text: message.text, ...(hue === undefined ? {} : { hue }) },
|
||||
},
|
||||
]
|
||||
const phase = { key: 'announce', label: 'Announce', steps }
|
||||
let summary = `Tells everyone online "${message.text}".`
|
||||
|
||||
if (newsTitle) {
|
||||
if (newsTitle.length > MAX_NEWS_TITLE) {
|
||||
return {
|
||||
ok: false,
|
||||
error: `a news title is capped at ${MAX_NEWS_TITLE} characters and this is ${newsTitle.length}`,
|
||||
}
|
||||
}
|
||||
// The body is the broadcast text, which is already within the broadcast cap;
|
||||
// the check is for the day the two caps move apart.
|
||||
if (message.text.length > MAX_NEWS_BODY) {
|
||||
return {
|
||||
ok: false,
|
||||
error: `a news article is capped at ${MAX_NEWS_BODY} characters and the text is ${message.text.length}`,
|
||||
}
|
||||
}
|
||||
|
||||
let minutes = DEFAULT_NEWS_MINUTES
|
||||
if (!isBlank(inputs.newsMinutes)) {
|
||||
const read = readMinutes(inputs.newsMinutes, MAX_HOLD_MINUTES, 'the news article')
|
||||
if (!read.ok) return read
|
||||
minutes = read.minutes
|
||||
}
|
||||
|
||||
steps.push({
|
||||
actionId: 'uo.news.post',
|
||||
label: 'Post the news article',
|
||||
// `announce: false`: the broadcast above has already told everyone, and the
|
||||
// criers proclaiming the title as well would be the same news twice.
|
||||
params: { title: newsTitle, body: message.text, announce: false },
|
||||
})
|
||||
// The article is taken down when the run ends, so the hold is what keeps it
|
||||
// posted — the phase lasts exactly as long as the article should.
|
||||
phase.advance = { after: `${minutes}m` }
|
||||
summary += ` Posts "${newsTitle}" in the Town Cryer news for ${minutesWords(minutes)}.`
|
||||
}
|
||||
|
||||
return {
|
||||
title: `Announcement: ${message.text.length > 60 ? `${message.text.slice(0, 57)}...` : message.text}`,
|
||||
summary,
|
||||
spec: { schedule: { kind: 'manual' }, phases: [phase] },
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
// ── 2. Boss raid ────────────────────────────────────────────────────────────
|
||||
|
||||
const bossRaid = {
|
||||
id: 'uo.template.boss_raid',
|
||||
label: 'Boss raid',
|
||||
description:
|
||||
'A named boss appears at a landmark, the shard is told so, and the boss is removed when the time is up. It needs boss spawning to be switched on: actions that put things in the world are off until an operator enables them. The boss is cleared when the run ends, even if nobody kills it.',
|
||||
inputs: [
|
||||
{
|
||||
name: 'place',
|
||||
type: 'string',
|
||||
required: true,
|
||||
example: 'Felucca/Britain',
|
||||
source: 'uo.options.landmarks',
|
||||
description: 'Where the boss appears.',
|
||||
},
|
||||
{
|
||||
name: 'creature',
|
||||
type: 'string',
|
||||
required: true,
|
||||
example: 'OrcCaptain',
|
||||
source: 'uo.options.creatures',
|
||||
description: 'The kind of creature the boss is built from.',
|
||||
},
|
||||
{
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
required: true,
|
||||
example: 'Gruk the Unbroken',
|
||||
description: 'What the boss is called. An unnamed boss is just a hard monster.',
|
||||
},
|
||||
{
|
||||
name: 'minutes',
|
||||
type: 'int',
|
||||
required: true,
|
||||
example: 30,
|
||||
duration: 'minutes',
|
||||
description: 'How many minutes the boss stays before it is cleared away.',
|
||||
},
|
||||
{
|
||||
name: 'count',
|
||||
type: 'int',
|
||||
required: false,
|
||||
example: 1,
|
||||
description: `How many bosses, 1 to ${MAX_BOSSES}. Left empty, one.`,
|
||||
},
|
||||
{
|
||||
name: 'strength',
|
||||
type: 'float',
|
||||
required: false,
|
||||
example: 3,
|
||||
description: `How many times tougher than normal, and how many times harder it hits, 1 to ${MAX_BOSS_MULTIPLIER}. Left empty, or 1, it is as strong as the creature normally is.`,
|
||||
},
|
||||
{
|
||||
name: 'message',
|
||||
type: 'string',
|
||||
required: false,
|
||||
example: 'Gruk the Unbroken has appeared near Britain!',
|
||||
description: `What the shard is told when the boss appears, up to ${MAX_BROADCAST_LEN} characters. Left empty, "<name> has appeared near <place>!".`,
|
||||
},
|
||||
],
|
||||
|
||||
build({ inputs }) {
|
||||
const place = readPlace(inputs.place)
|
||||
if (!place) return { ok: false, error: placeRefusal(inputs.place) }
|
||||
|
||||
const creature = oneLine(inputs.creature)
|
||||
if (!creature) return { ok: false, error: 'pick a creature for the boss to be built from' }
|
||||
|
||||
const name = oneLine(inputs.name)
|
||||
if (!name) return { ok: false, error: 'a boss needs a name' }
|
||||
|
||||
const read = readMinutes(inputs.minutes, MAX_HOLD_MINUTES, 'a raid')
|
||||
if (!read.ok) return read
|
||||
const { minutes } = read
|
||||
|
||||
let count = 1
|
||||
if (!isBlank(inputs.count)) {
|
||||
count = Number(inputs.count)
|
||||
if (!Number.isInteger(count) || count < 1 || count > MAX_BOSSES) {
|
||||
return { ok: false, error: `a raid has 1 to ${MAX_BOSSES} bosses, and "${inputs.count}" is not that` }
|
||||
}
|
||||
}
|
||||
|
||||
let strength = 1
|
||||
if (!isBlank(inputs.strength)) {
|
||||
strength = Number(inputs.strength)
|
||||
if (!Number.isFinite(strength) || strength < 1 || strength > MAX_BOSS_MULTIPLIER) {
|
||||
return {
|
||||
ok: false,
|
||||
error: `a boss is 1 to ${MAX_BOSS_MULTIPLIER} times as strong as normal, and "${inputs.strength}" is not`,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const message = readMessage(
|
||||
isBlank(inputs.message) ? `${name} has appeared near ${place.name}!` : inputs.message,
|
||||
isBlank(inputs.message) ? 'the default message (shorten the boss name or write your own)' : 'the message',
|
||||
)
|
||||
if (!message.ok) return message
|
||||
|
||||
const spawn = {
|
||||
place: place.value,
|
||||
creature,
|
||||
name,
|
||||
count,
|
||||
// 1 is "as normal", so it is left out rather than written as a multiplier
|
||||
// that does nothing.
|
||||
...(strength > 1 ? { hitsMultiplier: strength, damageMultiplier: strength } : {}),
|
||||
}
|
||||
|
||||
const who = count === 1 ? name : `${count} bosses called ${name}`
|
||||
return {
|
||||
title: `${creatureWords(creature)} raid at ${place.value} for ${minutesWords(minutes)}`,
|
||||
summary:
|
||||
`${who}, built from ${creatureWords(creature)}${strength > 1 ? ` and ${strength} times as strong` : ''}, ` +
|
||||
`appear${count === 1 ? 's' : ''} near ${place.value} and ${count === 1 ? 'is' : 'are'} removed after ${minutesWords(minutes)}.`,
|
||||
spec: {
|
||||
schedule: { kind: 'manual' },
|
||||
phases: [
|
||||
{
|
||||
key: 'raid',
|
||||
label: 'The raid',
|
||||
// The boss is cleared when the run ends, so the hold is its lifetime.
|
||||
advance: { after: `${minutes}m` },
|
||||
steps: [
|
||||
{ actionId: 'uo.boss.spawn', label: count === 1 ? 'Spawn the boss' : 'Spawn the bosses', params: spawn },
|
||||
{ actionId: 'uo.broadcast', label: 'Tell everyone it has appeared', params: { text: message.text } },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
// ── 3. Seasonal event ───────────────────────────────────────────────────────
|
||||
|
||||
const seasonal = {
|
||||
id: 'uo.template.seasonal',
|
||||
label: 'Seasonal event for a few hours',
|
||||
description:
|
||||
`Switches one of ServUO's own seasonal events on, and back off by itself when the time is up (up to ${MAX_SEASONAL_MINUTES / 60} hours). Six of the eight add or remove things in the world when they change, so this is a bigger switch than it looks. It borrows the event's setting and puts the old one back when the run ends.`,
|
||||
inputs: [
|
||||
{
|
||||
name: 'event',
|
||||
type: 'string',
|
||||
required: true,
|
||||
example: 'Fellowship',
|
||||
source: 'uo.options.seasonal',
|
||||
description: 'Which of the shard\'s seasonal events to switch on.',
|
||||
},
|
||||
{
|
||||
name: 'minutes',
|
||||
type: 'int',
|
||||
required: true,
|
||||
example: 180,
|
||||
duration: 'minutes',
|
||||
description: `How many minutes it stays on, up to ${MAX_SEASONAL_MINUTES} (${MAX_SEASONAL_MINUTES / 60} hours). 180 is three hours.`,
|
||||
},
|
||||
{
|
||||
name: 'message',
|
||||
type: 'string',
|
||||
required: false,
|
||||
example: 'The Krampus has come to Britannia for a few hours!',
|
||||
description: `What the shard is told once it is on, up to ${MAX_BROADCAST_LEN} characters. Left empty, nobody is told.`,
|
||||
},
|
||||
],
|
||||
|
||||
build({ inputs }) {
|
||||
const event = oneLine(inputs.event)
|
||||
if (!SEASONAL_EVENTS.includes(event)) {
|
||||
return {
|
||||
ok: false,
|
||||
error: `"${inputs.event}" is not a seasonal event this recipe can switch on — pick one from the list`,
|
||||
}
|
||||
}
|
||||
|
||||
const read = readMinutes(inputs.minutes, MAX_SEASONAL_MINUTES, 'a seasonal event')
|
||||
if (!read.ok) return read
|
||||
const { minutes } = read
|
||||
|
||||
const message = readMessage(inputs.message, 'the message')
|
||||
if (!message.ok) return message
|
||||
|
||||
const label = SEASONAL_LABELS[event] || event
|
||||
const steps = [
|
||||
{
|
||||
actionId: 'core.lease',
|
||||
label: `Switch on ${label}`,
|
||||
params: { lease: 'uo.seasonal.status', target: event, value: 'Active', minutes },
|
||||
},
|
||||
]
|
||||
if (message.text) {
|
||||
steps.push({ actionId: 'uo.broadcast', label: 'Tell everyone it is on', params: { text: message.text } })
|
||||
}
|
||||
|
||||
return {
|
||||
title: `${label} for ${minutesWords(minutes)}`,
|
||||
summary: `Switches ${label} on for ${minutesWords(minutes)}, then puts it back as it was.`,
|
||||
spec: {
|
||||
schedule: { kind: 'manual' },
|
||||
phases: [
|
||||
{
|
||||
key: 'season',
|
||||
label,
|
||||
// The lease is given back when the run ends, so the hold is how long the
|
||||
// event stays on — and the lease's own `minutes` is the game's deadline.
|
||||
advance: { after: `${minutes}m` },
|
||||
steps,
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
// ── 4. Gathering giveaway ───────────────────────────────────────────────────
|
||||
|
||||
const gatheringGiveaway = {
|
||||
id: 'uo.template.gathering_giveaway',
|
||||
label: 'Gathering giveaway',
|
||||
description:
|
||||
'Players gather at a landmark for a while; when the time is up, everyone the shard counted in the area during that window is given the item. Gifts go into backpacks and cannot be taken back, so check the item and amount before you start.',
|
||||
inputs: [
|
||||
{
|
||||
name: 'place',
|
||||
type: 'string',
|
||||
required: true,
|
||||
example: 'Felucca/Britain',
|
||||
source: 'uo.options.landmarks',
|
||||
description: 'Where players gather.',
|
||||
},
|
||||
{
|
||||
name: 'minutes',
|
||||
type: 'int',
|
||||
required: true,
|
||||
example: 30,
|
||||
duration: 'minutes',
|
||||
description: 'How many minutes players have to gather before the gifts are handed out.',
|
||||
},
|
||||
{
|
||||
name: 'item',
|
||||
type: 'string',
|
||||
required: true,
|
||||
example: 'gold',
|
||||
source: 'uo.options.items',
|
||||
description: 'What everyone is given. The list is what the shard is willing to hand out.',
|
||||
},
|
||||
{
|
||||
name: 'amount',
|
||||
type: 'int',
|
||||
required: false,
|
||||
example: 500,
|
||||
description: `How many each, up to ${MAX_GRANT_STACK}. Only items that stack, like gold, can be given more than one at a time. Left empty, one.`,
|
||||
},
|
||||
{
|
||||
name: 'radius',
|
||||
type: 'int',
|
||||
required: false,
|
||||
example: DEFAULT_RADIUS,
|
||||
description: `How many tiles around the place count as being there, 1 to ${MAX_AREA_RADIUS}. Left empty, ${DEFAULT_RADIUS}.`,
|
||||
},
|
||||
{
|
||||
name: 'message',
|
||||
type: 'string',
|
||||
required: false,
|
||||
example: 'Gather near Britain in the next 30 minutes for a gift!',
|
||||
description: `What the shard is told when the gathering opens, up to ${MAX_BROADCAST_LEN} characters. Left empty, "Gather near <place> in the next <minutes> minutes for a gift!".`,
|
||||
},
|
||||
],
|
||||
|
||||
build({ inputs }) {
|
||||
const place = readPlace(inputs.place)
|
||||
if (!place) return { ok: false, error: placeRefusal(inputs.place) }
|
||||
|
||||
const read = readMinutes(inputs.minutes, MAX_HOLD_MINUTES, 'a gathering')
|
||||
if (!read.ok) return read
|
||||
const { minutes } = read
|
||||
|
||||
const itemKey = oneLine(inputs.item)
|
||||
const item = GRANTABLE.find((g) => g.key === itemKey)
|
||||
if (!item) {
|
||||
return { ok: false, error: `this shard does not give out "${inputs.item}" — pick one from the list` }
|
||||
}
|
||||
|
||||
let amount = 1
|
||||
if (!isBlank(inputs.amount)) {
|
||||
amount = Number(inputs.amount)
|
||||
if (!Number.isInteger(amount) || amount < 1 || amount > MAX_GRANT_STACK) {
|
||||
return { ok: false, error: `give 1 to ${MAX_GRANT_STACK} each, and "${inputs.amount}" is not that` }
|
||||
}
|
||||
}
|
||||
if (!item.stackable && amount > 1) {
|
||||
return { ok: false, error: `${item.label} does not stack, so it can only be given one at a time` }
|
||||
}
|
||||
|
||||
let radius = DEFAULT_RADIUS
|
||||
if (!isBlank(inputs.radius)) {
|
||||
radius = Number(inputs.radius)
|
||||
if (!Number.isInteger(radius) || radius < 1 || radius > MAX_AREA_RADIUS) {
|
||||
return { ok: false, error: `the gathering area is 1 to ${MAX_AREA_RADIUS} tiles, and "${inputs.radius}" is not that` }
|
||||
}
|
||||
}
|
||||
|
||||
const custom = !isBlank(inputs.message)
|
||||
const message = readMessage(
|
||||
custom ? inputs.message : `Gather near ${place.name} in the next ${minutesWords(minutes)} for a gift!`,
|
||||
custom ? 'the message' : 'the default message (write your own)',
|
||||
)
|
||||
if (!message.ok) return message
|
||||
|
||||
const gift = amount === 1 ? `one ${item.label.toLowerCase()}` : `${amount} ${item.label.toLowerCase()}`
|
||||
return {
|
||||
title: `Gathering giveaway at ${place.value} for ${minutesWords(minutes)}`,
|
||||
summary:
|
||||
`Players gather within ${radius} tiles of ${place.value} for ${minutesWords(minutes)}; ` +
|
||||
`then everyone who was there is given ${gift} each. Gifts cannot be taken back.`,
|
||||
spec: {
|
||||
schedule: { kind: 'manual' },
|
||||
phases: [
|
||||
{
|
||||
key: 'gather',
|
||||
label: 'Gather',
|
||||
// The counting slot is given back when the run ends, so this hold is the
|
||||
// window: the reward phase starts when it is up, not before.
|
||||
advance: { after: `${minutes}m` },
|
||||
steps: [
|
||||
{ actionId: 'uo.broadcast', label: 'Invite everyone', params: { text: message.text } },
|
||||
{
|
||||
actionId: 'uo.participation.open',
|
||||
label: 'Start counting who is there',
|
||||
params: { place: place.value, radius },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'reward',
|
||||
label: 'Give the gifts',
|
||||
steps: [
|
||||
{ actionId: 'uo.participation.collect', label: 'Record who was there', params: {} },
|
||||
{ actionId: 'uo.item.grant', label: 'Give everyone the gift', params: { item: item.key, amount } },
|
||||
{
|
||||
actionId: 'uo.broadcast',
|
||||
label: 'Say thank you',
|
||||
params: { text: 'Thank you for coming — gifts are in your backpacks.' },
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
const TEMPLATES = [announce, bossRaid, seasonal, gatheringGiveaway]
|
||||
|
||||
module.exports = {
|
||||
TEMPLATES,
|
||||
DEFAULT_NEWS_MINUTES,
|
||||
DEFAULT_RADIUS,
|
||||
MAX_HOLD_MINUTES,
|
||||
MAX_SEASONAL_MINUTES,
|
||||
minutesWords,
|
||||
creatureWords,
|
||||
}
|
||||
@@ -48,6 +48,7 @@ module.exports = function register(ctx, api) {
|
||||
const shardAudiences = require('./config/shardAudiences')
|
||||
const engagementSeeds = require('./config/engagementSeeds')
|
||||
const uoEventActions = require('./config/uoEventActions')
|
||||
const eventTemplates = require('./eventTemplates')
|
||||
const townCrierLeg = require('./utils/shardAnnounce')
|
||||
const teamProvider = require('./model/teamProvider/teamProvider.model')
|
||||
const guildCommand = require('./commands/guild.command')
|
||||
@@ -181,6 +182,10 @@ const engagementSeeds = require('./config/engagementSeeds')
|
||||
// two-events-one-target check and the teardown restore.
|
||||
api.registerEventLeases(uoEventActions.LEASES)
|
||||
api.registerEventOptionSources(uoEventActions.OPTION_SOURCES)
|
||||
// MODULE_API 1.13.0. Four recipes — named starting points built out of the verbs
|
||||
// above. They are only declarations: `build()` runs when an author fills one in,
|
||||
// and makes no shard call, so they work with the shard down.
|
||||
api.registerEventTemplates(eventTemplates.TEMPLATES)
|
||||
|
||||
api.onBoot(boot.onBoot)
|
||||
api.onShutdown(boot.onShutdown)
|
||||
|
||||
299
server/scripts/templateBuild.js
Normal file
299
server/scripts/templateBuild.js
Normal file
@@ -0,0 +1,299 @@
|
||||
#!/usr/bin/env node
|
||||
// ── Do core's own validators accept the event recipes? ─────────────────────
|
||||
//
|
||||
// `test/eventTemplates.test.js` runs against a FAKE core. It can say a recipe
|
||||
// builds the spec it means to; it cannot say core agrees, because the things core
|
||||
// would object to — a phase key's grammar, a step param that action no longer has,
|
||||
// a lease core cannot find, an input shape `registerEventTemplates` refuses — are
|
||||
// facts about core's code, not ours. A recipe core refuses is also worse than a
|
||||
// missing one: a template that fails `registerEventTemplates` fails the whole
|
||||
// module's load, and one whose `build()` returns a spec core rejects shows an
|
||||
// author "made a plan core cannot accept" for a form they filled in correctly.
|
||||
//
|
||||
// So this script puts the module through core's real loader and builds every
|
||||
// recipe through `buildFromTemplate`, which is the path the New event page takes:
|
||||
// inputs checked against the declaration, `build()` called, the spec run through
|
||||
// core's real `spec.validate` with this module's actions registered.
|
||||
//
|
||||
// It needs a core checkout with its server dependencies installed, and nothing
|
||||
// else: no database (the pool is pointed at a closed port, as core's own tests do
|
||||
// and for the same reason), no shard, no network except the one `npm ci` below.
|
||||
//
|
||||
// The module is COPIED to a temp directory as `uo`, never symlinked (core's loader
|
||||
// skips a link silently) and never installed over the checkout — a check that
|
||||
// rewrote the tree it was checking would be a strange thing to run locally.
|
||||
// `client/dist/entry.js` has to exist before the loader accepts the module at all;
|
||||
// CI builds it in the step before, and locally `npm run build --prefix client`.
|
||||
//
|
||||
// Usage:
|
||||
// node server/scripts/templateBuild.js --core <core checkout> --module <module dir>
|
||||
|
||||
const fs = require('fs')
|
||||
const os = require('os')
|
||||
const path = require('path')
|
||||
const { createRequire } = require('module')
|
||||
const { spawnSync } = require('child_process')
|
||||
|
||||
// ── The fixtures ────────────────────────────────────────────────────────────
|
||||
//
|
||||
// Every recipe, with and without its optional inputs, plus a few refusals, which
|
||||
// prove the author's sentence survives core's handling intact. An `expect` of
|
||||
// `'refused'` means core must answer `ok: false` with status 400 and the given
|
||||
// words in the first error; otherwise the build must come back `ok: true`, which
|
||||
// means the spec passed core's real validator.
|
||||
|
||||
const FIXTURES = [
|
||||
{
|
||||
template: 'uo.template.announce',
|
||||
label: 'text only',
|
||||
inputs: { text: 'The gates of Britain open at dusk. Gather at the bank.' },
|
||||
},
|
||||
{
|
||||
template: 'uo.template.announce',
|
||||
label: 'with colour and a news article',
|
||||
inputs: { text: 'The fair opens on Friday.', hue: 1153, newsTitle: 'The Britannian Midsummer Fair', newsMinutes: 2880 },
|
||||
},
|
||||
{
|
||||
template: 'uo.template.announce',
|
||||
label: 'news title, default length',
|
||||
inputs: { text: 'The fair opens on Friday.', newsTitle: 'The Fair' },
|
||||
},
|
||||
{
|
||||
template: 'uo.template.announce',
|
||||
label: 'a news length with no title is refused',
|
||||
inputs: { text: 'Hello', newsMinutes: 60 },
|
||||
expect: 'refused',
|
||||
words: /news title/,
|
||||
},
|
||||
|
||||
{
|
||||
template: 'uo.template.boss_raid',
|
||||
label: 'required inputs only',
|
||||
inputs: { place: 'Felucca/Britain', creature: 'OrcCaptain', name: 'Gruk the Unbroken', minutes: 30 },
|
||||
},
|
||||
{
|
||||
template: 'uo.template.boss_raid',
|
||||
label: 'every input',
|
||||
inputs: {
|
||||
place: 'Felucca/Cities/Britain',
|
||||
creature: 'OrcCaptain',
|
||||
name: 'Gruk the Unbroken',
|
||||
minutes: 90,
|
||||
count: 3,
|
||||
strength: 2.5,
|
||||
message: 'Gruk and his warband march on Britain!',
|
||||
},
|
||||
},
|
||||
{
|
||||
template: 'uo.template.boss_raid',
|
||||
label: 'a count above the cap is refused',
|
||||
inputs: { place: 'Felucca/Britain', creature: 'OrcCaptain', name: 'Gruk', minutes: 30, count: 99 },
|
||||
expect: 'refused',
|
||||
words: /bosses/,
|
||||
},
|
||||
|
||||
{
|
||||
template: 'uo.template.seasonal',
|
||||
label: 'required inputs only',
|
||||
inputs: { event: 'Fellowship', minutes: 180 },
|
||||
},
|
||||
{
|
||||
template: 'uo.template.seasonal',
|
||||
label: 'with a message, at the lease ceiling',
|
||||
inputs: { event: 'KrampusEncounter', minutes: 720, message: 'The Krampus has come to Britannia!' },
|
||||
},
|
||||
{
|
||||
template: 'uo.template.seasonal',
|
||||
label: 'an event the lease excludes is refused',
|
||||
inputs: { event: 'TreasuresOfTokuno', minutes: 60 },
|
||||
expect: 'refused',
|
||||
words: /not a seasonal event/,
|
||||
},
|
||||
|
||||
{
|
||||
template: 'uo.template.gathering_giveaway',
|
||||
label: 'required inputs only',
|
||||
inputs: { place: 'Felucca/Britain', minutes: 30, item: 'gold' },
|
||||
},
|
||||
{
|
||||
template: 'uo.template.gathering_giveaway',
|
||||
label: 'every input',
|
||||
inputs: {
|
||||
place: 'Felucca/Cities/Britain',
|
||||
minutes: 45,
|
||||
item: 'gold',
|
||||
amount: 500,
|
||||
radius: 100,
|
||||
message: 'Come to Britain for a gift of gold!',
|
||||
},
|
||||
},
|
||||
{
|
||||
template: 'uo.template.gathering_giveaway',
|
||||
label: 'a non-stacking item, one each',
|
||||
inputs: { place: 'Felucca/Britain', minutes: 60, item: 'cloak' },
|
||||
},
|
||||
{
|
||||
template: 'uo.template.gathering_giveaway',
|
||||
label: 'a non-stacking item in quantity is refused',
|
||||
inputs: { place: 'Felucca/Britain', minutes: 60, item: 'cloak', amount: 5 },
|
||||
expect: 'refused',
|
||||
words: /does not stack/,
|
||||
},
|
||||
]
|
||||
|
||||
// ── Plumbing ────────────────────────────────────────────────────────────────
|
||||
|
||||
function parseArgs(argv) {
|
||||
const out = {}
|
||||
for (let i = 0; i < argv.length; i++) {
|
||||
if (argv[i] === '--core') out.core = argv[++i]
|
||||
else if (argv[i] === '--module') out.module = argv[++i]
|
||||
else throw new Error(`unknown argument "${argv[i]}"`)
|
||||
}
|
||||
if (!out.core || !out.module) {
|
||||
throw new Error('usage: node server/scripts/templateBuild.js --core <core checkout> --module <module dir>')
|
||||
}
|
||||
return { core: path.resolve(out.core), module: path.resolve(out.module) }
|
||||
}
|
||||
|
||||
/** Copy the module as `<tmp>/uo`, without `.git` or any `node_modules`, and install its production deps. */
|
||||
function stageModule(moduleDir, tmpRoot) {
|
||||
const dest = path.join(tmpRoot, 'uo')
|
||||
fs.cpSync(moduleDir, dest, {
|
||||
recursive: true,
|
||||
filter: (src) => {
|
||||
const base = path.basename(src)
|
||||
return base !== '.git' && base !== 'node_modules'
|
||||
},
|
||||
})
|
||||
if (!fs.existsSync(path.join(dest, 'client', 'dist', 'entry.js'))) {
|
||||
throw new Error(
|
||||
`${path.join(moduleDir, 'client', 'dist', 'entry.js')} is missing — the loader refuses a module with no client chunk. ` +
|
||||
'Build it first: npm run build --prefix client',
|
||||
)
|
||||
}
|
||||
// What the release ships and CI installs: the production dependencies, from the
|
||||
// lockfile. One command string through a shell, because npm is a .cmd on Windows
|
||||
// and Node will not spawn one directly; the only path in it is our own temp dir.
|
||||
const install = spawnSync(`npm ci --omit=dev --no-audit --no-fund --prefix "${path.join(dest, 'server')}"`, {
|
||||
encoding: 'utf8',
|
||||
shell: true,
|
||||
})
|
||||
if (install.status !== 0) {
|
||||
throw new Error(`npm ci in the staged module failed:\n${install.stdout || ''}${install.stderr || ''}`)
|
||||
}
|
||||
return dest
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const args = parseArgs(process.argv.slice(2))
|
||||
const coreServer = path.join(args.core, 'server')
|
||||
if (!fs.existsSync(path.join(coreServer, 'node_modules'))) {
|
||||
throw new Error(`${coreServer}/node_modules is missing — run npm ci --prefix ${path.join(args.core, 'server')}`)
|
||||
}
|
||||
|
||||
const tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'uo-template-build-'))
|
||||
let exitCode = 1
|
||||
let db = null
|
||||
try {
|
||||
stageModule(args.module, tmpRoot)
|
||||
|
||||
// BEFORE core is required: the loader reads MODULES_DIR once, when its file is
|
||||
// evaluated, and the pool opens a connection lazily against whatever these say.
|
||||
// A closed port makes a stray query fail at once instead of hanging a check
|
||||
// that is meant to need no database.
|
||||
process.env.MODULES_DIR = tmpRoot
|
||||
process.env.DB_HOST = '127.0.0.1'
|
||||
process.env.DB_PORT = '59999'
|
||||
|
||||
const coreRequire = createRequire(path.join(coreServer, 'package.json'))
|
||||
const express = coreRequire('express')
|
||||
db = coreRequire('./src/utils/db')
|
||||
const registries = coreRequire('./src/modules/registries')
|
||||
const loader = coreRequire('./src/modules/loader')
|
||||
const definitions = coreRequire('./src/model/events/eventDefinitions.model')
|
||||
|
||||
// The module fills `admin.users.detail`, a slot core's own users router
|
||||
// declares as it is required (`registries.declareSlot`). Requiring that router
|
||||
// is what declares it for real, rather than this script claiming a slot exists.
|
||||
coreRequire('./src/router/v1/admin/users.router')
|
||||
|
||||
// The same three tier routers core's own step-editor test hands the loader.
|
||||
loader.load({ public: express.Router(), admin: express.Router(), player: express.Router() })
|
||||
const record = loader.list().find((m) => m.id === 'uo')
|
||||
if (!record || record.state !== 'registered') {
|
||||
throw new Error(`core did not register the module: ${record ? `${record.state} — ${record.reason}` : 'it was not found'}`)
|
||||
}
|
||||
// Core's own actions (`core.lease`, `core.wait`…) are what a recipe's spec may
|
||||
// name beside the module's, and they are registered separately from the scan.
|
||||
registries.registerCore()
|
||||
|
||||
const catalog = registries.allEventTemplates().filter((t) => t.owner === 'uo')
|
||||
const registered = new Set(catalog.map((t) => t.id))
|
||||
const covered = new Set(FIXTURES.map((f) => f.template))
|
||||
let failures = 0
|
||||
for (const id of registered) {
|
||||
if (!covered.has(id)) {
|
||||
failures++
|
||||
console.log(`FAIL ${id} has no fixture in templateBuild.js`)
|
||||
}
|
||||
}
|
||||
for (const id of covered) {
|
||||
if (!registered.has(id)) {
|
||||
failures++
|
||||
console.log(`FAIL ${id} is not registered by the module`)
|
||||
}
|
||||
}
|
||||
|
||||
for (const fixture of FIXTURES) {
|
||||
const name = `${fixture.template} (${fixture.label})`
|
||||
let result
|
||||
try {
|
||||
result = await definitions.buildFromTemplate(fixture.template, fixture.inputs)
|
||||
} catch (err) {
|
||||
failures++
|
||||
console.log(`FAIL ${name} threw: ${err.message}`)
|
||||
continue
|
||||
}
|
||||
|
||||
if (fixture.expect === 'refused') {
|
||||
const said = (result.errors || [])[0] || ''
|
||||
if (result.ok === false && result.status === 400 && fixture.words.test(said)) {
|
||||
console.log(`OK ${name} refused: ${said}`)
|
||||
} else {
|
||||
failures++
|
||||
console.log(`FAIL ${name} expected a 400 refusal matching ${fixture.words}, got ${JSON.stringify(result)}`)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
if (result.ok === true) {
|
||||
const phases = result.draft.spec.phases.map((p) => p.key).join(' > ')
|
||||
console.log(`OK ${name} "${result.draft.title}" [${phases}]`)
|
||||
} else {
|
||||
failures++
|
||||
console.log(`FAIL ${name} status ${result.status}: ${(result.errors || []).join(' | ')}`)
|
||||
}
|
||||
}
|
||||
|
||||
console.log(failures ? `\n${failures} failure(s)` : `\nAll ${FIXTURES.length} fixtures passed through core's registry and spec validator.`)
|
||||
exitCode = failures ? 1 : 0
|
||||
} finally {
|
||||
// Close core's pool or the process hangs on it, then take the copy away.
|
||||
try {
|
||||
if (db && typeof db.close === 'function') await db.close()
|
||||
} catch {
|
||||
/* the pool never opened a connection; nothing to close */
|
||||
}
|
||||
fs.rmSync(tmpRoot, { recursive: true, force: true })
|
||||
}
|
||||
return exitCode
|
||||
}
|
||||
|
||||
main().then(
|
||||
(code) => process.exit(code),
|
||||
(err) => {
|
||||
console.error(`templateBuild: ${err.message}`)
|
||||
process.exit(1)
|
||||
},
|
||||
)
|
||||
@@ -107,6 +107,7 @@ function fakeApi() {
|
||||
eventActions: null,
|
||||
eventBudgets: null,
|
||||
eventOptionSources: null,
|
||||
eventTemplates: null,
|
||||
hooks: {},
|
||||
}
|
||||
const called = new Set()
|
||||
@@ -147,6 +148,9 @@ function fakeApi() {
|
||||
// for a second one: a verb this module calls and this fake does not have is a
|
||||
// TypeError in `entry.test.js` rather than a surprise at somebody's boot.
|
||||
registerEventLeases(leases) { once('registerEventLeases'); record.eventLeases = leases },
|
||||
// MODULE_API 1.13.0. `once` as for the rest: core stages a registrant's whole
|
||||
// batch and applies it as one.
|
||||
registerEventTemplates(templates) { once('registerEventTemplates'); record.eventTemplates = templates },
|
||||
onBoot(fn) { once('onBoot'); record.hooks.onBoot = fn },
|
||||
onShutdown(fn) { once('onShutdown'); record.hooks.onShutdown = fn },
|
||||
// MODULE_API 1.20.0 (account deletion, ACCOUNT_DELETION.md §4.4).
|
||||
|
||||
@@ -128,6 +128,17 @@ test('registers exactly what module.json declares', () => {
|
||||
'uo.options.spawners',
|
||||
],
|
||||
)
|
||||
// The four recipes (MODULE_API 1.13.0). Each id carries this module's prefix, which
|
||||
// core's loader enforces, and its own suite is eventTemplates.test.js.
|
||||
assert.deepStrictEqual(
|
||||
api.record.eventTemplates.map((t) => t.id).sort(),
|
||||
[
|
||||
'uo.template.announce',
|
||||
'uo.template.boss_raid',
|
||||
'uo.template.gathering_giveaway',
|
||||
'uo.template.seasonal',
|
||||
],
|
||||
)
|
||||
assert.ok(api.record.streams.length > 0)
|
||||
assert.strictEqual(typeof api.record.hooks.onBoot, 'function')
|
||||
assert.strictEqual(typeof api.record.hooks.onShutdown, 'function')
|
||||
|
||||
395
server/test/eventTemplates.test.js
Normal file
395
server/test/eventTemplates.test.js
Normal file
@@ -0,0 +1,395 @@
|
||||
// The four event recipes (MODULE_API 1.13.0): what each one builds, and what it
|
||||
// refuses in words an author can read.
|
||||
//
|
||||
// This suite runs against a FAKE core, so it can say a spec has the right shape
|
||||
// but not that core accepts it. That half is `scripts/templateBuild.js`, which
|
||||
// builds every recipe through core's own registry and spec validator in CI.
|
||||
|
||||
const test = require('node:test')
|
||||
const assert = require('node:assert')
|
||||
|
||||
const register = require('../index')
|
||||
const { fakeCtx, fakeApi } = require('./_fakes')
|
||||
const templates = require('../eventTemplates')
|
||||
const actions = require('../config/uoEventActions')
|
||||
|
||||
const byId = (id) => templates.TEMPLATES.find((t) => t.id === id)
|
||||
const build = (id, inputs) => byId(id).build({ inputs })
|
||||
|
||||
const ID_GRAMMAR = /^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)+$/
|
||||
const PHASE_KEY = /^[a-z][a-z0-9]*(?:[-_][a-z0-9]+)*$/
|
||||
// What core's `checkActionParam` lets through (registries.js).
|
||||
const INPUT_KEYS = ['name', 'type', 'required', 'example', 'description', 'source', 'duration', 'max']
|
||||
const TYPES = ['string', 'int', 'float', 'boolean', 'datetime', 'url']
|
||||
|
||||
const refused = (result, pattern) => {
|
||||
assert.strictEqual(result.ok, false, 'expected a refusal')
|
||||
assert.strictEqual(typeof result.error, 'string')
|
||||
assert.ok(result.error.length > 10, 'a refusal is a sentence')
|
||||
if (pattern) assert.match(result.error, pattern)
|
||||
}
|
||||
|
||||
const stepIds = (phase) => phase.steps.map((s) => s.actionId)
|
||||
|
||||
// ── Registration and declarations ───────────────────────────────────────────
|
||||
|
||||
test('index.js registers the four recipes, once, through registerEventTemplates', () => {
|
||||
const api = fakeApi()
|
||||
register(fakeCtx(), api)
|
||||
assert.deepStrictEqual(
|
||||
api.record.eventTemplates.map((t) => t.id).sort(),
|
||||
['uo.template.announce', 'uo.template.boss_raid', 'uo.template.gathering_giveaway', 'uo.template.seasonal'],
|
||||
)
|
||||
})
|
||||
|
||||
test('every recipe is shaped the way core\'s registry demands', () => {
|
||||
assert.strictEqual(templates.TEMPLATES.length, 4)
|
||||
const actionIds = new Set(actions.ACTIONS.map((a) => a.id).concat('core.lease'))
|
||||
const leaseIds = new Set(actions.LEASES.map((l) => l.id))
|
||||
const sourceIds = new Set(actions.OPTION_SOURCES.map((s) => s.id))
|
||||
|
||||
for (const t of templates.TEMPLATES) {
|
||||
assert.match(t.id, ID_GRAMMAR)
|
||||
assert.ok(t.id.startsWith('uo.'), `${t.id} must carry this module's prefix`)
|
||||
assert.ok(t.label, `${t.id} has no label`)
|
||||
assert.ok(t.description.length > 40, `${t.id} needs a description an author can read`)
|
||||
assert.strictEqual(typeof t.build, 'function')
|
||||
assert.ok(t.inputs.length >= 1 && t.inputs.length <= 8, `${t.id} asks for ${t.inputs.length} inputs`)
|
||||
|
||||
const seen = new Set()
|
||||
for (const input of t.inputs) {
|
||||
const where = `${t.id}.${input.name}`
|
||||
assert.match(input.name, /^[A-Za-z][A-Za-z0-9_]*$/, where)
|
||||
assert.ok(!seen.has(input.name), `${where} declared twice`)
|
||||
seen.add(input.name)
|
||||
assert.ok(TYPES.includes(input.type), `${where} has type ${input.type}`)
|
||||
for (const key of Object.keys(input)) assert.ok(INPUT_KEYS.includes(key), `${where} has unknown key ${key}`)
|
||||
// Core refuses an input with no example, optional or not, and silently drops `default`.
|
||||
assert.ok(input.example !== undefined && input.example !== null && input.example !== '', `${where} needs an example`)
|
||||
assert.ok(input.description && input.description.length > 10, `${where} needs a plain-English description`)
|
||||
assert.strictEqual(input.default, undefined, `${where}: core drops \`default\`; apply it in build()`)
|
||||
assert.strictEqual(input.multiple, undefined, `${where}: a template input cannot be multiple`)
|
||||
assert.strictEqual(typeof input.required, 'boolean', `${where} should say whether it is required`)
|
||||
if (input.duration !== undefined) {
|
||||
assert.strictEqual(input.duration, 'minutes')
|
||||
assert.ok(input.type === 'int' || input.type === 'float', `${where}: a duration is a number`)
|
||||
}
|
||||
if (input.source) assert.ok(sourceIds.has(input.source), `${where} names a source no module declares`)
|
||||
}
|
||||
}
|
||||
|
||||
// The actions and lease the recipes build steps out of all exist.
|
||||
const used = new Set()
|
||||
const sample = {
|
||||
'uo.template.announce': { text: 'Hello', newsTitle: 'News' },
|
||||
'uo.template.boss_raid': { place: 'Felucca/Britain', creature: 'OrcCaptain', name: 'Gruk', minutes: 10 },
|
||||
'uo.template.seasonal': { event: 'Fellowship', minutes: 60, message: 'On' },
|
||||
'uo.template.gathering_giveaway': { place: 'Felucca/Britain', minutes: 10, item: 'gold' },
|
||||
}
|
||||
for (const [id, inputs] of Object.entries(sample)) {
|
||||
const built = build(id, inputs)
|
||||
for (const phase of built.spec.phases) {
|
||||
for (const step of phase.steps) {
|
||||
used.add(step.actionId)
|
||||
assert.ok(actionIds.has(step.actionId), `${id} uses ${step.actionId}, which nobody declares`)
|
||||
if (step.actionId === 'core.lease') assert.ok(leaseIds.has(step.params.lease), `${id} leases ${step.params.lease}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
assert.ok(used.size >= 7)
|
||||
})
|
||||
|
||||
test('every built plan is a plain spec: three top-level keys at most, legal phase keys, one gate form', () => {
|
||||
const fixtures = [
|
||||
['uo.template.announce', { text: 'Hello', newsTitle: 'News', newsMinutes: 90, hue: 5 }],
|
||||
['uo.template.boss_raid', { place: 'Felucca/Britain', creature: 'OrcCaptain', name: 'Gruk', minutes: 30, count: 2, strength: 2.5 }],
|
||||
['uo.template.seasonal', { event: 'RisingTide', minutes: 720 }],
|
||||
['uo.template.gathering_giveaway', { place: 'Felucca/Cities/Britain', minutes: 30, item: 'cloak' }],
|
||||
]
|
||||
for (const [id, inputs] of fixtures) {
|
||||
const built = build(id, inputs)
|
||||
assert.ok(!('ok' in built), `${id}: ${built.error}`)
|
||||
assert.ok(built.title && built.summary)
|
||||
assert.deepStrictEqual(built.spec.schedule, { kind: 'manual' })
|
||||
for (const key of Object.keys(built.spec)) assert.ok(['schedule', 'phases', 'starts'].includes(key), `${id}: ${key}`)
|
||||
const keys = new Set()
|
||||
for (const phase of built.spec.phases) {
|
||||
assert.match(phase.key, PHASE_KEY)
|
||||
assert.ok(!keys.has(phase.key))
|
||||
keys.add(phase.key)
|
||||
assert.ok(phase.label)
|
||||
assert.ok(phase.steps.length > 0)
|
||||
if (phase.advance) assert.match(phase.advance.after, /^\d+m$/)
|
||||
for (const step of phase.steps) {
|
||||
assert.ok(step.label)
|
||||
assert.strictEqual(typeof step.params, 'object')
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// ── Announcement ────────────────────────────────────────────────────────────
|
||||
|
||||
test('announce: a broadcast alone has no hold', () => {
|
||||
const built = build('uo.template.announce', { text: ' The gates open at dusk. ' })
|
||||
assert.strictEqual(built.spec.phases.length, 1)
|
||||
const [phase] = built.spec.phases
|
||||
assert.strictEqual(phase.key, 'announce')
|
||||
assert.deepStrictEqual(stepIds(phase), ['uo.broadcast'])
|
||||
assert.deepStrictEqual(phase.steps[0].params, { text: 'The gates open at dusk.' })
|
||||
assert.strictEqual(phase.advance, undefined)
|
||||
assert.match(built.title, /^Announcement: The gates open at dusk\.$/)
|
||||
})
|
||||
|
||||
test('announce: a hue is passed through, and an empty one is left out', () => {
|
||||
const [phase] = build('uo.template.announce', { text: 'Hi', hue: 1153 }).spec.phases
|
||||
assert.deepStrictEqual(phase.steps[0].params, { text: 'Hi', hue: 1153 })
|
||||
const [bare] = build('uo.template.announce', { text: 'Hi', hue: '' }).spec.phases
|
||||
assert.deepStrictEqual(bare.steps[0].params, { text: 'Hi' })
|
||||
// Zero is a colour, not an empty box.
|
||||
const [zero] = build('uo.template.announce', { text: 'Hi', hue: 0 }).spec.phases
|
||||
assert.strictEqual(zero.steps[0].params.hue, 0)
|
||||
})
|
||||
|
||||
test('announce: a news title adds the article, holds the phase for a day by default, and does not proclaim twice', () => {
|
||||
const built = build('uo.template.announce', { text: 'Fair opens Friday.', newsTitle: ' The Fair ' })
|
||||
const [phase] = built.spec.phases
|
||||
assert.deepStrictEqual(stepIds(phase), ['uo.broadcast', 'uo.news.post'])
|
||||
assert.deepStrictEqual(phase.steps[1].params, { title: 'The Fair', body: 'Fair opens Friday.', announce: false })
|
||||
assert.deepStrictEqual(phase.advance, { after: '1440m' })
|
||||
assert.match(built.summary, /Town Cryer news for 24 hours/)
|
||||
})
|
||||
|
||||
test('announce: newsMinutes sets the hold', () => {
|
||||
const [phase] = build('uo.template.announce', { text: 'x y', newsTitle: 'T', newsMinutes: 90 }).spec.phases
|
||||
assert.deepStrictEqual(phase.advance, { after: '90m' })
|
||||
})
|
||||
|
||||
test('announce: refusals are sentences', () => {
|
||||
refused(build('uo.template.announce', { text: ' ' }), /no text/)
|
||||
refused(build('uo.template.announce', { text: 'x'.repeat(actions.MAX_BROADCAST_LEN + 1) }), /capped at 300/)
|
||||
// At the cap is fine.
|
||||
assert.ok(!('ok' in build('uo.template.announce', { text: 'x'.repeat(actions.MAX_BROADCAST_LEN) })))
|
||||
refused(build('uo.template.announce', { text: 'Hi', hue: -1 }), /colour/)
|
||||
refused(build('uo.template.announce', { text: 'Hi', hue: 1.5 }), /colour/)
|
||||
refused(build('uo.template.announce', { text: 'Hi', newsMinutes: 60 }), /needs a news title/)
|
||||
refused(build('uo.template.announce', { text: 'Hi', newsTitle: 'T'.repeat(actions.MAX_NEWS_TITLE + 1) }), /news title is capped/)
|
||||
refused(build('uo.template.announce', { text: 'Hi', newsTitle: 'T', newsMinutes: 0 }), /1 to \d+ minutes/)
|
||||
refused(build('uo.template.announce', { text: 'Hi', newsTitle: 'T', newsMinutes: 1.5 }), /1 to \d+ minutes/)
|
||||
refused(build('uo.template.announce', { text: 'Hi', newsTitle: 'T', newsMinutes: templates.MAX_HOLD_MINUTES + 1 }), /1 to \d+ minutes/)
|
||||
})
|
||||
|
||||
// ── Boss raid ───────────────────────────────────────────────────────────────
|
||||
|
||||
const RAID = { place: 'Felucca/Britain', creature: 'OrcCaptain', name: 'Gruk the Unbroken', minutes: 30 }
|
||||
|
||||
test('boss raid: defaults — one boss, no strength keys, a plain message, held for the raid', () => {
|
||||
const built = build('uo.template.boss_raid', RAID)
|
||||
assert.strictEqual(built.title, 'Orc Captain raid at Felucca/Britain for 30 minutes')
|
||||
assert.match(built.summary, /^Gruk the Unbroken, built from Orc Captain, appears near Felucca\/Britain and is removed after 30 minutes\.$/)
|
||||
const [phase] = built.spec.phases
|
||||
assert.strictEqual(built.spec.phases.length, 1)
|
||||
assert.strictEqual(phase.key, 'raid')
|
||||
assert.deepStrictEqual(phase.advance, { after: '30m' })
|
||||
assert.deepStrictEqual(stepIds(phase), ['uo.boss.spawn', 'uo.broadcast'])
|
||||
assert.deepStrictEqual(phase.steps[0].params, {
|
||||
place: 'Felucca/Britain',
|
||||
creature: 'OrcCaptain',
|
||||
name: 'Gruk the Unbroken',
|
||||
count: 1,
|
||||
})
|
||||
assert.deepStrictEqual(phase.steps[1].params, { text: 'Gruk the Unbroken has appeared near Britain!' })
|
||||
})
|
||||
|
||||
test('boss raid: strength 1 is the same as leaving it out', () => {
|
||||
const [phase] = build('uo.template.boss_raid', { ...RAID, strength: 1 }).spec.phases
|
||||
assert.strictEqual(phase.steps[0].params.hitsMultiplier, undefined)
|
||||
assert.strictEqual(phase.steps[0].params.damageMultiplier, undefined)
|
||||
})
|
||||
|
||||
test('boss raid: strength sets both multipliers, and a count and message are kept', () => {
|
||||
const built = build('uo.template.boss_raid', { ...RAID, strength: 2.5, count: 3, message: ' Run! ', minutes: 120 })
|
||||
const [phase] = built.spec.phases
|
||||
assert.strictEqual(phase.steps[0].params.hitsMultiplier, 2.5)
|
||||
assert.strictEqual(phase.steps[0].params.damageMultiplier, 2.5)
|
||||
assert.strictEqual(phase.steps[0].params.count, 3)
|
||||
assert.deepStrictEqual(phase.steps[1].params, { text: 'Run!' })
|
||||
assert.deepStrictEqual(phase.advance, { after: '120m' })
|
||||
assert.match(built.title, /for 2 hours$/)
|
||||
assert.match(built.summary, /^3 bosses called Gruk the Unbroken, built from Orc Captain and 2\.5 times as strong, appear near/)
|
||||
})
|
||||
|
||||
test('boss raid: the bounds are the action\'s own', () => {
|
||||
const top = build('uo.template.boss_raid', { ...RAID, count: actions.MAX_BOSSES, strength: actions.MAX_BOSS_MULTIPLIER })
|
||||
assert.ok(!('ok' in top))
|
||||
refused(build('uo.template.boss_raid', { ...RAID, count: actions.MAX_BOSSES + 1 }), /1 to 4 bosses/)
|
||||
refused(build('uo.template.boss_raid', { ...RAID, count: 0 }), /1 to 4 bosses/)
|
||||
refused(build('uo.template.boss_raid', { ...RAID, strength: actions.MAX_BOSS_MULTIPLIER + 0.5 }), /1 to 10 times/)
|
||||
refused(build('uo.template.boss_raid', { ...RAID, strength: 0.5 }), /1 to 10 times/)
|
||||
})
|
||||
|
||||
test('boss raid: refusals are sentences', () => {
|
||||
refused(build('uo.template.boss_raid', { ...RAID, place: 'Britain' }), /not a place/)
|
||||
refused(build('uo.template.boss_raid', { ...RAID, place: 'Felucca/' }), /not a place/)
|
||||
refused(build('uo.template.boss_raid', { ...RAID, creature: ' ' }), /pick a creature/)
|
||||
refused(build('uo.template.boss_raid', { ...RAID, name: '' }), /needs a name/)
|
||||
refused(build('uo.template.boss_raid', { ...RAID, minutes: 0 }), /1 to \d+ minutes/)
|
||||
refused(build('uo.template.boss_raid', { ...RAID, minutes: 'soon' }), /1 to \d+ minutes/)
|
||||
refused(build('uo.template.boss_raid', { ...RAID, message: 'x'.repeat(301) }), /capped at 300/)
|
||||
// The default message is what overflows when the name is huge, and the refusal says so.
|
||||
refused(build('uo.template.boss_raid', { ...RAID, name: 'N'.repeat(300) }), /default message/)
|
||||
})
|
||||
|
||||
// ── Seasonal ────────────────────────────────────────────────────────────────
|
||||
|
||||
test('seasonal: one lease step on the chosen event, held for the same length, no broadcast without a message', () => {
|
||||
const built = build('uo.template.seasonal', { event: 'KrampusEncounter', minutes: 180 })
|
||||
const [phase] = built.spec.phases
|
||||
assert.strictEqual(phase.key, 'season')
|
||||
assert.deepStrictEqual(phase.advance, { after: '180m' })
|
||||
assert.deepStrictEqual(stepIds(phase), ['core.lease'])
|
||||
assert.deepStrictEqual(phase.steps[0].params, {
|
||||
lease: 'uo.seasonal.status',
|
||||
target: 'KrampusEncounter',
|
||||
value: 'Active',
|
||||
minutes: 180,
|
||||
})
|
||||
assert.strictEqual(built.title, 'Krampus Encounter for 3 hours')
|
||||
})
|
||||
|
||||
test('seasonal: a message adds a broadcast after the lease', () => {
|
||||
const [phase] = build('uo.template.seasonal', { event: 'Fellowship', minutes: 45, message: 'It is on!' }).spec.phases
|
||||
assert.deepStrictEqual(stepIds(phase), ['core.lease', 'uo.broadcast'])
|
||||
assert.deepStrictEqual(phase.steps[1].params, { text: 'It is on!' })
|
||||
})
|
||||
|
||||
test('seasonal: every event the lease allows builds, and the lease ceiling is the limit', () => {
|
||||
for (const event of actions.SEASONAL_EVENTS) {
|
||||
assert.ok(!('ok' in build('uo.template.seasonal', { event, minutes: 60 })), event)
|
||||
}
|
||||
assert.strictEqual(templates.MAX_SEASONAL_MINUTES, actions.MAX_PROP_LEASE_MS / 60_000)
|
||||
assert.strictEqual(templates.MAX_SEASONAL_MINUTES, 720)
|
||||
assert.ok(!('ok' in build('uo.template.seasonal', { event: 'Fellowship', minutes: 720 })))
|
||||
refused(build('uo.template.seasonal', { event: 'Fellowship', minutes: 721 }), /1 to 720 minutes/)
|
||||
})
|
||||
|
||||
test('seasonal: refusals are sentences', () => {
|
||||
refused(build('uo.template.seasonal', { event: 'TreasuresOfTokuno', minutes: 60 }), /not a seasonal event/)
|
||||
refused(build('uo.template.seasonal', { event: 'Christmas', minutes: 60 }), /not a seasonal event/)
|
||||
refused(build('uo.template.seasonal', { event: 'Fellowship', minutes: 0 }), /1 to 720 minutes/)
|
||||
refused(build('uo.template.seasonal', { event: 'Fellowship', minutes: 2.5 }), /1 to 720 minutes/)
|
||||
refused(build('uo.template.seasonal', { event: 'Fellowship', minutes: 60, message: 'x'.repeat(301) }), /capped at 300/)
|
||||
})
|
||||
|
||||
test('seasonal: the description carries the warnings the decision asks for', () => {
|
||||
const { description } = byId('uo.template.seasonal')
|
||||
assert.match(description, /back off by itself|puts the old one back/)
|
||||
assert.match(description, /six of the eight/i)
|
||||
assert.match(description, /12 hours/)
|
||||
})
|
||||
|
||||
// ── Gathering giveaway ──────────────────────────────────────────────────────
|
||||
|
||||
const GIVEAWAY = { place: 'Felucca/Britain', minutes: 30, item: 'gold' }
|
||||
|
||||
test('giveaway: two phases — gather (held), then reward — with defaults applied', () => {
|
||||
const built = build('uo.template.gathering_giveaway', GIVEAWAY)
|
||||
assert.strictEqual(built.spec.phases.length, 2)
|
||||
const [gather, reward] = built.spec.phases
|
||||
|
||||
assert.strictEqual(gather.key, 'gather')
|
||||
assert.deepStrictEqual(gather.advance, { after: '30m' })
|
||||
assert.deepStrictEqual(stepIds(gather), ['uo.broadcast', 'uo.participation.open'])
|
||||
assert.deepStrictEqual(gather.steps[0].params, { text: 'Gather near Britain in the next 30 minutes for a gift!' })
|
||||
assert.deepStrictEqual(gather.steps[1].params, { place: 'Felucca/Britain', radius: 40 })
|
||||
|
||||
assert.strictEqual(reward.key, 'reward')
|
||||
assert.strictEqual(reward.advance, undefined)
|
||||
assert.deepStrictEqual(stepIds(reward), ['uo.participation.collect', 'uo.item.grant', 'uo.broadcast'])
|
||||
assert.deepStrictEqual(reward.steps[0].params, {})
|
||||
assert.deepStrictEqual(reward.steps[1].params, { item: 'gold', amount: 1 })
|
||||
assert.deepStrictEqual(reward.steps[2].params, { text: 'Thank you for coming — gifts are in your backpacks.' })
|
||||
|
||||
assert.strictEqual(built.title, 'Gathering giveaway at Felucca/Britain for 30 minutes')
|
||||
assert.match(built.summary, /Gifts cannot be taken back\.$/)
|
||||
})
|
||||
|
||||
test('giveaway: amount, radius and message are carried', () => {
|
||||
const built = build('uo.template.gathering_giveaway', { ...GIVEAWAY, amount: 500, radius: 100, message: 'Come on down' })
|
||||
const [gather, reward] = built.spec.phases
|
||||
assert.deepStrictEqual(gather.steps[0].params, { text: 'Come on down' })
|
||||
assert.deepStrictEqual(gather.steps[1].params, { place: 'Felucca/Britain', radius: 100 })
|
||||
assert.deepStrictEqual(reward.steps[1].params, { item: 'gold', amount: 500 })
|
||||
assert.match(built.summary, /500 gold each/)
|
||||
})
|
||||
|
||||
test('giveaway: a long window reads in hours in the default message', () => {
|
||||
const [gather] = build('uo.template.gathering_giveaway', { ...GIVEAWAY, minutes: 120 }).spec.phases
|
||||
assert.match(gather.steps[0].params.text, /in the next 2 hours for a gift!$/)
|
||||
})
|
||||
|
||||
test('giveaway: a non-stackable item is one each, and says why when asked for more', () => {
|
||||
const ok = build('uo.template.gathering_giveaway', { ...GIVEAWAY, item: 'cloak', amount: 1 })
|
||||
assert.deepStrictEqual(ok.spec.phases[1].steps[1].params, { item: 'cloak', amount: 1 })
|
||||
refused(build('uo.template.gathering_giveaway', { ...GIVEAWAY, item: 'cloak', amount: 2 }), /does not stack/)
|
||||
// Every non-stackable on the allowlist behaves the same; gold alone stacks.
|
||||
for (const g of actions.GRANTABLE) {
|
||||
const result = build('uo.template.gathering_giveaway', { ...GIVEAWAY, item: g.key, amount: 2 })
|
||||
if (g.stackable) assert.ok(!('ok' in result), g.key)
|
||||
else refused(result, /does not stack/)
|
||||
}
|
||||
})
|
||||
|
||||
test('giveaway: refusals are sentences', () => {
|
||||
refused(build('uo.template.gathering_giveaway', { ...GIVEAWAY, place: 'nowhere' }), /not a place/)
|
||||
refused(build('uo.template.gathering_giveaway', { ...GIVEAWAY, minutes: -5 }), /1 to \d+ minutes/)
|
||||
refused(build('uo.template.gathering_giveaway', { ...GIVEAWAY, item: 'dragon' }), /does not give out "dragon"/)
|
||||
refused(build('uo.template.gathering_giveaway', { ...GIVEAWAY, amount: 0 }), /1 to 1000 each/)
|
||||
refused(build('uo.template.gathering_giveaway', { ...GIVEAWAY, amount: actions.MAX_GRANT_STACK + 1 }), /1 to 1000 each/)
|
||||
assert.ok(!('ok' in build('uo.template.gathering_giveaway', { ...GIVEAWAY, amount: actions.MAX_GRANT_STACK })))
|
||||
refused(build('uo.template.gathering_giveaway', { ...GIVEAWAY, radius: 0 }), /1 to 300 tiles/)
|
||||
refused(build('uo.template.gathering_giveaway', { ...GIVEAWAY, radius: actions.MAX_AREA_RADIUS + 1 }), /1 to 300 tiles/)
|
||||
assert.ok(!('ok' in build('uo.template.gathering_giveaway', { ...GIVEAWAY, radius: actions.MAX_AREA_RADIUS })))
|
||||
refused(build('uo.template.gathering_giveaway', { ...GIVEAWAY, message: 'x'.repeat(301) }), /capped at 300/)
|
||||
})
|
||||
|
||||
test('giveaway: the description says who gets it and that it cannot be undone', () => {
|
||||
const { description } = byId('uo.template.gathering_giveaway')
|
||||
assert.match(description, /everyone the shard counted/)
|
||||
assert.match(description, /cannot be taken back/)
|
||||
})
|
||||
|
||||
test('boss raid: the description says boss spawning must be on and the boss is cleared at the end', () => {
|
||||
const { description } = byId('uo.template.boss_raid')
|
||||
assert.match(description, /switched on/)
|
||||
assert.match(description, /cleared when the run ends/)
|
||||
})
|
||||
|
||||
// ── No shard calls ──────────────────────────────────────────────────────────
|
||||
|
||||
test('build() makes no sidecar call and reads no database', async () => {
|
||||
const link = require('../utils/uoLinkClient')
|
||||
const atlas = require('../model/shardAtlas/shardAtlas.model')
|
||||
const real = {}
|
||||
const touched = []
|
||||
// Every function either module exposes is replaced by one that records the call.
|
||||
for (const [name, mod] of [['uoLinkClient', link], ['shardAtlas', atlas]]) {
|
||||
for (const key of Object.keys(mod)) {
|
||||
if (typeof mod[key] !== 'function') continue
|
||||
real[`${name}.${key}`] = mod[key]
|
||||
mod[key] = (...args) => { touched.push(`${name}.${key}`); return Promise.resolve({ ok: false }) }
|
||||
}
|
||||
}
|
||||
try {
|
||||
await build('uo.template.boss_raid', RAID)
|
||||
await build('uo.template.seasonal', { event: 'Fellowship', minutes: 60 })
|
||||
await build('uo.template.gathering_giveaway', GIVEAWAY)
|
||||
await build('uo.template.announce', { text: 'Hi', newsTitle: 'T' })
|
||||
} finally {
|
||||
for (const [full, fn] of Object.entries(real)) {
|
||||
const [name, key] = full.split('.')
|
||||
;(name === 'uoLinkClient' ? link : atlas)[key] = fn
|
||||
}
|
||||
}
|
||||
assert.deepStrictEqual(touched, [])
|
||||
})
|
||||
Reference in New Issue
Block a user