From 459f926feb54f55aa99e9075d670915e9440c197 Mon Sep 17 00:00:00 2001
From: IceCola <739201322@qq.com>
Date: Sun, 19 May 2024 11:58:38 +0800
Subject: [PATCH] =?UTF-8?q?step=E8=BD=ACasync=EF=BC=9A=E5=AD=99=E4=BA=AE?=
=?UTF-8?q?=E3=80=81=E8=AE=B8=E6=94=B8=E3=80=81=E5=8D=A2=E6=A4=8D=E3=80=81?=
=?UTF-8?q?=E8=92=AF=E8=89=AF=E8=92=AF=E8=B6=8A=E3=80=81=E6=9B=B9=E4=BB=81?=
=?UTF-8?q?=E3=80=81=E5=BA=9E=E5=BE=B7=E3=80=81=E8=A2=81=E7=BB=8D=E3=80=81?=
=?UTF-8?q?=E9=AD=8F=E5=BB=B6=E3=80=81=E9=BB=84=E5=BF=A0=E3=80=81=E5=A7=9C?=
=?UTF-8?q?=E7=BB=B4=E3=80=81=E5=88=98=E7=A6=85=E3=80=81=E5=BC=A0=E9=83=83?=
=?UTF-8?q?=E3=80=81=E9=82=93=E8=89=BE=E3=80=81=E5=AD=99=E7=AD=96=E3=80=81?=
=?UTF-8?q?=E5=BC=A0=E6=98=AD=E5=BC=A0=E7=BA=AE=E3=80=81=E8=94=A1=E6=96=87?=
=?UTF-8?q?=E5=A7=AC=EF=BC=9Bbugfix?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
character/shenhua/skill.js | 1159 +++++++++++++++++-------------------
1 file changed, 531 insertions(+), 628 deletions(-)
diff --git a/character/shenhua/skill.js b/character/shenhua/skill.js
index 5949c2aef..2558cd35b 100644
--- a/character/shenhua/skill.js
+++ b/character/shenhua/skill.js
@@ -654,8 +654,9 @@ const skills = {
const { result } = await player.choosePlayerCard("hej", get.prompt("drlt_zhenrong"), trigger.player).set("ai", function (button) {
return -get.attitude(player, trigger.player) + 1;
});
- if (result && result.links && result.links.length) {
+ if (result.bool && result.links && result.links.length) {
event.result = result;
+ event.result.cards = result.links;
}
},
async content(event, trigger, player) {
@@ -1964,24 +1965,22 @@ const skills = {
trigger: {
player: "phaseDiscardAfter",
},
- direct: true,
filter(event, player) {
- var cards = [];
+ const cards = [];
player.getHistory("lose", function (evt) {
if (evt.type == "discard" && evt.getParent("phaseDiscard") == event) cards.addArray(evt.cards2);
});
return cards.length > 0;
},
- content() {
- "step 0";
- var cards = [];
+ async cost(event, trigger, player) {
+ const cards = [];
player.getHistory("lose", function (evt) {
if (evt.type == "discard" && evt.getParent("phaseDiscard") == trigger) cards.addArray(evt.cards2);
});
event.num = cards.length;
event.str1 = "令至多" + event.num + "名角色摸一张牌";
event.str2 = "对任意名体力值之和为" + event.num + "的角色造成1点伤害";
- player
+ const result = await player
.chooseControl("cancel2")
.set("ai", function () {
if (
@@ -1994,68 +1993,42 @@ const skills = {
return 0;
})
.set("choiceList", [event.str1, event.str2])
- .set("prompt", "是否发动【溃诛】?");
- "step 1";
- if (result.control == "cancel2") event.finish();
- event.control = [event.str1, event.str2][result.index];
- "step 2";
- var str = "请选择〖溃诛〗的目标";
- if (event.bool == false) str = "
所选目标体力之和不足" + event.num + ",请重选";
- if (event.control == event.str2) {
- player
- .chooseTarget(str, function (card, player, target) {
- var targets = ui.selected.targets;
- var num = 0;
- for (var i = 0; i < targets.length; i++) {
- num += targets[i].hp;
- }
+ .set("prompt", "是否发动【溃诛】?")
+ .forResult();
+ if (result.control == "cancel2") return;
+ if (result.index == 1) {
+ event.result = await player
+ .chooseTarget("请选择〖溃诛〗造成伤害的目标", function (card, player, target) {
+ const num = ui.selected.targets.map(t => t.hp).reduce((a, b) => a + b, 0);
return num + target.hp <= _status.event.num;
})
+ .set("filterOk", function () {
+ const num = ui.selected.targets.map(t => t.hp).reduce((a, b) => a + b);
+ return num == _status.event.num;
+ })
.set("ai", function (target) {
if (ui.selected.targets[0] != undefined) return -1;
return get.attitude(player, target) < 0;
})
+ .set("complexTarget", true)
.set("promptbar", "none")
.set("num", event.num)
- .set("selectTarget", function () {
- var targets = ui.selected.targets;
- var num = 0;
- for (var i = 0; i < targets.length; i++) {
- num += targets[i].hp;
- }
- if (num == _status.event.num) return ui.selected.targets.length;
- return ui.selected.targets.length + 1;
- });
+ .set("selectTarget", [1, Infinity])
+ .forResult();
+ event.result.cost_data = "damage";
} else {
- player.chooseTarget("请选择〖溃诛〗的目标", [1, event.num]).ai = function (target) {
+ const next = player.chooseTarget("请选择〖溃诛〗摸牌的目标", [1, event.num]);
+ next.ai = function (target) {
return get.attitude(player, target);
};
+ event.result = await next.forResult();
}
- "step 3";
- if (result.bool) {
- var targets = result.targets.sortBySeat();
- if (event.control == event.str1) {
- //player.line(targets);
- player.logSkill("nzry_kuizhu", targets);
- game.asyncDraw(targets);
- } else {
- var num = 0;
- for (var i = 0; i < targets.length; i++) {
- num += targets[i].hp;
- }
- if (num < event.num) {
- event.bool = false;
- event.goto(2);
- } else {
- //player.line(targets);
- player.logSkill("nzry_kuizhu", targets);
- for (var i = 0; i < targets.length; i++) {
- targets[i].damage();
- }
- //if(targets.length>=2) player.loseHp();
- }
- }
- }
+ },
+ async content(event, trigger, player) {
+ const targets = event.targets.sortBySeat();
+ if (event.cost_data == "damage") {
+ await Promise.all(targets.map(target => target.damage()));
+ } else game.asyncDraw(targets);
},
},
rechezheng: {
@@ -2066,7 +2039,7 @@ const skills = {
},
forced: true,
logTarget: "player",
- content() {
+ async content(event, trigger, player) {
trigger.cancel();
},
ai: {
@@ -2081,7 +2054,7 @@ const skills = {
audio: 2,
//mod:{
// playerEnabled:function(card,player,target){
- // var info=get.info(card);
+ // const info=get.info(card);
// if(target!=player&&(!info||!info.singleCard||!ui.selected.targets.length)&&player.isPhaseUsing()&&!target.inRange(player)) return false;
// },
//},
@@ -2102,14 +2075,14 @@ const skills = {
})
);
},
- content() {
- "step 0";
- player.chooseTarget("请选择〖掣政〗的目标", "弃置一名攻击范围内不包含你的角色的一张牌", true, function (card, player, target) {
+ async content(event, trigger, player) {
+ const next = player.chooseTarget("请选择〖掣政〗的目标", "弃置一名攻击范围内不包含你的角色的一张牌", true, function (card, player, target) {
return target != player && !target.inRange(player) && target.countDiscardableCards(player, "he");
- }).ai = function (target) {
+ });
+ next.ai = function (target) {
return -get.attitude(player, target);
};
- "step 1";
+ const { result } = await next;
if (result.bool) {
player.line(result.targets);
player.discardPlayerCard(result.targets[0], "he", 1, true);
@@ -2137,6 +2110,7 @@ const skills = {
trigger: {
player: "useCardAfter",
},
+ log: false, // 实际发动者是主公,所以给牌的人不log喵
filter(event, player) {
if (event.card.name != "sha" || player.group != "wu") return false;
if (player.hasSkill("nzry_lijun2")) return false;
@@ -2147,50 +2121,46 @@ const skills = {
})
)
return false;
- for (var i = 0; i < event.cards.length; i++) {
+ for (let i = 0; i < event.cards.length; i++) {
if (get.position(event.cards[i], true) == "o") {
return true;
}
}
return false;
},
- direct: true,
- content() {
- "step 0";
- var list = game.filterPlayer(function (target) {
+ async cost(event, trigger, player) {
+ const list = game.filterPlayer(function (target) {
return player != target && target.hasZhuSkill("nzry_lijun", player);
});
- player.chooseTarget(get.prompt("nzry_lijun"), "将" + get.translation(trigger.cards) + "交给" + get.translation(list) + (list.length > 1 ? "中的一人" : ""), function (card, player, target) {
+ const next = player.chooseTarget(get.prompt("nzry_lijun"), "将" + get.translation(trigger.cards) + "交给" + get.translation(list) + (list.length > 1 ? "中的一人" : ""), function (card, player, target) {
return player != target && target.hasZhuSkill("nzry_lijun", player);
- }).ai = function (target) {
+ });
+ next.ai = function (target) {
return get.attitude(_status.event.player, target);
};
- "step 1";
- if (!result.bool) event.finish();
- else {
- player.addTempSkill("nzry_lijun2", "phaseUseEnd");
- var zhu = result.targets[0];
- player.line(zhu, "green");
- zhu.logSkill("nzry_lijun");
- var list = [];
- for (var i = 0; i < trigger.cards.length; i++) {
- if (get.position(trigger.cards[i], true) == "o") {
- list.push(trigger.cards[i]);
- }
- }
- zhu.gain(list, "gain2").giver = player;
- zhu.chooseBool()
- .set("ai", function () {
- if (get.attitude(zhu, player) > 0) return true;
- return false;
- })
- .set("prompt", "是否令" + get.translation(player) + "摸一张牌?");
- }
- "step 2";
- if (result.bool) {
- player.draw();
- player.addMark("nzry_lijun2", 1, false);
- }
+ event.result = await next.forResult();
+ },
+ async content(event, trigger, player) {
+ player.addTempSkill("nzry_lijun2", "phaseUseEnd");
+ const [zhu] = event.targets;
+ player.line(zhu, "green");
+ zhu.logSkill("nzry_lijun"); // 给牌的人去logSkill好像还是不太好喵?
+ const list = trigger.cards.filter(function (card) {
+ return get.position(card, true) == "o";
+ });
+ const next = zhu.gain(list, "gain2");
+ next.giver = player;
+ await next;
+ const { result } = await zhu
+ .chooseBool()
+ .set("ai", function () {
+ if (get.attitude(zhu, player) > 0) return true;
+ return false;
+ })
+ .set("prompt", "是否令" + get.translation(player) + "摸一张牌?");
+ if (!result.bool) return;
+ await player.draw();
+ player.addMark("nzry_lijun2", 1, false);
},
},
nzry_chenglve: {
@@ -2200,7 +2170,7 @@ const skills = {
marktext: "☯",
intro: {
content(storage, player, skill) {
- var str = player.storage.nzry_chenglve ? "出牌阶段限一次,你可以摸两张牌,然后弃置一张手牌。若如此做,直到本回合结束,你使用与弃置牌花色相同的牌无距离和次数限制" : "出牌阶段限一次,你可以摸一张牌,然后弃置两张手牌。若如此做,直到本回合结束,你使用与弃置牌花色相同的牌无距离和次数限制";
+ let str = player.storage.nzry_chenglve ? "出牌阶段限一次,你可以摸两张牌,然后弃置一张手牌。若如此做,直到本回合结束,你使用与弃置牌花色相同的牌无距离和次数限制" : "出牌阶段限一次,你可以摸一张牌,然后弃置两张手牌。若如此做,直到本回合结束,你使用与弃置牌花色相同的牌无距离和次数限制";
if (player.storage.nzry_chenglve1) {
str += "
当前花色:";
str += get.translation(player.storage.nzry_chenglve1);
@@ -2211,22 +2181,25 @@ const skills = {
enable: "phaseUse",
usable: 1,
audio: 2,
- content() {
- "step 0";
+ filter(event, player) {
+ // 加个检查喵
+ if (player.storage.nzry_chenglve != true) {
+ return player.countDiscardableCards(player, "h");
+ }
+ return true;
+ },
+ async content(event, trigger, player) {
+ let result;
if (player.storage.nzry_chenglve == true) {
- player.draw(2);
- player.chooseToDiscard("h", true);
+ await player.draw(2);
+ result = await player.chooseToDiscard("h", true).forResult();
} else {
- player.draw();
- player.chooseToDiscard("h", 2, true);
+ await player.draw();
+ result = await player.chooseToDiscard("h", 2, true).forResult();
}
player.changeZhuanhuanji("nzry_chenglve");
- "step 1";
if (result.bool) {
- player.storage.nzry_chenglve1 = [];
- for (var i = 0; i < result.cards.length; i++) {
- player.storage.nzry_chenglve1.add(get.suit(result.cards[i], player));
- }
+ player.storage.nzry_chenglve1 = result.cards.map(card => get.suit(card, player)).unique();
player.markSkill("nzry_chenglve");
player.addTempSkill("nzry_chenglve1");
}
@@ -2283,8 +2256,8 @@ const skills = {
if (get.type(event.card) == "equip") {
if (get.subtype(event.card) == "equip6") return true;
if (get.equipResult(player, player, event.card.name) <= 0) return true;
- var eff1 = player.getUseValue(event.card);
- var subtype = get.subtype(event.card);
+ const eff1 = player.getUseValue(event.card);
+ const subtype = get.subtype(event.card);
return (
player.countCards("h", function (card) {
return get.subtype(card) == subtype && player.getUseValue(card) >= eff1;
@@ -2293,31 +2266,27 @@ const skills = {
}
return true;
},
- content() {
- "step 0";
- var cards = trigger.cards.filterInD();
- if (cards.length == 1) {
- event._result = { bool: true, moved: [cards] };
- } else {
- var next = player.chooseToMove("恃才:将牌按顺序置于牌堆顶", true);
- next.set("list", [["牌堆顶", cards]]);
- next.set("reverse", _status.currentPhase && _status.currentPhase.next ? get.attitude(player, _status.currentPhase.next) > 0 : false);
- next.set("processAI", function (list) {
- var cards = list[0][1].slice(0);
- cards.sort(function (a, b) {
- return (_status.event.reverse ? 1 : -1) * (get.value(b) - get.value(a));
+ async content(event, trigger, player) {
+ let cards = trigger.cards.filterInD();
+ if (cards.length > 1) {
+ const { result } = await player
+ .chooseToMove("恃才:将牌按顺序置于牌堆顶", true)
+ .set("list", [["牌堆顶", cards]])
+ .set("reverse", _status.currentPhase && _status.currentPhase.next && get.attitude(player, _status.currentPhase.next) > 0)
+ .set("processAI", function (list) {
+ const cards = list[0][1].slice(0);
+ cards.sort(function (a, b) {
+ return (_status.event.reverse ? 1 : -1) * (get.value(b) - get.value(a));
+ });
+ return [cards];
});
- return [cards];
- });
+ if (!result.bool) return;
+ cards = result.moved[0];
}
- "step 1";
- if (result.bool) {
- var cards = result.moved[0];
- cards.reverse();
- game.cardsGotoPile(cards, "insert");
- game.log(player, "将", cards, "置于了牌堆顶");
- }
- player.draw();
+ cards.reverse();
+ await game.cardsGotoPile(cards, "insert");
+ game.log(player, "将", cards, "置于了牌堆顶");
+ await player.draw();
},
subSkill: { 2: { audio: 2 } },
ai: {
@@ -2351,7 +2320,7 @@ const skills = {
player: "drawBegin",
},
forced: true,
- content() {
+ async content(event, trigger, player) {
trigger.bottom = true;
},
},
@@ -2364,7 +2333,7 @@ const skills = {
markcount: "expansion",
},
onremove(player, skill) {
- var cards = player.getExpansions(skill);
+ const cards = player.getExpansions(skill);
if (cards.length) player.loseToDiscardpile(cards);
},
group: ["nzry_mingren_1", "nzry_mingren_2"],
@@ -2384,18 +2353,16 @@ const skills = {
filter(event, player) {
return (event.name != "phase" || game.phaseNumber == 0) && !player.getExpansions("nzry_mingren").length;
},
- content() {
- "step 0";
- player.draw(2);
- "step 1";
- if (!player.countCards("h")) event.finish();
- else
- player.chooseCard("h", "将一张手牌置于武将牌上,称为“任”", true).set("ai", function (card) {
- return 6 - get.value(card);
- });
- "step 2";
+ async content(event, trigger, player) {
+ await player.draw(2);
+ if (!player.countCards("h")) return;
+ const { result } = await player.chooseCard("h", "将一张手牌置于武将牌上,称为“任”", true).set("ai", function (card) {
+ return 6 - get.value(card);
+ });
if (result.bool) {
- player.addToExpansion(result.cards[0], player, "give", "log").gaintag.add("nzry_mingren");
+ const next = player.addToExpansion(result.cards[0], player, "give", "log");
+ next.gaintag.add("nzry_mingren");
+ await next;
}
},
},
@@ -2406,40 +2373,42 @@ const skills = {
filter(event, player) {
return player.countCards("h") > 0 && player.getExpansions("nzry_mingren").length > 0;
},
- direct: true,
- content() {
- "step 0";
- player.chooseCard("h", get.prompt("nzry_mingren"), "选择一张手牌替换“任”(" + get.translation(player.getExpansions("nzry_mingren")[0]) + ")").set("ai", function (card) {
- var player = _status.event.player;
- var color = get.color(card);
- if (color == get.color(player.getExpansions("nzry_mingren")[0])) return false;
- var num = 0;
- var list = [];
- player.countCards("h", function (cardx) {
- if (cardx != card || get.color(cardx) != color) return false;
- if (list.includes(cardx.name)) return false;
- list.push(cardx.name);
- switch (cardx.name) {
- case "wuxie":
- num += game.countPlayer() / 2.2;
- break;
- case "caochuan":
- num += 1.1;
- break;
- case "shan":
- num += 1;
- break;
- }
- });
- return num * (30 - get.value(card));
- });
- "step 1";
- if (result.bool) {
- player.logSkill("nzry_mingren");
- player.addToExpansion(result.cards[0], "log", "give", player).gaintag.add("nzry_mingren");
- var card = player.getExpansions("nzry_mingren")[0];
- if (card) player.gain(card, "gain2");
- }
+ async cost(event, trigger, player) {
+ event.result = await player
+ .chooseCard("h", get.prompt("nzry_mingren"), "选择一张手牌替换“任”(" + get.translation(player.getExpansions("nzry_mingren")[0]) + ")")
+ .set("ai", function (card) {
+ const player = _status.event.player;
+ const color = get.color(card);
+ if (color == get.color(player.getExpansions("nzry_mingren")[0])) return false;
+ let num = 0;
+ const list = [];
+ player.countCards("h", function (cardx) {
+ if (cardx != card || get.color(cardx) != color) return false;
+ if (list.includes(cardx.name)) return false;
+ list.push(cardx.name);
+ switch (cardx.name) {
+ case "wuxie":
+ num += game.countPlayer() / 2.2;
+ break;
+ case "caochuan":
+ num += 1.1;
+ break;
+ case "shan":
+ num += 1;
+ break;
+ }
+ });
+ return num * (30 - get.value(card));
+ })
+ .forResult();
+ },
+ async content(event, trigger, player) {
+ // 考虑到getExpansions的实际执行在addToExpansion之前喵,此处调换顺序
+ const card = player.getExpansions("nzry_mingren")[0];
+ const next = player.addToExpansion(event.cards[0], "log", "give", player);
+ next.gaintag.add("nzry_mingren");
+ await next;
+ if (card) await player.gain(card, "gain2");
},
},
},
@@ -2464,9 +2433,9 @@ const skills = {
enable: "phaseUse",
filter(event, player) {
if (player.storage.nzry_zhenliang) return false;
- var storage = player.getExpansions("nzry_mingren");
+ const storage = player.getExpansions("nzry_mingren");
if (!storage.length) return false;
- var color = get.color(storage[0]);
+ const color = get.color(storage[0]);
if (
player.countCards("he", function (card) {
return get.color(card) == color;
@@ -2487,9 +2456,9 @@ const skills = {
check(card) {
return 6.5 - get.value(card);
},
- content() {
+ async content(event, trigger, player) {
player.changeZhuanhuanji("nzry_zhenliang");
- target.damage("nocard");
+ await event.target.damage("nocard");
},
ai: {
order: 5,
@@ -2506,23 +2475,21 @@ const skills = {
},
filter(event, player) {
if (_status.currentPhase == player || !player.storage.nzry_zhenliang) return false;
- var card = player.getExpansions("nzry_mingren")[0];
+ const card = player.getExpansions("nzry_mingren")[0];
return card && get.color(event.card) == get.color(card);
},
- direct: true,
- content() {
- "step 0";
- player.chooseTarget(get.prompt("nzry_zhenliang"), "令一名角色摸一张牌").ai = function (target) {
+ async cost(event, trigger, player) {
+ const next = player.chooseTarget(get.prompt("nzry_zhenliang"), "令一名角色摸一张牌");
+ next.ai = function (target) {
if (target.hasSkillTag("nogain")) return 0.1;
- var att = get.attitude(player, target);
+ const att = get.attitude(player, target);
return att * (Math.max(5 - target.countCards("h"), 2) + 3);
};
- "step 1";
- if (result.bool) {
- player.changeZhuanhuanji("nzry_zhenliang");
- player.logSkill("nzry_zhenliang", result.targets);
- result.targets[0].draw();
- }
+ event.result = await next.forResult();
+ },
+ async content(event, trigger, player) {
+ player.changeZhuanhuanji("nzry_zhenliang");
+ event.targets[0].draw();
},
},
},
@@ -2538,19 +2505,17 @@ const skills = {
filter(event, player) {
return event.player != player;
},
- direct: true,
- content() {
- "step 0";
- player.chooseTarget(get.prompt("nzry_jianxiang"), "令场上手牌数最少的一名角色摸一张牌", function (card, player, target) {
+ async cost(event, trigger, player) {
+ const next = player.chooseTarget(get.prompt("nzry_jianxiang"), "令场上手牌数最少的一名角色摸一张牌", function (card, player, target) {
return target.isMinHandcard();
- }).ai = function (target) {
+ });
+ next.ai = function (target) {
return get.attitude(player, target);
};
- "step 1";
- if (result.bool) {
- player.logSkill("nzry_jianxiang", result.targets);
- result.targets[0].draw();
- }
+ event.result = await next.forResult();
+ },
+ async content(event, trigger, player) {
+ await event.targets[0].draw();
},
},
nzry_shenshi: {
@@ -2592,27 +2557,22 @@ const skills = {
check(card) {
return 5 - get.value(card);
},
- content() {
- "step 0";
+ async content(event, trigger, player) {
+ const target = event.target;
player.changeZhuanhuanji("nzry_shenshi");
- player.give(cards, target);
- target.damage("nocard");
- "step 1";
- if (!target.isIn()) {
- player
- .chooseTarget("令一名角色将手牌摸至四张", function (card, player, target) {
- return target.countCards("h") < 4;
- })
- .set("ai", function (target) {
- return get.attitude(player, target);
- });
- } else {
- event.finish();
- }
- "step 2";
+ await player.give(event.cards, target);
+ await target.damage("nocard");
+ if (target.isIn()) return;
+ const { result } = await player
+ .chooseTarget("令一名角色将手牌摸至四张", function (card, player, target) {
+ return target.countCards("h") < 4;
+ })
+ .set("ai", function (target) {
+ return get.attitude(player, target);
+ });
if (result.bool) {
player.line(result.targets);
- result.targets[0].draw(4 - result.targets[0].countCards("h"));
+ await result.targets[0].draw(4 - result.targets[0].countCards("h"));
}
},
ai: {
@@ -2637,16 +2597,14 @@ const skills = {
},
logTarget: "source",
prompt2: "其他角色对你造成伤害后,你可以观看该角色的手牌,然后交给其一张牌,当前角色回合结束时,若此牌仍在该角色的区域内,你将手牌摸至四张",
- content() {
- "step 0";
+ async content(event, trigger, player) {
player.changeZhuanhuanji("nzry_shenshi");
- player.viewHandcards(trigger.source);
- player.chooseCard("he", true, "交给" + get.translation(trigger.source) + "一张牌").set("ai", function (card) {
+ await player.viewHandcards(trigger.source);
+ const { result } = await player.chooseCard("he", true, "交给" + get.translation(trigger.source) + "一张牌").set("ai", function (card) {
return 5 - get.value(card);
});
- "step 1";
if (result.bool) {
- player.give(result.cards, trigger.source);
+ await player.give(result.cards, trigger.source);
trigger.source.storage.nzry_shenshi1 = result.cards[0];
trigger.source.storage.nzry_shenshi2 = player;
trigger.source.addSkill("nzry_shenshi1");
@@ -2666,11 +2624,11 @@ const skills = {
filter(event, player) {
return player.storage.nzry_shenshi1 != undefined && player.storage.nzry_shenshi2 != undefined;
},
- content() {
- var pl = player.storage.nzry_shenshi2;
- var card = player.storage.nzry_shenshi1;
+ async content(event, trigger, player) {
+ const pl = player.storage.nzry_shenshi2;
+ const card = player.storage.nzry_shenshi1;
if (player.getCards("he").includes(card) && 4 - pl.countCards("h") > 0) {
- pl.draw(4 - pl.countCards("h"));
+ await pl.drawTo(4);
pl.logSkill("nzry_shenshi");
}
player.removeSkill("nzry_shenshi1");
@@ -2681,12 +2639,10 @@ const skills = {
xinjushou: {
audio: 2,
trigger: { player: "phaseJieshuBegin" },
- content() {
- "step 0";
- player.draw(4);
- player.turnOver();
- "step 1";
- player
+ async content(event, trigger, player) {
+ await player.draw(4);
+ await player.turnOver();
+ const { result } = await player
.chooseCard("h", true, "弃置一张手牌,若以此法弃置的是装备牌,则你改为使用之")
.set("ai", function (card) {
if (get.type(card) == "equip") {
@@ -2695,9 +2651,8 @@ const skills = {
return -get.value(card);
})
.set("filterCard", lib.filter.cardDiscardable);
- "step 2";
if (result.bool && result.cards.length) {
- var card = result.cards[0];
+ const card = result.cards[0];
if (get.type(card) == "equip" && player.hasUseTarget(card)) {
player.chooseUseTarget(card, true, "nopopup");
} else {
@@ -2734,27 +2689,22 @@ const skills = {
subSkill: {
move: {
trigger: { player: "turnOverEnd" },
- direct: true,
audio: "jiewei",
filter(event, player) {
return !player.isTurnedOver() && player.canMoveCard();
},
- content() {
- "step 0";
- player
+ async cost(event, trigger, player) {
+ event.result = await player
.chooseToDiscard("he", get.prompt("xinjiewei"), "弃置一张牌并移动场上的一张牌", lib.filter.cardDiscardable)
.set("ai", function (card) {
if (!_status.event.check) return 0;
return 7 - get.value(card);
})
.set("check", player.canMoveCard(true))
- .set("logSkill", "xinjiewei");
- "step 1";
- if (result.bool) {
- player.moveCard(true);
- } else {
- event.finish();
- }
+ .forResult();
+ },
+ async content(event, trigger, player) {
+ await player.moveCard(true);
},
},
},
@@ -2772,9 +2722,8 @@ const skills = {
return get.attitude(player, event.target) <= 0;
},
logTarget: "target",
- content() {
- "step 0";
- player
+ async content(event, trigger, player) {
+ const { result } = await player
.discardPlayerCard(trigger.target, get.prompt("jianchu", trigger.target), true)
.set("ai", function (button) {
if (!_status.event.att) return 0;
@@ -2785,13 +2734,12 @@ const skills = {
return 1;
})
.set("att", get.attitude(player, trigger.target) <= 0);
- "step 1";
if (result.bool && result.links && result.links.length) {
if (get.type(result.links[0], null, result.links[0].original == "h" ? player : false) == "equip") {
trigger.getParent().directHit.add(trigger.target);
} else if (trigger.cards) {
- var list = [];
- for (var i = 0; i < trigger.cards.length; i++) {
+ const list = [];
+ for (let i = 0; i < trigger.cards.length; i++) {
if (get.position(trigger.cards[i], true) == "o") list.push(trigger.cards[i]);
}
if (list.length) trigger.target.gain(list, "gain2", "log");
@@ -2834,22 +2782,15 @@ const skills = {
},
multitarget: true,
multiline: true,
- content() {
- "step 0";
- var cards = targets[0].getCards("h").concat(targets[1].getCards("h"));
- var dialog = ui.create.dialog("缔盟", true);
- if (player.isUnderControl(true) || targets[0].isUnderControl(true) || targets[1].isUnderControl(true)) {
- dialog.add(cards);
- dialog.seeing = true;
- } else {
- dialog.add([cards, "blank"]);
- }
- _status.dieClose.push(dialog);
- dialog.videoId = lib.status.videoId++;
- game.addVideo("cardDialog", null, ["缔盟", get.cardsInfo(cards), dialog.videoId]);
- game.broadcast(
+ async content(event, trigger, player) {
+ // 改到一半发现又没人用这个技能
+ // 心态炸了喵_(:з」∠)_
+ const [target, target1] = event.targets;
+ const cards = target.getCards("h").concat(target1.getCards("h"));
+ event.dialogRef = true;
+ game.broadcastAll(
function (cards, id, player, targets) {
- var dialog = ui.create.dialog("缔盟", true);
+ const dialog = ui.create.dialog("缔盟", true);
if (player.isUnderControl(true) || targets[0].isUnderControl(true) || targets[1].isUnderControl(true)) {
dialog.add(cards);
dialog.seeing = true;
@@ -2858,99 +2799,88 @@ const skills = {
}
_status.dieClose.push(dialog);
dialog.videoId = id;
+ if (_status.event.dialogRef) event.dialog = dialog;
},
cards,
dialog.videoId,
player,
- targets
+ event.targets
);
-
- event.current = targets[0];
- event.dialog = dialog;
- event.num1 = 0;
- event.num2 = 0;
- game.delay();
- "step 1";
- if (event.dialog.buttons.length > 1) {
- var next = event.current.chooseButton(true, function (button) {
- return get.value(button.link, _status.event.player);
- });
- next.set("dialog", event.dialog.videoId);
- next.set("closeDialog", false);
- next.set("dialogdisplay", true);
- } else {
- event.directButton = event.dialog.buttons[0];
- }
- "step 2";
- var dialog = event.dialog;
- var card;
- if (event.directButton) {
- card = event.directButton.link;
- } else {
- card = result.links[0];
- }
- for (var i = 0; i < dialog.buttons.length; i++) {
- if (dialog.buttons[i].link == card) {
- var button = dialog.buttons[i];
+ game.addVideo("cardDialog", null, ["缔盟", get.cardsInfo(cards), dialog.videoId]);
+ delete event.dialogRef;
+ const dialog = event.dialog;
+ let current = target;
+ let num1 = 0;
+ let num2 = 0;
+ await game.asyncDelay();
+ while (dialog.buttons.length) {
+ let card;
+ if (dialog.buttons.length > 1) {
+ const next = current.chooseButton(true, function (button) {
+ return get.value(button.link, _status.event.player);
+ });
+ next.set("dialog", dialog.videoId);
+ next.set("closeDialog", false);
+ next.set("dialogdisplay", true);
+ const { result } = await next;
+ if (!result.bool) return;
+ card = result.links[0];
+ } else {
+ card = dialog.buttons[0].link;
+ }
+ const button = dialog.buttons.find(button => button.link == card);
+ if (button) {
if (dialog.seeing) {
- button.querySelector(".info").innerHTML = get.translation(event.current.name);
+ button.querySelector(".info").innerHTML = get.translation(current.name);
if (!_status.connectMode) {
- game.log(event.current, "选择了", button.link);
+ game.log(current, "选择了", button.link);
}
}
dialog.buttons.remove(button);
- break;
}
- }
- if (card) {
- event.current.gain(card);
- if (dialog.seeing) {
- event.current.$draw(card, "nobroadcast");
- } else {
- event.current.$draw(1, "nobroadcast");
- }
- game.broadcast(
- function (card, id, target) {
- var dialog = get.idDialog(id);
- if (dialog && dialog.seeing) {
- for (var i = 0; i < dialog.buttons.length; i++) {
- if (dialog.buttons[i].link == card) {
- dialog.buttons[i].querySelector(".info").innerHTML = get.translation(target.name);
- dialog.buttons.splice(i--, 1);
- break;
+ if (card) {
+ await current.gain(card);
+ if (dialog.seeing) {
+ current.$draw(card, "nobroadcast");
+ } else {
+ current.$draw(1, "nobroadcast");
+ }
+ game.broadcast(
+ function (card, id, current) {
+ const dialog = get.idDialog(id);
+ if (dialog && dialog.seeing) {
+ const button = dialog.buttons.find(button => button.link == card);
+ if (button) {
+ button.querySelector(".info").innerHTML = get.translation(current.name);
+ dialog.buttons.remove(button);
}
+ current.$draw(card, "nobroadcast");
+ } else {
+ current.$draw(1, "nobroadcast");
}
- target.$draw(card, "nobroadcast");
- } else {
- target.$draw(1, "nobroadcast");
- }
- },
- card,
- dialog.videoId,
- event.current
- );
+ },
+ card,
+ dialog.videoId,
+ current
+ );
+ }
+ if (current == target) {
+ num1++;
+ current = target1;
+ } else {
+ num2++;
+ current = target;
+ }
+ await game.asyncDelay(2);
}
- game.delay(2);
- if (event.current == targets[0]) {
- event.num1++;
- event.current = targets[1];
- } else {
- event.num2++;
- event.current = targets[0];
- }
- if (dialog.buttons.length) {
- event.goto(1);
- }
- "step 3";
if (!_status.connectMode) {
- game.log(targets[0], "获得了" + get.cnNumber(event.num1) + "张牌");
- game.log(targets[1], "获得了" + get.cnNumber(event.num2) + "张牌");
+ game.log(targets[0], "获得了" + get.cnNumber(num1) + "张牌");
+ game.log(targets[1], "获得了" + get.cnNumber(num2) + "张牌");
}
- var dialog = event.dialog;
dialog.close();
_status.dieClose.remove(dialog);
game.broadcast(function (id) {
- var dialog = get.idDialog(id);
+ const dialog = get.idDialog(id);
if (dialog) {
dialog.close();
_status.dieClose.remove(dialog);
@@ -2960,15 +2890,15 @@ const skills = {
},
targetprompt: ["先拿牌", "后拿牌"],
find(type) {
- var list = game.filterPlayer(function (current) {
+ let list = game.filterPlayer(function (current) {
return current != player && get.attitude(player, current) > 3;
});
- var player = _status.event.player;
- var num = player.countCards("he", function (card) {
+ const player = _status.event.player;
+ const num = player.countCards("he", function (card) {
return get.value(card) < 7;
});
- var count = null;
- var from, nh;
+ let count = null;
+ let from, nh;
if (list.length == 0) return null;
list.sort(function (a, b) {
return a.countCards("h") - b.countCards("h");
@@ -2984,8 +2914,8 @@ const skills = {
list.sort(function (a, b) {
return b.countCards("h") - a.countCards("h");
});
- for (var i = 0; i < list.length; i++) {
- var nh2 = list[i].countCards("h");
+ for (let i = 0; i < list.length; i++) {
+ const nh2 = list[i].countCards("h");
if (nh2 - nh <= num) {
count = nh2 - nh;
break;
@@ -2996,7 +2926,7 @@ const skills = {
return list[i];
},
check(card) {
- var count = lib.skill.redimeng.find(3);
+ const count = lib.skill.redimeng.find(3);
if (count == null) return -1;
if (ui.selected.cards.length < count) return 7 - get.value(card);
return -1;
@@ -3029,13 +2959,13 @@ const skills = {
position: "hs",
selectCard: 2,
check(card) {
- var player = _status.event.player;
- var targets = game.filterPlayer(function (current) {
+ const player = _status.event.player;
+ const targets = game.filterPlayer(function (current) {
return player.canUse("wanjian", current);
});
- var num = 0;
- for (var i = 0; i < targets.length; i++) {
- var eff = get.sgn(get.effect(targets[i], { name: "wanjian" }, player, player));
+ let num = 0;
+ for (let i = 0; i < targets.length; i++) {
+ let eff = get.sgn(get.effect(targets[i], { name: "wanjian" }, player, player));
if (targets[i].hp == 1) {
eff *= 1.5;
}
@@ -3060,7 +2990,7 @@ const skills = {
reset: {
trigger: { player: "phaseAfter" },
silent: true,
- content() {
+ async content(event, trigger, player) {
delete player.storage.reluanji;
delete player.storage.reluanji2;
},
@@ -3071,14 +3001,12 @@ const skills = {
filter(event) {
return event.skill == "reluanji";
},
- content() {
+ async content(event, trigger, player) {
player.storage.reluanji2 = trigger.card;
if (!player.storage.reluanji) {
player.storage.reluanji = [];
}
- for (var i = 0; i < trigger.cards.length; i++) {
- player.storage.reluanji.add(get.suit(trigger.cards[i]));
- }
+ player.storage.reluanji.addArray(trigger.cards.map(c => get.suit(c)));
},
},
respond: {
@@ -3087,8 +3015,8 @@ const skills = {
filter(event) {
return event.getParent(2).skill == "reluanji";
},
- content() {
- trigger.player.draw();
+ async content(event, trigger, player) {
+ await trigger.player.draw();
},
},
damage: {
@@ -3099,7 +3027,7 @@ const skills = {
filter(event, player) {
return player.storage.reluanji2 && event.card == player.storage.reluanji2;
},
- content() {
+ async content(event, trigger, player) {
delete player.storage.reluanji2;
},
},
@@ -3111,8 +3039,8 @@ const skills = {
filter(event, player) {
return player.storage.reluanji2 && event.card == player.storage.reluanji2;
},
- content() {
- player.draw(trigger.targets.length);
+ async content(event, trigger, player) {
+ await player.draw(trigger.targets.length);
delete player.storage.reluanji2;
},
},
@@ -3135,10 +3063,9 @@ const skills = {
},
skillAnimation: true,
animationColor: "orange",
- content() {
- "step 0";
- var shas = player.getCards("h", "sha");
- var num;
+ async content(event, trigger, player) {
+ const shas = player.getCards("h", "sha");
+ let num;
if (player.hp >= 4 && shas.length >= 3) {
num = 3;
} else if (player.hp >= 3 && shas.length >= 2) {
@@ -3146,39 +3073,37 @@ const skills = {
} else {
num = 1;
}
- var map = {};
- var list = [];
- for (var i = 1; i <= player.hp; i++) {
- var cn = get.cnNumber(i, true);
+ const map = {};
+ const list = [];
+ for (let i = 1; i <= player.hp; i++) {
+ const cn = get.cnNumber(i, true);
map[cn] = i;
list.push(cn);
}
- event.map = map;
player.awakenSkill("qimou");
player.storage.qimou = true;
- player
+ const { result } = await player
.chooseControl(list, function () {
return get.cnNumber(_status.event.goon, true);
})
.set("prompt", "失去任意点体力")
.set("goon", num);
- "step 1";
- var num = event.map[result.control] || 1;
+ num = map[result.control] || 1;
player.storage.qimou2 = num;
- player.loseHp(num);
player.addTempSkill("qimou2");
+ await player.loseHp(num);
},
ai: {
order: 2,
result: {
player(player) {
if (player.hp == 1) return 0;
- var shas = player.getCards("h", "sha");
+ const shas = player.getCards("h", "sha");
if (!shas.length) return 0;
- var card = shas[0];
+ const card = shas[0];
if (!lib.filter.cardEnabled(card, player)) return 0;
if (lib.filter.cardUsable(card, player)) return 0;
- var mindist;
+ let mindist;
if (player.hp >= 4 && shas.length >= 3) {
mindist = 4;
} else if (player.hp >= 3 && shas.length >= 2) {
@@ -3220,13 +3145,12 @@ const skills = {
filter(event, player) {
return event.kuangguCheck && event.num > 0;
},
- direct: true,
+ getIndex(event, player, triggername) {
+ return event.num;
+ },
preHidden: true,
- content() {
- "step 0";
- event.num = trigger.num;
- "step 1";
- var choice;
+ async cost(event, trigger, player) {
+ let choice;
if (
player.isDamaged() &&
get.recoverEffect(player) > 0 &&
@@ -3238,20 +3162,17 @@ const skills = {
} else {
choice = "draw_card";
}
- var next = player.chooseDrawRecover("###" + get.prompt(event.name) + "###摸一张牌或回复1点体力").set("logSkill", event.name);
+ const next = player.chooseDrawRecover("###" + get.prompt("xinkuanggu") + "###摸一张牌或回复1点体力");
next.set("choice", choice);
next.set("ai", function () {
return _status.event.getParent().choice;
});
next.setHiddenSkill("xinkuanggu");
- "step 2";
- if (result.control != "cancel2") {
- event.num--;
- if (event.num > 0 && player.hasSkill("xinkuanggu")) {
- event.goto(1);
- }
- }
+ const control = await next.forResultControl();
+ if (control == "cancel2") return;
+ event.result = { bool: true }; // 好像在content里面不能中断getIndex喵
},
+ async content(event, trigger, player) {},
group: "kuanggu_check",
},
xinliegong: {
@@ -3280,11 +3201,11 @@ const skills = {
if (event.target.hp >= player.hp) return true;
return false;
},
- content() {
+ async content(event, trigger, player) {
if (trigger.target.countCards("h") <= player.countCards("h")) trigger.getParent().directHit.push(trigger.target);
if (trigger.target.hp >= player.hp) {
- var id = trigger.target.playerid;
- var map = trigger.getParent().customArgs;
+ const id = trigger.target.playerid;
+ const map = trigger.getParent().customArgs;
if (!map[id]) map[id] = {};
if (typeof map[id].extraDamage != "number") {
map[id].extraDamage = 0;
@@ -3319,9 +3240,9 @@ const skills = {
filterTarget(card, player, target) {
return target != player && target.inRange(player) && target.countCards("he") > 0;
},
- content() {
- "step 0";
- target
+ async content(event, trigger, player) {
+ const target = event.target;
+ const { result } = await target
.chooseToUse(
function (card, player, event) {
if (get.name(card) != "sha") return false;
@@ -3336,11 +3257,8 @@ const skills = {
return lib.filter.filterTarget.apply(this, arguments);
})
.set("sourcex", player);
- "step 1";
if (result.bool == false && target.countCards("he") > 0) {
player.discardPlayerCard(target, "he", true);
- } else {
- event.finish();
}
},
ai: {
@@ -3375,13 +3293,11 @@ const skills = {
if (player.storage.zhiji) return false;
return player.countCards("h") == 0;
},
- content() {
- "step 0";
+ async content(event, trigger, player) {
player.awakenSkill("zhiji");
- player.chooseDrawRecover(2, true);
- "step 1";
- player.loseMaxHp();
- player.addSkills("reguanxing");
+ await player.chooseDrawRecover(2, true);
+ await player.loseMaxHp();
+ await player.addSkills("reguanxing");
},
},
xiangle: {
@@ -3393,10 +3309,9 @@ const skills = {
filter(event, player) {
return event.card.name == "sha";
},
- content() {
- "step 0";
- var eff = get.effect(player, trigger.card, trigger.player, trigger.player);
- trigger.player
+ async content(event, trigger, player) {
+ const eff = get.effect(player, trigger.card, trigger.player, trigger.player);
+ const { result } = await trigger.player
.chooseToDiscard("享乐:弃置一张基本牌,否则杀对" + get.translation(player) + "无效", function (card) {
return get.type(card) == "basic";
})
@@ -3407,10 +3322,7 @@ const skills = {
return 0;
})
.set("eff", eff);
- "step 1";
- if (result.bool == false) {
- trigger.getParent().excluded.add(player);
- }
+ if (result.bool == false) trigger.getParent().excluded.add(player);
},
ai: {
effect: {
@@ -3418,14 +3330,14 @@ const skills = {
if (card.name == "sha" && get.attitude(player, target) < 0) {
if (_status.event.name == "xiangle") return;
if (get.attitude(player, target) > 0 && current < 0) return "zerotarget";
- var bs = player.getCards("h", { type: "basic" });
+ const bs = player.getCards("h", { type: "basic" });
bs.remove(card);
if (card.cards) bs.removeArray(card.cards);
else bs.removeArray(ui.selected.cards);
if (!bs.length) return "zerotarget";
if (player.hasSkill("jiu") || player.hasSkill("tianxianjiu")) return;
if (bs.length <= 2) {
- for (var i = 0; i < bs.length; i++) {
+ for (let i = 0; i < bs.length; i++) {
if (get.value(bs[i]) < 7) {
return [1, 0, 1, -0.5];
}
@@ -3444,12 +3356,10 @@ const skills = {
filter(event, player) {
return player.countCards("h") > 0 && !player.hasSkill("fangquan3");
},
- direct: true,
preHidden: true,
- content() {
- "step 0";
- var fang = player.countMark("fangquan2") == 0 && player.hp >= 2 && player.countCards("h") <= player.hp + 1;
- player
+ async cost(event, trigger, player) {
+ const fang = player.countMark("fangquan2") == 0 && player.hp >= 2 && player.countCards("h") <= player.hp + 1;
+ event.result = await player
.chooseBool(get.prompt2("fangquan"))
.set("ai", function () {
if (!_status.event.fang) return false;
@@ -3462,48 +3372,47 @@ const skills = {
});
})
.set("fang", fang)
- .setHiddenSkill(event.name);
- "step 1";
- if (result.bool) {
- player.logSkill("fangquan");
- trigger.cancel();
- player.addTempSkill("fangquan2");
- player.addMark("fangquan2", 1, false);
- //player.storage.fangquan=result.targets[0];
- }
+ .setHiddenSkill(event.name)
+ .forResult();
+ },
+ async content(event, trigger, player) {
+ trigger.cancel();
+ player.addTempSkill("fangquan2");
+ player.addMark("fangquan2", 1, false);
+ //player.storage.fangquan=result.targets[0];
},
},
fangquan2: {
trigger: { player: "phaseEnd" },
- forced: true,
- popup: false,
+ locked: true,
+ log: false,
audio: false,
//priority:-50,
onremove: true,
- content() {
- "step 0";
- event.count = player.countMark(event.name);
- player.removeMark(event.name, event.count);
- "step 1";
- event.count--;
- player.chooseToDiscard("是否弃置一张牌并令一名其他角色进行一个额外回合?").set("logSkill", player.name == "re_liushan" ? "refangquan" : "fangquan").ai = function (card) {
+ getIndex(event, player) {
+ return player.countMark("fangquan2") || 1;
+ },
+ async cost(event, trigger, player) {
+ const chooseToDiscard = player.chooseToDiscard("是否弃置一张牌并令一名其他角色进行一个额外回合?");
+ chooseToDiscard.ai = function (card) {
return 20 - get.value(card);
};
- "step 2";
- if (result.bool) {
- player.chooseTarget(true, "请选择进行额外回合的目标角色", lib.filter.notMe).ai = function (target) {
- if (target.hasJudge("lebu") || get.attitude(player, target) <= 0) return -1;
- if (target.isTurnedOver()) return 0.18;
- return get.threaten(target) / Math.sqrt(target.hp + 1) / Math.sqrt(target.countCards("h") + 1);
- };
- } else event.finish();
- "step 3";
- var target = result.targets[0];
- player.line(target, "fire");
+ if (!(await chooseToDiscard.forResultBool())) return;
+ const chooseTarget = player.chooseTarget(true, "请选择进行额外回合的目标角色", lib.filter.notMe);
+ chooseTarget.ai = function (target) {
+ if (target.hasJudge("lebu") || get.attitude(player, target) <= 0) return -1;
+ if (target.isTurnedOver()) return 0.18;
+ return get.threaten(target) / Math.sqrt(target.hp + 1) / Math.sqrt(target.countCards("h") + 1);
+ };
+ event.result = await chooseTarget.forResult();
+ },
+ async content(event, trigger, player) {
+ const [target] = event.targets;
+ player.logSkill(player.name == "re_liushan" ? "refangquan" : "fangquan", event.targets, "fire");
target.markSkillCharacter("fangquan", player, "放权", "进行一个额外回合");
target.insertPhase();
+ player.removeMark("fangquan2");
target.addSkill("fangquan3");
- if (event.count > 0) event.goto(1);
},
},
fangquan3: {
@@ -3511,7 +3420,7 @@ const skills = {
forced: true,
popup: false,
audio: false,
- content() {
+ async content(event, trigger, player) {
player.unmarkSkill("fangquan");
player.removeSkill("fangquan3");
},
@@ -3531,13 +3440,11 @@ const skills = {
filter(event, player) {
return player.isMinHp();
},
- content() {
- "step 0";
+ async content(event, trigger, player) {
player.awakenSkill("ruoyu");
- player.gainMaxHp();
- player.recover();
- "step 1";
- player.addSkills("rejijiang");
+ await player.gainMaxHp();
+ await player.recover();
+ await player.addSkills("rejijiang");
},
},
qiaobian: {
@@ -3548,11 +3455,9 @@ const skills = {
filter(event, player) {
return player.countCards("h") > 0;
},
- direct: true,
preHidden: true,
- content() {
- "step 0";
- var check,
+ async cost(event, trigger, player) {
+ let check,
str = "弃置一张手牌并跳过";
str += ["判定", "摸牌", "出牌", "弃牌"][lib.skill.qiaobian.trigger.player.indexOf(event.triggername)];
str += "阶段";
@@ -3563,13 +3468,13 @@ const skills = {
check = player.countCards("j");
break;
case "phaseDraw":
- var i,
+ let i,
num = 0,
- num2 = 0,
- players = game.filterPlayer();
+ num2 = 0;
+ const players = game.filterPlayer();
for (i = 0; i < players.length; i++) {
if (player != players[i] && players[i].countCards("h")) {
- var att = get.attitude(player, players[i]);
+ const att = get.attitude(player, players[i]);
if (att <= 0) {
num++;
}
@@ -3602,43 +3507,36 @@ const skills = {
check = player.needsToDiscard();
break;
}
- player
+ event.result = await player
.chooseToDiscard(get.prompt("qiaobian"), str, lib.filter.cardDiscardable)
.set("ai", card => {
if (!_status.event.check) return -1;
return 7 - get.value(card);
})
.set("check", check)
- .set("logSkill", "qiaobian")
- .setHiddenSkill("qiaobian");
- "step 1";
- if (result.bool) {
- trigger.cancel();
- game.log(player, "跳过了", "#y" + ["判定", "摸牌", "出牌", "弃牌"][lib.skill.qiaobian.trigger.player.indexOf(event.triggername)] + "阶段");
- if (trigger.name == "phaseUse") {
- if (player.canMoveCard()) player.moveCard();
- event.finish();
- } else if (trigger.name == "phaseDraw") {
- player
- .chooseTarget([1, 2], "获得至多两名角色各一张手牌", function (card, player, target) {
- return target != player && target.countCards("h");
- })
- .set("ai", function (target) {
- return 1 - get.attitude(_status.event.player, target);
- });
- } else event.finish();
- } else event.finish();
- "step 2";
- if (result.bool) {
+ .setHiddenSkill("qiaobian")
+ .forResult();
+ },
+ async content(event, trigger, player) {
+ trigger.cancel();
+ game.log(player, "跳过了", "#y" + ["判定", "摸牌", "出牌", "弃牌"][lib.skill.qiaobian.trigger.player.indexOf(event.triggername)] + "阶段");
+ if (trigger.name == "phaseUse") {
+ if (player.canMoveCard()) await player.moveCard();
+ } else if (trigger.name == "phaseDraw") {
+ const { result } = await player
+ .chooseTarget([1, 2], "获得至多两名角色各一张手牌", function (card, player, target) {
+ return target != player && target.countCards("h");
+ })
+ .set("ai", function (target) {
+ return 1 - get.attitude(_status.event.player, target);
+ });
+ if (!result.bool) return;
result.targets.sortBySeat();
player.line(result.targets, "green");
- event.targets = result.targets;
- if (!event.targets.length) event.finish();
- } else event.finish();
- "step 3";
- player.gainMultiple(event.targets);
- "step 4";
- game.delay();
+ if (!result.targets.length) return;
+ await player.gainMultiple(result.targets);
+ await game.asyncDelay();
+ }
},
ai: { threaten: 3 },
},
@@ -3654,44 +3552,42 @@ const skills = {
filter(event, player) {
if (player == _status.currentPhase) return false;
if (event.name == "gain" && event.player == player) return false;
- var evt = event.getl(player);
+ const evt = event.getl(player);
return evt && evt.cards2 && evt.cards2.length > 0;
},
- content() {
- "step 0";
- var next = player.judge(function (card) {
+ async content(event, trigger, player) {
+ const judge = player.judge(function (card) {
if (get.suit(card) == "heart") return -1;
return 1;
});
- next.judge2 = function (result) {
+ judge.judge2 = function (result) {
return result.bool;
};
if (get.mode() != "guozhan") {
- next.callback = lib.skill.tuntian.callback;
- event.finish();
+ judge.callback = lib.skill.tuntian.callback;
+ return void (await judge);
}
- "step 1";
+ const { result } = await judge;
if (!result.bool || get.position(result.card) != "d") {
//game.cardsDiscard(card);
- event.finish();
return;
}
- event.card = result.card;
- player.chooseBool("是否将" + get.translation(event.card) + "作为“田”置于武将牌上?").ai = function () {
+ const card = result.card;
+ const chooseBool = player.chooseBool("是否将" + get.translation(card) + "作为“田”置于武将牌上?");
+ chooseBool.ai = function () {
return true;
};
- "step 2";
- if (!result.bool && !event.directbool) {
- return;
- }
- player.addToExpansion(event.card, "gain2").gaintag.add("tuntian");
+ const bool = await chooseBool.forResultBool();
+ if (!bool && !event.directbool) return;
+ const addToExpansion = player.addToExpansion(event.card, "gain2");
+ addToExpansion.gaintag.add("tuntian");
+ await addToExpansion;
},
- callback() {
- if (!event.judgeResult.bool) {
- event.finish();
- return;
- }
- player.addToExpansion(event.judgeResult.card, "gain2").gaintag.add("tuntian");
+ async callback(event, trigger, player) {
+ if (!event.judgeResult.bool) return;
+ const next = player.addToExpansion(event.judgeResult.card, "gain2");
+ next.gaintag.add("tuntian");
+ await next;
},
marktext: "田",
intro: {
@@ -3699,7 +3595,7 @@ const skills = {
markcount: "expansion",
},
onremove(player, skill) {
- var cards = player.getExpansions(skill);
+ const cards = player.getExpansions(skill);
if (cards.length) player.loseToDiscardpile(cards);
},
group: "tuntian_dist",
@@ -3709,7 +3605,7 @@ const skills = {
locked: false,
mod: {
globalFrom(from, to, distance) {
- var num = distance - from.getExpansions("tuntian").length;
+ let num = distance - from.getExpansions("tuntian").length;
if (_status.event.skill == "jixi_backup" || _status.event.skill == "gzjixi_backup") num++;
return num;
},
@@ -3773,10 +3669,10 @@ const skills = {
return player.getExpansions("tuntian").length >= 3;
},
derivation: "jixi",
- content() {
+ async content(event, trigger, player) {
player.awakenSkill("zaoxian");
- player.loseMaxHp();
- player.addSkills("jixi");
+ await player.loseMaxHp();
+ await player.addSkills("jixi");
},
ai: {
combo: "tuntian",
@@ -3794,13 +3690,13 @@ const skills = {
return ui.create.dialog("急袭", player.getExpansions("tuntian"), "hidden");
},
filter(button, player) {
- var card = button.link;
+ const card = button.link;
if (!game.checkMod(card, player, "unchanged", "cardEnabled2", player)) return false;
- var evt = _status.event.getParent();
+ const evt = _status.event.getParent();
return evt.filterCard(get.autoViewAs({ name: "shunshou" }, [card]), player, evt);
},
backup(links, player) {
- var skill = _status.event.buttoned;
+ const skill = _status.event.buttoned;
return {
audio: "jixi",
audioname: ["re_dengai", "gz_dengai", "ol_dengai"],
@@ -3845,7 +3741,7 @@ const skills = {
},
locked: false,
frequent: true,
- content() {
+ async content(event, trigger, player) {
player.draw();
},
ai: {
@@ -3873,10 +3769,10 @@ const skills = {
},
forced: true,
//priority:3,
- content() {
+ async content(event, trigger, player) {
player.awakenSkill(event.name);
- player.loseMaxHp();
- player.addSkills(["reyingzi", "gzyinghun"]);
+ await player.loseMaxHp();
+ await player.addSkills(["reyingzi", "gzyinghun"]);
},
ai: {
threaten(player, target) {
@@ -3906,11 +3802,11 @@ const skills = {
//forceaudio:true,
enable: "phaseUse",
prompt() {
- var player = _status.event.player;
- var list = game.filterPlayer(function (target) {
+ const player = _status.event.player;
+ const list = game.filterPlayer(function (target) {
return target.hasZhuSkill("zhiba", player) && player.canCompare(target);
});
- var str = "和" + get.translation(list);
+ let str = "和" + get.translation(list);
if (list.length > 1) str += "中的一人";
str += "进行拼点。若你没赢,其可以获得两张拼点牌。";
return str;
@@ -3929,49 +3825,49 @@ const skills = {
targets[0].logSkill("zhiba");
},
usable: 1,
- content() {
- "step 0";
+ async content(event, trigger, player) {
+ const target = event.target;
if (target.storage.hunzi || target.storage.rehunzi) {
- target
+ const control = await target
.chooseControl("拒绝", "不拒绝")
.set("prompt", "是否拒绝制霸拼点?")
- .set("choice", get.attitude(target, player) <= 0);
- } else {
- event.forced = true;
- }
- "step 1";
+ .set("choice", get.attitude(target, player) <= 0)
+ .forResultControl();
+ if (control == "拒绝") {
+ game.log(target, "拒绝了拼点");
+ target.chat("拒绝");
+ return;
+ }
+ } else event.forced = true;
if (!event.forced && result.control == "拒绝") {
game.log(target, "拒绝了拼点");
target.chat("拒绝");
event.finish();
return;
}
- player
+ const { result } = await player
.chooseToCompare(target, function (card) {
if (card.name == "du") return 20;
- var player = get.owner(card);
- var target = _status.event.getParent().target;
+ const player = get.owner(card);
+ const target = _status.event.getParent().target;
if (player != target && get.attitude(player, target) > 0) {
return -get.number(card);
}
return get.number(card);
})
.set("preserve", "lose");
- "step 2";
if (result.bool == false) {
- var list = [];
+ const list = [];
if (get.position(result.player) == "d") list.push(result.player);
if (get.position(result.target) == "d") list.push(result.target);
- if (!list.length) event.finish();
- else {
- event.list = list;
- target.chooseBool("是否获得" + get.translation(list) + "?").ai = function () {
- return get.value(list) > 0;
- };
- }
- } else event.finish();
- "step 3";
- if (result.bool) target.gain(event.list, "gain2");
+ if (!list.length) return;
+ event.list = list;
+ const next = target.chooseBool("是否获得" + get.translation(list) + "?");
+ next.ai = function () {
+ return get.value(list) > 0;
+ };
+ if (await next.forResultBool()) await target.gain(event.list, "gain2");
+ }
},
ai: {
basic: {
@@ -3982,17 +3878,17 @@ const skills = {
target(player, target) {
if (player.countCards("h", "du") && get.attitude(player, target) < 0) return -1;
if (player.countCards("h") <= player.hp) return 0;
- var maxnum = 0;
- var cards2 = target.getCards("h");
- for (var i = 0; i < cards2.length; i++) {
+ let maxnum = 0;
+ const cards2 = target.getCards("h");
+ for (let i = 0; i < cards2.length; i++) {
if (get.number(cards2[i]) > maxnum) {
maxnum = get.number(cards2[i]);
}
}
if (maxnum > 10) maxnum = 10;
if (maxnum < 5 && cards2.length > 1) maxnum = 5;
- var cards = player.getCards("h");
- for (var i = 0; i < cards.length; i++) {
+ const cards = player.getCards("h");
+ for (let i = 0; i < cards.length; i++) {
if (get.number(cards[i]) < maxnum) return 1;
}
return 0;
@@ -4010,7 +3906,7 @@ const skills = {
return get.type(card) == "equip";
},
check(card) {
- var player = _status.currentPhase;
+ const player = _status.currentPhase;
if (player.countCards("he", { subtype: get.subtype(card) }) > 1) {
return 11 - get.equipValue(card);
}
@@ -4021,8 +3917,8 @@ const skills = {
return player != target && target.canEquip(card);
},
async content(event, trigger, player) {
- event.target.equip(event.cards[0]);
- player.draw();
+ await event.target.equip(event.cards[0]);
+ await player.draw();
},
discard: false,
lose: false,
@@ -4035,7 +3931,7 @@ const skills = {
},
result: {
target(player, target) {
- var card = ui.selected.cards[0];
+ const card = ui.selected.cards[0];
if (card) return get.effect(target, card, target, target);
return 0;
},
@@ -4059,50 +3955,53 @@ const skills = {
},
checkx(event, player, cards, cards2) {
if (cards.length > 2 || get.attitude(player, event.player) > 0) return true;
- for (var i = 0; i < cards2.length; i++) {
+ for (let i = 0; i < cards2.length; i++) {
if (get.value(cards2[i], event.player, "raw") < 0) return true;
}
return false;
},
- direct: true,
preHidden: true,
- content() {
- "step 0";
- var cards = [],
+ async cost(event, trigger, player) {
+ const cards = [],
cards2 = [];
- var target = trigger.player;
+ const target = trigger.player;
game.getGlobalHistory("cardMove", function (evt) {
if (evt.name == "cardsDiscard") {
if (evt.getParent("phaseDiscard") == trigger) {
- var moves = evt.cards.filterInD("d");
+ const moves = evt.cards.filterInD("d");
cards.addArray(moves);
cards2.removeArray(moves);
}
}
if (evt.name == "lose") {
if (evt.type != "discard" || evt.position != ui.discardPile || evt.getParent("phaseDiscard") != trigger) return;
- var moves = evt.cards.filterInD("d");
+ const moves = evt.cards.filterInD("d");
cards.addArray(moves);
if (evt.player == target) cards2.addArray(moves);
else cards2.removeArray(moves);
}
});
- if (!cards2.length) event.finish();
- else if (cards.length == 1) {
+ if (!cards2.length) return;
+ if (cards.length == 1) {
event.card = cards[0];
- player
+ event.result = await player
.chooseBool()
.set("createDialog", [get.prompt("guzheng", target), '点击“确认”以令其收回此牌', cards])
.set("choice", lib.skill.guzheng.checkx(trigger, player, cards, cards2))
.set("ai", function () {
return _status.event.choice;
})
- .setHiddenSkill("guzheng");
+ .setHiddenSkill("guzheng")
+ .forResult();
+ event.result.cost_data = {
+ action: "single",
+ cards: cards,
+ };
} else {
- player
+ event.result = await player
.chooseButton(2, [get.prompt("guzheng", target), '被选择的牌将成为对方收回的牌', cards, [["获得剩余的牌", "放弃剩余的牌"], "tdnodes"]])
.set("filterButton", function (button) {
- var type = typeof button.link;
+ const type = typeof button.link;
if (ui.selected.buttons.length && type == typeof ui.selected.buttons[0].link) return false;
return type == "string" || _status.event.allowed.includes(button.link);
})
@@ -4117,38 +4016,47 @@ const skills = {
}
return 0;
})
- .setHiddenSkill("guzheng");
+ .setHiddenSkill("guzheng")
+ .forResult();
+ event.result.cost_data = {
+ action: "multiple",
+ cards: event.result.links,
+ };
+ }
+ },
+ logTarget: "player",
+ async content(event, trigger, player) {
+ const target = trigger.player;
+ const action = event.cost_data.action;
+ const cards = event.cost_data.cards;
+ if (action != "multiple") {
+ const gain = target.gain(cards[0], "gain2");
+ gain.giver = player;
+ await gain;
+ } else {
+ if (typeof cards[0] != "string") cards.reverse();
+ const [, card] = cards;
+ const gain = target.gain(card, "gain2");
+ gain.giver = player;
+ await gain;
+ if (cards[0] != "获得剩余的牌") return;
}
- "step 1";
- if (result.bool) {
- var target = trigger.player;
- player.logSkill("guzheng", target);
- if (!result.links || !result.links.length) {
- target.gain(card, "gain2").giver = player;
- } else {
- if (typeof result.links[0] != "string") result.links.reverse();
- var card = result.links[1];
- target.gain(card, "gain2").giver = player;
- if (result.links[0] != "获得剩余的牌") event.finish();
- }
- } else event.finish();
- "step 2";
//避免插入结算改变弃牌堆 重新判断一次
- var cards = [];
+ cards.length = 0;
game.getGlobalHistory("cardMove", function (evt) {
if (evt.name == "cardsDiscard") {
if (evt.getParent("phaseDiscard") == trigger) {
- var moves = evt.cards.filterInD("d");
+ const moves = evt.cards.filterInD("d");
cards.addArray(moves);
}
}
if (evt.name == "lose") {
if (evt.type != "discard" || evt.position != ui.discardPile || evt.getParent("phaseDiscard") != trigger) return;
- var moves = evt.cards.filterInD("d");
+ const moves = evt.cards.filterInD("d");
cards.addArray(moves);
}
});
- if (cards.length > 0) player.gain(cards, "gain2");
+ if (cards.length > 0) await player.gain(cards, "gain2");
},
ai: {
threaten: 1.3,
@@ -4162,43 +4070,37 @@ const skills = {
filter(event, player) {
return event.card && event.card.name == "sha" && event.source && event.player.isIn() && player.countCards("he");
},
- direct: true,
checkx(event, player) {
- var att1 = get.attitude(player, event.player);
- var att2 = get.attitude(player, event.source);
+ const att1 = get.attitude(player, event.player);
+ const att2 = get.attitude(player, event.source);
return att1 > 0 && att2 <= 0;
},
preHidden: true,
- content() {
- "step 0";
- var next = player.chooseToDiscard("he", get.prompt2("beige", trigger.player));
- var check = lib.skill.beige.checkx(trigger, player);
+ async cost(event, trigger, player) {
+ const next = player.chooseToDiscard("he", get.prompt2("beige", trigger.player));
+ const check = lib.skill.beige.checkx(trigger, player);
next.set("ai", function (card) {
if (_status.event.goon) return 8 - get.value(card);
return 0;
});
- next.set("logSkill", "beige");
next.set("goon", check);
next.setHiddenSkill("beige");
- "step 1";
- if (result.bool) {
- trigger.player.judge();
- } else {
- event.finish();
- }
- "step 2";
+ event.result = await next.forResult();
+ },
+ async content(event, trigger, player) {
+ const { result } = await trigger.player.judge();
switch (result.suit) {
case "heart":
- trigger.player.recover();
+ await trigger.player.recover();
break;
case "diamond":
- trigger.player.draw(2);
+ await trigger.player.draw(2);
break;
case "club":
- trigger.source.chooseToDiscard("he", 2, true);
+ await trigger.source.chooseToDiscard("he", 2, true);
break;
case "spade":
- trigger.source.turnOver();
+ await trigger.source.turnOver();
break;
}
},
@@ -4218,7 +4120,7 @@ const skills = {
filter(event) {
return event.source && event.source.isIn();
},
- content() {
+ async content(event, trigger, player) {
trigger.source.clearSkills();
},
logTarget: "source",
@@ -4239,6 +4141,7 @@ const skills = {
},
},
},
+ // ---------- 本次分界线喵 ----------
huashen: {
audio: "huashen2",
unique: true,