| 432 | } |
| 433 | } |
| 434 | moveToAndCollect({ |
| 435 | x, |
| 436 | y, |
| 437 | duration |
| 438 | }) { |
| 439 | let movedX = 0; |
| 440 | let movedY = 0; |
| 441 | let movedT = 0; |
| 442 | const times = duration / this.minDuration; |
| 443 | let perX = x / times; |
| 444 | let perY = y / times; |
| 445 | let padDuration = 0; |
| 446 | if (Math.abs(perX) < 1) { |
| 447 | padDuration = duration / Math.abs(x) - this.minDuration; |
| 448 | perX = 1; |
| 449 | perY = y / Math.abs(x); |
| 450 | } |
| 451 | while (Math.abs(movedX) < Math.abs(x)) { |
| 452 | const rDuration = parseInt(padDuration + Math.random() * 16 - 4, 10); |
| 453 | movedX += perX + Math.random() * 2 - 1; |
| 454 | movedY += perY; |
| 455 | movedT += this.minDuration + rDuration; |
| 456 | const currX = parseInt(this.x + 20, 10); |
| 457 | const currY = parseInt(this.y + 20, 10); |
| 458 | const currT = this.t + movedT; |
| 459 | this.pos.push([currX, currY, currT]); |
| 460 | } |
| 461 | this.x += x; |
| 462 | this.y += y; |
| 463 | this.t += Math.max(duration, movedT); |
| 464 | } |
| 465 | } |
| 466 | exports.JDJRValidator = JDJRValidator |