create-ifloom 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +18 -2
- package/bin.js +4 -0
- package/dist/bin.js +391 -0
- package/dist/bin.js.map +1 -0
- package/dist/examples/cafe/index.html +12 -0
- package/dist/examples/cafe/package.json +26 -0
- package/dist/examples/cafe/src/game.ts +41 -0
- package/dist/examples/cafe/src/layout.tsx +49 -0
- package/dist/examples/cafe/src/main.ts +7 -0
- package/dist/examples/cafe/src/rules.ts +38 -0
- package/dist/examples/cafe/src/story/hiring.ts +25 -0
- package/dist/examples/cafe/src/story/opening.ts +19 -0
- package/dist/examples/cafe/src/styles.css +7 -0
- package/dist/examples/cafe/src/world/actions.ts +40 -0
- package/dist/examples/cafe/src/world/menu.ts +14 -0
- package/dist/examples/cafe/src/world/staff.ts +12 -0
- package/dist/examples/cafe/src/world/stats.ts +10 -0
- package/dist/examples/cafe/src/world/triggers.ts +18 -0
- package/dist/examples/cafe/tsconfig.json +9 -0
- package/dist/examples/cafe/vite.config.ts +7 -0
- package/dist/examples/novel/index.html +12 -0
- package/dist/examples/novel/package.json +26 -0
- package/dist/examples/novel/src/game.ts +49 -0
- package/dist/examples/novel/src/layout.tsx +25 -0
- package/dist/examples/novel/src/main.ts +8 -0
- package/dist/examples/novel/src/story/ch1.ts +36 -0
- package/dist/examples/novel/src/story/ch2.ts +42 -0
- package/dist/examples/novel/src/story/ch3.ts +41 -0
- package/dist/examples/novel/src/styles.css +7 -0
- package/dist/examples/novel/src/world/stats.ts +6 -0
- package/dist/examples/novel/tsconfig.json +9 -0
- package/dist/examples/novel/vite.config.ts +7 -0
- package/dist/examples/showcase/.env +4 -0
- package/dist/examples/showcase/index.html +12 -0
- package/dist/examples/showcase/package.json +44 -0
- package/dist/examples/showcase/public/art/character/ava.svg +1 -0
- package/dist/examples/showcase/public/art/character/sam.svg +1 -0
- package/dist/examples/showcase/public/art/photo/ava.svg +1 -0
- package/dist/examples/showcase/public/art/photo/sam.svg +1 -0
- package/dist/examples/showcase/src/game.ts +168 -0
- package/dist/examples/showcase/src/layout.tsx +84 -0
- package/dist/examples/showcase/src/main.tsx +55 -0
- package/dist/examples/showcase/src/place.ts +8 -0
- package/dist/examples/showcase/src/rules.ts +51 -0
- package/dist/examples/showcase/src/story/ava.prose.ts +12 -0
- package/dist/examples/showcase/src/story/ava.ts +199 -0
- package/dist/examples/showcase/src/story/cafe.ts +157 -0
- package/dist/examples/showcase/src/story/flat.ts +90 -0
- package/dist/examples/showcase/src/story/high-street.ts +37 -0
- package/dist/examples/showcase/src/story/moving-day.ts +74 -0
- package/dist/examples/showcase/src/story/office.ts +26 -0
- package/dist/examples/showcase/src/story/park.ts +172 -0
- package/dist/examples/showcase/src/story/sam.ts +27 -0
- package/dist/examples/showcase/src/styles.css +8 -0
- package/dist/examples/showcase/src/ui.ts +44 -0
- package/dist/examples/showcase/src/unlocks/supporter.ts +40 -0
- package/dist/examples/showcase/src/world/achievements.ts +13 -0
- package/dist/examples/showcase/src/world/actions.ts +13 -0
- package/dist/examples/showcase/src/world/cast.ts +46 -0
- package/dist/examples/showcase/src/world/cheats.ts +33 -0
- package/dist/examples/showcase/src/world/phone.ts +88 -0
- package/dist/examples/showcase/src/world/settings.ts +24 -0
- package/dist/examples/showcase/src/world/stats.ts +24 -0
- package/dist/examples/showcase/src/world/strings.ts +7 -0
- package/dist/examples/showcase/src/world/things.ts +59 -0
- package/dist/examples/showcase/tsconfig.json +9 -0
- package/dist/examples/showcase/vite.config.ts +7 -0
- package/dist/templates/next/AGENTS.md +60 -0
- package/dist/templates/next/README.md +33 -0
- package/dist/templates/next/app/Game.tsx +46 -0
- package/dist/templates/next/app/layout.tsx +13 -0
- package/dist/templates/next/app/page.tsx +6 -0
- package/dist/templates/next/gitignore +6 -0
- package/dist/templates/next/next.config.ts +6 -0
- package/dist/templates/next/package.json +33 -0
- package/dist/templates/next/postcss.config.mjs +6 -0
- package/dist/templates/next/src/layout.tsx +73 -0
- package/dist/templates/next/src/styles.css +16 -0
- package/dist/templates/next/tsconfig.json +21 -0
- package/dist/templates/plugin/README.md +81 -0
- package/dist/templates/plugin/gitignore +2 -0
- package/dist/templates/plugin/package.json +66 -0
- package/dist/templates/plugin/src/index.ts +162 -0
- package/dist/templates/plugin/src/react/index.tsx +95 -0
- package/dist/templates/plugin/tests/contracts.test.ts +28 -0
- package/dist/templates/plugin/tests/plugin.test.ts +59 -0
- package/dist/templates/plugin/tests/react.test.tsx +47 -0
- package/dist/templates/plugin/tsconfig.json +21 -0
- package/dist/templates/plugin/tsdown.config.ts +14 -0
- package/dist/templates/react/package.json +30 -0
- package/dist/templates/react/src/layout.tsx +69 -0
- package/dist/templates/react/src/main.ts +11 -0
- package/dist/templates/react/src/styles.css +16 -0
- package/dist/templates/react/vite.config.ts +7 -0
- package/dist/templates/shared/AGENTS.md +58 -0
- package/dist/templates/shared/gitignore +3 -0
- package/dist/templates/shared/index.html +12 -0
- package/dist/templates/shared/src/game.ts +23 -0
- package/dist/templates/shared/src/story/opening.ts +34 -0
- package/dist/templates/shared/src/styles.css +228 -0
- package/dist/templates/shared/src/world/stats.ts +6 -0
- package/dist/templates/shared/tsconfig.json +9 -0
- package/dist/templates/shared/vite.config.ts +5 -0
- package/dist/templates/svelte/package.json +25 -0
- package/dist/templates/svelte/src/App.svelte +11 -0
- package/dist/templates/svelte/src/Beat.svelte +31 -0
- package/dist/templates/svelte/src/InputField.svelte +36 -0
- package/dist/templates/svelte/src/Layout.svelte +84 -0
- package/dist/templates/svelte/src/Line.svelte +26 -0
- package/dist/templates/svelte/src/Minigame.svelte +21 -0
- package/dist/templates/svelte/src/Panel.svelte +27 -0
- package/dist/templates/svelte/src/main.ts +5 -0
- package/dist/templates/svelte/src/runner.ts +29 -0
- package/dist/templates/svelte/vite.config.ts +5 -0
- package/dist/templates/vanilla/package.json +22 -0
- package/dist/templates/vanilla/src/layout.ts +35 -0
- package/dist/templates/vanilla/src/main.ts +253 -0
- package/dist/templates/vue/package.json +25 -0
- package/dist/templates/vue/src/App.vue +12 -0
- package/dist/templates/vue/src/Beat.vue +28 -0
- package/dist/templates/vue/src/InputField.vue +34 -0
- package/dist/templates/vue/src/Layout.vue +84 -0
- package/dist/templates/vue/src/Line.vue +41 -0
- package/dist/templates/vue/src/Minigame.vue +19 -0
- package/dist/templates/vue/src/Panel.vue +30 -0
- package/dist/templates/vue/src/main.ts +5 -0
- package/dist/templates/vue/src/runner.ts +32 -0
- package/dist/templates/vue/vite.config.ts +5 -0
- package/package.json +48 -4
- package/src/bin.ts +18 -0
- package/src/create.ts +89 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The supporter content: what the unlock "supporter" opens. A file in
|
|
3
|
+
* src/unlocks/ is never part of the page. `ifloom build` encrypts it under
|
|
4
|
+
* the unlock's code (IFLOOM_UNLOCK_SUPPORTER, from .env here) and puts only
|
|
5
|
+
* the ciphertext in the page; a player who enters the code gets it back.
|
|
6
|
+
*
|
|
7
|
+
* It must be data, as a mod is: no functions.
|
|
8
|
+
*/
|
|
9
|
+
import { SCHEMA, type Pack } from '@ifloom/engine'
|
|
10
|
+
import { unlocks } from '@ifloom/plugin-unlocks'
|
|
11
|
+
|
|
12
|
+
const supporter: Pack = {
|
|
13
|
+
id: 'supporter',
|
|
14
|
+
schema: SCHEMA,
|
|
15
|
+
scenes: [
|
|
16
|
+
// One more of the café's storylets, drawn by "Sit a while" once the unlock is recorded.
|
|
17
|
+
{
|
|
18
|
+
id: 'cafe.back-room',
|
|
19
|
+
title: 'The back room',
|
|
20
|
+
speaker: 'ava',
|
|
21
|
+
drawnFrom: ['cafe'],
|
|
22
|
+
weight: 5,
|
|
23
|
+
when: { all: [unlocks.has('supporter'), { not: { seen: 'cafe.back-room' } }] },
|
|
24
|
+
body: [
|
|
25
|
+
{
|
|
26
|
+
text: 'Ava lifts the counter flap and waves you through to the back room, where the regulars who chip in for the new espresso machine get their names chalked on the beam above the sink. Yours is there now, in her careful capitals.',
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
choices: [
|
|
30
|
+
{
|
|
31
|
+
id: 'leave',
|
|
32
|
+
label: 'Thank her and head back out',
|
|
33
|
+
effects: [{ stat: 'charm', by: 1 }, { scene: null }],
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default supporter
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Achievements that belong to no one place. Ava's is in `story/ava.ts`. */
|
|
2
|
+
import type { Content } from '@ifloom/engine'
|
|
3
|
+
|
|
4
|
+
export const achievements: Content = {
|
|
5
|
+
data: {
|
|
6
|
+
achievements: {
|
|
7
|
+
achievements: [
|
|
8
|
+
// A count to watch: coins on hand, out of 100.
|
|
9
|
+
{ id: 'nest-egg', name: 'Nest egg', description: 'Have 100 coins at once.', progress: { value: 'coins', target: 100 } },
|
|
10
|
+
],
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Things to do anywhere: wait. A place's own actions are in its file in
|
|
3
|
+
* `story/`, and the camera's are on the phone, in `world/phone.ts`.
|
|
4
|
+
*/
|
|
5
|
+
import type { Content } from '@ifloom/engine'
|
|
6
|
+
import { calendar } from '@ifloom/plugin-calendar'
|
|
7
|
+
|
|
8
|
+
export const actions: Content = {
|
|
9
|
+
// Offered wherever you are.
|
|
10
|
+
actions: [{ id: 'wait', label: 'Wait a while', effects: [calendar.pass(1)] }],
|
|
11
|
+
// One post a day: each new day (a turn, here) resets it.
|
|
12
|
+
resets: { postedToday: false },
|
|
13
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** The people in town: their storylines, and who they are, where they go and how to talk to them. */
|
|
2
|
+
import type { Content } from '@ifloom/engine'
|
|
3
|
+
import { calendar } from '@ifloom/plugin-calendar'
|
|
4
|
+
import { places } from '@ifloom/plugin-places'
|
|
5
|
+
import { cast } from '@ifloom/plugin-cast'
|
|
6
|
+
|
|
7
|
+
const they = { they: 'she', them: 'her', their: 'her', theirs: 'hers' }
|
|
8
|
+
|
|
9
|
+
export const people: Content = {
|
|
10
|
+
storylines: [
|
|
11
|
+
{ id: 'ava', name: 'Ava' },
|
|
12
|
+
{ id: 'sam', name: 'Sam' },
|
|
13
|
+
],
|
|
14
|
+
// Each person is an entity of the cast's kind, `character`: a name, a line about them and a portrait, with where they go and how to talk to them.
|
|
15
|
+
entities: [
|
|
16
|
+
cast.person({
|
|
17
|
+
id: 'ava',
|
|
18
|
+
name: 'Ava',
|
|
19
|
+
fullName: 'Ava Marsh',
|
|
20
|
+
description: 'Runs the café',
|
|
21
|
+
image: 'art/character/ava.svg',
|
|
22
|
+
pronouns: they,
|
|
23
|
+
// The React UI colours her lines with this hue.
|
|
24
|
+
ui: { hue: 20 },
|
|
25
|
+
home: 'park',
|
|
26
|
+
// At the counter through the working day; by the river in the evening.
|
|
27
|
+
schedule: [{ location: 'cafe', when: { all: [calendar.weekday(0, 1, 2, 3, 4, 5), calendar.period('morning', 'afternoon')] } }],
|
|
28
|
+
// By the river, once she is a friend, a different conversation from Ava at the till.
|
|
29
|
+
talk: [{ scene: 'ava.river', when: { all: [places.at('park'), { stat: 'friendship', of: '$', gte: 25 }] } }, { scene: 'ava.hi' }],
|
|
30
|
+
storyline: 'ava',
|
|
31
|
+
call: { scene: 'ava.call', when: calendar.period('evening', 'night'), busy: 'She’s busy at the counter. Try her this evening.' },
|
|
32
|
+
}),
|
|
33
|
+
cast.person({
|
|
34
|
+
id: 'sam',
|
|
35
|
+
name: 'Sam',
|
|
36
|
+
description: 'Neighbour',
|
|
37
|
+
image: 'art/character/sam.svg',
|
|
38
|
+
pronouns: { they: 'they', them: 'them', their: 'their', theirs: 'theirs' },
|
|
39
|
+
ui: { hue: 200 },
|
|
40
|
+
home: 'park',
|
|
41
|
+
schedule: [{ location: 'high-street', when: calendar.period('morning') }],
|
|
42
|
+
talk: 'sam.hi',
|
|
43
|
+
storyline: 'sam',
|
|
44
|
+
}),
|
|
45
|
+
],
|
|
46
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Cheats for the player, and the supporter code that opens one of them: both the unlocks plugin's. */
|
|
2
|
+
import type { Content } from '@ifloom/engine'
|
|
3
|
+
import { unlocks } from '@ifloom/plugin-unlocks'
|
|
4
|
+
|
|
5
|
+
export const cheats: Content = {
|
|
6
|
+
data: {
|
|
7
|
+
unlocks: {
|
|
8
|
+
cheats: [
|
|
9
|
+
// Free for everyone.
|
|
10
|
+
{ id: 'coins', name: '+20 coins', description: 'A little help with the rent.', effects: [{ stat: 'coins', by: 20 }] },
|
|
11
|
+
// For supporters: refused until the supporter code has been entered (the unlocks plugin's `unlocks/has`).
|
|
12
|
+
{
|
|
13
|
+
id: 'energy',
|
|
14
|
+
name: 'Full energy',
|
|
15
|
+
description: 'As if you had slept.',
|
|
16
|
+
group: 'Supporters',
|
|
17
|
+
blocked: [{ when: { not: unlocks.has('supporter') }, reason: 'For supporters.' }],
|
|
18
|
+
effects: [{ stat: 'energy', to: 100 }],
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
unlocks: [
|
|
22
|
+
// The code's hash, from `ifloom unlock-hash supporter`; the code is in .env, never here.
|
|
23
|
+
// It opens the cheat above and src/unlocks/supporter.ts, a scene in the café.
|
|
24
|
+
{
|
|
25
|
+
id: 'supporter',
|
|
26
|
+
name: 'Supporter edition',
|
|
27
|
+
description: 'A thank-you scene in the café, and the Full energy cheat.',
|
|
28
|
+
hash: '7b141ff9f5210e0e3064dd089920697c712fa1b31ff56c2e42737dcd71bbed5f',
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The phone: a device on the sidebar, and the apps on it. The devices,
|
|
3
|
+
* messages and feed plugins each do their part, and this content puts them
|
|
4
|
+
* together: an app for the texts and one for the social feed, each with an
|
|
5
|
+
* unread badge and a section the plugin draws; Contacts, from the cast; a
|
|
6
|
+
* Gallery of the photos you hold, a kind declared here; and the town's own
|
|
7
|
+
* camera and notes. It's all content, so a mod can add an app or replace one
|
|
8
|
+
* by id.
|
|
9
|
+
*/
|
|
10
|
+
import type { Content } from '@ifloom/engine'
|
|
11
|
+
import type { AppDef, DeviceDef } from '@ifloom/plugin-devices'
|
|
12
|
+
import type { Channel } from '@ifloom/plugin-messages'
|
|
13
|
+
import type { FeedDef } from '@ifloom/plugin-feed'
|
|
14
|
+
import { cast } from '@ifloom/plugin-cast'
|
|
15
|
+
|
|
16
|
+
const device: DeviceDef = { id: 'phone', name: 'Phone', frame: 'phone', sidebar: true }
|
|
17
|
+
|
|
18
|
+
/** Where texts arrive, and the town's social feed. */
|
|
19
|
+
const channels: Channel[] = [{ id: 'texts', name: 'Messages' }]
|
|
20
|
+
const feeds: FeedDef[] = [{ id: 'social', name: 'Social' }]
|
|
21
|
+
|
|
22
|
+
/** The camera: one photo of each person, if they're here to take, and a post a day. A photo is a thing the camera makes, kept by the player. */
|
|
23
|
+
const camera: AppDef = {
|
|
24
|
+
id: 'camera',
|
|
25
|
+
name: 'Camera',
|
|
26
|
+
icon: 'camera',
|
|
27
|
+
on: 'phone',
|
|
28
|
+
sections: [
|
|
29
|
+
{
|
|
30
|
+
actions: [
|
|
31
|
+
...(['ava', 'sam'] as const).map((who) => ({
|
|
32
|
+
id: `photo-${who}`,
|
|
33
|
+
label: who === 'ava' ? 'Photograph Ava' : 'Photograph Sam',
|
|
34
|
+
blocked: [{ when: { not: cast.here(who) }, reason: 'They aren’t here.' }],
|
|
35
|
+
effects: [{ create: 'photo', with: { id: who, name: who === 'ava' ? 'Ava at work' : 'Sam and the dog', image: `photo/${who}.svg` }, at: 'player' }],
|
|
36
|
+
})),
|
|
37
|
+
{
|
|
38
|
+
id: 'post',
|
|
39
|
+
label: 'Post your latest photo',
|
|
40
|
+
cost: { stats: { energy: 5 } },
|
|
41
|
+
blocked: [
|
|
42
|
+
{ when: { not: { count: { of: 'photo', at: 'player' } } }, reason: 'Take a photo first.' },
|
|
43
|
+
{ when: { kv: 'postedToday' }, reason: 'You have posted today.' },
|
|
44
|
+
],
|
|
45
|
+
effects: [{ 'game/postLatest': true }, { kv: 'postedToday', to: true }],
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const apps: AppDef[] = [
|
|
53
|
+
// An app for each channel and each feed, with a count of what's unread and the plugin's own view as its section.
|
|
54
|
+
...channels.map((channel): AppDef => ({
|
|
55
|
+
id: channel.id,
|
|
56
|
+
name: channel.name,
|
|
57
|
+
icon: 'messages',
|
|
58
|
+
on: 'phone',
|
|
59
|
+
badge: { value: 'messages/unread', with: { channel: channel.id } },
|
|
60
|
+
sections: [{ plugin: 'messages', with: { channel: channel.id } }],
|
|
61
|
+
})),
|
|
62
|
+
...feeds.map((entry): AppDef => ({
|
|
63
|
+
id: entry.id,
|
|
64
|
+
name: entry.name,
|
|
65
|
+
icon: 'feed',
|
|
66
|
+
on: 'phone',
|
|
67
|
+
badge: { value: 'feed/unread', with: { feed: entry.id } },
|
|
68
|
+
sections: [{ plugin: 'feed', with: { feed: entry.id } }],
|
|
69
|
+
})),
|
|
70
|
+
// The people you've met who can be called, each with a Call button.
|
|
71
|
+
{ id: 'contacts', name: 'Contacts', icon: 'contacts', on: 'phone', sections: [{ contacts: true }] },
|
|
72
|
+
// The photos you hold, newest first.
|
|
73
|
+
{ id: 'gallery', name: 'Gallery', icon: 'gallery', on: 'phone', sections: [{ things: { of: 'photo' } }] },
|
|
74
|
+
camera,
|
|
75
|
+
// The notes you keep, such as Sam's welcome note.
|
|
76
|
+
{ id: 'notes', name: 'Notes', icon: 'notes', on: 'phone', sections: [{ things: { of: 'note' } }] },
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
export const phone: Content = {
|
|
80
|
+
name: 'phone',
|
|
81
|
+
// Photos are things you hold, kept off the town's lists: the Gallery shows them.
|
|
82
|
+
kinds: [{ id: 'photo', label: 'Photo', plural: 'Photos', listed: false }],
|
|
83
|
+
data: {
|
|
84
|
+
devices: { devices: [device], apps },
|
|
85
|
+
messages: { channels },
|
|
86
|
+
feed: { feeds },
|
|
87
|
+
},
|
|
88
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** What the player can change on the settings page. */
|
|
2
|
+
import type { Content } from '@ifloom/engine'
|
|
3
|
+
|
|
4
|
+
export const settings: Content = {
|
|
5
|
+
// What the player can change on the settings page. `hints` is part of the
|
|
6
|
+
// game (the high street reads it); `textSize` only changes how the page looks,
|
|
7
|
+
// and the React UI sizes the page by it, as `ui.settings` below says.
|
|
8
|
+
settings: [
|
|
9
|
+
{ id: 'hints', label: 'Show hints', type: 'toggle', default: true },
|
|
10
|
+
{
|
|
11
|
+
id: 'textSize',
|
|
12
|
+
label: 'Text size',
|
|
13
|
+
type: 'choice',
|
|
14
|
+
affects: 'ui',
|
|
15
|
+
options: [
|
|
16
|
+
{ value: 'normal', label: 'Normal' },
|
|
17
|
+
{ value: 'large', label: 'Large' },
|
|
18
|
+
],
|
|
19
|
+
default: 'normal',
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
// The React UI copies `textSize` to <html data-text-size>, which its styles size the page by.
|
|
23
|
+
ui: { settings: { textSize: 'textSize' } },
|
|
24
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** The player's numbers, and the friendship each character keeps with them. */
|
|
2
|
+
import type { Content } from '@ifloom/engine'
|
|
3
|
+
|
|
4
|
+
export const stats: Content = {
|
|
5
|
+
stats: [
|
|
6
|
+
// Each person's: the cast's characters are entities of the kind `character`.
|
|
7
|
+
{ id: 'friendship', label: 'Friendship', of: 'character' },
|
|
8
|
+
// One coin, two coins: the words for 1 and for any other number.
|
|
9
|
+
{
|
|
10
|
+
id: 'coins',
|
|
11
|
+
label: 'Coins',
|
|
12
|
+
start: 12,
|
|
13
|
+
max: 999,
|
|
14
|
+
spendable: true,
|
|
15
|
+
format: { one: '{n} coin', other: '{n} coins' },
|
|
16
|
+
lacking: { one: 'You need {n} coin.', other: 'You need {n} coins.' },
|
|
17
|
+
},
|
|
18
|
+
// The React UI draws energy as a bar and charm as pips, one per point.
|
|
19
|
+
{ id: 'energy', label: 'Energy', start: 80, spendable: true, format: '{n}%', lacking: 'Too tired.', round: 'round', ui: { display: 'bar' } },
|
|
20
|
+
{ id: 'charm', label: 'Charm', start: 1, max: 20, ui: { display: 'pips' } },
|
|
21
|
+
],
|
|
22
|
+
// The stats whose changes the layout's <Changes /> shows as pills after a choice: friendship on every character.
|
|
23
|
+
changes: { stats: ['coins', 'energy', 'charm', 'friendship'] },
|
|
24
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the player can carry: things, each an entity. Clothes are each one
|
|
3
|
+
* particular thing, worn by the wardrobe; food and the newspaper stack, and
|
|
4
|
+
* the inventory uses them. Their prices are the shop's, from their traits.
|
|
5
|
+
* Notes are things too, read in the phone's Notes app; photos are the
|
|
6
|
+
* phone's `photo` kind, made by the camera app in `phone.ts`.
|
|
7
|
+
*/
|
|
8
|
+
import type { Content } from '@ifloom/engine'
|
|
9
|
+
import { inventory } from '@ifloom/plugin-inventory'
|
|
10
|
+
import { jobs } from '@ifloom/plugin-jobs'
|
|
11
|
+
import { shop } from '@ifloom/plugin-shop'
|
|
12
|
+
import { wardrobe } from '@ifloom/plugin-wardrobe'
|
|
13
|
+
|
|
14
|
+
export const things: Content = {
|
|
15
|
+
// Not listed with the town's people and visitors: what you hold is in `view.held`.
|
|
16
|
+
kinds: [
|
|
17
|
+
{ id: 'clothing', label: 'Clothing', unique: true, listed: false },
|
|
18
|
+
{ id: 'item', label: 'Thing', plural: 'Things', listed: false },
|
|
19
|
+
{ id: 'note', label: 'Note', plural: 'Notes', listed: false },
|
|
20
|
+
],
|
|
21
|
+
entities: [
|
|
22
|
+
{ id: 'raincoat', of: 'clothing', name: 'raincoat', description: 'Yellow, a size too big.', at: 'player', traits: { ...wardrobe.wearable('coat') } },
|
|
23
|
+
{ id: 'scarf', of: 'clothing', name: 'scarf', description: 'Knitted by someone who loved you.', traits: { ...wardrobe.wearable('neck') } },
|
|
24
|
+
{
|
|
25
|
+
id: 'sandwich',
|
|
26
|
+
of: 'item',
|
|
27
|
+
name: 'sandwich',
|
|
28
|
+
description: 'Cheese and pickle, wrapped in paper.',
|
|
29
|
+
traits: { ...inventory.usable('Eat the sandwich', [{ stat: 'energy', by: 25 }]), ...shop.sellable({ coins: 4 }) },
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: 'flapjack',
|
|
33
|
+
of: 'item',
|
|
34
|
+
name: 'flapjack',
|
|
35
|
+
description: 'Oats, syrup and a lot of butter.',
|
|
36
|
+
traits: { ...inventory.usable('Eat the flapjack', [{ stat: 'energy', by: 10 }]), ...shop.sellable({ coins: 2 }) },
|
|
37
|
+
},
|
|
38
|
+
// Reading it opens the job board with only the paper's ads on it: a thing opening a panel. It's kept to read again.
|
|
39
|
+
{
|
|
40
|
+
id: 'paper',
|
|
41
|
+
of: 'item',
|
|
42
|
+
name: 'newspaper',
|
|
43
|
+
description: 'Today’s Small Town Gazette. The back page is job ads.',
|
|
44
|
+
at: 'player',
|
|
45
|
+
traits: { ...inventory.usable('Read the job ads', [jobs.open(['dogs'])], { keep: true }), ...shop.sellable({ coins: 2 }) },
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
data: {
|
|
49
|
+
// The inventory card shows what you carry; notes and photos are in the phone.
|
|
50
|
+
inventory: { kinds: [{ id: 'clothing' }, { id: 'item' }, { id: 'keepsake' }] },
|
|
51
|
+
wardrobe: {
|
|
52
|
+
// You arrive in your raincoat.
|
|
53
|
+
slots: [
|
|
54
|
+
{ id: 'coat', label: 'Coat', start: 'clothing:raincoat' },
|
|
55
|
+
{ id: 'neck', label: 'Neck' },
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import tailwindcss from '@tailwindcss/vite'
|
|
2
|
+
import react from '@vitejs/plugin-react'
|
|
3
|
+
import { ifloom } from '@ifloom/cli/vite'
|
|
4
|
+
|
|
5
|
+
// The React UI needs React's Vite plugin, and Tailwind for its stylesheet.
|
|
6
|
+
// `dedupe` keeps one React when @ifloom/react is linked from a checkout.
|
|
7
|
+
export default ifloom({ vite: { plugins: [react(), tailwindcss()], resolve: { dedupe: ['react', 'react-dom'] } } })
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# {{title}}
|
|
2
|
+
|
|
3
|
+
An interactive fiction game built on IFLoom, a TypeScript engine, inside a
|
|
4
|
+
Next.js app. This file is for coding agents working on the game.
|
|
5
|
+
|
|
6
|
+
## Learn the engine
|
|
7
|
+
|
|
8
|
+
- The docs, in one file: https://ifloom.dev/llms-full.txt
|
|
9
|
+
- The docs' MCP server, to search them and fetch single pages: https://ifloom.dev/api/mcp
|
|
10
|
+
- Working games to copy patterns from: `examples/novel`, `examples/cafe` and
|
|
11
|
+
`examples/showcase` in the IFLoom repository, https://github.com/IFLoom/ifloom.
|
|
12
|
+
- How a game runs in Next: https://ifloom.dev/docs/how-to/build-with-next
|
|
13
|
+
|
|
14
|
+
## Where things go
|
|
15
|
+
|
|
16
|
+
- `src/game.ts` only assembles the game: its default export is `defineGame({ build })`, where
|
|
17
|
+
`build` returns `loadGame([...content], { id, title, plugins, rules })`.
|
|
18
|
+
Content doesn't go here, and neither does anything a mod could change: the
|
|
19
|
+
actions, locks, where the game starts (`introScene`) and its starting kv are
|
|
20
|
+
content too.
|
|
21
|
+
- `src/world/` holds what the whole game shares, one file per kind:
|
|
22
|
+
`stats.ts`, `things.ts`, `cast.ts` for the people, `settings.ts` for what the
|
|
23
|
+
player can change. Each file exports a `Content` object.
|
|
24
|
+
- `src/story/` holds the story, one file per area: a place, a chapter or a
|
|
25
|
+
character's arc. Each exports a `Content` object with that area's scenes,
|
|
26
|
+
choices and its slice of plugin content (that place, its vendor, its jobs).
|
|
27
|
+
- The words a player reads are written in place: a choice's `label`, an
|
|
28
|
+
entity's `name`, a block of words in a scene, `text('…')` or
|
|
29
|
+
`{ text: '…' }`. Only lines read by key, `{ prose: 'key' }` blocks,
|
|
30
|
+
`variants` and pools, go in the `prose` table. A translation is one pack
|
|
31
|
+
with a `words` table: https://ifloom.dev/docs/how-to/translate-your-game
|
|
32
|
+
- `src/rules.ts` holds the game's own code once it has any: `rules`, with its
|
|
33
|
+
hooks (`onTurn`, `onStat`, ...) and the conditions, effects and values content
|
|
34
|
+
calls as `{ 'game/name': args }`.
|
|
35
|
+
- A new file's content goes in the list in `src/game.ts`. Files can be renamed
|
|
36
|
+
and split freely, but each scene, stat, prose key or other key is declared
|
|
37
|
+
once: `npm run check` reports one declared twice.
|
|
38
|
+
- A pack is different: content from outside the code, with an `id` and a
|
|
39
|
+
`schema`, such as a mod. Packs go in `loadGame`'s third argument and replace
|
|
40
|
+
what the content declares.
|
|
41
|
+
- Content is plain data: scenes, choices, conditions, effects, stats and words.
|
|
42
|
+
Prefer data over code.
|
|
43
|
+
- How to organise a game: https://ifloom.dev/docs/how-to/organise-your-files
|
|
44
|
+
|
|
45
|
+
## How the game is put together
|
|
46
|
+
|
|
47
|
+
- The engine is deterministic and has no DOM. Randomness is seeded from the save.
|
|
48
|
+
- Plugins (a calendar, places, a cast of characters…) are added to `plugins: [...]`
|
|
49
|
+
when the game is loaded, and their content goes under `data.<plugin>`.
|
|
50
|
+
- `app/Game.tsx` draws the game with the React UI, in the browser only.
|
|
51
|
+
`src/layout.tsx` is the game's page: the side column, the story and its sections.
|
|
52
|
+
`app/page.tsx` is an ordinary Next page around it.
|
|
53
|
+
- Pictures and sound go in `public/`, as for any Next app.
|
|
54
|
+
|
|
55
|
+
## After every change
|
|
56
|
+
|
|
57
|
+
- `npm run check` lists anything the game names that doesn't exist. It should print "No problems."
|
|
58
|
+
- `npm run playtest` plays the game with no one at the keyboard and writes what it saw.
|
|
59
|
+
- `npm run dev` serves the app; `npm run build` builds it for a web host.
|
|
60
|
+
It can't make the single offline `index.html` that `ifloom build` makes.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# {{title}}
|
|
2
|
+
|
|
3
|
+
An IFLoom game in a Next.js app, for a game you host on the web: on Vercel,
|
|
4
|
+
Netlify or any host that runs Next. `src/game.ts` puts the game together from
|
|
5
|
+
its content in `src/world/` (stats and the rest the whole game shares) and
|
|
6
|
+
`src/story/` (the scenes, one file per area), and `app/Game.tsx` draws it with
|
|
7
|
+
the React UI.
|
|
8
|
+
|
|
9
|
+
Next builds a website for a server to host. If you want a game players can
|
|
10
|
+
download and open from disk, as one `index.html`, start from another template instead
|
|
11
|
+
(`ifloom new my-game` gives you the React UI on the `ifloom` CLI), or see the
|
|
12
|
+
esbuild recipe in the docs.
|
|
13
|
+
|
|
14
|
+
## Scripts
|
|
15
|
+
|
|
16
|
+
| npm | pnpm | yarn | bun | What it does |
|
|
17
|
+
|---|---|---|---|---|
|
|
18
|
+
| `npm run dev` | `pnpm dev` | `yarn run dev` | `bun run dev` | Serves the app while you edit it. |
|
|
19
|
+
| `npm run build` | `pnpm build` | `yarn run build` | `bun run build` | Builds it for a web host. |
|
|
20
|
+
| `npm run start` | `pnpm start` | `yarn run start` | `bun run start` | Serves the build. |
|
|
21
|
+
| `npm run check` | `pnpm check` | `yarn run check` | `bun run check` | Checks the game's content. Prints "No problems." |
|
|
22
|
+
| `npm run playtest` | `pnpm playtest` | `yarn run playtest` | `bun run playtest` | Plays 5 turns with no one at the keyboard, into `playtest/run.txt`. |
|
|
23
|
+
| `npm run typecheck` | `pnpm typecheck` | `yarn run typecheck` | `bun run typecheck` | Type-checks the app and the game. |
|
|
24
|
+
|
|
25
|
+
`check` and `playtest` are the `ifloom` CLI. They load `src/game.ts`, the game
|
|
26
|
+
module, on their own, through the CLI's own Vite, so they work beside Next.
|
|
27
|
+
`app/Game.tsx` builds the game from the same module with `build()`.
|
|
28
|
+
|
|
29
|
+
## Docs
|
|
30
|
+
|
|
31
|
+
- Running a game in Next: https://ifloom.dev/docs/how-to/build-with-next
|
|
32
|
+
- The React UI: https://ifloom.dev/docs/reference/react
|
|
33
|
+
- Everything else: https://ifloom.dev/docs
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
/**
|
|
3
|
+
* The game, drawn with the React UI. It runs in the browser only: the runner
|
|
4
|
+
* reads saves and settings from localStorage, so it starts after the page has
|
|
5
|
+
* loaded, and the server sends an empty spot for it.
|
|
6
|
+
*/
|
|
7
|
+
import { useEffect, useState } from 'react'
|
|
8
|
+
import { browserRunner } from '@ifloom/browser'
|
|
9
|
+
import type { Runner } from '@ifloom/engine'
|
|
10
|
+
import { GameShell } from '@ifloom/react'
|
|
11
|
+
import type { PluginUi } from '@ifloom/react/kit'
|
|
12
|
+
import module from '../src/game.ts'
|
|
13
|
+
import { Layout } from '../src/layout.tsx'
|
|
14
|
+
|
|
15
|
+
/** The plugins' own UIs. One list for the whole app, so the provider keeps the same one. */
|
|
16
|
+
const PLUGINS: PluginUi[] = []
|
|
17
|
+
|
|
18
|
+
export function Game() {
|
|
19
|
+
const [runner, setRunner] = useState<Runner | null>(null)
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
// The game module builds the game, and says what the loader found wrong with it.
|
|
23
|
+
const { game, problems } = module.build()
|
|
24
|
+
if (problems.length) console.warn(problems)
|
|
25
|
+
// A new game with a random seed, undo, saves in localStorage and an autosave each turn.
|
|
26
|
+
let live = true
|
|
27
|
+
void browserRunner(game).then((made) => {
|
|
28
|
+
if (live) setRunner(made)
|
|
29
|
+
})
|
|
30
|
+
return () => {
|
|
31
|
+
live = false
|
|
32
|
+
}
|
|
33
|
+
}, [])
|
|
34
|
+
|
|
35
|
+
return runner ? <Playing runner={runner} /> : null
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function Playing({ runner }: { runner: Runner }) {
|
|
39
|
+
// `layout` is the page, in `src/layout.tsx`. `pages` opens on a title
|
|
40
|
+
// screen with New game, Continue, Load and Settings. Leave it out to start
|
|
41
|
+
// straight in the story. `plugins` lists the UIs of the plugins in
|
|
42
|
+
// src/game.ts, such as `shopUi` from `@ifloom/plugin-shop/react`; leave one
|
|
43
|
+
// out to draw that plugin yourself. The shell plays what the game's `audio`
|
|
44
|
+
// asks for, from the first click or key press.
|
|
45
|
+
return <GameShell runner={runner} layout={Layout} pages plugins={PLUGINS} />
|
|
46
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Metadata } from 'next'
|
|
2
|
+
import type { ReactNode } from 'react'
|
|
3
|
+
import '../src/styles.css'
|
|
4
|
+
|
|
5
|
+
export const metadata: Metadata = { title: '{{title}}' }
|
|
6
|
+
|
|
7
|
+
export default function RootLayout({ children }: { children: ReactNode }) {
|
|
8
|
+
return (
|
|
9
|
+
<html lang="en">
|
|
10
|
+
<body>{children}</body>
|
|
11
|
+
</html>
|
|
12
|
+
)
|
|
13
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{name}}",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "next dev",
|
|
8
|
+
"build": "next build",
|
|
9
|
+
"start": "next start",
|
|
10
|
+
"check": "ifloom check",
|
|
11
|
+
"typecheck": "next typegen && tsc --noEmit",
|
|
12
|
+
"playtest": "ifloom playtest --turns 5 --out playtest/run.txt"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@ifloom/audio": "^0.1.1",
|
|
16
|
+
"@ifloom/browser": "^0.1.1",
|
|
17
|
+
"@ifloom/engine": "^0.1.1",
|
|
18
|
+
"@ifloom/react": "^0.1.1",
|
|
19
|
+
"next": "16.4.6",
|
|
20
|
+
"react": "19.3.0",
|
|
21
|
+
"react-dom": "19.3.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@ifloom/cli": "^0.1.1",
|
|
25
|
+
"@tailwindcss/postcss": "4.3.3",
|
|
26
|
+
"@types/node": "^26.6.4",
|
|
27
|
+
"@types/react": "^19.3.0",
|
|
28
|
+
"@types/react-dom": "^19.3.0",
|
|
29
|
+
"postcss": "8.5.30",
|
|
30
|
+
"tailwindcss": "4.3.3",
|
|
31
|
+
"typescript": "6.0.3"
|
|
32
|
+
}
|
|
33
|
+
}
|