Skip to content

Commit

Permalink
+++
Browse files Browse the repository at this point in the history
  • Loading branch information
Offirmo committed Sep 16, 2024
1 parent eb0b15a commit 2ff37e6
Show file tree
Hide file tree
Showing 18 changed files with 237 additions and 252 deletions.
2 changes: 0 additions & 2 deletions stack--current/9-rpg/state--codes/src/state.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/////////////////////

import { type Immutable, enforceꓽimmutable } from '@offirmo-private/state-utils'
import { getꓽUTC_timestampⵧhuman_readable‿minutes } from '@offirmo-private/timestamps'

Expand Down
9 changes: 5 additions & 4 deletions stack--current/9-rpg/state--codes/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { type Immutable } from '@offirmo-private/ts-types'
import { HumanReadableTimestampUTCMinutes } from '@offirmo-private/timestamps'
import { BaseUState } from '@offirmo-private/state-utils'

/////////////////////
/////////////////////////////////////////////////

interface CodeSpec<T> {
code: string // also serves as unique key
Expand All @@ -12,21 +12,22 @@ interface CodeSpec<T> {
}

interface CodeRedemption {
// TODO rename to redemption?
redeem_count: number
last_redeem_date_minutes: HumanReadableTimestampUTCMinutes
}

/////////////////////

interface State extends BaseUState {
redeemed_codes: { [key: string]: CodeRedemption }
}

/////////////////////
/////////////////////////////////////////////////

export {
type CodeSpec,
type CodeRedemption,

type State,
}

/////////////////////
4 changes: 0 additions & 4 deletions stack--current/9-rpg/state--meta/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { Enum } from 'typescript-string-enums'

import { BaseUState } from '@offirmo-private/state-utils'

/////////////////////
Expand All @@ -18,5 +16,3 @@ interface State extends BaseUState {
export {
type State,
}

/////////////////////
1 change: 0 additions & 1 deletion stack--current/9-rpg/state--prng/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ interface State extends BaseUState {
}
}


/////////////////////////////////////////////////

export {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
registry=https://registry.npmjs.org/
package-lock=false
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tabset --badge $1 --color "#39CCCC"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
see @tbrpg/logic--adventures
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"name": "@tbrpg/logic--adventure--resolved",
"description": "resolved adventure logic and utilities",
"version": "0.0.1",
"author": "Offirmo <offirmo.net@gmail.com>",
"license": "Unlicense",
"private": true,

"sideEffects": false,
"type": "module",
"exports": {
".": {
"import": "./dist/src.es2023.esm/index.js",
"require": "./dist/src.es2023.cjs/index.js"
}
},
"module": "dist/src.es2023.esm/index.js",
"main": "dist/src.es2023.cjs/index.js",
"typings": "dist/src.es2023.esm/index.d.ts",
"source": "src/index.ts",

"peerDependencies": {
"tslib": "^2"
},
"dependencies": {
"@offirmo-private/state-utils": "*",
"@offirmo-private/ts-types": "*",
"@offirmo/random": "^3",
"@oh-my-rpg/state--prng": "^0",
"@tbrpg/definitions": "^0",
"@tbrpg/logic--armors": "^0",
"@tbrpg/logic--monsters": "^0",
"@tbrpg/logic--weapons": "^0",
"@tbrpg/state--character": "^0",
"@tbrpg/state--inventory": "^0",
"@tbrpg/state--wallet": "^0",
"tiny-invariant": "^1",
"typescript-string-enums": "^1"
},

"scripts": {
"clean": "monorepo-script--clean-package …dist",

"_build:dev:watch": "monorepo-script--build-typescript-package --watch",
"_build:prod": "monorepo-script--build-typescript-package",

"dev": "run-s clean _build:dev:watch",
"test": "./node_modules/.bin/mocha --bail --config ./node_modules/@offirmo/unit-test-toolbox/mocharc.json ./node_modules/@offirmo/unit-test-toolbox/mocha-chai-init-node.mjs 'dist/src.es2023.esm/**/*spec.js'",
"build": "run-s clean _build:prod",
"cheatsheet": "node doc/cheatsheet.js"
},
"devDependencies": {
"@offirmo-private/monorepo-scripts": "*",
"@offirmo-private/ts-types": "*",
"@offirmo/unit-test-toolbox": "^9",
"npm-run-all": "^4",
"tslib": "^2"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
////////////////////////////////////

const LIB = '@tbrpg/logic--adventure--resolved'

////////////////////////////////////

export {
LIB,
}

////////////////////////////////////
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import { type Immutable, enforceꓽimmutable } from '@offirmo-private/state-utils'

import { DEMO_WEAPON_1 } from '@tbrpg/logic--weapons'
import { DEMO_MONSTER_01 } from '@tbrpg/logic--monsters'

import { ResolvedAdventure } from '../types.js'

/////////////////////////////////////////////////

// needed to test migrations, both here and in composing parents

const DEMO_ADVENTURE_01: Immutable<ResolvedAdventure> = enforceꓽimmutable<ResolvedAdventure>({
hid: 'fight_lost_any',
uuid: 'uu1~example~adventure~01',
good: true,
encounter: DEMO_MONSTER_01,
gains: {
level: 0,
health: 0,
mana: 0,
strength: 0,
agility: 0,
charisma: 0,
wisdom: 0,
luck: 1,
coin: 0,
token: 0,
armor: null,
weapon: null,
improvementⵧarmor: false,
improvementⵧweapon: false,
},
})
// with coin gain
const DEMO_ADVENTURE_02: Immutable<ResolvedAdventure> = enforceꓽimmutable<ResolvedAdventure>({
hid: 'dying_man',
uuid: 'uu1~example~adventure~02',
good: true,
encounter: null,
gains: {
level: 0,
health: 0,
mana: 0,
strength: 0,
agility: 0,
charisma: 0,
wisdom: 0,
luck: 0,
coin: 1234,
token: 0,
weapon: null,
armor: null,
improvementⵧweapon: false,
improvementⵧarmor: false,
},
})
// with loot gain
const DEMO_ADVENTURE_03: Immutable<ResolvedAdventure> = enforceꓽimmutable<ResolvedAdventure>({
hid: 'rare_goods_seller',
uuid: 'uu1~example~adventure~03',
good: true,
encounter: null,
gains: {
level: 0,
health: 0,
mana: 0,
strength: 0,
agility: 0,
charisma: 0,
wisdom: 0,
luck: 0,
coin: 0,
token: 0,
weapon: DEMO_WEAPON_1,
armor: null,
improvementⵧweapon: false,
improvementⵧarmor: false,
},
})
// with weapon enhancement gain
const DEMO_ADVENTURE_04: Immutable<ResolvedAdventure> = enforceꓽimmutable<ResolvedAdventure>({
hid: 'princess',
uuid: 'uu1~example~adventure~04',
good: true,
encounter: null,
gains: {
level: 0,
health: 0,
mana: 0,
strength: 0,
agility: 0,
charisma: 0,
wisdom: 0,
luck: 0,
coin: 123,
token: 0,
weapon: null,
armor: null,
improvementⵧweapon: false,
improvementⵧarmor: true,
},
})

/////////////////////////////////////////////////

export {
DEMO_ADVENTURE_01,
DEMO_ADVENTURE_02,
DEMO_ADVENTURE_03,
DEMO_ADVENTURE_04,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './types.js'
export * from './reducers/index.js'
export * from './examples/index.js'
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../../../0-meta/tsconfig.json",
"include": [
"../../../0-meta/typescript-custom-typings/*.d.ts",
"src/**/*.ts"
]
}
7 changes: 4 additions & 3 deletions stack--current/A-apps--core/the-boring-rpg/state/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,16 @@
"@oh-my-rpg/state--meta": "^0",
"@oh-my-rpg/state--prng": "^0",
"@tbrpg/definitions": "^0",
"@tbrpg/logic--shop": "^0",
"@tbrpg/logic--adventure--resolved": "*",
"@tbrpg/logic--adventures": "^0",
"@tbrpg/logic--armors": "^0",
"@tbrpg/logic--monsters": "^0",
"@tbrpg/logic--shop": "^0",
"@tbrpg/logic--weapons": "^0",
"@tbrpg/state--character": "^0",
"@tbrpg/state--inventory": "^0",
"@tbrpg/state--achievements": "^0",
"@tbrpg/state--character": "^0",
"@tbrpg/state--energy": "^0",
"@tbrpg/state--inventory": "^0",
"@tbrpg/state--wallet": "^0",
"tiny-invariant": "^1",
"typescript-string-enums": "^1"
Expand Down
Loading

0 comments on commit 2ff37e6

Please sign in to comment.