Comparing version 0.7.3 to 0.8.0
@@ -74,5 +74,3 @@ 'use strict'; | ||
let diff = this.getDiff(length); | ||
// console.log('diff', diff) | ||
if (diff > this.endurance) { | ||
// console.log('true') | ||
return [binding.setBind(false)]; | ||
@@ -94,3 +92,14 @@ } | ||
resolve() { | ||
resolve(stateMap) { | ||
let p1 = stateMap.get(this.p1); | ||
let p2 = stateMap.get(this.p2); | ||
let q1 = stateMap.get(this.q1); | ||
let q2 = stateMap.get(this.q2); | ||
let binding = stateMap.get(this.binding); | ||
// allow kramuals | ||
if (_v2.default.cross((0, _v2.default)(p2.pos).sub(p1.pos), (0, _v2.default)(q2.pos).sub(q1.pos)) >= 0) { | ||
return []; | ||
} else if (binding.isBinded()) { | ||
return [binding.setBind(false)]; | ||
} | ||
return []; | ||
@@ -97,0 +106,0 @@ } |
@@ -19,5 +19,5 @@ 'use strict'; | ||
var _Rider = require('./Rider.js'); | ||
var _rider = require('./rider.js'); | ||
var _Rider2 = _interopRequireDefault(_Rider); | ||
var _rider2 = _interopRequireDefault(_rider); | ||
@@ -97,3 +97,3 @@ var _grids = require('./grids'); | ||
makeRider() { | ||
return new _Rider2.default(); | ||
return new _rider2.default(); | ||
} | ||
@@ -100,0 +100,0 @@ |
@@ -127,2 +127,3 @@ 'use strict'; | ||
} | ||
return this; | ||
} | ||
@@ -129,0 +130,0 @@ step() { |
{ | ||
"name": "lr-core", | ||
"version": "0.7.3", | ||
"version": "0.8.0", | ||
"description": "Line Rider core library", | ||
@@ -31,3 +31,3 @@ "main": "index.js", | ||
"standard": "^7.1.1", | ||
"tape": "^4.5.1" | ||
"tape": "^4.6.3" | ||
}, | ||
@@ -34,0 +34,0 @@ "dependencies": { |
@@ -162,4 +162,4 @@ import test from 'tape' | ||
test.skip('LineRiderEngine Compatibility', (t) => { | ||
const runTestTrack = (trackPath, legacy, extraTest = () => {}) => (t) => { | ||
test('LineRiderEngine Compatibility', (t) => { | ||
const runTestTrack = (trackPath, {shouldCrash = false, legacy = false, extraTest = () => {}}) => (t) => { | ||
let track = require(trackPath) | ||
@@ -175,35 +175,50 @@ let engine = (legacy ? new CustomLineRiderEngine({legacy: true}) : new LineRiderEngine()) | ||
.framesSinceUnbind | ||
t.equal(track.duration - riderCrashed, 1 + track.duration, 'rider should not have crashed') | ||
if (shouldCrash) { | ||
t.ok(riderCrashed > 0, 'rider should have crashed') | ||
} else { | ||
t.equal(track.duration - riderCrashed, 1 + track.duration, 'rider should not have crashed') | ||
} | ||
t.end() | ||
} | ||
t.test('test track', runTestTrack('../fixtures/testTrack.track.json', false, (t, engine) => { | ||
t.skip('extra tests for test track', t => { | ||
t.comment('Crashing at frame 63: line extensions have not been implemented') | ||
t.comment('Crashing at frame 86: no grid is being used') | ||
t.comment('Crashing at frame 433: order of lines is backwards') | ||
t.equal(engine.getRider(416).get('TAIL').pos.x, 804.1054060579701, 'frame 416 tail should be consistent') | ||
t.equal(engine.getRider(416).get('NOSE').pos.x, 813.3255772705486, 'frame 416 nose should be consistent') | ||
t.equal(engine.getRider(417).get('TAIL').pos.x, 797.8845320873339, 'frame 417 tail should be consistent') | ||
t.equal(engine.getRider(417).get('NOSE').pos.x, 810.0876743591476, 'frame 417 nose should be consistent') | ||
// printSim(engine, 2, 416) | ||
t.end() | ||
}) | ||
t.skip('test track', runTestTrack('../fixtures/testTrack.track.json', { | ||
extraTest: (t, engine) => { | ||
t.skip('extra tests for test track', t => { | ||
t.comment('Crashing at frame 63: line extensions have not been implemented') | ||
t.comment('Crashing at frame 86: no grid is being used') | ||
t.comment('Crashing at frame 433: order of lines is backwards') | ||
t.equal(engine.getRider(416).get('TAIL').pos.x, 804.1054060579701, 'frame 416 tail should be consistent') | ||
t.equal(engine.getRider(416).get('NOSE').pos.x, 813.3255772705486, 'frame 416 nose should be consistent') | ||
t.equal(engine.getRider(417).get('TAIL').pos.x, 797.8845320873339, 'frame 417 tail should be consistent') | ||
t.equal(engine.getRider(417).get('NOSE').pos.x, 810.0876743591476, 'frame 417 nose should be consistent') | ||
// printSim(engine, 2, 416) | ||
t.end() | ||
}) | ||
} | ||
})) | ||
t.test('cycloid', runTestTrack('../fixtures/cycloid.track.json', false, (t) => { | ||
t.skip('extra tests for cycloid', t => { | ||
t.comment('Crashing at frame 146: using dda instead of classic cells') | ||
t.end() | ||
}) | ||
t.skip('cycloid', runTestTrack('../fixtures/cycloid.track.json', { | ||
extraTest: (t) => { | ||
t.skip('extra tests for cycloid', t => { | ||
t.comment('Crashing at frame 146: using dda instead of classic cells') | ||
t.end() | ||
}) | ||
} | ||
})) | ||
t.test('legacy test track', runTestTrack('../fixtures/legacyTestTrack.track.json', true, (t) => { | ||
t.skip('extra tests for legacy test track', t => { | ||
t.comment('Crashing at frame 862: not using legacy cells') | ||
t.end() | ||
}) | ||
t.skip('legacy test track', runTestTrack('../fixtures/legacyTestTrack.track.json', { | ||
legacy: true, | ||
extraTest: (t) => { | ||
t.skip('extra tests for legacy test track', t => { | ||
t.comment('Crashing at frame 862: not using legacy cells') | ||
t.end() | ||
}) | ||
} | ||
})) | ||
t.test('cripple track', runTestTrack('../fixtures/cripple.track.json', { | ||
shouldCrash: true | ||
})) | ||
t.end() | ||
}) |
@@ -64,5 +64,3 @@ import V2 from '../../v2' | ||
let diff = this.getDiff(length) | ||
// console.log('diff', diff) | ||
if (diff > this.endurance) { | ||
// console.log('true') | ||
return [binding.setBind(false)] | ||
@@ -83,3 +81,16 @@ } | ||
resolve () { return [] } | ||
resolve (stateMap) { | ||
let p1 = stateMap.get(this.p1) | ||
let p2 = stateMap.get(this.p2) | ||
let q1 = stateMap.get(this.q1) | ||
let q2 = stateMap.get(this.q2) | ||
let binding = stateMap.get(this.binding) | ||
// allow kramuals | ||
if (V2.cross(V2(p2.pos).sub(p1.pos), V2(q2.pos).sub(q1.pos)) >= 0) { | ||
return [] | ||
} else if (binding.isBinded()) { | ||
return [binding.setBind(false)] | ||
} | ||
return [] | ||
} | ||
} | ||
@@ -86,0 +97,0 @@ export class DirectedChain { |
@@ -6,3 +6,3 @@ import {setupImmo} from '../immo' | ||
import {ITERATE, GRAVITY, DEFAULT_START_POSITION, DEFAULT_START_VELOCITY} from './constants.js' | ||
import Rider from './Rider.js' | ||
import Rider from './rider.js' | ||
import {ClassicGrid} from './grids' | ||
@@ -9,0 +9,0 @@ |
@@ -110,2 +110,3 @@ import Immo, {setupImmo} from '../../immo' | ||
} | ||
return this | ||
} | ||
@@ -112,0 +113,0 @@ step () { |
@@ -18,4 +18,10 @@ import test from 'tape' | ||
const tester = ({method, params = [], expected}) => | ||
t.deepEquals(space[method](...params), expected, `${method}: ${JSON.stringify(params)}`) | ||
const tester = ({method, params = [], expected}) => { | ||
let result = space[method](...params) | ||
if (expected instanceof Array) { | ||
// convert SubclassableArray to Array | ||
result = Array.from(result) | ||
} | ||
t.deepEquals(result, expected, `${method}: ${JSON.stringify(params)}`) | ||
} | ||
@@ -22,0 +28,0 @@ t.comment('0 lines') |
@@ -42,6 +42,6 @@ import Table from 'easy-table' | ||
let points = IDs.map((id) => | ||
rider.stateMap.get(id).pos | ||
rider.get(id).pos | ||
).map(({x, y}) => [x, y]) | ||
.reduce((a, b) => [...a, ...b]) | ||
return [...a, ...b, [i, 'FrameEnd', '', rider.stateMap.get('RIDER_MOUNTED').isBinded(), ...points]] | ||
return [...a, ...b, [i, 'FrameEnd', '', rider.get('RIDER_MOUNTED').isBinded(), ...points]] | ||
}, []) | ||
@@ -48,0 +48,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
168499
5519
0