熔炉战线:二战锻造营【完整版】
by ChromeOtter32589 lines24.0 KB
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>熔炉战线:二战锻造营【完整版】</title>
<style>
*{box-sizing:border-box;margin:0;padding:0;font-family:system-ui, sans-serif}
body{background:#1a1a1a;color:#e2e2e2;overflow:hidden}
#gameCanvas{display:block;background:#222}
.panel{position:absolute;background:#2b2b2b;border:2px solid #666;padding:12px;min-width:360px;max-width:90vw;display:none;z-index:10}
.panel h3{border-bottom:1px solid #555;padding-bottom:6px;margin-bottom:10px;color:#f0b868}
.btn{background:#444;border:1px solid #774;color:#eee;padding:6px 10px;margin:3px;cursor:pointer;font-size:14px}
.btn:hover{background:#555}
.btnDanger{border-color:#a44}
.btnGood{border-color:#4a4}
.btnPrimary{border-color:#48a}
.itemBox{display:inline-flex;flex-direction:column;background:#333;border:1px solid #555;padding:4px;margin:3px;font-size:12px;vertical-align:top;align-items:center}
.itemBox.normal{width:64px;height:56px}
.itemBox.tank{width:84px;height:72px}
.itemBox.plane{width:104px;height:76px}
.itemBox .name{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;width:100%;text-align:center}
.itemBox .val{color:#fc9}
.toast{position:fixed;bottom:20px;left:50%;transform:translateX(-50%);background:#111;color:#ee9;padding:8px 16px;border:1px solid #884;display:none;z-index:20}
#startPanel{top:50%;left:50%;transform:translate(-50%,-50)}
#hud{position:absolute;top:4px;left:4px;font-size:14px;background:rgba(0,0,0,0.7);padding:8px;border-radius:4px}
#hud span{color:#fc9}
.row{display:flex;gap:8px;flex-wrap:wrap;margin:6px 0}
.flexGrow{flex-grow:1}
.scrollArea{max-height:280px;overflow-y:auto;border:1px solid #444;padding:6px;margin:4px 0}
.quality0{color:#aaa}
.quality1{color:#bbb}
.quality2{color:#eee}
.quality3{color:#8cf}
.quality4{color:#8f8}
.quality5{color:#ff8}
.quality6{color:#f8f}
.quality7{color:#f66;font-weight:bold}
</style>
</head>
<body>
<canvas id="gameCanvas"></canvas>
<div id="hud">
<div>兵力:<span id="hudPower">3</span></div>
<div>当日补给需求:<span id="hudNeed">0</span></div>
<div>当前补给价值:<span id="hudVal">0</span></div>
<div>天数:<span id="hudDay">1</span></div>
<div>图纸点:<span id="hudDraw">0</span></div>
<div>军工点:<span id="hudArmy">0</span></div>
<div>专注进度:<span id="hudFocus">0/6</span> <span id="focusTag"></span></div>
</div>
<div class="panel" id="startPanel">
<h3>熔炉战线:二战锻造营</h3>
<p>你是前线兵工厂主管,每日生产军备上交补给,支撑防线。<br>WASD移动 | E交互 | ESC关闭面板</p>
<div class="row">
<button class="btn btnGood" onclick="gameStart()">开始新对局</button>
<button class="btn btnPrimary" onclick="openBuildPanel()">工厂升级</button>
<button class="btn" onclick="openAchievePanel()">成就</button>
</div>
<div class="row">
<button class="btn" onclick="loadGlobal()">读取全局存档</button>
<button class="btn btnDanger" onclick="clearAllSave()">清空全部存档</button>
</div>
</div>
<div class="panel" id="stationPanel">
<h3 id="stationTitle">站点</h3>
<div id="stationContent"></div>
<button class="btn" onclick="closePanel()">关闭【ESC】</button>
</div>
<div class="panel" id="buildPanel">
<h3>兵工厂升级(消耗军工点)</h3>
<div id="buildContent" class="scrollArea"></div>
<button class="btn" onclick="closeBuildPanel()">关闭</button>
</div>
<div class="panel" id="achievePanel">
<h3>成就列表</h3>
<div id="achieveContent" class="scrollArea"></div>
<button class="btn" onclick="closeAchievePanel()">关闭</button>
</div>
<div class="panel" id="contractPanel">
<h3>司令部军令(三选一)</h3>
<div id="contractContent"></div>
</div>
<div class="panel" id="battlePanel">
<h3>终局决战!派出战备仓库军备</h3>
<div id="battleContent" class="scrollArea"></div>
<button class="btn btnGood" onclick="runFinalBattle()">发起决战</button>
<button class="btn" onclick="closeBattlePanel()">放弃决战结算本局</button>
</div>
<div class="toast" id="toast"></div>
<script>
const canvas=document.getElementById('gameCanvas');
const ctx=canvas.getContext('2d');
function resize(){canvas.width=window.innerWidth;canvas.height=window.innerHeight}
resize();window.addEventListener('resize',resize);
// ========== 全局存档 ==========
let globalSave={
armyPoint:0,
buildings:{
press:0,furnace:0,workbench:0,storage:0,merchant:0,fuse:0,test:0,logistic:0,drawRoom:0,
tankShop:0,airShop:0
},
unlockItem:[],
unlockFuse:[],
achieve:[],
passStage:[],
stat:{make:0,fuse:0,testWin:0,contract:0}
};
const BUILD_DEF = [
{key:"press",name:"冲压机床",desc:"降低冲压冷却,提升普通加工成功率",cost:8,max:10},
{key:"furnace",name:"热处理炉",desc:"缩短加热时间,提高单次加工上限",cost:8,max:10},
{key:"workbench",name:"物料台",desc:"扩大当日待发区格子",cost:12,max:8},
{key:"storage",name:"战备仓库",desc:"增加战备仓库容量",cost:12,max:8},
{key:"merchant",name:"军需商人",desc:"解锁更多商品、采购折扣",cost:10,max:8},
{key:"fuse",name:"改装装配台",desc:"提高融合成功率,解锁配方",cost:15,max:10},
{key:"test",name:"靶场试炼台",desc:"试炼奖励提升",cost:10,max:8},
{key:"logistic",name:"后勤指挥部",desc:"降低每日补给需求",cost:20,max:8},
{key:"drawRoom",name:"图纸档案室",desc:"开局赠送图纸点",cost:12,max:8},
{key:"tankShop",name:"装甲总装车间",desc:"解锁坦克制造,降低组装失败率",cost:25,max:10},
{key:"airShop",name:"航空组装棚",desc:"解锁飞机制造,降低坠毁概率",cost:30,max:10},
];
const ACHIEVE_DEF = [
{id:"make10",name:"熟练工匠",desc:"累计制造10件军备",need:()=>globalSave.stat.make>=10,rew:10},
{id:"make100",name:"流水线",desc:"累计制造100件军备",need:()=>globalSave.stat.make>=100,rew:50},
{id:"fuse10",name:"改装专家",desc:"成功融合10次",need:()=>globalSave.stat.fuse>=10,rew:30},
{id:"test20",name:"测试王牌",desc:"试炼胜利20次",need:()=>globalSave.stat.testWin>=20,rew:40},
{id:"contract5",name:"军令执行者",desc:"接受5次军令",need:()=>globalSave.stat.contract>=5,rew:25},
{id:"firstTank",name:"装甲先驱",desc:"造出第一台坦克",need:()=>globalSave.unlockItem.includes("reconTank"),rew:20},
{id:"firstPlane",name:"雄鹰起航",desc:"造出第一架飞机",need:()=>globalSave.unlockItem.includes("reconPlane"),rew:20},
];
const CONTRACT_LIST = [
{txt:"补给需求+30%,图纸点+40",debuff:"supplyUp",gain:40},
{txt:"冲压报废概率上升,图纸点+35",debuff:"pressRisk",gain:35},
{txt:"重型载具组装难度提高,图纸点+50",debuff:"heavyRisk",gain:50},
{txt:"待发区上限减少2格,图纸点+45",debuff:"workLimit",gain:45},
];
// ========== 对局状态 ==========
let game={
running:false,
player:{x:120,y:120,w:24,h:24,speed:3},
power:3,
day:1,
drawPoint:0,
supplyNeed:100,
supplyVal:0,
maxDay:20,
stage:1,
focusCount:0,
focusNeed:6,
focusActive:false,
workArea:[],
reserve:[],
tool:[],
bag:[],
debuffs:[],
stations:[
{name:"热处理炉",x:80,y:80,w:50,h:50,type:"furnace"},
{name:"冲压机床",x:160,y:80,w:50,h:50,type:"press"},
{name:"军需商人",x:240,y:80,w:50,h:50,type:"merchant"},
{name:"改装装配台",x:320,y:80,w:50,h:50,type:"fuse"},
{name:"靶场试炼台",x:400,y:80,w:50,h:50,type:"test"},
{name:"前线指挥部",x:480,y:80,w:50,h:50,type:"hq"},
{name:"装甲总装车间",x:80,y:160,w:50,h:50,type:"tank"},
{name:"航空组装棚",x:160,y:160,w:50,h:50,type:"air"}
],
keys:{w:false,a:false,s:false,d:false}
};
// ========== 军备定义 ==========
const ITEM_DEF={
rifle:{name:"栓动步枪",type:"normal",base:10},
smg:{name:"冲锋枪",type:"normal",base:16},
lmg:{name:"轻机枪",type:"normal",base:24},
mortar:{name:"迫击炮",type:"normal",base:40},
atGun:{name:"反坦克炮",type:"normal",base:60},
heShell:{name:"高爆弹",type:"normal",base:12},
apShell:{name:"穿甲弹",type:"normal",base:15},
mine:{name:"地雷",type:"normal",base:18},
grenade:{name:"反坦克手雷",type:"normal",base:14},
autoRifle:{name:"半自动步枪",type:"normal",base:22},
hmg:{name:"重机枪",type:"normal",base:35},
howitzer:{name:"野战炮",type:"normal",base:55},
fireShell:{name:"燃烧弹",type:"normal",base:20},
dynamite:{name:"炸药包",type:"normal",base:25},
reconTank:{name:"侦察坦克",type:"tank",base:120},
medTank:{name:"中型坦克",type:"tank",base:260},
heavyTank:{name:"重型坦克",type:"tank",base:520},
atSpg:{name:"自行反坦克炮",type:"tank",base:380},
spg:{name:"自行榴弹炮",type:"tank",base:440},
amphTank:{name:"两栖坦克",type:"tank",base:420},
reconPlane:{name:"侦察机",type:"plane",base:140},
fighter:{name:"战斗机",type:"plane",base:280},
diveBomb:{name:"俯冲轰炸机",type:"plane",base:460},
heavyBomb:{name:"水平轰炸机",type:"plane",base:700},
attack:{name:"攻击机",type:"plane",base:340},
torpPlane:{name:"鱼雷机",type:"plane",base:540}
};
const QUALITY=["毛坯","粗制","合格","精良","优质","王牌","特种","传奇"];
const FUSE_RECIPE=[
{a:"medTank",b:"apShell",out:"jtank",name:"歼击坦克",base:500},
{a:"heavyTank",b:"heShell",out:"siegeTank",name:"攻城重坦",base:900},
{a:"diveBomb",b:"fireShell",out:"fireBomb",name:"烈焰轰炸机",base:820},
{a:"fighter",b:"atGun",out:"cannonFighter",name:"航炮攻击机",base:620},
];
// ========== 工具函数 ==========
function fmtNum(n){
if(n<10000)return n.toString();
return n.toExponential(2);
}
function getQualityClass(lv){
return "quality"+lv;
}
function randomResult(isHeavy=false){
let br=0.12,bad=0.25;
if(isHeavy && game.debuffs.includes("heavyRisk")){br=0.18;bad=0.33}
if(!isHeavy && game.debuffs.includes("pressRisk")){br=0.18;bad=0.33}
let r=Math.random();
if(r<br)return "break";
if(r<bad)return "bad";
if(r<0.55)return "ok";
if(r<0.88)return "good";
return "top";
}
function calcItemVal(def,qualityLv){
return Math.floor(def.base * (1 + qualityLv*0.45));
}
function createItem(key,quality=2){
const d=ITEM_DEF[key];
if(!globalSave.unlockItem.includes(key))globalSave.unlockItem.push(key);
globalSave.stat.make++;
saveGlobal();
return {key,name:d.name,type:d.type,quality,qualityName:QUALITY[quality],val:calcItemVal(d,quality)};
}
function showToast(txt){
const t=document.getElementById('toast');
t.innerText=txt;t.style.display="block";
setTimeout(()=>t.style.display="none",1800);
}
function closePanel(){document.getElementById('stationPanel').style.display="none";}
function openPanel(title,html){
const p=document.getElementById('stationPanel');
document.getElementById('stationTitle').innerText=title;
document.getElementById('stationContent').innerHTML=html;
p.style.display="block";
}
function updateHUD(){
document.getElementById('hudPower').innerText=game.power;
document.getElementById('hudNeed').innerText=fmtNum(game.supplyNeed);
document.getElementById('hudVal').innerText=fmtNum(game.supplyVal);
document.getElementById('hudDay').innerText=game.day;
document.getElementById('hudDraw').innerText=game.drawPoint;
document.getElementById('hudArmy').innerText=globalSave.armyPoint;
document.getElementById('hudFocus').innerText=`${game.focusCount}/${game.focusNeed}`;
document.getElementById('focusTag').innerText=game.focusActive?"【专注激活】":"";
}
// ========== 存档 ==========
function saveGlobal(){localStorage.setItem("forgeArmySave",JSON.stringify(globalSave))}
function loadGlobal(){
const s=localStorage.getItem("forgeArmySave");
if(s)globalSave=JSON.parse(s);
checkAchieve();
updateHUD();
showToast("全局存档已加载");
}
function clearAllSave(){
localStorage.removeItem("forgeArmySave");
globalSave={armyPoint:0,buildings:{press:0,furnace:0,workbench:0,storage:0,merchant:0,fuse:0,test:0,logistic:0,drawRoom:0,tankShop:0,airShop:0},unlockItem:[],unlockFuse:[],achieve:[],passStage:[],stat:{make:0,fuse:0,testWin:0,contract:0}};
showToast("存档清空");
}
function checkAchieve(){
for(const a of ACHIEVE_DEF){
if(!globalSave.achieve.includes(a.id) && a.need()){
globalSave.achieve.push(a.id);
globalSave.armyPoint += a.rew;
showToast(`解锁成就【${a.name}】+${a.rew}军工点`);
}
}
saveGlobal();
}
// ========== 建造面板 ==========
function openBuildPanel(){
closePanel();
let html="";
for(const b of BUILD_DEF){
const lv=globalSave.buildings[b.key];
const cost = b.cost*(lv+1);
const can=lv < b.max && globalSave.armyPoint >= cost;
html += `<div><b>${b.name}</b> Lv.${lv}/${b.max}:${b.desc}
<button class="btn ${can?'btnGood':'btnDanger'}" onclick="upgrade('${b.key}',${cost})" ${!can?'disabled':''}>升级(${cost}军工点)</button></div>`;
}
document.getElementById('buildContent').innerHTML=html;
document.getElementById('buildPanel').style.display="block";
}
function closeBuildPanel(){document.getElementById('buildPanel').style.display="none";}
function upgrade(key,cost){
if(globalSave.armyPoint >= cost){
globalSave.armyPoint -= cost;
globalSave.buildings[key]++;
saveGlobal();
openBuildPanel();
updateHUD();
showToast("升级成功!");
}
}
// ========== 成就面板 ==========
function openAchievePanel(){
closePanel();
let html="";
for(const a of ACHIEVE_DEF){
const ok = globalSave.achieve.includes(a.id);
html += `<div style="color:${ok?'#8f8':'#888'}">【${ok?'✓':'○'}】${a.name}: ${a.desc}(奖励${a.rew}军工点)</div>`;
}
document.getElementById('achieveContent').innerHTML=html;
document.getElementById('achievePanel').style.display="block";
}
function closeAchievePanel(){document.getElementById('achievePanel').style.display="none";}
// ========== 军令弹窗 ==========
function openContractPanel(){
let html="<p>司令部下发军令,选择其一接受:</p>";
const pick = CONTRACT_LIST.sort(()=>Math.random()-0.5).slice(0,3);
for(let i=0;i<pick.length;i++){
const c=pick[i];
html += `<button class="btn btnPrimary" onclick="acceptContract('${c.debuff}',${c.gain})">${c.txt}</button>`;
}
document.getElementById('contractContent').innerHTML=html;
document.getElementById('contractPanel').style.display="block";
}
function closeContractPanel(){document.getElementById('contractPanel').style.display="none";}
function acceptContract(debuff,gain){
game.drawPoint += gain;
game.debuffs.push(debuff);
globalSave.stat.contract++;
saveGlobal();
closeContractPanel();
showToast("已接受军令!");
updateHUD();
}
// ========== 终局决战 ==========
function openBattlePanel(){
closePanel();
let html="<p>战备仓库军备将全部参战,价值越高军工奖励越高!</p>";
html += `<div>仓库军备总价值:${fmtNum(game.reserve.reduce((s,i)=>s+i.val,0))}</div>`;
document.getElementById('battleContent').innerHTML=html;
document.getElementById('battlePanel').style.display="block";
}
function closeBattlePanel(){document.getElementById('battlePanel').style.display="none";game.running=false;}
function runFinalBattle(){
const totalVal = game.reserve.reduce((s,i)=>s+i.val,0);
const reward = Math.floor(totalVal * 0.08);
globalSave.armyPoint += reward;
saveGlobal();
showToast(`决战胜利!获得 ${fmtNum(reward)} 军工点!`);
closeBattlePanel();
game.running=false;
}
// ========== 对局启动 ==========
function gameStart(){
game.running=true;
game.power=3;game.day=1;game.drawPoint=globalSave.buildings.drawRoom*15;
let baseNeed=100*Math.pow(1.35,game.stage-1);
baseNeed *= (1 - globalSave.buildings.logistic*0.04);
game.supplyNeed=baseNeed;
game.supplyVal=0;game.workArea=[];game.reserve=[];game.tool=[];game.bag=[];game.debuffs=[];
game.focusCount=0;game.focusActive=false;
game.workArea.push(createItem("rifle",1));
game.workArea.push(createItem("smg",1));
closePanel();
updateHUD();
showToast("对局开始,生产军备上交补给!");
}
// ========== 交互 ==========
function checkInteract(){
const px=game.player.x,py=game.player.y;
for(const st of game.stations){
if(px<st.x+st.w && px+game.player.w>st.x && py<st.y+st.h && py+game.player.h>st.y){
openStation(st);
return;
}
}
}
function itemHtml(it){
return `<div class="itemBox ${it.type} ${getQualityClass(it.quality)}">
<div class="name">${it.name}</div>
<div>${it.qualityName}</div>
<div class="val">${fmtNum(it.val)}</div>
</div>`;
}
function openStation(st){
let html="";
switch(st.type){
case "furnace":
html="<p>加热毛坯,为冲压/总装做准备</p>";
html += `<div>待发区:${game.workArea.map(itemHtml).join("")}</div>`;
html += `<button class="btn" onclick='doHeat()'>加热一件物品</button>`;
break;
case "press":
html="<p>加工轻武器</p>";
html += `<div>待发区:${game.workArea.map(itemHtml).join("")}</div>`;
html += `<button class="btn" onclick='doPress()'>冲压加工</button>`;
break;
case "tank":
html="<p>装甲总装车间 Lv."+globalSave.buildings.tankShop+"</p>";
html += `<div>待发区:${game.workArea.map(itemHtml).join("")}</div>`;
html += `<button class="btn" onclick='doMakeTank()'>组装坦克</button>`;
break;
case "air":
html="<p>航空组装棚 Lv."+globalSave.buildings.airShop+"</p>";
html += `<div>待发区:${game.workArea.map(itemHtml).join("")}</div>`;
html += `<button class="btn" onclick='doMakePlane()'>组装飞机</button>`;
break;
case "merchant":
html="<p>军需商人</p>";
html += `<button class="btn" onclick='buyItem("rifle")'>步枪毛坯</button>`;
html += `<button class="btn" onclick='buyItem("smg")'>冲锋枪毛坯</button>`;
html += `<button class="btn" onclick='buyItem("apShell")'>穿甲弹</button>`;
break;
case "fuse":
html="<p>消耗图纸点融合军备(2件融合)</p>";
html += `<div>待发区:${game.workArea.map(itemHtml).join("")}</div>`;
html += `<button class="btn" onclick='doFuse()'>尝试融合(20图纸点)</button>`;
break;
case "test":
html="<p>靶场试炼台,选一件军备试炼</p>";
html += `<div>待发区:${game.workArea.map(itemHtml).join("")}</div>`;
html += `<button class="btn" onclick='doTest()'>开始试炼</button>`;
break;
case "hq":
html="<p>提交今日补给,进入下一天</p>";
html += `<div>待发区军备:${game.workArea.map(itemHtml).join("")}</div>`;
html += `<button class="btn btnGood" onclick='submitSupply()'>提交补给</button>`;
break;
}
openPanel(st.name,html);
}
// ========== 加工逻辑 ==========
function doHeat(){
if(game.workArea.length===0){showToast("待发区没有物品!");return;}
showToast("加热完成,可以加工");
}
function doPress(){
if(game.workArea.length===0){showToast("先准备毛坯!");return;}
const res=randomResult(false);
applyProcessResult(res,"普通加工");
}
function doMakeTank(){
if(globalSave.buildings.tankShop<1){showToast("装甲车间未解锁!去工厂升级");return;}
const res=randomResult(true);
applyProcessResult(res,"坦克组装");
}
function doMakePlane(){
if(globalSave.buildings.airShop<1){showToast("航空棚未解锁!去工厂升级");return;}
const res=randomResult(true);
applyProcessResult(res,"飞机组装");
}
function applyProcessResult(res,typeName){
game.focusCount++;
if(game.focusCount >= game.focusNeed) game.focusActive=true;
if(game.focusActive && (res==="break"||res==="bad")) res="ok";
const it=game.workArea.pop();
if(res==="break"){showToast(`${typeName}:报废!物品消失`);return;}
if(res==="bad"){it.quality=Math.max(0,it.quality-1);it.val=calcItemVal(ITEM_DEF[it.key],it.quality);it.qualityName=QUALITY[it.quality];game.workArea.push(it);showToast(`${typeName}:次品!品质下降`);return;}
if(res==="ok"){game.workArea.push(it);showToast(`${typeName}:合格`);return;}
if(res==="good"){it.quality=Math.min(7,it.quality+1);it.val=calcItemVal(ITEM_DEF[it.key],it.quality);it.qualityName=QUALITY[it.quality];game.workArea.push(it);showToast(`${typeName}:精良!品质提升`);return;}
if(res==="top"){it.quality=Math.min(7,it.quality+2);it.val=calcItemVal(ITEM_DEF[it.key],it.quality);it.qualityName=QUALITY[it.quality];game.workArea.push(it);showToast(`${typeName}:王牌!大幅升级`);return;}
}
function buyItem(key){
game.workArea.push(createItem(key,1));
showToast("购入毛坯");
updateHUD();
}
function doFuse(){
if(game.drawPoint<20){showToast("图纸点不足20");return;}
if(game.workArea.length<2){showToast("待发区至少留2件物品");return;}
game.drawPoint-=20;
const a=game.workArea.pop();
const b=game.workArea.pop();
const successRate = 0.4 + globalSave.buildings.fuse*0.04;
if(Math.random() < successRate){
const newIt=createItem("medTank",3);
game.workArea.push(newIt);
globalSave.stat.fuse++;
saveGlobal();
showToast("融合成功!");
}else{
showToast("融合爆炸,两件损毁!");
}
checkAchieve();
updateHUD();
}
function doTest(){
if(game.workArea.length<1){showToast("需要军备");return;}
const it=game.workArea.pop();
const winRate=0.45 + globalSave.buildings.test*0.03;
if(Math.random() < winRate){
game.drawPoint+=25;
game.workArea.push(it);
globalSave.stat.testWin++;
saveGlobal();
showToast("试炼胜利,图纸点+25");
}else{
showToast("试炼失败,军备损毁");
}
checkAchieve();
updateHUD();
}
function submitSupply(){
game.supplyVal=game.workArea.reduce((s,i)=>s+i.val,0);
if(game.supplyVal >= game.supplyNeed){
showToast("补给达标!防线稳住");
}else{
game.power--;
showToast(`补给不足!兵力-1,剩余${game.power}`);
if(game.power<=0){showToast("防线崩溃,本局失败");game.running=false;closePanel();return;}
}
game.reserve.push(...game.workArea);
game.workArea=[];
game.day++;
let mul=1.22;
if(game.debuffs.includes("supplyUp")) mul *=1.3;
game.supplyNeed *= mul;
if(game.day%5===0){
openContractPanel();
}
if(game.day >= game.maxDay){
openBattlePanel();
closePanel();
return;
}
game.workArea.push(createItem("smg",1));
checkAchieve();
updateHUD();
closePanel();
}
// ========== 输入 ==========
document.addEventListener('keydown',e=>{
const k=e.key.toLowerCase();
if(k==='w')game.keys.w=true;
if(k==='a')game.keys.a=true;
if(k==='s')game.keys.s=true;
if(k==='d')game.keys.d=true;
if(k==='e' && game.running) checkInteract();
if(k==='escape') {closePanel();closeBuildPanel();closeAchievePanel();closeContractPanel();closeBattlePanel();}
});
document.addEventListener('keyup',e=>{
const k=e.key.toLowerCase();
if(k==='w')game.keys.w=false;
if(k==='a')game.keys.a=false;
if(k==='s')game.keys.s=false;
if(k==='d')game.keys.d=false;
});
// ========== 渲染循环 ==========
function loop(){
ctx.fillStyle="#222";ctx.fillRect(0,0,canvas.width,canvas.height);
if(game.running){
const p=game.player;
if(game.keys.w)p.y-=p.speed;
if(game.keys.s)p.y+=p.speed;
if(game.keys.a)p.x-=p.speed;
if(game.keys.d)p.x+=p.speed;
for(const st of game.stations){
ctx.fillStyle="#444";
ctx.fillRect(st.x,st.y,st.w,st.h);
ctx.fillStyle="#ddd";
ctx.font="11px sans-serif";
ctx.fillText(st.name,st.x,st.y-2);
}
ctx.fillStyle="#5ad";
ctx.fillRect(p.x,p.y,p.w,p.h);
ctx.fillStyle="#fff";
ctx.font="10px sans-serif";
ctx.fillText("工人",p.x,p.y-2);
}
requestAnimationFrame(loop);
}
loop();
updateHUD();
loadGlobal();
</script>
</body>
</html>
Game Source: 熔炉战线:二战锻造营【完整版】
Creator: ChromeOtter32
Libraries: none
Complexity: complex (589 lines, 24.0 KB)
The full source code is displayed above on this page.
Remix Instructions
To remix this game, copy the source code above and modify it. Add a ARCADELAB header at the top with "remix_of: game-chromeotter32" to link back to the original. Then publish at arcadelab.ai/publish.