feat: support origin debugger in new-style content.
This commit is contained in:
parent
c73e76af1f
commit
6afbb56165
20
game/game.js
20
game/game.js
|
@ -11183,10 +11183,11 @@
|
||||||
case "object":
|
case "object":
|
||||||
if(Array.isArray(item)){
|
if(Array.isArray(item)){
|
||||||
let lastEvent=null;
|
let lastEvent=null;
|
||||||
return (event,step,source,player,target,targets,card,cards,skill,forced,num,trigger,result,_status,lib,game,ui,get,ai)=>{
|
return function*(event,step,source,player,target,targets,card,cards,skill,forced,num,trigger,result,_status,lib,game,ui,get,ai){
|
||||||
if(step>=item.length) return event.finish();
|
if(step>=item.length) return event.finish();
|
||||||
var current=item[step];
|
var current=item[step];
|
||||||
lastEvent=current(event,{
|
if(typeof current!="function") throw new Error(`content ${step} of ${event.name} is not vaild: ${current}`);
|
||||||
|
var currentResult=current(event,{
|
||||||
event:event,
|
event:event,
|
||||||
step:step,
|
step:step,
|
||||||
source:source,
|
source:source,
|
||||||
|
@ -11201,11 +11202,14 @@
|
||||||
trigger:trigger,
|
trigger:trigger,
|
||||||
result:result
|
result:result
|
||||||
},(lastEvent&&("result" in lastEvent))?lastEvent.result:null);
|
},(lastEvent&&("result" in lastEvent))?lastEvent.result:null);
|
||||||
|
// TODO: use `event.debugger` to replace source
|
||||||
|
if(gnc.is.generator(currentResult)) lastEvent=yield* currentResult;
|
||||||
|
else lastEvent=currentResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(Symbol.iterator in item) return lib.init.parsex(Array.from(item));
|
if(Symbol.iterator in item) return lib.init.parsex(Array.from(item));
|
||||||
if("toString" in item) return lib.init.parsex(item.toString());
|
if(item.toString !== Object.prototype.toString) return lib.init.parsex(item.toString());
|
||||||
if("render" in item) {
|
if("render" in item) {
|
||||||
// TODO: Object Render Parse
|
// TODO: Object Render Parse
|
||||||
throw new Error("NYI: Object Render Parse");
|
throw new Error("NYI: Object Render Parse");
|
||||||
|
@ -11216,7 +11220,8 @@
|
||||||
case "function":
|
case "function":
|
||||||
if (gnc.is.generatorFunc(item)) {
|
if (gnc.is.generatorFunc(item)) {
|
||||||
let gen,lastEvent;
|
let gen,lastEvent;
|
||||||
return (event,step,source,player,target,targets,card,cards,skill,forced,num,trigger,result,_status,lib,game,ui,get,ai)=>{
|
return function*(event,step,source,player,target,targets,card,cards,skill,forced,num,trigger,result,_status,lib,game,ui,get,ai){
|
||||||
|
event.step=NaN;
|
||||||
if(!gen)gen=item(event,{
|
if(!gen)gen=item(event,{
|
||||||
event:event,
|
event:event,
|
||||||
step:step,
|
step:step,
|
||||||
|
@ -11234,7 +11239,12 @@
|
||||||
});
|
});
|
||||||
var res=gen.next((lastEvent&&("result" in lastEvent))?lastEvent.result:null);
|
var res=gen.next((lastEvent&&("result" in lastEvent))?lastEvent.result:null);
|
||||||
if(res.done) event.finish();
|
if(res.done) event.finish();
|
||||||
else lastEvent=res.value;
|
else {
|
||||||
|
var currentResult=res.value;
|
||||||
|
// TODO: use `event.debugger` to replace source
|
||||||
|
if(typeof currentResult=="function") yield currentResult;
|
||||||
|
else lastEvent=currentResult;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue