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,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The café's own code: the week's sums, worked out from the state. Content
|
|
3
|
+
* calls them by name, `{ 'game/takings': true }` and `{{payroll}}`.
|
|
4
|
+
*/
|
|
5
|
+
import { entitiesOf, statValue, type EffectRef, type Game, type GameRules, type GameState } from '@ifloom/engine'
|
|
6
|
+
|
|
7
|
+
/** The café's calls, declared so content written in code is checked against them. */
|
|
8
|
+
declare module '@ifloom/engine' {
|
|
9
|
+
interface EffectRegistry {
|
|
10
|
+
'game/takings': true
|
|
11
|
+
'game/wages': true
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** The sum of one stat over every entity of a kind. */
|
|
16
|
+
function total(state: GameState, game: Game, kind: string, stat: string): number {
|
|
17
|
+
return entitiesOf(state, game, kind).reduce((sum, ref) => sum + statValue(state, game, stat, ref), 0)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** The week's sums: worked out from the state, so they are the game's own code. */
|
|
21
|
+
export const rules: GameRules = {
|
|
22
|
+
macros: {
|
|
23
|
+
// Each dish sells by its price and quality, and the kitchen's skill decides how many go out.
|
|
24
|
+
takings: (state, _args, { game }): EffectRef[] => {
|
|
25
|
+
if (entitiesOf(state, game, 'staff').length === 0) return []
|
|
26
|
+
const covers = 10 + total(state, game, 'staff', 'skill') * 2 + Math.floor((state.stats.reputation ?? 0) / 5)
|
|
27
|
+
const perCover = entitiesOf(state, game, 'dish').reduce(
|
|
28
|
+
(sum, ref) => sum + statValue(state, game, 'price', ref) * statValue(state, game, 'quality', ref),
|
|
29
|
+
0,
|
|
30
|
+
)
|
|
31
|
+
return [{ stat: 'coins', by: Math.round((covers * perCover) / 10) }]
|
|
32
|
+
},
|
|
33
|
+
wages: (state, _args, { game }): EffectRef[] => [{ stat: 'coins', by: -total(state, game, 'staff', 'wage') }],
|
|
34
|
+
},
|
|
35
|
+
values: {
|
|
36
|
+
payroll: (state, _args, { game }) => total(state, game, 'staff', 'wage'),
|
|
37
|
+
},
|
|
38
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Interviews: the scene a card in the window opens, where you hire Dev, Fen or nobody. */
|
|
2
|
+
import type { Content } from '@ifloom/engine'
|
|
3
|
+
|
|
4
|
+
export const hiring: Content = {
|
|
5
|
+
scenes: [
|
|
6
|
+
{
|
|
7
|
+
id: 'hiring',
|
|
8
|
+
title: 'Interviews',
|
|
9
|
+
body: [{ text: 'Two people answer the card in the window. Wages are {{payroll}} a week already.' }],
|
|
10
|
+
choices: [
|
|
11
|
+
{
|
|
12
|
+
id: 'dev',
|
|
13
|
+
label: 'Dev: keen, cheap, still learning',
|
|
14
|
+
effects: [{ create: 'staff', with: { name: 'Dev', stats: { skill: 2, wage: 8, morale: 80 } } }, { scene: null }],
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
id: 'fen',
|
|
18
|
+
label: 'Fen: ten years in kitchens, and knows it',
|
|
19
|
+
effects: [{ create: 'staff', with: { name: 'Fen', stats: { skill: 7, wage: 18 } } }, { scene: null }],
|
|
20
|
+
},
|
|
21
|
+
{ id: 'nobody', label: 'Not this week', effects: [{ scene: null }] },
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** The first scene: the café's opening day. */
|
|
2
|
+
import type { Content } from '@ifloom/engine'
|
|
3
|
+
|
|
4
|
+
export const opening: Content = {
|
|
5
|
+
// The game opens on the café's first day.
|
|
6
|
+
introScene: 'opening',
|
|
7
|
+
scenes: [
|
|
8
|
+
{
|
|
9
|
+
id: 'opening',
|
|
10
|
+
title: 'The Corner Café',
|
|
11
|
+
body: [
|
|
12
|
+
{
|
|
13
|
+
text: 'The lease is signed, the sign is up, and Ana has already rearranged the mugs. Every week the till is counted, the staff are paid, and you find out what the town thought.',
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
choices: [{ id: 'begin', label: 'Open the doors', effects: [{ scene: null }] }],
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** What the café can do in a week: end it, feed the staff, improve the soup, hire. Each is a button the café always has. */
|
|
2
|
+
import type { Content } from '@ifloom/engine'
|
|
3
|
+
|
|
4
|
+
export const actions: Content = {
|
|
5
|
+
actions: [
|
|
6
|
+
{
|
|
7
|
+
id: 'end-week',
|
|
8
|
+
label: 'Count the till and end the week',
|
|
9
|
+
effects: [
|
|
10
|
+
{ 'game/takings': true },
|
|
11
|
+
{ 'game/wages': true },
|
|
12
|
+
// A week's work wears everyone down a little.
|
|
13
|
+
{ each: 'staff', effects: [{ stat: 'morale', by: -8, of: '$' }] },
|
|
14
|
+
// Anyone at the end of their tether hands in their apron.
|
|
15
|
+
{ each: 'staff', where: { stat: 'morale', of: '$', lt: 20 }, effects: [{ remove: '$' }] },
|
|
16
|
+
{ turn: true },
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: 'lunch',
|
|
21
|
+
label: 'Buy the staff lunch',
|
|
22
|
+
cost: { stats: { coins: 25 } },
|
|
23
|
+
blocked: [{ when: { not: { count: 'staff' } }, reason: 'There is nobody to feed.' }],
|
|
24
|
+
effects: [{ each: 'staff', effects: [{ stat: 'morale', by: 15, of: '$' }] }],
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: 'soup',
|
|
28
|
+
label: 'Better ingredients for the soup',
|
|
29
|
+
cost: { stats: { coins: 40 } },
|
|
30
|
+
blocked: [{ when: { stat: 'quality', of: 'dish:soup', gte: 5 }, reason: 'It could not be better.' }],
|
|
31
|
+
effects: [{ stat: 'quality', by: 1, of: 'dish:soup' }],
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: 'hire',
|
|
35
|
+
label: 'Put a card in the window',
|
|
36
|
+
blocked: [{ when: { count: 'staff', gte: 4 }, reason: 'There is no room behind the counter.' }],
|
|
37
|
+
effects: [{ scene: 'hiring' }],
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** The menu: dishes as a kind of entity, each with a price and a quality. */
|
|
2
|
+
import type { Content } from '@ifloom/engine'
|
|
3
|
+
|
|
4
|
+
export const menu: Content = {
|
|
5
|
+
kinds: [{ id: 'dish', label: 'Dish', plural: 'Menu' }],
|
|
6
|
+
stats: [
|
|
7
|
+
{ id: 'price', label: 'Price', of: 'dish', start: 4, min: 1, max: 20, format: '£{n}' },
|
|
8
|
+
{ id: 'quality', label: 'Quality', of: 'dish', start: 2, min: 1, max: 5 },
|
|
9
|
+
],
|
|
10
|
+
entities: [
|
|
11
|
+
{ id: 'toast', of: 'dish', name: 'Cheese on toast', description: 'Thick bread, sharp cheddar.', stats: { price: 4, quality: 2 } },
|
|
12
|
+
{ id: 'soup', of: 'dish', name: 'Soup of the day', description: 'Whatever the market had.', stats: { price: 6, quality: 3 } },
|
|
13
|
+
],
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** The staff: a kind of entity (each one a particular person), the numbers each of them has, and Ana, there from the start. */
|
|
2
|
+
import type { Content } from '@ifloom/engine'
|
|
3
|
+
|
|
4
|
+
export const staff: Content = {
|
|
5
|
+
kinds: [{ id: 'staff', label: 'Member of staff', plural: 'Staff', unique: true }],
|
|
6
|
+
stats: [
|
|
7
|
+
{ id: 'skill', label: 'Skill', of: 'staff', start: 1, min: 1, max: 10 },
|
|
8
|
+
{ id: 'morale', label: 'Morale', of: 'staff', start: 60 },
|
|
9
|
+
{ id: 'wage', label: 'Wage', of: 'staff', start: 10, max: 50, format: '£{n}' },
|
|
10
|
+
],
|
|
11
|
+
entities: [{ id: 'ana', of: 'staff', name: 'Ana', description: 'Has run the kitchen since the day you opened.', stats: { skill: 5, wage: 12 } }],
|
|
12
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** The café's own numbers: the till and its reputation in town. */
|
|
2
|
+
import type { Content } from '@ifloom/engine'
|
|
3
|
+
|
|
4
|
+
export const stats: Content = {
|
|
5
|
+
stats: [
|
|
6
|
+
{ id: 'coins', label: 'Coins', start: 120, min: -9999, max: 99999, format: '£{n}', spendable: true, lacking: 'Not enough in the till.' },
|
|
7
|
+
// Word gets round in steps: the sidebar shows the level, and a notice says when it goes up.
|
|
8
|
+
{ id: 'reputation', label: 'Reputation', start: 20, levels: { at: [40, 70, 90], notice: 'Word gets round: {label} is now level {level}.' } },
|
|
9
|
+
],
|
|
10
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** What the game watches for after every command: the till, the staff and a good review. */
|
|
2
|
+
import type { Content } from '@ifloom/engine'
|
|
3
|
+
|
|
4
|
+
export const triggers: Content = {
|
|
5
|
+
triggers: [
|
|
6
|
+
{ id: 'overdrawn', once: { per: 'turn' }, when: { stat: 'coins', lt: 0 }, effects: [{ notify: 'The bank has written.', tag: 'money' }] },
|
|
7
|
+
{ id: 'empty', once: { per: 'turn' }, when: { count: 'staff', lt: 1 }, effects: [{ notify: 'Nobody to open up tomorrow.', tag: 'staff' }] },
|
|
8
|
+
// A happy team is a good review: once, the first week two of them are glad to be there.
|
|
9
|
+
{
|
|
10
|
+
id: 'review',
|
|
11
|
+
when: { count: 'staff', where: { stat: 'morale', of: '$', gte: 75 }, gte: 2 },
|
|
12
|
+
effects: [
|
|
13
|
+
{ stat: 'reputation', by: 10 },
|
|
14
|
+
{ notify: 'A glowing review in the local paper.', tag: 'press' },
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
}
|
|
@@ -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,12 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>The Letter</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="root"></div>
|
|
10
|
+
<script type="module" src="./src/main.ts"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ifloom/example-novel",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"description": "A short linear novel on IFLoom: chapters, choices remembered, a counter and one stat. No plugins, no places, no clock.",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"dev": "ifloom dev",
|
|
10
|
+
"build": "ifloom build",
|
|
11
|
+
"check": "ifloom check",
|
|
12
|
+
"playtest": "ifloom playtest --turns 3 --out playtest/read.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
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@ifloom/cli": "^0.1.1",
|
|
22
|
+
"@tailwindcss/vite": "4.3.3",
|
|
23
|
+
"@vitejs/plugin-react": "6.1.1",
|
|
24
|
+
"tailwindcss": "4.3.3"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Letter: a linear novel in three chapters, as small as IFLoom gets.
|
|
3
|
+
*
|
|
4
|
+
* No plugins, no places, no characters, no clock. What it uses is what a
|
|
5
|
+
* novel with light tracking needs: a name the player types, one stat, choices
|
|
6
|
+
* the engine remembers on its own (`{ chose }`), a kv key counted up
|
|
7
|
+
* (`{ kv, by }`), a chapter as a turn, a migration step for
|
|
8
|
+
* saves from the game's first version, no saving until the reader has typed
|
|
9
|
+
* a name, and endings that start the story over with `newGame`.
|
|
10
|
+
*
|
|
11
|
+
* This file only puts the game together. The stat is in `world/stats.ts`,
|
|
12
|
+
* and each chapter is a file of its own in `story/`, its words written in
|
|
13
|
+
* its scenes.
|
|
14
|
+
*/
|
|
15
|
+
import { loadGame, startingState, type Content, type Loaded } from '@ifloom/engine'
|
|
16
|
+
import { defineGame } from '@ifloom/cli/game'
|
|
17
|
+
import { stats } from './world/stats.ts'
|
|
18
|
+
import { ch1 } from './story/ch1.ts'
|
|
19
|
+
import { ch2 } from './story/ch2.ts'
|
|
20
|
+
import { ch3 } from './story/ch3.ts'
|
|
21
|
+
|
|
22
|
+
/** The game's content: what every chapter shares, then the chapters. */
|
|
23
|
+
export const content: Content[] = [stats, ch1, ch2, ch3]
|
|
24
|
+
|
|
25
|
+
/** The game: its content, with a base that says what it is, and rules that name its saves and carry old ones forward. */
|
|
26
|
+
export function theLetter(): Loaded {
|
|
27
|
+
return loadGame(content, {
|
|
28
|
+
id: 'the-letter',
|
|
29
|
+
title: 'The Letter',
|
|
30
|
+
// Version 2 counts `fibs` where version 1 counted `lies`. A version-1 save is carried
|
|
31
|
+
// forward by the step below when it loads, so a reader mid-story keeps their count.
|
|
32
|
+
version: 2,
|
|
33
|
+
rules: {
|
|
34
|
+
migrations: {
|
|
35
|
+
1: (state) => {
|
|
36
|
+
const { lies, ...kv } = state.kv
|
|
37
|
+
return lies === undefined ? state : { ...state, kv: { ...kv, fibs: lies } }
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
saveName: (state) => (typeof state.kv.playerName === 'string' ? state.kv.playerName : undefined),
|
|
41
|
+
},
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** What the command line reads: the game, and where `ifloom playtest` and `ifloom snapshot` start, a reader who has already typed a name. */
|
|
46
|
+
export default defineGame({
|
|
47
|
+
build: theLetter,
|
|
48
|
+
start: (game) => startingState(game, { kv: { playerName: 'Sam' } }),
|
|
49
|
+
})
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Game, GameMenu, InputFields, Notices, Overlay, PanelHost, RoomActions, Scene, StatList, Story, Title } from '@ifloom/react'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A page to read: no side column, so the story is one centred column, like a
|
|
5
|
+
* book. The title over the chapter, then what to type and the buttons, and
|
|
6
|
+
* the reader's stats and menu at the foot.
|
|
7
|
+
*/
|
|
8
|
+
export function Layout() {
|
|
9
|
+
return (
|
|
10
|
+
<Game>
|
|
11
|
+
<Story>
|
|
12
|
+
<Title />
|
|
13
|
+
<Scene />
|
|
14
|
+
<InputFields />
|
|
15
|
+
<RoomActions />
|
|
16
|
+
<StatList />
|
|
17
|
+
<GameMenu />
|
|
18
|
+
</Story>
|
|
19
|
+
<PanelHost />
|
|
20
|
+
<Overlay>
|
|
21
|
+
<Notices />
|
|
22
|
+
</Overlay>
|
|
23
|
+
</Game>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { mountGame } from '@ifloom/react'
|
|
2
|
+
import { theLetter } from './game.ts'
|
|
3
|
+
import { Layout } from './layout.tsx'
|
|
4
|
+
import './styles.css'
|
|
5
|
+
|
|
6
|
+
// A page to read: no side column, no clock, no map. It opens on a title
|
|
7
|
+
// screen, which offers New Game+ once the reader has reached an ending.
|
|
8
|
+
mountGame(theLetter(), { layout: Layout, pages: { subtitle: 'A novel in three chapters' } })
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chapter one: the letter on the mat. The reader types their name here, and
|
|
3
|
+
* opens the letter or shelves it.
|
|
4
|
+
*/
|
|
5
|
+
import type { Content } from '@ifloom/engine'
|
|
6
|
+
|
|
7
|
+
export const ch1: Content = {
|
|
8
|
+
// The story opens on the mat.
|
|
9
|
+
introScene: 'ch1.mat',
|
|
10
|
+
// No saving on the first page until the reader has typed a name, so every save has one.
|
|
11
|
+
saveable: [{ when: { not: { kv: 'playerName' } }, reason: 'Type your name first.' }],
|
|
12
|
+
inputs: [{ id: 'playerName', label: 'Your name', type: 'text', maxLength: 20, when: { not: { kv: 'playerName' } } }],
|
|
13
|
+
scenes: [
|
|
14
|
+
{
|
|
15
|
+
id: 'ch1.mat',
|
|
16
|
+
title: 'Chapter one: the mat',
|
|
17
|
+
body: [
|
|
18
|
+
{
|
|
19
|
+
text: 'The flat still smells of someone else’s cooking. On the mat, under the takeaway menus, is a letter with a stamp from the seaside and a name on it that isn’t yours: J. Hart.',
|
|
20
|
+
},
|
|
21
|
+
// Only in a New Game+, which carries `readBefore` over from a finished read.
|
|
22
|
+
{ text: 'You have the oddest feeling you have stood here before, with this exact letter in your hand.', when: { kv: 'readBefore' } },
|
|
23
|
+
{ text: 'You turn it over, {{playerName}}. The flap is barely stuck.', when: { kv: 'playerName' } },
|
|
24
|
+
],
|
|
25
|
+
choices: [
|
|
26
|
+
{
|
|
27
|
+
id: 'open',
|
|
28
|
+
label: 'Open it',
|
|
29
|
+
when: { kv: 'playerName' },
|
|
30
|
+
effects: [{ stat: 'courage', by: 1 }, { turn: true }, { scene: 'ch2.stairs' }],
|
|
31
|
+
},
|
|
32
|
+
{ id: 'shelf', label: 'Put it on the shelf by the door', when: { kv: 'playerName' }, effects: [{ turn: true }, { scene: 'ch2.stairs' }] },
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chapter two: Mrs Okafor on the stairs, and the first chance to lie. A
|
|
3
|
+
* flowing scene: its words are written in place, the answer you give brings
|
|
4
|
+
* her reply, and the chapter reads on to Saturday.
|
|
5
|
+
*/
|
|
6
|
+
import { choice, decide, text, when, type Content } from '@ifloom/engine'
|
|
7
|
+
|
|
8
|
+
export const ch2: Content = {
|
|
9
|
+
scenes: [
|
|
10
|
+
{
|
|
11
|
+
id: 'ch2.stairs',
|
|
12
|
+
title: 'Chapter two: the stairs',
|
|
13
|
+
body: [
|
|
14
|
+
text(`Mrs Okafor from downstairs catches you on the landing. “Has anything come for June? Her sister keeps asking.”`),
|
|
15
|
+
when({ chose: 'ch1.mat#open' }, [text(`You think of the postcard tucked inside, and the phone number written on it twice.`)]),
|
|
16
|
+
when({ chose: 'ch1.mat#shelf' }, [text(`You think of the letter on the shelf, still sealed.`)]),
|
|
17
|
+
decide('answer', [
|
|
18
|
+
choice('truth', 'Tell her about the letter', {
|
|
19
|
+
effects: [{ stat: 'courage', by: 1 }],
|
|
20
|
+
then: [text(`She nods, and pats the banister as if it had done well. “I’ll tell her sister.”`)],
|
|
21
|
+
}),
|
|
22
|
+
choice('deny', '“Nothing yet.”', {
|
|
23
|
+
effects: [{ kv: 'fibs', by: 1 }],
|
|
24
|
+
then: [text(`“Oh well.” She looks at the shelf by your door for a second too long.`)],
|
|
25
|
+
}),
|
|
26
|
+
// A lie to cover a letter you opened is a second lie.
|
|
27
|
+
choice('blame', '“Only something that came open in the post.”', {
|
|
28
|
+
when: { chose: 'ch1.mat#open' },
|
|
29
|
+
effects: [{ kv: 'fibs', by: 2 }],
|
|
30
|
+
then: [text(`Her eyebrows go up, and stay up all the way down the stairs.`)],
|
|
31
|
+
}),
|
|
32
|
+
]),
|
|
33
|
+
text(`
|
|
34
|
+
The rest of the week goes quietly. The letter stays where you left it.
|
|
35
|
+
|
|
36
|
+
Then it's Saturday.
|
|
37
|
+
`),
|
|
38
|
+
],
|
|
39
|
+
choices: [{ id: 'saturday', label: 'Answer the door', effects: [{ turn: true }, { scene: 'ch3.door' }] }],
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** Chapter three: June's sister at the door, and the two endings. */
|
|
2
|
+
import type { Content } from '@ifloom/engine'
|
|
3
|
+
|
|
4
|
+
const readIt = { kv: 'readBefore', to: true } as const
|
|
5
|
+
|
|
6
|
+
export const ch3: Content = {
|
|
7
|
+
// Reaching either ending finishes the game, and the title screen then offers New Game+.
|
|
8
|
+
finished: { scene: ['end.kept', 'end.posted'] },
|
|
9
|
+
// A New Game+ keeps only this: that the reader has been through it once.
|
|
10
|
+
carryOver: { kv: ['readBefore'] },
|
|
11
|
+
scenes: [
|
|
12
|
+
{
|
|
13
|
+
id: 'ch3.door',
|
|
14
|
+
title: 'Chapter three: the door',
|
|
15
|
+
body: [
|
|
16
|
+
{ text: 'On Saturday someone knocks. A woman with June’s chin and a carrier bag of shopping: “I’m her sister. I was told there might be post.”' },
|
|
17
|
+
{ text: 'You already told Mrs Okafor everything, and it shows: she smiles before you speak.', when: { kv: 'fibs', lt: 1 } },
|
|
18
|
+
{ text: 'Mrs Okafor is behind her on the stairs, not quite looking at you.', when: { kv: 'fibs', is: 1 } },
|
|
19
|
+
{ text: 'Mrs Okafor is behind her on the stairs, and she has clearly been talking.', when: { kv: 'fibs', gte: 2 } },
|
|
20
|
+
],
|
|
21
|
+
choices: [
|
|
22
|
+
// Either ending marks the story as read, for a New Game+ to carry over.
|
|
23
|
+
{ id: 'hand', label: 'Give her the letter yourself', when: { stat: 'courage', gte: 3 }, effects: [readIt, { scene: 'end.kept' }] },
|
|
24
|
+
{ id: 'post', label: 'Say you’ll send it on', effects: [readIt, { scene: 'end.posted' }] },
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
// Each ending offers the story again: `newGame` starts it over, keeping the reader's settings.
|
|
28
|
+
{
|
|
29
|
+
id: 'end.kept',
|
|
30
|
+
title: 'The end',
|
|
31
|
+
body: [{ text: 'She reads it on your doorstep and laughs, then cries a bit, then asks if you want a biscuit. You do.' }],
|
|
32
|
+
choices: [{ id: 'again', label: 'Read it again', command: { type: 'newGame' }, effects: [] }],
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: 'end.posted',
|
|
36
|
+
title: 'The end',
|
|
37
|
+
body: [{ text: 'You write the address she gives you on a fresh envelope. It goes in the postbox on the corner, and that is that.' }],
|
|
38
|
+
choices: [{ id: 'again', label: 'Read it again', command: { type: 'newGame' }, effects: [] }],
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
}
|
|
@@ -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,12 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>Small Town</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="root"></div>
|
|
10
|
+
<script type="module" src="./src/main.tsx"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ifloom/showcase",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"description": "The IFLoom showcase: a small town that uses every feature the engine has. Its source is what the docs point at.",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"dev": "ifloom dev",
|
|
10
|
+
"build": "ifloom build",
|
|
11
|
+
"check": "ifloom check",
|
|
12
|
+
"playtest": "ifloom playtest --turns 7 --out playtest/week.txt",
|
|
13
|
+
"snapshot": "ifloom snapshot",
|
|
14
|
+
"build:one-file": "ifloom build --inline-assets --out dist-one"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@ifloom/audio": "^0.1.1",
|
|
18
|
+
"@ifloom/browser": "^0.1.1",
|
|
19
|
+
"@ifloom/engine": "^0.1.1",
|
|
20
|
+
"@ifloom/plugin-achievements": "^0.1.1",
|
|
21
|
+
"@ifloom/plugin-calendar": "^0.1.1",
|
|
22
|
+
"@ifloom/plugin-cast": "^0.1.1",
|
|
23
|
+
"@ifloom/plugin-debug": "^0.1.1",
|
|
24
|
+
"@ifloom/plugin-devices": "^0.1.1",
|
|
25
|
+
"@ifloom/plugin-statuses": "^0.1.1",
|
|
26
|
+
"@ifloom/plugin-feed": "^0.1.1",
|
|
27
|
+
"@ifloom/plugin-generators": "^0.1.1",
|
|
28
|
+
"@ifloom/plugin-inventory": "^0.1.1",
|
|
29
|
+
"@ifloom/plugin-jobs": "^0.1.1",
|
|
30
|
+
"@ifloom/plugin-messages": "^0.1.1",
|
|
31
|
+
"@ifloom/plugin-places": "^0.1.1",
|
|
32
|
+
"@ifloom/plugin-quests": "^0.1.1",
|
|
33
|
+
"@ifloom/plugin-shop": "^0.1.1",
|
|
34
|
+
"@ifloom/plugin-unlocks": "^0.1.1",
|
|
35
|
+
"@ifloom/plugin-wardrobe": "^0.1.1",
|
|
36
|
+
"@ifloom/react": "^0.1.1"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@ifloom/cli": "^0.1.1",
|
|
40
|
+
"@tailwindcss/vite": "4.3.3",
|
|
41
|
+
"@vitejs/plugin-react": "6.1.1",
|
|
42
|
+
"tailwindcss": "4.3.3"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96"><circle cx="48" cy="48" r="48" fill="hsl(20 55% 55%)"/><text x="48" y="62" font-family="Georgia, serif" font-size="44" text-anchor="middle" fill="white">A</text></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96"><circle cx="48" cy="48" r="48" fill="hsl(200 55% 55%)"/><text x="48" y="62" font-family="Georgia, serif" font-size="44" text-anchor="middle" fill="white">S</text></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 200"><rect width="320" height="200" fill="hsl(20 40% 85%)"/><circle cx="160" cy="88" r="44" fill="hsl(20 55% 55%)"/><rect x="0" y="160" width="320" height="40" fill="hsl(20 30% 30%)"/><text x="160" y="186" font-family="Georgia, serif" font-size="18" text-anchor="middle" fill="white">Ava at work</text></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 200"><rect width="320" height="200" fill="hsl(200 40% 85%)"/><circle cx="160" cy="88" r="44" fill="hsl(200 55% 55%)"/><rect x="0" y="160" width="320" height="40" fill="hsl(200 30% 30%)"/><text x="160" y="186" font-family="Georgia, serif" font-size="18" text-anchor="middle" fill="white">Sam and the dog</text></svg>
|