cards and lot of

This commit is contained in:
33333-33333 2026-06-07 22:04:17 +09:00
commit ca40a0cb73
13 changed files with 624 additions and 92 deletions

View file

@ -2,6 +2,7 @@ import { GRID, THEME, EFFECT_PRIORITY, VERSION } from '../core/config.js';
import { key, parseKey, pointToCell, cellCenter, mixHex, randomBetween, yen } from '../core/utils.js';
import { getConveyorNeighbors, routeFromFarmToScanner, outputRoute, scannerCenter, scannerConnector, scannerOutputs, destinationLabel, destinationColor, scannerPortHasConveyor } from '../systems/routing.js';
import { upgradedMixerPrice, upgradedTruckPrice } from '../systems/economy.js';
import { cardTargetBounds } from '../systems/cards.js';
const ASSET_PATHS = {
chickMale: './assets/images/chick_male.png',
@ -44,6 +45,7 @@ export function drawAll(ctx, canvas, game, helpers) {
drawEggFarms(ctx, game);
drawScanners(ctx, game);
drawChicks(ctx, game, helpers.activeQueuedChick);
drawCardTargetOverlay(ctx, canvas, game);
drawSelectedTooltip(ctx, game, helpers.selectedObject, helpers.selectedTitle);
drawSelectionBox(ctx, game);
drawEffects(ctx, game);
@ -445,6 +447,58 @@ function drawSelectedTooltip(ctx, game, selectedObject, selectedTitle) {
else if (obj.type === 'facility') { x = obj.x + obj.w / 2 - 76; y = obj.y - 48; }
ctx.save(); ctx.fillStyle = 'rgba(255,255,255,.95)'; ctx.strokeStyle = THEME.ink; ctx.lineWidth = 3; rect(ctx, x, y, 176, 40, true, true); ctx.fillStyle = THEME.ink; ctx.font = '900 11px ui-monospace, monospace'; ctx.fillText(selectedTitle(obj), x + 9, y + 16); ctx.fillStyle = THEME.muted; ctx.font = '900 9px ui-monospace, monospace'; ctx.fillText('drag to move / panel to edit', x + 9, y + 31); ctx.restore();
}
function drawCardTargetOverlay(ctx, canvas, game) {
if (!game.cardTargetPick?.pending) return;
const items = cardTargetBounds(game);
ctx.save();
// The canvas is already translated by the camera. Offset the dark layer back to screen space
// so every non-candidate object is reliably dimmed even after panning.
ctx.fillStyle = 'rgba(0,0,0,.66)';
ctx.fillRect(-game.view.x, -game.view.y, canvas.width, canvas.height);
if (!items.length) {
ctx.fillStyle = 'rgba(255,255,255,.95)';
ctx.strokeStyle = THEME.ink;
ctx.lineWidth = 3;
rect(ctx, 260 - game.view.x, 96 - game.view.y, 420, 42, true, true);
ctx.fillStyle = THEME.danger;
ctx.font = '900 12px ui-monospace, monospace';
ctx.textAlign = 'center';
ctx.fillText('NO VALID UPGRADE TARGET. PRESS ESC.', 470 - game.view.x, 122 - game.view.y);
ctx.restore();
return;
}
for (const item of items) {
const b = item.bounds;
ctx.save();
ctx.shadowColor = THEME.white;
ctx.shadowBlur = 20;
ctx.fillStyle = 'rgba(255,255,255,.32)';
ctx.strokeStyle = THEME.white;
ctx.lineWidth = 8;
ctx.setLineDash([10, 6]);
rect(ctx, b.x - 10, b.y - 10, b.w + 20, b.h + 20, true, true);
ctx.restore();
ctx.save();
ctx.strokeStyle = THEME.green;
ctx.lineWidth = 4;
ctx.strokeRect(b.x - 4, b.y - 4, b.w + 8, b.h + 8);
ctx.restore();
ctx.fillStyle = 'rgba(255,255,255,.96)';
ctx.strokeStyle = THEME.ink;
ctx.lineWidth = 3;
const labelW = Math.min(300, Math.max(150, item.label.length * 7));
rect(ctx, b.cx - labelW / 2, b.y - 34, labelW, 24, true, true);
ctx.fillStyle = THEME.ink;
ctx.font = '900 10px ui-monospace, monospace';
ctx.textAlign = 'center';
ctx.fillText(item.label, b.cx, b.y - 18);
}
ctx.restore();
}
function drawSelectionBox(ctx, game) {
if (game.phase !== 'build' || !game.selectionBox) return;
const b = game.selectionBox;