将ai.effect(card,player,target)写法改为通用写法

This commit is contained in:
157 2024-05-11 15:03:05 +08:00
parent d9727e1104
commit 9287cd33c0
7 changed files with 85 additions and 69 deletions

View File

@ -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: {

View File

@ -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: {

View File

@ -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,
];
}
},
},
},
},

View File

@ -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];
}
},
}
},
},
},

View File

@ -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: {

View File

@ -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: {

View File

@ -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) {