/* ============================================================
   config.js - Tunable placement for every PNG graphic.

   Adjust these live to line the artwork up with the game logic.

     scale : size multiplier applied to the PNG's natural size
     dx,dy : pixel nudge in canvas space (600x400) AFTER anchoring

   Character / prop anchors are fixed in code:
     - characters (snoopy/charlie/lucy)  : bottom-centre (their feet)
     - woodstock, ball                   : centre
     - missMark                          : top-left
   For those, use scale + dx/dy to fine-tune.

   Background pieces are absolutely placed: set their top-left with
   x,y (plus optional dx/dy nudge) and size with scale.

   Tip: from the browser console you can tweak and see it next frame,
   e.g.  ST.SpriteConfig.snoopy.scale = 1.1
         ST.SpriteConfig.bg_tree.y = 96
   ============================================================ */
(function (ST) {
  "use strict";

  ST.SpriteConfig = {
    /* --- characters & props (anchored in code) --- */
    snoopy:    { scale: 0.75, dx: -15, dy: 20 },
    charlie:   { scale: 1.5, dx: -40, dy: 0 },
    lucy:      { scale: 1.4, dx: -20, dy: -10 },
    woodstock: { scale: 1, dx: 0, dy: 0 },
    ball:      { scale: 1, dx: 0, dy: 0 },
    missMark:  { scale: 1, dx: 0, dy: -22 },   // lift to sit by the "MISS" label

    // Snoopy asleep on the doghouse after a miss (absolute top-left x,y)
    snoopy_sleep: { scale: 1.3, dx: 15, dy: 0, x: 475, y: 190 },

    /* --- background pieces (absolute top-left x,y) --- */
    bg_grass:    { scale: 0.8, dx: 50, dy: 0, x: 0,   y: 368 },
    bg_platform: { scale: 3.65, dx: -220, dy: 0, x: 24,  y: 168 },
    bg_tree:     { scale: 1.35, dx: -75, dy: -65, x: 460, y: 90  },
    bg_doghouse: { scale: 1.2, dx: -10, dy: -17, x: 495, y: 290 },
    bg_leaves:   { scale: 0.4, dx: 0, dy: 260, x: 455, y: 85  },
    bg_nest:     { scale: 1.5, dx: -50, dy: 10, x: 528, y: 90  }
  };

  // draw order for background pieces (back -> front)
  ST.BgOrder = ["bg_grass", "bg_platform", "bg_tree", "bg_doghouse", "bg_leaves", "bg_nest"];

  /* ============================================================
     Snoopy's three playing positions on the tree.
     Each level has an absolute x and feet-y (canvas 600x400 space),
     so you can slide each one to line up with a branch.
       faceDY : how far the ball meets Snoopy's face above his feet
       hitDX  : ball meets the racket this far from Snoopy's x
                (negative = to the left of him)
     ============================================================ */
  ST.SnoopyLevels = {
    levels: [
      { x: 436, feetY: 158 },   // 0 = top
      { x: 436, feetY: 250 },   // 1 = middle
      { x: 436, feetY: 338 }    // 2 = bottom
    ],
    faceDY: 52,
    hitDX: -48
  };

  /* ============================================================
     Gameplay tuning - speeds, probabilities, timings.
       normalStep     : base ball step interval (ms); LOWER = faster
       gameBFactor    : Game B interval multiplier vs Game A (<1 = faster)
       lucyFactor     : Lucy-smash interval multiplier vs normal (<1 = faster)
       pLucy          : chance Lucy intercepts Snoopy's return
       pCharlieMiss   : chance Charlie fails to return a ball
       sleepMs        : how long Snoopy sleeps on the doghouse after a miss
       serveStart     : where Charlie's serve launches (absolute x,y)
       powMs / indicator: on-screen text timings/placement
     ============================================================ */
  ST.Gameplay = {
    normalStep:   170,
    gameBFactor:  0.95,
    lucyFactor:   0.90,
    pLucy:        0.34,
    pCharlieMiss: 0.18,
    sleepMs:      2000,
    serveStart:   { x: 150, y: 300 },      // raised above Charlie's feet
    powMs:        650,
    pow:          { x: 116, y: 250 },      // POW! text anchor (above Charlie)
    gameLabelA:   { x: 96,  y: 372 },      // "GAME A" below Charlie
    gameLabelB:   { x: 470, y: 384 }       // "GAME B" below the doghouse
  };

  function cfg(key) {
    return (ST.SpriteConfig && ST.SpriteConfig[key]) || { scale: 1, dx: 0, dy: 0 };
  }
  ST.cfg = cfg;
})(window.ST = window.ST || {});
