4.2.2 • Published 4 months ago

@rpgjs/interpreter v4.2.2

Weekly downloads
-
License
MIT
Repository
-
Last release
4 months ago

RPGJS Interpreter

Goal

The aim is to interpret JSON to trigger server-side commands. What's the point? This allows you to launch commands on the fly, via an HTTP request for example, without having to write them in hard code. It gives you greater flexibility. What's more, we can imagine a graphical game editor mode that constructs the events

Installation

npm install @rpgjs/interpreter

Usage

Example:

// in player.ts
import { RpgInterpreter} from '@rpgjs/interpreter'
import { RpgPlayer, RpgPlayerHooks } from '@rpgjs/server'


const blocks = {
    block1: {
        id: 'text',
        text: 'Hello World'
    },
    block2: {
        id: 'change_gold',
        value: 10
    },
    block3: {
        id: 'choice',
        text: 'Please ?',
        choices: 1
    },
    block4: {
        id: 'text',
        text: 'Thanks'
    },
    block5: {
        id: 'text',
        text: 'Ok...'
    }
}

const edges = {
    'block1': 'block2',
    'block2': 'block3',
    'block3': {
        blocks: [{
            blockId: 'block5',
            handle: 'choices.0'
        }]
    }
}

const interpreter = new Interpreter(blocks, edges)

const player: RpgPlayerHooks = {
    onConnected(player: RpgPlayer) {
        interpreter
            .start({
                block: 'block1',
                player
            })
            .subscribe()
    }
}

export default player
4.2.2

4 months ago

4.2.1

4 months ago

4.2.0

5 months ago

4.1.3

6 months ago

4.1.2

7 months ago

4.1.1

7 months ago

4.1.0

7 months ago

4.0.5

7 months ago

4.0.4

7 months ago

4.0.3

7 months ago

4.0.2

7 months ago

4.0.0

8 months ago

4.0.0-rc.13

8 months ago

4.0.0-rc.12

8 months ago

4.0.0-rc.11

9 months ago

4.0.0-rc.10

9 months ago

4.0.0-rc.9

9 months ago

4.0.0-rc.8

9 months ago

4.0.0-rc.7

9 months ago

4.0.0-rc.6

9 months ago

4.0.0-rc.5

9 months ago

4.0.0-rc.4

9 months ago

4.0.0-rc.3

10 months ago

4.0.0-rc.2

10 months ago

4.0.0-beta.17

10 months ago

4.0.0-beta.15

10 months ago