Add the ability for lib.init.parsex to remove all comments before parsing.
This commit is contained in:
parent
f3b2cda7da
commit
07c9bc831b
|
@ -494,9 +494,9 @@ game.import('card',function(lib,game,ui,get,ai,_status){
|
|||
usable:1,
|
||||
content:function(){
|
||||
player.recast(cards,null,(player,cards)=>{
|
||||
const cardsToGain=[];
|
||||
var cardsToGain=[];
|
||||
for(let repetition=0;repetition<cards.length;repetition++){
|
||||
const card=get.cardPile(card=>get.type(card,'trick')=='trick');
|
||||
var card=get.cardPile(card=>get.type(card,'trick')=='trick');
|
||||
if(card) cardsToGain.push(card);
|
||||
}
|
||||
if(cardsToGain.length) player.gain(cardsToGain,'draw');
|
||||
|
|
|
@ -4059,18 +4059,10 @@ game.import('character',function(lib,game,ui,get,ai,_status){
|
|||
reyanyu2:{
|
||||
trigger:{player:'phaseUseEnd'},
|
||||
direct:true,
|
||||
filter:function(event,player){
|
||||
return player.getHistory('lose',function(evt){
|
||||
var evt2=evt.getParent();
|
||||
return evt2.name=='useSkill'&&evt2.skill=='reyanyu'&&evt.getParent(3)==event;
|
||||
}).length>0;
|
||||
},
|
||||
filter:(event,player)=>player.hasHistory('useSkill',evt=>evt.skill=='reyanyu'&&evt.event.getParent(2)==event),
|
||||
content:function(){
|
||||
'step 0'
|
||||
event.num=Math.min(3,player.getHistory('lose',function(evt){
|
||||
var evt2=evt.getParent();
|
||||
return evt2.name=='useSkill'&&evt2.skill=='reyanyu'&&evt.getParent(3)==trigger;
|
||||
}).length);
|
||||
event.num=Math.min(3,player.getHistory('useSkill',evt=>evt.skill=='reyanyu'&&evt.event.getParent(2)==trigger).length);
|
||||
player.chooseTarget(get.prompt('reyanyu'),'令一名男性角色摸'+get.cnNumber(event.num)+'张牌',function(card,player,target){
|
||||
return target.hasSex('male')&&target!=player;
|
||||
}).set('ai',function(target){
|
||||
|
|
|
@ -11190,7 +11190,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
|
|||
direct:true,
|
||||
filter:function(event,player){
|
||||
return player.getHistory('lose',function(evt){
|
||||
return evt.getParent(2).name=='twgezhi'&&evt.getParent('phaseUse')==event;
|
||||
return evt.getParent(3).name=='twgezhi'&&evt.getParent('phaseUse')==event;
|
||||
}).length>1;
|
||||
},
|
||||
content:function(){
|
||||
|
|
13
game/game.js
13
game/game.js
|
@ -9714,9 +9714,11 @@
|
|||
localStorage.removeItem(lib.configprefix+'background');
|
||||
}
|
||||
},
|
||||
//by 诗笺
|
||||
//by 诗笺、Tipx-L
|
||||
parsex:function(func){
|
||||
var str=func.toString();
|
||||
//Remove all comments
|
||||
//移除所有注释
|
||||
var str=func.toString().replace(/((?:(?:^[ \t]*)?(?:\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\/(?:[ \t]*\r?\n(?=[ \t]*(?:\r?\n|\/\*|\/\/)))?|\/\/(?:[^\\]|\\(?:\r?\n)?)*?(?:\r?\n(?=[ \t]*(?:\r?\n|\/\*|\/\/))|(?=\r?\n))))+)|("(?:\\[\S\s]|[^"\\])*"|'(?:\\[\S\s]|[^'\\])*'|(?:\r?\n|[\S\s])[^\/"'\\\s]*)/mg,'$2').trim();
|
||||
//获取第一个 { 后的所有字符
|
||||
str=str.slice(str.indexOf('{')+1);
|
||||
//func中要写步骤的话,必须要写step 0
|
||||
|
@ -9750,7 +9752,6 @@
|
|||
}
|
||||
str=`if(event.step==${k}){event.finish();return;}`+str;
|
||||
}
|
||||
str=`"use strict";\n${str}`;
|
||||
return (new Function('event','step','source','player','target','targets',
|
||||
'card','cards','skill','forced','num','trigger','result',
|
||||
'_status','lib','game','ui','get','ai',str));
|
||||
|
@ -29946,7 +29947,7 @@
|
|||
let numberOfCardsToDraw=cards.length;
|
||||
cards.forEach(value=>{
|
||||
if(lib.config.mode=='stone'&&_status.mode=='deck'&&!player.isMin()&&get.type(value).indexOf('stone')==0){
|
||||
const stonecard=get.stonecard(1,player.career);
|
||||
var stonecard=get.stonecard(1,player.career);
|
||||
numberOfCardsToDraw--;
|
||||
if(stonecard.length) player.gain(game.createCard(stonecard.randomGet()),'draw');
|
||||
else player.draw({
|
||||
|
@ -29954,13 +29955,13 @@
|
|||
}).log=false;
|
||||
}
|
||||
else if(get.subtype(value)=='spell_gold'){
|
||||
const libCard=get.libCard(info=>info.subtype=='spell_silver');
|
||||
var libCard=get.libCard(info=>info.subtype=='spell_silver');
|
||||
if(!libCard.length) return;
|
||||
numberOfCardsToDraw--;
|
||||
player.gain(game.createCard(libCard.randomGet()),'draw');
|
||||
}
|
||||
else if(get.subtype(value)=='spell_silver'){
|
||||
const libCard=get.libCard(info=>info.subtype=='spell_bronze');
|
||||
var libCard=get.libCard(info=>info.subtype=='spell_bronze');
|
||||
if(!libCard.length) return;
|
||||
numberOfCardsToDraw--;
|
||||
player.gain(game.createCard(libCard.randomGet()),'draw');
|
||||
|
|
Loading…
Reference in New Issue