dsh-plugin-token-war 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/index.html +24 -10
- package/lib/client.js +13 -11
- package/lib/game.js +1 -1
- package/lib/ui.js +11 -9
- package/package.json +1 -1
package/lib/game.js
CHANGED
|
@@ -2,7 +2,7 @@ import {amount,fromLog,log,add,subtract,multiply,scale,divide,power,numeric,rati
|
|
|
2
2
|
import {TASKS,ROSTER,EVENTS} from './config.js';
|
|
3
3
|
|
|
4
4
|
export const SAVE_VERSION = 1;
|
|
5
|
-
export const GAME_VERSION = '0.4.
|
|
5
|
+
export const GAME_VERSION = '0.4.2';
|
|
6
6
|
export const MAX_OFFLINE_MS = 30 * 86400000;
|
|
7
7
|
const HP_GROWTH = 1.085;
|
|
8
8
|
const TRAIN_GROWTH = 1.15;
|
package/lib/ui.js
CHANGED
|
@@ -223,14 +223,16 @@ export function mountGame(root,{assetData={},hostNotice=null}={}) {
|
|
|
223
223
|
for(let x=-100;x<W+200;x+=90){ctx.beginPath();ctx.moveTo(W*.5+(x-W*.5)*.75,groundY+1);ctx.lineTo(x,H);ctx.stroke();}
|
|
224
224
|
const ev=currentEvent(s);
|
|
225
225
|
ctx.textAlign='left';ctx.textBaseline='alphabetic';
|
|
226
|
-
//
|
|
226
|
+
// 左侧:手机/窄屏最多 3 个角色,避免和敌人卡互相遮挡
|
|
227
227
|
const owned=ROSTER.enabledVendors.filter(v=>ROSTER.models.some(m=>m.vendor===v&&s.models.includes(m.id)));
|
|
228
|
-
const
|
|
228
|
+
const compactCanvas=W<520;
|
|
229
|
+
const visibleOwned=compactCanvas?owned.slice(0,3):owned;
|
|
230
|
+
const leftW=W*(compactCanvas?0.66:0.70);
|
|
229
231
|
const charH=Math.max(40,Math.min(H*0.64,groundY-14));
|
|
230
232
|
const scaleC=charH/192;
|
|
231
233
|
const slot=Math.max(56,Math.min(150,leftW/Math.max(1,owned.length)));
|
|
232
|
-
const x0=(leftW-slot*
|
|
233
|
-
|
|
234
|
+
const x0=(leftW-slot*visibleOwned.length)/2+slot/2;
|
|
235
|
+
visibleOwned.forEach((id,i)=>{
|
|
234
236
|
loadCharacter(id);
|
|
235
237
|
const character=CATALOG.characters.find(c=>c.id===id),image=images.get(id),x=x0+i*slot;
|
|
236
238
|
const t=(animationTime+i*550)%2800;
|
|
@@ -242,11 +244,11 @@ export function mountGame(root,{assetData={},hostNotice=null}={}) {
|
|
|
242
244
|
if(image)drawFrame(ctx,image,CATALOG,frame,x,groundY+1,scaleC);
|
|
243
245
|
else{ctx.fillStyle=VENDOR_COLORS[id];ctx.fillRect(x-charH*.18,groundY-charH*.7,charH*.36,charH*.7);}
|
|
244
246
|
ctx.save();ctx.shadowColor='#000000';ctx.shadowBlur=3;ctx.shadowOffsetY=1;
|
|
245
|
-
ctx.textAlign='center';ctx.font
|
|
247
|
+
ctx.textAlign='center';ctx.font=`700 ${compactCanvas?10:11}px 'PingFang SC','Heiti SC',system-ui,sans-serif`;ctx.fillStyle=VENDOR_TEXT[id]||VENDOR_COLORS[id];
|
|
246
248
|
ctx.fillText(fitText(VENDOR_LABELS[id],slot-4),x,groundY+14);
|
|
247
249
|
if(H>=112){
|
|
248
250
|
const latest=ROSTER.models.filter(m=>m.vendor===id&&s.models.includes(m.id)).at(-1);
|
|
249
|
-
ctx.globalAlpha=.86;ctx.font
|
|
251
|
+
ctx.globalAlpha=.86;ctx.font=`${compactCanvas?9:10}px 'PingFang SC','Heiti SC',system-ui,sans-serif`;ctx.fillStyle=VENDOR_TEXT[id]||VENDOR_COLORS[id];
|
|
250
252
|
ctx.fillText(fitText(latest?latest.name:'',slot-4),x,groundY+26);
|
|
251
253
|
ctx.globalAlpha=1;
|
|
252
254
|
}
|
|
@@ -258,7 +260,7 @@ export function mountGame(root,{assetData={},hostNotice=null}={}) {
|
|
|
258
260
|
}
|
|
259
261
|
});
|
|
260
262
|
// 右侧 26%:敌人 / TODO 任务卡
|
|
261
|
-
const cardW=Math.max(132,Math.round(W*0.26)),cardX=Math.round(W-cardW-12);
|
|
263
|
+
const cardW=Math.max(compactCanvas?96:132,Math.round(W*(compactCanvas?0.27:0.26))),cardX=Math.round(W-cardW-(compactCanvas?8:12));
|
|
262
264
|
const cardTop=Math.max(26,Math.round(H*0.16)),cardH=Math.max(38,groundY-cardTop-26);
|
|
263
265
|
const boss=s.stage%10===0;
|
|
264
266
|
ctx.save();ctx.shadowColor='#000000';ctx.shadowBlur=3;ctx.shadowOffsetY=1;
|
|
@@ -286,8 +288,8 @@ export function mountGame(root,{assetData={},hostNotice=null}={}) {
|
|
|
286
288
|
const labelY=barY+barH+4,labelH=17;
|
|
287
289
|
ctx.fillStyle='#17181D';ctx.fillRect(cardX,labelY,cardW,labelH);
|
|
288
290
|
ctx.strokeStyle='#E9E3D6';ctx.lineWidth=1;ctx.strokeRect(cardX+.5,labelY+.5,cardW-1,labelH-1);
|
|
289
|
-
ctx.textAlign='center';ctx.font
|
|
290
|
-
ctx.fillText(
|
|
291
|
+
ctx.textAlign='center';ctx.font=`600 ${compactCanvas?8:10}px 'PingFang SC','Heiti SC',system-ui,sans-serif`;ctx.fillStyle='#E9E3D6';
|
|
292
|
+
ctx.fillText(compactCanvas?`剩余 ${Math.round(hp*100)}% · ST ${s.stage}`:`剩余工作量 ${Math.round(hp*100)}% · STAGE ${s.stage}`,cardX+cardW/2,labelY+(compactCanvas?11:12));
|
|
291
293
|
lastRenderedStage=s.stage;
|
|
292
294
|
if(s.paused||!held){
|
|
293
295
|
ctx.fillStyle='#0E0F12E6';ctx.fillRect(0,0,W,H);
|