import { grid, cols, rows } from './state.js'; import { config } from './config.js'; import { createCell } from './physics.js'; export function updateIce(x, y, cell) { const dxs = [0, 0, -1, 1]; const dys = [-1, 1, 0, 0]; for (let i = 0; i < 4; i++) { const nx = x + dxs[i]; const ny = y + dys[i]; if (nx >= 0 && nx < cols && ny >= 0 && ny < rows) { const neighbor = grid[nx][ny]; if (neighbor) { const nt = neighbor.type; if (nt === 'fire' || nt === 'lava') { // Melt immediately grid[x][y] = createCell('water'); return; } else if (nt === 'steam') { // Condenses steam into water grid[nx][ny] = createCell('water'); } else if (nt === 'water' && Math.random() < config.ice.freezeChance) { // Freezes adjacent water into ice grid[nx][ny] = createCell('ice'); } } } } // Ambient melting if in hot conditions if (Math.random() < config.ice.meltChance * 0.05) { grid[x][y] = createCell('water'); } }