formatted code

This commit is contained in:
157 2023-12-21 08:55:27 +08:00
parent 0231dd8442
commit e9c6fb0ea1
1 changed files with 100 additions and 100 deletions

View File

@ -24394,72 +24394,72 @@ export class Library extends Uninstantable {
next._args = Array.from(arguments); next._args = Array.from(arguments);
return next; return next;
} }
chooseToCompare(target,check){ chooseToCompare(target, check) {
var next=game.createEvent('chooseToCompare'); var next = game.createEvent('chooseToCompare');
next.player=this; next.player = this;
if(Array.isArray(target)){ if (Array.isArray(target)) {
next.targets=target; next.targets = target;
if(check) next.ai=check; if (check) next.ai = check;
else next.ai=function(card){ else next.ai = function (card) {
if(typeof card=='string'&&lib.skill[card]){ if (typeof card == 'string' && lib.skill[card]) {
var ais=lib.skill[card].check||function(){return 0}; var ais = lib.skill[card].check || function () { return 0 };
return ais(); return ais();
} }
var addi=(get.value(card)>=8&&get.type(card)!='equip')?-3:0; var addi = (get.value(card) >= 8 && get.type(card) != 'equip') ? -3 : 0;
if(card.name=='du') addi-=3; if (card.name == 'du') addi -= 3;
var source=_status.event.source; var source = _status.event.source;
var player=_status.event.player; var player = _status.event.player;
var event=_status.event.getParent(); var event = _status.event.getParent();
var getn=function(card){ var getn = function (card) {
if(player.hasSkill('tianbian')&&get.suit(card)=='heart') return 13*(Boolean(event.small)?-1:1); if (player.hasSkill('tianbian') && get.suit(card) == 'heart') return 13 * (Boolean(event.small) ? -1 : 1);
return get.number(card)*(Boolean(event.small)?-1:1); return get.number(card) * (Boolean(event.small) ? -1 : 1);
} }
if(source&&source!=player){ if (source && source != player) {
if(get.attitude(player,source)>1){ if (get.attitude(player, source) > 1) {
if(Boolean(event.small)) return getn(card)-get.value(card)/3+addi; if (Boolean(event.small)) return getn(card) - get.value(card) / 3 + addi;
return -getn(card)-get.value(card)/3+addi; return -getn(card) - get.value(card) / 3 + addi;
} }
if(Boolean(event.small)) return -getn(card)-get.value(card)/5+addi; if (Boolean(event.small)) return -getn(card) - get.value(card) / 5 + addi;
return getn(card)-get.value(card)/5+addi; return getn(card) - get.value(card) / 5 + addi;
} }
else{ else {
if(Boolean(event.small)) return -getn(card)-get.value(card)/5+addi; if (Boolean(event.small)) return -getn(card) - get.value(card) / 5 + addi;
return getn(card)-get.value(card)/5+addi; return getn(card) - get.value(card) / 5 + addi;
} }
} }
next.setContent('chooseToCompareMultiple'); next.setContent('chooseToCompareMultiple');
} }
else{ else {
next.target=target; next.target = target;
if(check) next.ai=check; if (check) next.ai = check;
else next.ai=function(card){ else next.ai = function (card) {
if(typeof card=='string'&&lib.skill[card]){ if (typeof card == 'string' && lib.skill[card]) {
var ais=lib.skill[card].check||function(){return 0}; var ais = lib.skill[card].check || function () { return 0 };
return ais(); return ais();
} }
var player=get.owner(card); var player = get.owner(card);
var getn=function(card){ var getn = function (card) {
if(player.hasSkill('tianbian')&&get.suit(card)=='heart') return 13; if (player.hasSkill('tianbian') && get.suit(card) == 'heart') return 13;
return get.number(card); return get.number(card);
} }
var event=_status.event.getParent(); var event = _status.event.getParent();
var to=(player==event.player?event.target:event.player); var to = (player == event.player ? event.target : event.player);
var addi=(get.value(card)>=8&&get.type(card)!='equip')?-6:0; var addi = (get.value(card) >= 8 && get.type(card) != 'equip') ? -6 : 0;
var friend=get.attitude(player,to)>0; var friend = get.attitude(player, to) > 0;
if(card.name=='du') addi-=5; if (card.name == 'du') addi -= 5;
if(player==event.player){ if (player == event.player) {
if(Boolean(event.small)) return -getn(card)-get.value(card)/(friend?4:5)+addi; if (Boolean(event.small)) return -getn(card) - get.value(card) / (friend ? 4 : 5) + addi;
return getn(card)-get.value(card)/(friend?4:5)+addi; return getn(card) - get.value(card) / (friend ? 4 : 5) + addi;
} }
else{ else {
if(friend==Boolean(event.small)) return getn(card)-get.value(card)/(friend?3:5)+addi; if (friend == Boolean(event.small)) return getn(card) - get.value(card) / (friend ? 3 : 5) + addi;
return -getn(card)-get.value(card)/(friend?3:5)+addi; return -getn(card) - get.value(card) / (friend ? 3 : 5) + addi;
} }
} }
next.setContent('chooseToCompare'); next.setContent('chooseToCompare');
} }
next.forceDie=true; next.forceDie = true;
next._args=Array.from(arguments); next._args = Array.from(arguments);
return next; return next;
} }
chooseSkill(target) { chooseSkill(target) {
@ -28793,81 +28793,81 @@ export class Library extends Uninstantable {
if (this.hasSkillTag('respondShan', true, null, true)) return true; if (this.hasSkillTag('respondShan', true, null, true)) return true;
return this.hasUsableCard('shan'); return this.hasUsableCard('shan');
} }
mayHaveSha(viewer,type,ignore,rvt){ mayHaveSha(viewer, type, ignore, rvt) {
//rvt: return value type 'count', 'odds', 'bool'(default) //rvt: return value type 'count', 'odds', 'bool'(default)
let count=0; let count = 0;
if((this.hp>2||!this.isZhu&&this.hp>1)&&this.hasSkillTag('respondSha',true,type,true)){ if ((this.hp > 2 || !this.isZhu && this.hp > 1) && this.hasSkillTag('respondSha', true, type, true)) {
if(rvt==='count') count++; if (rvt === 'count') count++;
else return true; else return true;
} }
if(get.itemtype(viewer)!=='player') viewer=_status.event.player; if (get.itemtype(viewer) !== 'player') viewer = _status.event.player;
let cards,selected=get.copy(ui.selected.cards); let cards, selected = get.copy(ui.selected.cards);
if(get.itemtype(ignore)==='cards') selected.addArray(ignore); if (get.itemtype(ignore) === 'cards') selected.addArray(ignore);
else if(get.itemtype(ignore)==='card') selected.add(ignore); else if (get.itemtype(ignore) === 'card') selected.add(ignore);
if(this === viewer || get.itemtype(viewer) == 'player') cards = this.getKnownCards(viewer); if (this === viewer || get.itemtype(viewer) == 'player') cards = this.getKnownCards(viewer);
else cards = this.getShownCards(); else cards = this.getShownCards();
count+=cards.filter(card=>{ count += cards.filter(card => {
if(selected.includes(card)) return false; if (selected.includes(card)) return false;
let name=get.name(card,this); let name = get.name(card, this);
if(name=='sha'||name=='hufu'||name=='yuchanqian'){ if (name == 'sha' || name == 'hufu' || name == 'yuchanqian') {
if(type==='use') return lib.filter.cardEnabled(card,this); if (type === 'use') return lib.filter.cardEnabled(card, this);
if(type==='respond') return lib.filter.cardRespondable(card,this); if (type === 'respond') return lib.filter.cardRespondable(card, this);
return true; return true;
} }
return false; return false;
}).length; }).length;
if(count&&rvt!=='count') return true; if (count && rvt !== 'count') return true;
let hs=this.getCards('hs').filter(i=>!cards.includes(i)&&!selected.includes(i)).length; let hs = this.getCards('hs').filter(i => !cards.includes(i) && !selected.includes(i)).length;
if(!hs){ if (!hs) {
if(rvt==='count') return count; if (rvt === 'count') return count;
return false; return false;
} }
if(rvt==='count'){ if (rvt === 'count') {
if(this.isPhaseUsing()) return count+hs/4; if (this.isPhaseUsing()) return count + hs / 4;
return count+hs/4.8; return count + hs / 4.8;
} }
if(this.isPhaseUsing()) count+=Math.pow(2+hs,2)/40; if (this.isPhaseUsing()) count += Math.pow(2 + hs, 2) / 40;
else count+=-1.5*Math.log(1-hs/10); else count += -1.5 * Math.log(1 - hs / 10);
if(rvt==='odds') return Math.min(1,count); if (rvt === 'odds') return Math.min(1, count);
return count>_status.event.getRand('mayHaveSha'+hs+this.playerid); return count > _status.event.getRand('mayHaveSha' + hs + this.playerid);
} }
mayHaveShan(viewer,type,ignore,rvt){ mayHaveShan(viewer, type, ignore, rvt) {
//rvt: return value type 'count', 'odds', 'bool'(default) //rvt: return value type 'count', 'odds', 'bool'(default)
let count=0; let count = 0;
if((this.hp>2||!this.isZhu&&this.hp>1)&&this.hasSkillTag('respondShan',true,type,true)){ if ((this.hp > 2 || !this.isZhu && this.hp > 1) && this.hasSkillTag('respondShan', true, type, true)) {
if(rvt==='count') count++; if (rvt === 'count') count++;
else return true; else return true;
} }
if(get.itemtype(viewer)!=='player') viewer=_status.event.player; if (get.itemtype(viewer) !== 'player') viewer = _status.event.player;
let cards,selected=get.copy(ui.selected.cards); let cards, selected = get.copy(ui.selected.cards);
if(get.itemtype(ignore)==='cards') selected.addArray(ignore); if (get.itemtype(ignore) === 'cards') selected.addArray(ignore);
else if(get.itemtype(ignore)==='card') selected.add(ignore); else if (get.itemtype(ignore) === 'card') selected.add(ignore);
if(this === viewer || get.itemtype(viewer) == 'player') cards = this.getKnownCards(viewer); if (this === viewer || get.itemtype(viewer) == 'player') cards = this.getKnownCards(viewer);
else cards = this.getShownCards(); else cards = this.getShownCards();
count+=cards.filter(card=>{ count += cards.filter(card => {
if(selected.includes(card)) return false; if (selected.includes(card)) return false;
let name=get.name(card,this); let name = get.name(card, this);
if(name==='shan'||name==='hufu'){ if (name === 'shan' || name === 'hufu') {
if(type==='use') return lib.filter.cardEnabled(card,this,'forceEnable'); if (type === 'use') return lib.filter.cardEnabled(card, this, 'forceEnable');
if(type==='respond') return lib.filter.cardRespondable(card,this); if (type === 'respond') return lib.filter.cardRespondable(card, this);
return true; return true;
} }
return false; return false;
}).length; }).length;
if(count&&rvt!=='count') return true; if (count && rvt !== 'count') return true;
let hs=this.getCards('hs').filter(i=>!cards.includes(i)&&!selected.includes(i)).length; let hs = this.getCards('hs').filter(i => !cards.includes(i) && !selected.includes(i)).length;
if(!hs){ if (!hs) {
if(rvt==='count') return count; if (rvt === 'count') return count;
return false; return false;
} }
if(rvt==='count'){ if (rvt === 'count') {
if(this.isPhaseUsing()) return count+hs/6; if (this.isPhaseUsing()) return count + hs / 6;
return count+hs/3.5; return count + hs / 3.5;
} }
if(this.isPhaseUsing()) count+=-1.5*Math.log(1-hs/10); if (this.isPhaseUsing()) count += -1.5 * Math.log(1 - hs / 10);
else count+=2*hs/(5+hs); else count += 2 * hs / (5 + hs);
if(rvt==='odds') return Math.min(1,count); if (rvt === 'odds') return Math.min(1, count);
return count>_status.event.getRand('mayHaveShan'+hs+this.playerid); return count > _status.event.getRand('mayHaveShan' + hs + this.playerid);
} }
hasCard(name, position) { hasCard(name, position) {
if (typeof name == 'function') { if (typeof name == 'function') {