Merge pull request #596 from Tipx-L/PR-Branch

More about handlers.
This commit is contained in:
Spmario233 2023-10-28 21:43:45 +08:00 committed by GitHub
commit 199cb93bbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 36 additions and 26 deletions

View File

@ -622,8 +622,8 @@
['tao',3]
]),
effect:new Map([
['sha',event=>{
if(event.step!=1) return;
['sha',(event,option)=>{
if(event.step!=0||option.state!='end') return;
game.log(event.player,'触发了强化效果');
game.log(event.card,'抵消所需要的',new lib.element.VCard({
name:'shan'
@ -636,8 +636,8 @@
else map[id].shanRequired=2;
});
}],
['shan',event=>{
if(event.step!=1) return;
['shan',(event,option)=>{
if(event.step!=0||option.state!='end') return;
game.log(event.player,'触发了强化效果');
game.log('使用',event.card,'时视为两张',new lib.element.VCard({
name:'shan'
@ -646,8 +646,8 @@
trigger.getParent(2).decrease('shanRequired',1);
});
}],
['juedou',event=>{
if(event.step!=1) return;
['juedou',(event,option)=>{
if(event.step!=0||option.state!='end') return;
game.log(event.player,'触发了强化效果');
game.log('对',event.card,'的目标造成伤害时,伤害+1');
event.player.when({
@ -656,14 +656,14 @@
trigger.increase('num');
});
}],
['huogong',event=>{
if(event.step!=1) return;
['huogong',(event,option)=>{
if(event.step!=0||option.state!='end') return;
game.log(event.player,'触发了强化效果');
game.log(event.card,'造成的伤害+1');
event.increase('baseDamage',1);
}],
['tao',event=>{
if(event.step!=1) return;
['tao',(event,option)=>{
if(event.step!=0||option.state!='end') return;
game.log(event.player,'触发了强化效果');
game.log(event.card,'回复的体力+1');
event.increase('baseDamage',1);
@ -30988,17 +30988,17 @@
return this;
}
/**
* @param {Parameters<typeof this.hasHandler>[0]} [type]
* @param {GameEvent} [event]
* @param {Parameters<typeof this.hasHandler>[0]} type
* @param {GameEvent} event
* @param {{
* state?: 'begin' | 'end';
* }} option
* @returns {this}
*/
callHandler(type,event){
if(this.hasHandler(type)){
if(!event) event=this;
this.getHandler(type).forEach(handler=>{
if(typeof handler=='function') handler(event);
});
}
callHandler(type,event,option){
if(this.hasHandler(type)) this.getHandler(type).forEach(handler=>{
if(typeof handler=='function') handler(event,option);
});
return this;
}
getDefaultHandlerType(){
@ -31007,7 +31007,9 @@
}
/**
* @param {Parameters<typeof this.hasHandler>[0]} [type]
* @returns {((event: GameEvent) => void)[]}
* @returns {((event: GameEvent, option: {
* state?: 'begin' | 'end';
* }) => void)[]}
*/
getHandler(type){
if(!type) type=this.getDefaultHandlerType();
@ -31025,13 +31027,17 @@
}
/**
* @overload
* @param {...((event: GameEvent) => void)[]} handlers
* @param {...((event: GameEvent, option: {
* state?: 'begin' | 'end';
* }) => void)[]} handlers
* @returns {number}
*/
/**
* @overload
* @param {Parameters<typeof this.hasHandler>[0]} type
* @param {...((event: GameEvent) => void)[]} handlers
* @param {...((event: GameEvent, option: {
* state?: 'begin' | 'end';
* }) => void)[]} handlers
* @returns {number}
*/
pushHandler(type){
@ -33109,8 +33115,8 @@
player.changeFury(-stratagemBuff.cost.get(cardName),true);
const gameEvent=get.event(),effect=stratagemBuff.effect.get(cardName);
if(typeof effect=='function') gameEvent.pushHandler('onNextUseCard',effect);
gameEvent.pushHandler('onNextUseCard',event=>{
if(event.step==1) game.broadcastAll(cards=>cards.forEach(card=>card.clone.classList.add('stratagem-fury-glow')),event.cards);
gameEvent.pushHandler('onNextUseCard',(event,option)=>{
if(event.step==0&&option.state=='end') game.broadcastAll(cards=>cards.forEach(card=>card.clone.classList.add('stratagem-fury-glow')),event.cards);
});
},
ai:{
@ -40913,7 +40919,9 @@
}*/
}
else{
event.callHandler();
event.callHandler(event.getDefaultHandlerType(),event,{
state:'begin'
});
if(player&&player.classList.contains('dead')&&!event.forceDie&&event.name!='phaseLoop'){
game.broadcastAll(function(){
while(_status.dieClose.length){
@ -41008,8 +41016,10 @@
}
}
event.clearStepCache();
event.callHandler(event.getDefaultHandlerType(),event,{
state:'end'
});
event.step++;
if(event.finished) event.callHandler();
}
}
}