UNPKG

917 BMarkdownView Raw
1# WarriorJS Engine
2
3```javascript
4import Engine from 'warriorjs-engine';
5```
6
7## Engine.play(config, warrior)
8
9Plays the level defined in the passed in `config` with the passed in `warrior`. Returning an object with the result (whether it passed the level or not), the points earned and the level trace.
10
11```javascript
12Engine.play(config, warrior) // => { passed, points, trace }
13```
14
15**Example**
16
17```javascript
18const config = {
19 timeBonus: 15,
20
21 size: {
22 width: 8,
23 height: 1
24 },
25 stairs: {
26 x: 7,
27 y: 0
28 },
29
30 warrior: {
31 x: 0,
32 y: 0,
33 facing: 'east',
34 abilities: {
35 'attack': [],
36 'feel': []
37 }
38 },
39
40 units: [
41 {
42 type: 'sludge',
43 x: 4,
44 y: 0,
45 facing: 'west'
46 }
47 ]
48};
49
50const warrior = {
51 name: 'Spartacus',
52 playerCode: 'class Player { ... }'
53};
54
55const result = Engine.play(config, warrior);
56result.passed;
57result.points;
58result.trace;
59```