Fix `ui.click.ok` and eliminate all shorthand name usages of object initializing.

This commit is contained in:
Tipx-L 2023-10-25 07:00:49 -07:00
parent 49a0439a34
commit 00072acb39
1 changed files with 27 additions and 25 deletions

View File

@ -5742,7 +5742,7 @@
name:'游戏人数', name:'游戏人数',
init:'8', init:'8',
get item(){ get item(){
const minimumNumberOfPlayers=3,maximumNumberOfPlayers=Math.max(_status.maximumNumberOfPlayers||10,minimumNumberOfPlayers),item={}; const minimumNumberOfPlayers=2,maximumNumberOfPlayers=Math.max(_status.maximumNumberOfPlayers||12,minimumNumberOfPlayers),item={};
for(let playerNumber=minimumNumberOfPlayers;playerNumber<=maximumNumberOfPlayers;playerNumber++){ for(let playerNumber=minimumNumberOfPlayers;playerNumber<=maximumNumberOfPlayers;playerNumber++){
item[playerNumber]=`${get.cnNumber(playerNumber)}`; item[playerNumber]=`${get.cnNumber(playerNumber)}`;
} }
@ -23172,6 +23172,11 @@
} }
return list; return list;
} }
/**
* @param {string} [arg1='h']
* @param {string | Record<string, any> | (card: Card) => boolean} [arg2]
* @returns {Card[]}
*/
getCards(arg1,arg2){ getCards(arg1,arg2){
if(typeof arg1!='string'){ if(typeof arg1!='string'){
arg1='h'; arg1='h';
@ -30585,7 +30590,7 @@
else Object.defineProperty(this,key,propertyDescriptor); else Object.defineProperty(this,key,propertyDescriptor);
}); });
if(Array.isArray(numberOrCards)){ if(Array.isArray(numberOrCards)){
const noCards=!('cards' in this); const noCards=!this.cards;
/** /**
* @type {Card[]} * @type {Card[]}
*/ */
@ -30593,8 +30598,8 @@
if(noCards){ if(noCards){
if(!lib.suits.includes(this.suit)) this.suit=get.suit(this); if(!lib.suits.includes(this.suit)) this.suit=get.suit(this);
if(!Object.keys(lib.color).includes(this.color)) this.color=get.color(this); if(!Object.keys(lib.color).includes(this.color)) this.color=get.color(this);
if(!('number' in this)) this.number=get.number(this); if(typeof this.number!='number') this.number=get.number(this);
if(!('nature' in this)) this.nature=get.nature(this); if(!this.nature) this.nature=get.nature(this);
} }
} }
const info=get.info(this,false); const info=get.info(this,false);
@ -30607,9 +30612,8 @@
if(typeof numberOrCards=='number') this.number=numberOrCards; if(typeof numberOrCards=='number') this.number=numberOrCards;
if(typeof name=='string') this.name=name; if(typeof name=='string') this.name=name;
if(typeof nature=='string') this.nature=nature; if(typeof nature=='string') this.nature=nature;
if('suit' in this&&!('color' in this)) this.color=get.color(this); if(!this.storage) this.storage={};
if(!('storage' in this)) this.storage={}; if(!this.cards) this.cards=[];
if(!('cards' in this)) this.cards=[];
} }
sameSuitAs(card){ sameSuitAs(card){
return get.suit(this)==get.suit(card); return get.suit(this)==get.suit(card);
@ -31537,7 +31541,6 @@
return this; return this;
} }
/** /**
* @throws {'Do not call this method'}
* @returns {never} * @returns {never}
*/ */
typeAnnotation(){ typeAnnotation(){
@ -31613,7 +31616,7 @@
* @type {boolean} * @type {boolean}
*/ */
this.unreal; this.unreal;
throw 'Do not call this method'; throw new Error('Do not call this method');
} }
}, },
Dialog:class extends HTMLDivElement{ Dialog:class extends HTMLDivElement{
@ -32899,7 +32902,7 @@
}, },
directHit_ai:true, directHit_ai:true,
skillTagFilter:(player,tag,arg)=>{ skillTagFilter:(player,tag,arg)=>{
const card=arg.card; const card=get.autoViewAs(arg.card);
if(card.name!='sha'||!card.storage.stratagem_buffed) return false; if(card.name!='sha'||!card.storage.stratagem_buffed) return false;
const target=arg.target; const target=arg.target;
if(target.countCards('h','shan')>=1&&!target.storage.stratagem_fury) return false; if(target.countCards('h','shan')>=1&&!target.storage.stratagem_fury) return false;
@ -56121,22 +56124,21 @@
const skillInformation=get.info(gameEvent.skill),viewAs=skillInformation.viewAs; const skillInformation=get.info(gameEvent.skill),viewAs=skillInformation.viewAs;
if(typeof viewAs=='function'){ if(typeof viewAs=='function'){
const viewedAs=viewAs(result.cards,gameEvent.player); const viewedAs=viewAs(result.cards,gameEvent.player);
if(viewedAs){ if(viewedAs) result.card=get.autoViewAs(viewedAs);
viewedAs.cards=result.cards; }
result.card=get.autoViewAs(viewedAs); else if(viewAs) result.card=get.autoViewAs(viewAs);
const resultCard=result.card;
if(resultCard){
const cards=result.cards;
if(cards.length==1){
const firstCard=cards[0];
if(!resultCard.suit) resultCard.suit=get.suit(firstCard);
if(!resultCard.number) resultCard.number=get.number(firstCard);
} }
} }
else if(viewAs){ const skillDialog=gameEvent.skillDialog;
viewAs.cards=result.cards; if(skillDialog&&get.objtype(skillDialog)=='div') skillDialog.close();
result.card=get.autoViewAs(viewAs); gameEvent.player.getCards('hej').forEach(card=>card.recheck('useSkill'));
}
if(gameEvent.skillDialog&&get.objtype(gameEvent.skillDialog)=='div'){
gameEvent.skillDialog.close();
}
var cards=gameEvent.player.getCards('hej');
for(var i=0;i<cards.length;i++){
cards[i].recheck('useSkill');
}
gameEvent.restore(); gameEvent.restore();
} }
else if(['chooseToUse','chooseToRespond'].includes(gameEvent.name)) result.card=get.autoViewAs(result.cards[0]); else if(['chooseToUse','chooseToRespond'].includes(gameEvent.name)) result.card=get.autoViewAs(result.cards[0]);
@ -62616,7 +62618,7 @@
} }
} }
}, },
get get:get
}; };
/** /**
* @template T * @template T