From 9287cd33c035e419fb46653b74b944088b780054 Mon Sep 17 00:00:00 2001 From: 157 <3619242020@qq.com> Date: Sat, 11 May 2024 15:03:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86ai.effect(card,player,target)=E5=86=99?= =?UTF-8?q?=E6=B3=95=E6=94=B9=E4=B8=BA=E9=80=9A=E7=94=A8=E5=86=99=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- card/swd.js | 14 +++++++----- character/diy/skill.js | 8 ++++--- character/refresh/skill.js | 44 ++++++++++++++++++++------------------ character/sb/skill.js | 22 ++++++++++--------- character/swd.js | 30 ++++++++++++++------------ character/yijiang/skill.js | 8 ++++--- noname/get/index.js | 28 +++++++++++++----------- 7 files changed, 85 insertions(+), 69 deletions(-) diff --git a/card/swd.js b/card/swd.js index 37f12d477..8db3fad3d 100644 --- a/card/swd.js +++ b/card/swd.js @@ -5030,8 +5030,10 @@ game.import("card", function () { player.updateMarks(); }, ai: { - effect: function (card, player, target) { - if (get.tag(card, "damage") && !target.hujia) return [1, 0.5]; + effect: { + target(card, player, target) { + if (get.tag(card, "damage") && !target.hujia) return [1, 0.5]; + } }, }, intro: { @@ -5133,9 +5135,11 @@ game.import("card", function () { player.recover(trigger.num); }, ai: { - effect: function (card) { - if (get.tag(card, "thunderDamage")) return [0, 2]; - }, + effect: { + target(card) { + if (get.tag(card, "thunderDamage")) return [0, 2]; + }, + } }, }, guiyanfadao: { diff --git a/character/diy/skill.js b/character/diy/skill.js index ced47b971..93a7d420c 100644 --- a/character/diy/skill.js +++ b/character/diy/skill.js @@ -6728,9 +6728,11 @@ const skills = { player.draw(); }, ai: { - effect(card, player, target) { - if (get.color(card) == "red") return [1, 1]; - }, + effect: { + target_use(card, player, target) { + if (get.color(card) == "red") return [1, 1]; + }, + } }, }, zaiqix: { diff --git a/character/refresh/skill.js b/character/refresh/skill.js index 245efdf19..c9196c012 100644 --- a/character/refresh/skill.js +++ b/character/refresh/skill.js @@ -14582,27 +14582,29 @@ const skills = { }, ai: { maihp: true, - effect: function (card, player, target) { - if (get.tag(card, "damage")) { - if (player.hasSkillTag("jueqing", false, target)) return [1, 1]; - return 1.2; - } - if (get.tag(card, "loseHp")) { - if (target.hp <= 1) return; - var using = target.isPhaseUsing(); - if (target.hp <= 2) return [1, player.countCards("h") <= 1 && using ? 3 : 0]; - if (using && target.countCards("h", { name: "sha", color: "red" })) return [1, 3]; - return [ - 1, - target.countCards("h") <= target.hp || - (using && - game.hasPlayer(function (current) { - return current != player && get.attitude(player, current) < 0 && player.inRange(current); - })) - ? 3 - : 2, - ]; - } + effect: { + target(card, player, target) { + if (get.tag(card, "damage")) { + if (player.hasSkillTag("jueqing", false, target)) return [1, 1]; + return 1.2; + } + if (get.tag(card, "loseHp")) { + if (target.hp <= 1) return; + var using = target.isPhaseUsing(); + if (target.hp <= 2) return [1, player.countCards("h") <= 1 && using ? 3 : 0]; + if (using && target.countCards("h", { name: "sha", color: "red" })) return [1, 3]; + return [ + 1, + target.countCards("h") <= target.hp || + (using && + game.hasPlayer(function (current) { + return current != player && get.attitude(player, current) < 0 && player.inRange(current); + })) + ? 3 + : 2, + ]; + } + }, }, }, }, diff --git a/character/sb/skill.js b/character/sb/skill.js index 508e60fa3..10192e2ee 100644 --- a/character/sb/skill.js +++ b/character/sb/skill.js @@ -6090,16 +6090,18 @@ const skills = { }, ai: { maihp: true, - effect: function (card, player, target) { - if (get.tag(card, "damage")) { - if (player.hasSkillTag("jueqing", false, target)) return [1, 1]; - return 1.2; - } - if (get.tag(card, "loseHp")) { - if (target.hp <= 1 || target.hujia >= 5) return; - return [1, 1]; - } - }, + effect: { + target(card, player, target) { + if (get.tag(card, "damage")) { + if (player.hasSkillTag("jueqing", false, target)) return [1, 1]; + return 1.2; + } + if (get.tag(card, "loseHp")) { + if (target.hp <= 1 || target.hujia >= 5) return; + return [1, 1]; + } + }, + } }, }, }, diff --git a/character/swd.js b/character/swd.js index ab7437725..96e1bdfb2 100644 --- a/character/swd.js +++ b/character/swd.js @@ -3834,22 +3834,24 @@ game.import("character", function () { ai: { maixie: true, maixie_hp: true, - effect: function (card, player, target) { - if (get.tag(card, "damage")) { - if (player.hasSkillTag("jueqing", false, target)) return [1, -0.5]; - if (!target.hasFriend()) { - if (get.mode() == "guozhan") { - if (!player.hasFriend()) return; - } else { - return; + effect: { + target(card, player, target) { + if (get.tag(card, "damage")) { + if (player.hasSkillTag("jueqing", false, target)) return [1, -0.5]; + if (!target.hasFriend()) { + if (get.mode() == "guozhan") { + if (!player.hasFriend()) return; + } else { + return; + } } + if (target.countCards("h") > 2 || target.countCards("e", { color: "black" })) { + return [1, 0, 0, -1]; + } + return [1, -0.5]; } - if (target.countCards("h") > 2 || target.countCards("e", { color: "black" })) { - return [1, 0, 0, -1]; - } - return [1, -0.5]; - } - }, + }, + } }, }, xuanyuan: { diff --git a/character/yijiang/skill.js b/character/yijiang/skill.js index 6c459f9ac..01ea930e7 100644 --- a/character/yijiang/skill.js +++ b/character/yijiang/skill.js @@ -11102,9 +11102,11 @@ const skills = { player.draw(); }, ai: { - effect: function (card, player, target) { - if (get.type(card) == "trick") return [1, 1]; - }, + effect: { + target_use(card, player, target) { + if (get.type(card) == "trick" && player !== target) return [1, 1]; + }, + } }, }, shenxing: { diff --git a/noname/get/index.js b/noname/get/index.js index 134ca0a60..022351f94 100644 --- a/noname/get/index.js +++ b/noname/get/index.js @@ -4587,20 +4587,10 @@ export class Get { game.expandSkills(skills2); for (var i = 0; i < skills2.length; i++) { temp2 = get.info(skills2[i]).ai; - if (temp2 && temp2.threaten) temp3 = cache.delegate(temp2).threaten; + if (!temp2) continue; + if (temp2.threaten) temp3 = cache.delegate(temp2).threaten; else temp3 = undefined; - if (temp2 && typeof temp2.effect == "function") { - if ( - !player.hasSkillTag("ignoreSkill", true, { - card: card, - target: target, - skill: skills2[i], - isLink: isLink, - }) - ) - temp2 = cache.delegate(temp2).effect(card, player, target, result2, isLink); - else temp2 = undefined; - } else if (temp2 && typeof temp2.effect == "object" && typeof temp2.effect.target == "function") { + if (typeof temp2.effect == "object" && typeof temp2.effect.target == "function") { if ( !player.hasSkillTag("ignoreSkill", true, { card: card, @@ -4611,6 +4601,18 @@ export class Get { ) temp2 = cache.delegate(temp2.effect).target(card, player, target, result2, isLink); else temp2 = undefined; + } else if (typeof temp2.effect == "function") { //考虑废弃 + console.log("此写法使用频率极低且影响代码可读性,不建议使用"); + if ( + !player.hasSkillTag("ignoreSkill", true, { + card: card, + target: target, + skill: skills2[i], + isLink: isLink, + }) + ) + temp2 = cache.delegate(temp2).effect(card, player, target, result2, isLink); + else temp2 = undefined; } else temp2 = undefined; if (typeof temp2 == "object") { if (temp2.length == 2 || temp2.length == 4) {