Commit c5a3c8be authored by Grant's avatar Grant
Browse files

fix: pixel stacking inconsistency

parent 7d940b5f
Loading
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -166,8 +166,7 @@ export const AudioSettings = () => {
    if (!canvas?.lastPlace) return;

    const cooldown = CanvasLib.getPixelCooldown(pixelsAvailable + 1, config);
    const availableAt =
      canvas.lastPlace + cooldown * 1000 * (pixelsAvailable + 1);
    const availableAt = canvas.lastPlace + cooldown * 1000;
    const soundAt = availableAt + pixelAvailableOffset * 1000;
    const delay = soundAt - Date.now();

+1 −6
Original line number Diff line number Diff line
@@ -35,12 +35,7 @@ const getTimeLeft = (available: number, config: ClientConfig) => {
  if (!lastPlace) return undefined;

  const cooldown = CanvasLib.getPixelCooldown(available + 1, config);
  const pixelAvailableAt =
    lastPlace +
    // include already collected pixels
    cooldown * 1000 * available +
    // pixel we're currently waiting for
    cooldown * 1000;
  const pixelAvailableAt = lastPlace + cooldown * 1000;

  const pixelCooldown = (Date.now() - pixelAvailableAt) / 1000;

+0 −1
Original line number Diff line number Diff line
@@ -794,7 +794,6 @@ export class CanvasCore extends EventEmitter<CanvasEvents> {
      .then((ack) => {
        if (ack.success) {
          this.handlePixel(ack.data);
          this.lastPlace = Date.now();
          Network.emit("placeSuccessful");
          return true;
        } else {
+0 −3
Original line number Diff line number Diff line
@@ -348,9 +348,6 @@ export class SocketController {
            new Date(Date.now() + CONFIG.canvas.undo.grace_period),
          );

          // flag the user placed (used for next available pixel countdown)
          await user.markPlaced();

          const newPixel: Pixel = {
            x: pixel.x,
            y: pixel.y,
+0 −16
Original line number Diff line number Diff line
@@ -212,22 +212,6 @@ export class User {
      .io.to("user:" + this.sub)
      .emit(...args);

  async markPlaced() {
    await prisma.user.update({
      where: {
        sub: this.sub,
      },
      data: {
        lastTimeGainStarted: new Date(),
      },
    });

    await this.update();
  }

  /**
   * Set undoExpires in database and notify all user's sockets of undo ttl
   */
  async setUndo(expires?: Date) {
    if (expires) {
      // expiration being set