mirror of
https://github.com/Shu-Ying/noname-shuying.git
synced 2026-10-24 08:39:58 +08:00
fixed # 补全部分卡牌
fixed # 修复部分已知BUG
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { LiuBeiCardPack } from "./liubei/index.js";
|
||||
import { ColorlessCardPack } from "./colorless/index.js";
|
||||
|
||||
// 后续角色各有目录和牌组类,仅在此登记,不扩张 mode-cards.js。
|
||||
const packTypes = Object.freeze([LiuBeiCardPack,ColorlessCardPack]);
|
||||
export function createCardPackRuntime(context) {
|
||||
const result={cards:{},translate:{},skills:{},names:[]}, runtimes=[];
|
||||
for(const Pack of packTypes){
|
||||
const runtime=new Pack(context).createRuntime();runtimes.push(runtime);
|
||||
for(const key of ["cards","skills"]){
|
||||
for(const name of Object.keys(runtime[key] || {}))if(Object.hasOwn(result[key],name))throw new Error(`重复的牌组定义:${Pack.id}/${name}`);
|
||||
Object.assign(result[key],runtime[key]);
|
||||
}
|
||||
Object.assign(result.translate,runtime.translate);result.names.push(...runtime.names);
|
||||
}
|
||||
result.vulnerableBonus=(source,target)=>runtimes.reduce((sum,r)=>sum+(r.vulnerableBonus?.(source,target)||0),0);
|
||||
result.onDeath=async event=>{for(const runtime of runtimes)await runtime.onDeath?.(event);};
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user