MCPcopy Create free account
hub / github.com/6dylan6/jdm / stepPos

Method stepPos

function/jdValidate.js:405–422  ·  view source on GitHub ↗
(x, duration)

Source from the content-addressed store, hash-verified

403 return this.pos;
404 }
405 stepPos(x, duration) {
406 let n = 0;
407 const sqrt2 = Math.sqrt(2);
408 for (let i = 1; i <= this.STEP; i++) {
409 n += 1 / i;
410 }
411 for (let i = 0; i < this.STEP; i++) {
412 x = this.puzzleX / (n * (i + 1));
413 const currX = parseInt((Math.random() * 30 - 15) + x, 10);
414 const currY = parseInt(Math.random() * 7 - 3, 10);
415 const currDuration = parseInt((Math.random() * 0.4 + 0.8) * duration, 10);
416 this.moveToAndCollect({
417 x: currX,
418 y: currY,
419 duration: currDuration,
420 });
421 }
422 }
423 fixPos() {
424 const actualX = this.pos[this.pos.length - 1][0] - this.pos[1][0];
425 const deviation = this.puzzleX - actualX;

Callers 1

runMethod · 0.95

Calls 2

moveToAndCollectMethod · 0.95
randomMethod · 0.45

Tested by

no test coverage detected