bugfix; 起许劭移除门客出错bugfix; ol华歆的排序调用出错bugfix

This commit is contained in:
IceCola 2024-05-11 20:30:38 +08:00
parent 6ac598d617
commit a7a0ba361f
4 changed files with 124 additions and 115 deletions

View File

@ -6101,7 +6101,7 @@ const skills = {
player.removeInvisibleSkill(skills); player.removeInvisibleSkill(skills);
}, },
onremove: function (player, skill) { onremove: function (player, skill) {
lib.skill.sbyingmen.removeVisitors(player.getSkills("sbyingmen"), player); lib.skill.sbyingmen.removeVisitors(player.getStorage("sbyingmen"), player);
player.removeSkillBlocker("sbyingmen"); player.removeSkillBlocker("sbyingmen");
}, },
skillBlocker: function (skill, player) { skillBlocker: function (skill, player) {

View File

@ -77,7 +77,7 @@ const skills = {
lose: false, lose: false,
delay: false, delay: false,
async precontent(event, trigger, player) { async precontent(event, trigger, player) {
var result = event.result; const result = event.result;
if (result.targets.length > 0) result.card = get.autoViewAs({ name: "tiesuo" }, result.cards); if (result.targets.length > 0) result.card = get.autoViewAs({ name: "tiesuo" }, result.cards);
}, },
async content(event, trigger, player) { async content(event, trigger, player) {
@ -104,8 +104,8 @@ const skills = {
if (player.hasSkill("dcwanglie2", null, null, false)) return true; if (player.hasSkill("dcwanglie2", null, null, false)) return true;
if (["wuzhong", "kaihua", "dongzhuxianji"].includes(event.card.name)) return false; if (["wuzhong", "kaihua", "dongzhuxianji"].includes(event.card.name)) return false;
player._wanglie_temp = true; player._wanglie_temp = true;
var eff = 0; let eff = 0;
for (var i of event.targets) { for (const i of event.targets) {
eff += get.effect(i, event.card, player, player); eff += get.effect(i, event.card, player, player);
} }
delete player._wanglie_temp; delete player._wanglie_temp;
@ -167,13 +167,13 @@ const skills = {
//if(tag=='pretao') return true; //if(tag=='pretao') return true;
if (player._wanglie_temp) return false; if (player._wanglie_temp) return false;
player._wanglie_temp = true; player._wanglie_temp = true;
var bool = (function () { const bool = (function () {
if (["wuzhong", "kaihua", "dongzhuxianji"].includes(arg.card.name)) return false; if (["wuzhong", "kaihua", "dongzhuxianji"].includes(arg.card.name)) return false;
if (get.attitude(player, arg.target) > 0 || !player.isPhaseUsing()) return false; if (get.attitude(player, arg.target) > 0 || !player.isPhaseUsing()) return false;
var cards = player.getCards("h", function (card) { let cards = player.getCards("h", function (card) {
return card != arg.card && (!arg.card.cards || !arg.card.cards.includes(card)); return card != arg.card && (!arg.card.cards || !arg.card.cards.includes(card));
}); });
var sha = player.getCardUsable("sha"); let sha = player.getCardUsable("sha");
if (arg.card.name == "sha") sha--; if (arg.card.name == "sha") sha--;
cards = cards.filter(function (card) { cards = cards.filter(function (card) {
if (card.name == "sha" && sha <= 0) return false; if (card.name == "sha" && sha <= 0) return false;
@ -216,18 +216,20 @@ const skills = {
}, },
usable: 1, usable: 1,
async cost(event, trigger, player) { async cost(event, trigger, player) {
event.result = await player.chooseTarget(get.prompt("olliangyin"), "选择一名其他角色,你与其各摸一张牌", lib.filter.notMe).set("ai", function (target) { event.result = await player
var player = _status.event.player, .chooseTarget(get.prompt("olliangyin"), "选择一名其他角色,你与其各摸一张牌", lib.filter.notMe)
num = player.getExpansions("olkongsheng").length - 1; .set("ai", function (target) {
var att = get.attitude(player, target); const player = _status.event.player,
if (att <= 0) return 0; num = player.getExpansions("olkongsheng").length - 1;
if (target.countCards("h") == num && target.isDamaged() && get.recoverEffect(target, player, player) > 0) return 3 * att; const att = get.attitude(player, target);
return att; if (att <= 0) return 0;
}); if (target.countCards("h") == num && target.isDamaged() && get.recoverEffect(target, player, player) > 0) return 3 * att;
return att;
})
.forResult();
}, },
async content(event, trigger, player) { async content(event, trigger, player) {
const { targets } = event.result; const target = event.targets[0];
const target = targets[0];
player.logSkill("olliangyin", target); player.logSkill("olliangyin", target);
await game.asyncDraw([player, target].sortBySeat()); await game.asyncDraw([player, target].sortBySeat());
await game.asyncDelayx(); await game.asyncDelayx();
@ -251,9 +253,9 @@ const skills = {
.set("choiceList", choiceList) .set("choiceList", choiceList)
.set("prompt", "良姻:是否令一名角色回复体力?") .set("prompt", "良姻:是否令一名角色回复体力?")
.set("ai", function () { .set("ai", function () {
var player = _status.event.player, const player = _status.event.player,
target = _status.event.getParent().target; target = _status.event.getParent().target;
var list = _status.event.controls.slice(0), let list = _status.event.controls.slice(0),
eff1 = 0, eff1 = 0,
eff2 = 0; eff2 = 0;
if (list.includes("选项一")) eff1 = get.recoverEffect(player, player, player); if (list.includes("选项一")) eff1 = get.recoverEffect(player, player, player);
@ -275,61 +277,62 @@ const skills = {
}, },
filter(event, player) { filter(event, player) {
return game.hasPlayer(function (current) { return game.hasPlayer(function (current) {
var evt = event.getl(current); const evt = event.getl(current);
return evt && (evt.xs.length > 0 || evt.ss.length > 0); return evt && (evt.xs.length > 0 || evt.ss.length > 0);
}); });
}, },
usable: 1, usable: 1,
async cost(event, trigger, player) { async cost(event, trigger, player) {
if (!player.countCards("he") || !game.hasPlayer(current => current != player && current.countCards("he") > 0)) return; if (!player.countCards("he") || !game.hasPlayer(current => current != player && current.countCards("he") > 0)) return;
event.result = await player.chooseCardTarget({ event.result = await player
prompt: get.prompt("olliangyin"), .chooseCardTarget({
prompt2: "弃置一张牌,并令一名其他角色也弃置一张牌", prompt: get.prompt("olliangyin"),
position: "he", prompt2: "弃置一张牌,并令一名其他角色也弃置一张牌",
filterCard: lib.filter.cardDiscardable, position: "he",
filterTarget(card, player, target) { filterCard: lib.filter.cardDiscardable,
return target != player && target.countCards("he") > 0; filterTarget(card, player, target) {
}, return target != player && target.countCards("he") > 0;
ai1(card) { },
let player = _status.event.player; ai1(card) {
if (_status.event.me) { let player = _status.event.player;
if (get.position(card) === _status.event.me) return 12 - player.hp - get.value(card); if (_status.event.me) {
return 0; if (get.position(card) === _status.event.me) return 12 - player.hp - get.value(card);
} return 0;
return 5 - get.value(card); }
}, return 5 - get.value(card);
ai2(target) { },
let player = _status.event.player, ai2(target) {
att = get.attitude(player, target); let player = _status.event.player,
if (att > 0 && (_status.event.me || target.isHealthy())) return -att; att = get.attitude(player, target);
if ( if (att > 0 && (_status.event.me || target.isHealthy())) return -att;
att > 0 && if (
(target.countCards("he") > target.hp || att > 0 &&
target.hasCard(function (card) { (target.countCards("he") > target.hp ||
return get.value(card, target) <= 0; target.hasCard(function (card) {
}, "e")) return get.value(card, target) <= 0;
) }, "e"))
return att; )
return -att; return att;
}, return -att;
me: (() => { },
if (player.isHealthy() || get.recoverEffect(player, player, _status.event.player) <= 0) return false; me: (() => {
let ph = player.countCards("h"), if (player.isHealthy() || get.recoverEffect(player, player, _status.event.player) <= 0) return false;
num = player.getExpansions("olkongsheng").length; let ph = player.countCards("h"),
if (ph === num) { num = player.getExpansions("olkongsheng").length;
if (player.hasSkillTag("noh")) return "h"; if (ph === num) {
return "e"; if (player.hasSkillTag("noh")) return "h";
} return "e";
if (ph - 1 === num) return "h"; }
return false; if (ph - 1 === num) return "h";
})(), return false;
}); })(),
})
.forResult();
}, },
async content(event, trigger, player) { async content(event, trigger, player) {
const { targets, cards } = event.result; const target = event.targets[0];
const target = targets[0];
player.logSkill("olliangyin_gain", target); player.logSkill("olliangyin_gain", target);
await player.discard(cards); await player.discard(event.cards);
await target.chooseToDiscard("he", true); await target.chooseToDiscard("he", true);
await game.asyncDelayx(); await game.asyncDelayx();
const num = player.getExpansions("olkongsheng").length; const num = player.getExpansions("olkongsheng").length;
@ -377,35 +380,37 @@ const skills = {
return player.countCards("he") > 0; return player.countCards("he") > 0;
}, },
async cost(event, trigger, player) { async cost(event, trigger, player) {
event.result = await player.chooseCard("he", [1, player.countCards("he")], get.prompt("olkongsheng"), "将任意张牌作为“箜”置于武将牌上").set("ai", function (card) { event.result = await player
const player = _status.event.player, .chooseCard("he", [1, player.countCards("he")], get.prompt("olkongsheng"), "将任意张牌作为“箜”置于武将牌上")
num = player.getExpansions("olkongsheng") + ui.selected.cards.length; .set("ai", function (card) {
if ( const player = _status.event.player,
ui.selected.cards.length > 0 && num = player.getExpansions("olkongsheng") + ui.selected.cards.length;
game.hasPlayer(function (current) { if (
if (current.isHealthy() || get.recoverEffect(current, player, player) <= 0) return false; ui.selected.cards.length > 0 &&
const num2 = game.hasPlayer(function (current) {
current.countCards("h", function (card) { if (current.isHealthy() || get.recoverEffect(current, player, player) <= 0) return false;
if (current != player) return true; const num2 =
return !ui.selected.cards.includes(card); current.countCards("h", function (card) {
}) + 1; if (current != player) return true;
return num == num2; return !ui.selected.cards.includes(card);
}) }) + 1;
) return num == num2;
return 0; })
if (get.type(card, null, false) == "equip") { )
for (const i of ui.selected.cards) { return 0;
if (get.type(i, null, false) == "equip") return 0; if (get.type(card, null, false) == "equip") {
for (const i of ui.selected.cards) {
if (get.type(i, null, false) == "equip") return 0;
}
return 5 - get.value(card);
} }
return 5 - get.value(card); if (!player.hasValueTarget(card)) return 1;
} return 0;
if (!player.hasValueTarget(card)) return 1; })
return 0; .forResult();
});
}, },
async content(event, trigger, player) { async content(event, trigger, player) {
player.logSkill("olkongsheng"); player.addToExpansion(event.cards, player, "give").gaintag.add("olkongsheng");
player.addToExpansion(event.result.cards, player, "give").gaintag.add("olkongsheng");
}, },
onremove(player, skill) { onremove(player, skill) {
const cards = player.getExpansions(skill); const cards = player.getExpansions(skill);
@ -483,11 +488,11 @@ const skills = {
.set("ai", function (target) { .set("ai", function (target) {
return (1 - get.attitude(_status.event.player, target)) / target.countCards("he"); return (1 - get.attitude(_status.event.player, target)) / target.countCards("he");
}) })
.set("targets", trigger.targets); .set("targets", trigger.targets)
.forResult();
}, },
async content(event, trigger, player) { async content(event, trigger, player) {
const target = result.targets[0]; const target = event.targets[0];
player.logSkill("zhengrong", target);
const next = player.choosePlayerCard(target, "he", true); const next = player.choosePlayerCard(target, "he", true);
next.ai = get.buttonValue; next.ai = get.buttonValue;
const { result } = await next; const { result } = await next;
@ -497,7 +502,7 @@ const skills = {
} }
}, },
onremove(player, skill) { onremove(player, skill) {
var cards = player.getExpansions(skill); const cards = player.getExpansions(skill);
if (cards.length) player.loseToDiscardpile(cards); if (cards.length) player.loseToDiscardpile(cards);
}, },
marktext: "荣", marktext: "荣",
@ -584,7 +589,7 @@ const skills = {
ai: { ai: {
result: { result: {
target(player, target) { target(player, target) {
var att = get.attitude(player, target); const att = get.attitude(player, target);
if ( if (
att > 0 && att > 0 &&
(target.countCards("j") > 0 || (target.countCards("j") > 0 ||
@ -604,11 +609,11 @@ const skills = {
return "选择弃置一张手牌,获得" + get.translation(links[0]) + "并弃置一名角色装备区或判定区内的一张牌"; return "选择弃置一张手牌,获得" + get.translation(links[0]) + "并弃置一名角色装备区或判定区内的一张牌";
}, },
}, },
async contentx(event, player, trigger) { async contentx(event, trigger, player) {
const card = lib.skill.qingce_backup.card; const card = lib.skill.qingce_backup.card;
await player.gain(card, "gain2", "log"); await player.gain(card, "gain2", "log");
if (event.target.countDiscardableCards(player, "ej") > 0) { if (event.target.countDiscardableCards(player, "ej") > 0) {
await player.discardPlayerCard("ej", true, target); await player.discardPlayerCard("ej", true, event.target);
} }
}, },
ai: { ai: {
@ -618,7 +623,7 @@ const skills = {
player(player) { player(player) {
if ( if (
game.hasPlayer(function (current) { game.hasPlayer(function (current) {
var att = get.attitude(player, current); const att = get.attitude(player, current);
if ((att > 0 && current.countCards("j") > 0) || (att < 0 && current.countCards("e") > 0)) return true; if ((att > 0 && current.countCards("j") > 0) || (att < 0 && current.countCards("e") > 0)) return true;
return false; return false;
}) })
@ -643,7 +648,7 @@ const skills = {
filter(event, player) { filter(event, player) {
return event.player != player && event.player.countCards("h") > player.countCards("h"); return event.player != player && event.player.countCards("h") > player.countCards("h");
}, },
async cost(event, player, trigger) { async cost(event, trigger, player) {
const { result } = await player.choosePlayerCard("hej", get.prompt("drlt_zhenrong"), trigger.player).set("ai", function (button) { const { result } = await player.choosePlayerCard("hej", get.prompt("drlt_zhenrong"), trigger.player).set("ai", function (button) {
return -get.attitude(player, trigger.player) + 1; return -get.attitude(player, trigger.player) + 1;
}); });
@ -651,8 +656,8 @@ const skills = {
event.result = result; event.result = result;
} }
}, },
async content(event, player, trigger) { async content(event, trigger, player) {
player.addToExpansion(event.result.cards, trigger.player, "give", "log").gaintag.add("drlt_zhenrong"); player.addToExpansion(event.cards, trigger.player, "give", "log").gaintag.add("drlt_zhenrong");
}, },
}, },
drlt_hongju: { drlt_hongju: {
@ -669,7 +674,7 @@ const skills = {
filter(event, player) { filter(event, player) {
return player.getExpansions("drlt_zhenrong").length >= 3 && game.dead.length > 0; return player.getExpansions("drlt_zhenrong").length >= 3 && game.dead.length > 0;
}, },
async content(event, player, trigger) { async content(event, trigger, player) {
player.awakenSkill("drlt_hongju"); player.awakenSkill("drlt_hongju");
const cards = player.getExpansions("drlt_zhenrong"); const cards = player.getExpansions("drlt_zhenrong");
if (cards.length && player.countCards("h")) { if (cards.length && player.countCards("h")) {
@ -719,7 +724,7 @@ const skills = {
filterTarget(card, player, target) { filterTarget(card, player, target) {
return target.countDiscardableCards(player, "ej") > 0; return target.countDiscardableCards(player, "ej") > 0;
}, },
async content(event, player, trigger) { async content(event, trigger, player) {
const next = player.chooseCardButton(player.getExpansions("drlt_zhenrong"), 1, "请选择需要弃置的“荣”", true); const next = player.chooseCardButton(player.getExpansions("drlt_zhenrong"), 1, "请选择需要弃置的“荣”", true);
next.ai = button => 6 - get.value(button.link); next.ai = button => 6 - get.value(button.link);
const { result } = await next; const { result } = await next;

View File

@ -1268,18 +1268,16 @@ const skills = {
audio: 2, audio: 2,
trigger: { global: "useCard" }, trigger: { global: "useCard" },
filter: function (event, player) { filter: function (event, player) {
var history = game.getAllGlobalHistory("useCard"); const history = game.getAllGlobalHistory("useCard");
var index = history.indexOf(event); const index = history.indexOf(event);
if (index <= 0) return false; if (index <= 0) return false;
var previous = history[index - 1].player; const previous = history[index - 1].player;
if (event.player == player && previous != player && previous.isIn()) return true; if (event.player == player && previous != player && previous.isIn()) return true;
if (event.player != player && previous == player) return true; if (event.player != player && previous == player) return true;
return false; return false;
}, },
async cost(event, trigger, player) { async cost(event, trigger, player) {
event.result = { bool: !!trigger.player }; if (!trigger.player) return;
},
async content(event, trigger, player) {
const history = game.getAllGlobalHistory("useCard"); const history = game.getAllGlobalHistory("useCard");
const index = history.indexOf(trigger); const index = history.indexOf(trigger);
const previous = history[index - 1].player; const previous = history[index - 1].player;
@ -1287,10 +1285,12 @@ const skills = {
.chooseBool("是否对" + get.translation(previous) + "发动【联对】?", "令" + get.translation(previous) + "摸两张牌") .chooseBool("是否对" + get.translation(previous) + "发动【联对】?", "令" + get.translation(previous) + "摸两张牌")
.set("ai", () => _status.event.bool) .set("ai", () => _status.event.bool)
.set("bool", get.effect(previous, { name: "draw" }, trigger.player, trigger.player) > 0); .set("bool", get.effect(previous, { name: "draw" }, trigger.player, trigger.player) > 0);
if (result.bool) { if (result.bool) event.result = { bool: true, cost_data: previous };
trigger.player.logSkill("liandui", previous); },
previous.draw(2); async content(event, trigger, player) {
} const { cost_data: previous } = event;
trigger.player.logSkill("liandui", previous);
previous.draw(2);
}, },
}, },
biejun: { biejun: {

View File

@ -1643,9 +1643,13 @@ const skills = {
.getCards("he", function (card) { .getCards("he", function (card) {
return lib.filter.canBeDiscarded(card, player, target); return lib.filter.canBeDiscarded(card, player, target);
}) })
.map(c => {
link: c;
})
.sort(function (a, b) { .sort(function (a, b) {
return get.buttonValue(b) - get.buttonValue(a); return get.buttonValue(b) - get.buttonValue(a);
}); })
.map(b => b.link);
if ( if (
target.countCards("h") - player.countCards("h") >= target.countCards("h") - player.countCards("h") >=
Math.max( Math.max(