Add interactive picnic journey and synchronize gameplay stages
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {createJourney, advanceJourney, tickJourney} from '../src/journey.js';
|
||||
|
||||
test('Driving requires player input and exit requires F at the entrance', () => {
|
||||
const j=createJourney();tickJourney(j,20);assert.equal(j.phase,'home');
|
||||
assert.ok(advanceJourney(j));tickJourney(j,2,true);assert.equal(j.phase,'boarding');
|
||||
tickJourney(j,2);assert.equal(j.phase,'driving');
|
||||
tickJourney(j,30);assert.equal(j.distance,0);assert.equal(j.phase,'driving');assert.equal(advanceJourney(j),false);
|
||||
for(let i=0;i<200;i++)tickJourney(j,.05,false,{throttle:1});
|
||||
assert.equal(j.phase,'entrance');assert.equal(j.distance,21);assert.equal(j.speed,0);
|
||||
tickJourney(j,20);assert.equal(j.phase,'entrance');assert.ok(advanceJourney(j));assert.equal(j.phase,'walking');
|
||||
assert.equal(advanceJourney(j),false);assert.equal(createJourney().distance,0);
|
||||
});
|
||||
test('Brake, steering bounds and pause work while driving', () => {
|
||||
const j=createJourney();advanceJourney(j);tickJourney(j,2);
|
||||
for(let i=0;i<20;i++)tickJourney(j,.05,false,{throttle:1,steer:1});
|
||||
assert.ok(j.speed>0);assert.ok(j.lane>0 && j.lane<=.75);
|
||||
const snapshot={...j};tickJourney(j,1,true,{throttle:1});assert.deepEqual(j,snapshot);
|
||||
for(let i=0;i<30;i++)tickJourney(j,.05,false,{throttle:-1});
|
||||
assert.equal(j.speed,0);assert.equal(j.phase,'driving');
|
||||
});
|
||||
+2
-2
@@ -4,7 +4,7 @@ import {createStory,completeChapter,nextChapter,storyReady,routeOffset,discoveri
|
||||
import {createState,purchase,readyForPicnic,productByCode} from '../src/game-state.js';
|
||||
for(const route of ['sunny'])test(`Complete ${route} story and picnic`,()=>{
|
||||
const story=createStory();assert.equal(nextChapter(story,-8),'morning');
|
||||
for(const [id,x,choice] of [['morning',-8],['rabbit',-3,'watch'],['bridge',-2],['fish',0],['courage',3],['wind',12],['paper',14,'recover'],['fork',16,route],[route,19]]){
|
||||
for(const [id,x,choice] of [['morning',-8],['rabbit',-3,'watch'],['bridge',-2],['fish',0],['camp',3,'ask'],['courage',7],['wind',12],['paper',14,'recover'],['fork',16,route],[route,19]]){
|
||||
assert.equal(nextChapter(story,x),id);assert.ok(completeChapter(story,id,choice));assert.equal(completeChapter(story,id,choice),false);
|
||||
}
|
||||
assert.ok(storyReady(story));assert.equal(nextChapter(story,22),null);assert.ok(discoveries(story).length>=5);
|
||||
@@ -21,5 +21,5 @@ test('No early triggers, unknown choices, or leaked reset state',()=>{
|
||||
test('Every story action exposes one fixed action instead of choices',async()=>{
|
||||
const {chapters}=await import('../src/story.js');
|
||||
for(const chapter of Object.values(chapters))assert.equal(chapter.choices,undefined);
|
||||
for(const id of ['rabbit','paper','fork','summit']){const s=createStory();assert.equal(completeChapter(s,id,'wrong'),false);assert.ok(completeChapter(s,id,chapters[id].action.value));}
|
||||
for(const id of ['rabbit','paper','fork','summit','camp']){const s=createStory();assert.equal(completeChapter(s,id,'wrong'),false);assert.ok(completeChapter(s,id,chapters[id].action.value));}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user