给根节点的event添加事件方法

This commit is contained in:
Spmario233 2023-10-05 13:47:48 +08:00
parent f175e0a7b7
commit b9b038a589
4 changed files with 24 additions and 14 deletions

View File

@ -1569,10 +1569,16 @@ game.import('character',function(lib,game,ui,get,ai,_status){
var list=[],names=[]; var list=[],names=[];
for(var card of cards){ for(var card of cards){
var name=get.name(card),nature=get.nature(card); var name=get.name(card),nature=get.nature(card);
var namex=name+nature; var namex=name;
if(names.contains(namex)) continue; if(nature&&nature.length){
if(nature.length) list.push([get.type(card),'',name,nature]); namex+=nature;
else list.push([get.type(card),'',name]); if(names.contains(namex)) continue;
list.push([get.type(card),'',name,nature]);
}
else{
if(names.contains(namex)) continue;
list.push([get.type(card),'',name]);
}
names.push(namex); names.push(namex);
} }
list.sort((a,b)=>{ list.sort((a,b)=>{

View File

@ -1188,7 +1188,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
'step 0' 'step 0'
player.chooseTarget('覆天:弃置一名角色的一张手牌',function(card,player,target){ player.chooseTarget('覆天:弃置一名角色的一张手牌',function(card,player,target){
return target!=player&&target.countCards('h'); return target!=player&&target.countCards('h');
}).set('ai',function(target){ },true).set('ai',function(target){
if(target.hasSkillTag('noh')) return 0; if(target.hasSkillTag('noh')) return 0;
return -get.attitude(player,target)/Math.sqrt(target.countCards('h')); return -get.attitude(player,target)/Math.sqrt(target.countCards('h'));
}); });

View File

@ -349,7 +349,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
var player=_status.event.player; var player=_status.event.player;
if(!game.hasPlayer(target=>target!=player&&get.damageEffect(target,player,player,'thunder')>0)) return 0; if(!game.hasPlayer(target=>target!=player&&get.damageEffect(target,player,player,'thunder')>0)) return 0;
if(player.getExpansions('rejijun').reduce(function(num,card){ if(player.getExpansions('rejijun').reduce(function(num,card){
return num=card.number; return num+get.number(card,false);
},0)>36) return 1/(get.value(card)||0.5); },0)>36) return 1/(get.value(card)||0.5);
else{ else{
if(lib.skill.refangtong.thunderEffect(card,player)) return 10-get.value(card); if(lib.skill.refangtong.thunderEffect(card,player)) return 10-get.value(card);
@ -367,17 +367,17 @@ game.import('character',function(lib,game,ui,get,ai,_status){
var player=_status.event.player; var player=_status.event.player;
var cards=player.getExpansions('rejijun'); var cards=player.getExpansions('rejijun');
if(cards.reduce(function(num,card){ if(cards.reduce(function(num,card){
return num=card.number; return num+get.number(card,false);
},0)<=36){ },0)<=36){
if(!ui.selected.buttons.length) return 1/button.link.number; if(!ui.selected.buttons.length) return 1/get.number(button.link,false);
return 0; return 0;
} }
else{ else{
var num=0,list=[]; var num=0,list=[];
cards.sort((a,b)=>b.number-a.number); cards.sort((a,b)=>get.number(b,false)-get.number(a,false));
for(var i=0;i<cards.length;i++){ for(var i=0;i<cards.length;i++){
list.push(cards[i]); list.push(cards[i]);
num+=cards[i].number; num+=get.number(cards[i],false)
if(num>36) break; if(num>36) break;
} }
return list.contains(button.link)?1:0; return list.contains(button.link)?1:0;
@ -386,7 +386,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
'step 3' 'step 3'
if(result.bool){ if(result.bool){
var bool=(result.links.reduce(function(num,card){ var bool=(result.links.reduce(function(num,card){
return num=card.number; return num+get.number(card,false);
},0)>36); },0)>36);
event.bool=bool; event.bool=bool;
player.loseToDiscardpile(result.links); player.loseToDiscardpile(result.links);
@ -404,13 +404,13 @@ game.import('character',function(lib,game,ui,get,ai,_status){
var cards=player.getExpansions('rejijun'),num=0; var cards=player.getExpansions('rejijun'),num=0;
cards.push(card); cards.push(card);
if(cards.reduce(function(num,card){ if(cards.reduce(function(num,card){
return num=card.number; return num+get.number(card,false);
},0)<=36) return false; },0)<=36) return false;
cards.sort((a,b)=>b.number-a.number); cards.sort((a,b)=>get.number(b,false)-get.number(a,false));
var bool=false; var bool=false;
for(var i=0;i<cards.length;i++){ for(var i=0;i<cards.length;i++){
if(cards[i]==card) bool=true; if(cards[i]==card) bool=true;
num+=cards[i].number; num+=get.number(cards[i],false);
if(num>36) break; if(num>36) break;
} }
return bool; return bool;
@ -440,6 +440,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
'step 0' 'step 0'
var target=trigger.player; var target=trigger.player;
event.player=player; event.player=player;
event.target=target;
target.chooseBool(target==player?get.prompt('rejunbing'):'是否响应'+get.translation(player)+'的【郡兵】?','摸一张牌'+(target==player?'':',将所有手牌交给'+get.translation(player)+',然后其可以交给你等量张牌')).set('choice',get.attitude(target,player)>0); target.chooseBool(target==player?get.prompt('rejunbing'):'是否响应'+get.translation(player)+'的【郡兵】?','摸一张牌'+(target==player?'':',将所有手牌交给'+get.translation(player)+',然后其可以交给你等量张牌')).set('choice',get.attitude(target,player)>0);
'step 1' 'step 1'
if(result.bool){ if(result.bool){

View File

@ -8079,6 +8079,9 @@
lib.ui=ui; lib.ui=ui;
lib.ai=ai; lib.ai=ai;
lib.game=game; lib.game=game;
for(let i in lib.element.event){
_status.event[i]=lib.element.event[i];
}
HTMLDivElement.prototype.animate=function(name,time){ HTMLDivElement.prototype.animate=function(name,time){
var that; var that;