Merge pull request #1230 from mengxinzxz/PR-Branch

chooseCard添加autochoose,技能bugfix+修改调整
This commit is contained in:
Spmario233 2024-04-19 18:57:50 +08:00 committed by GitHub
commit 6fa6fc7bf4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 46 additions and 30 deletions

View File

@ -1162,7 +1162,7 @@ game.import("character", function () {
var num = get.cardNameLength(event.card); var num = get.cardNameLength(event.card);
return typeof num == "number" && num > 0 && player.countCards("he") > 0; return typeof num == "number" && num > 0 && player.countCards("he") > 0;
}, },
async content(event, trigger, player) { async cost(event, trigger, player) {
var num = get.cardNameLength(trigger.card), var num = get.cardNameLength(trigger.card),
str = ""; str = "";
if (player.getDamagedHp() > 0) if (player.getDamagedHp() > 0)

View File

@ -892,7 +892,7 @@ game.import("character", function () {
game.swapSeat(list[0], list[1], false); game.swapSeat(list[0], list[1], false);
} }
}, toSwapList); }, toSwapList);
if (trigger.name === "phase" && trigger.player !== toSortPlayers[0] && !trigger._finished) { if (trigger.name === "phase" && !trigger.player.isZhu2() && trigger.player !== toSortPlayers[0] && !trigger._finished) {
trigger.finish(); trigger.finish();
trigger._triggered = 5; trigger._triggered = 5;
const evt = toSortPlayers[0].insertPhase(); const evt = toSortPlayers[0].insertPhase();
@ -919,8 +919,9 @@ game.import("character", function () {
audio: 2, audio: 2,
trigger: { player: "phaseAfter" }, trigger: { player: "phaseAfter" },
filter(event, player) { filter(event, player) {
return game.hasPlayer((current) => { return game.hasPlayer(target => {
return current.countCards("h") + player.countCards("h") > 0 && player != current; if(target==player||target.countCards('h')+player.countCards('h')==0) return false;
return get.mode()=='identity'||target.countCards('h')<=player.countCards('h')+1;
}); });
}, },
direct: true, direct: true,
@ -932,9 +933,8 @@ game.import("character", function () {
get.prompt("zhimeng"), get.prompt("zhimeng"),
"与一名其他角色平分手牌", "与一名其他角色平分手牌",
(card, player, target) => { (card, player, target) => {
return ( if(target==player||target.countCards('h')+player.countCards('h')==0) return false;
target.countCards("h") + player.countCards("h") > 0 && player != target return get.mode()=='identity'||target.countCards('h')<=player.countCards('h')+1;
);
} }
) )
.set("ai", (target) => { .set("ai", (target) => {
@ -10842,8 +10842,8 @@ game.import("character", function () {
tamo_faq_info: tamo_faq_info:
"<br><li>Q在一号位不为主公的情况下〖榻谟〗如何结算</li><li>A该角色可以正常进行座次交换。若受此技能影响导致一号位角色发生了变化则以排列后的一号位角色为起始角色开始本局游戏。</li>", "<br><li>Q在一号位不为主公的情况下〖榻谟〗如何结算</li><li>A该角色可以正常进行座次交换。若受此技能影响导致一号位角色发生了变化则以排列后的一号位角色为起始角色开始本局游戏。</li>",
zhimeng: "智盟", zhimeng: "智盟",
zhimeng_info: zhimeng_info_identity:'回合结束后,你可以选择一名其他角色。若如此做,你与其将各自所有手牌置于处理区,然后你随机获得这些牌中的一半(向上取整),其获得剩余的牌。',
"回合结束后,你可以与一名其他角色将各自所有手牌置于处理区,然后你随机获得这些牌中的一半(向上取整),其获得剩余的牌。", zhimeng_info:'回合结束后你可以选择一名手牌数不大于Y的其他角色Y为你的手牌数+1。若如此做你与其将各自所有手牌置于处理区,然后你随机获得这些牌中的一半(向上取整),其获得剩余的牌。',
shen_xuzhu: "神许褚", shen_xuzhu: "神许褚",
shen_xuzhu_prefix: "神", shen_xuzhu_prefix: "神",
zhengqing: "争擎", zhengqing: "争擎",

View File

@ -1913,10 +1913,9 @@ game.import("character", function () {
if (name == "damageSource" && player.getHistory("sourceDamage").indexOf(event) != 0) if (name == "damageSource" && player.getHistory("sourceDamage").indexOf(event) != 0)
return false; return false;
return game.hasPlayer((target) => { return game.hasPlayer((target) => {
if (get.mode() != "doudizhu") { const num = (get.mode() == 'doudizhu' ? 1 : 2);
if (name == "damageEnd" && get.distance(player, target) <= 2) return false; if (name == "damageEnd" && get.distance(player, target) <= num) return false;
if (name == "damageSource" && get.distance(player, target) > 2) return false; if (name == "damageSource" && get.distance(player, target) > num) return false;
}
const zhoufa = player.storage.zhoulin_zhoufa; const zhoufa = player.storage.zhoulin_zhoufa;
if (!zhoufa) return true; if (!zhoufa) return true;
if (zhoufa == "豹" || zhoufa == "兔") return true; if (zhoufa == "豹" || zhoufa == "兔") return true;
@ -1937,7 +1936,7 @@ game.import("character", function () {
: "令其随机执行一个效果"; : "令其随机执行一个效果";
const nodoudizhu = const nodoudizhu =
get.mode() == "doudizhu" get.mode() == "doudizhu"
? "" ? "距离" + (event.triggername == "damageEnd" ? "" : "不") + "大于1的"
: "距离" + (event.triggername == "damageEnd" ? "" : "不") + "大于2的"; : "距离" + (event.triggername == "damageEnd" ? "" : "不") + "大于2的";
const { const {
result: { bool, targets }, result: { bool, targets },
@ -1947,12 +1946,9 @@ game.import("character", function () {
"选择一名" + nodoudizhu + "角色," + str, "选择一名" + nodoudizhu + "角色," + str,
(card, player, target) => { (card, player, target) => {
const name = _status.event.triggername; const name = _status.event.triggername;
if (get.mode() != "doudizhu") { const num = (get.mode() == 'doudizhu' ? 1 : 2);
if (name == "damageEnd" && get.distance(player, target) <= 2) if (name == "damageEnd" && get.distance(player, target) <= num) return false;
return false; if (name == "damageSource" && get.distance(player, target) > num) return false;
if (name == "damageSource" && get.distance(player, target) > 2)
return false;
}
const zhoufa = player.storage.zhoulin_zhoufa; const zhoufa = player.storage.zhoulin_zhoufa;
if (!zhoufa) return true; if (!zhoufa) return true;
if (zhoufa == "豹" || zhoufa == "兔") return true; if (zhoufa == "豹" || zhoufa == "兔") return true;
@ -20049,7 +20045,7 @@ game.import("character", function () {
}, },
shoufa: function (player) { shoufa: function (player) {
const zhoufa = player.storage.zhoulin_zhoufa; const zhoufa = player.storage.zhoulin_zhoufa;
const nodoudizhu = get.mode() == "doudizhu" ? "" : "与你距离大于/不大于2的"; const nodoudizhu = get.mode() == "doudizhu" ? "与你距离大于/不大于1的" : "与你距离大于/不大于2的";
if (!zhoufa) if (!zhoufa)
return ( return (
"当你受到伤害后/于一回合首次造成伤害后,你可以选择一名" + "当你受到伤害后/于一回合首次造成伤害后,你可以选择一名" +
@ -21163,7 +21159,7 @@ game.import("character", function () {
shoufa_info: shoufa_info:
"当你受到伤害后/于一回合首次造成伤害后,你可以选择一名与你距离大于/不大于2的角色令其随机执行以下一项令其受到1点无来源伤害你随机获得其一张牌你随机弃置其装备区的一张牌令其摸一张牌。", "当你受到伤害后/于一回合首次造成伤害后,你可以选择一名与你距离大于/不大于2的角色令其随机执行以下一项令其受到1点无来源伤害你随机获得其一张牌你随机弃置其装备区的一张牌令其摸一张牌。",
shoufa_info_doudizhu: shoufa_info_doudizhu:
"当你受到伤害后/于一回合首次造成伤害后,你可以选择一名角色令其随机执行以下一项令其受到1点无来源伤害你随机获得其一张牌你随机弃置其装备区的一张牌令其摸一张牌。", "当你受到伤害后/于一回合首次造成伤害后,你可以选择一名与你距离大于/不大于1的角色令其随机执行以下一项令其受到1点无来源伤害你随机获得其一张牌你随机弃置其装备区的一张牌令其摸一张牌。",
yuxiang: "御象", yuxiang: "御象",
yuxiang_info: yuxiang_info:
"锁定技,若你有护甲值,则:①你计算与其他角色的距离-1其他角色计算与你的距离+1②当你受到火焰伤害时此伤害+1。", "锁定技,若你有护甲值,则:①你计算与其他角色的距离-1其他角色计算与你的距离+1②当你受到火焰伤害时此伤害+1。",

View File

@ -890,7 +890,7 @@ game.import("character", function () {
} = await player } = await player
.chooseTarget( .chooseTarget(
get.prompt("sbjieming"), get.prompt("sbjieming"),
`令一名角色摸张牌,然后其可以弃置任意张牌。若其弃置的牌数不大于${get.cnNumber( `令一名角色摸张牌,然后其可以弃置任意张牌。若其弃置的牌数不大于${get.cnNumber(
num num
)}你失去1点体力` )}你失去1点体力`
) )
@ -921,7 +921,7 @@ game.import("character", function () {
if (!bool) return; if (!bool) return;
const target = targets[0]; const target = targets[0];
player.logSkill("sbjieming", target); player.logSkill("sbjieming", target);
await target.draw(3); await target.draw(4);
num = Math.max(1, player.getDamagedHp()); num = Math.max(1, player.getDamagedHp());
const { const {
result: { bool: bool2, cards }, result: { bool: bool2, cards },
@ -8984,7 +8984,7 @@ game.import("character", function () {
"出牌阶段限一次。你可以选择两名有牌的其他角色你与这些角色同时将任意张牌扣置于武将牌上。若你以此法扣置的牌唯一最少则扣置牌最多的其他角色获得你扣置的牌且这些角色获得各自扣置的牌否则这两名角色中扣置牌较多的角色对较少的角色造成1点伤害获得你扣置的牌然后这些角色将各自扣置的牌置入弃牌堆若这两名角色扣置的牌数相同视为与你逆时针最近座次的角色扣置牌较多。", "出牌阶段限一次。你可以选择两名有牌的其他角色你与这些角色同时将任意张牌扣置于武将牌上。若你以此法扣置的牌唯一最少则扣置牌最多的其他角色获得你扣置的牌且这些角色获得各自扣置的牌否则这两名角色中扣置牌较多的角色对较少的角色造成1点伤害获得你扣置的牌然后这些角色将各自扣置的牌置入弃牌堆若这两名角色扣置的牌数相同视为与你逆时针最近座次的角色扣置牌较多。",
sbjieming: "节命", sbjieming: "节命",
sbjieming_info: sbjieming_info:
"当你受到伤害后,你可以令一名角色摸张牌然后其可以弃置任意张牌。若其弃置的牌数不大于X你失去1点体力X为你已损失的体力值至少为1。", "当你受到伤害后,你可以令一名角色摸张牌然后其可以弃置任意张牌。若其弃置的牌数不大于X你失去1点体力X为你已损失的体力值至少为1。",
sb_xiahoudun: "谋夏侯惇", sb_xiahoudun: "谋夏侯惇",
sb_xiahoudun_prefix: "谋", sb_xiahoudun_prefix: "谋",
sbganglie: "刚烈", sbganglie: "刚烈",

View File

@ -999,7 +999,7 @@ game.import("character", function () {
list.push( list.push(
cards.reduce((sum, card) => { cards.reduce((sum, card) => {
const juedou = get.autoViewAs({ name: "juedou" }, [card]); const juedou = get.autoViewAs({ name: "juedou" }, [card]);
return sum + get.effect(target, card, player, player); return sum + get.effect(target, juedou, player, player);
}, 0) }, 0)
); );
} }
@ -1030,7 +1030,7 @@ game.import("character", function () {
}) })
.reduce((num, card) => { .reduce((num, card) => {
const juedou = get.autoViewAs({ name: "juedou" }, [card]); const juedou = get.autoViewAs({ name: "juedou" }, [card]);
return num + get.effect(player, card, source, player); return num + get.effect(player, juedou, source, player);
}, 0); }, 0);
}; };
return controls.sort( return controls.sort(

View File

@ -2448,7 +2448,7 @@ game.import("character", function () {
} = await player.chooseButton(dialog, true).set("ai", (button) => { } = await player.chooseButton(dialog, true).set("ai", (button) => {
const player = get.event("player"), const player = get.event("player"),
target = get.event().getParent().targets[0]; target = get.event().getParent().targets[0];
return get.value(card, player) * get.value(card, target) * (1 + Math.random()); return get.value(button.link, player) * get.value(button.link, target) * (1 + Math.random());
}); });
if (bool) { if (bool) {
await player.gain(links, target, "giveAuto", "bySelf"); await player.gain(links, target, "giveAuto", "bySelf");

View File

@ -5296,6 +5296,16 @@ export const Content = {
bool: true, bool: true,
links: [], links: [],
}; };
} else if (event.autochoose()) {
event.result = {
bool: true,
autochoose: true,
cards: player.getCards(event.position),
confirm: "ok",
buttons: [],
targets: [],
links: [],
};
} else { } else {
if (event.isMine()) { if (event.isMine()) {
game.check(); game.check();

View File

@ -4522,7 +4522,9 @@ export class Player extends HTMLDivElement {
next.autochoose = function () { next.autochoose = function () {
if (!this.forced) return false; if (!this.forced) return false;
if (typeof this.selectCard == "function") return false; if (typeof this.selectCard == "function") return false;
if (this.complexCard || this.complexSelect || this.filterOk) return false;
var cards = this.player.getCards(this.position); var cards = this.player.getCards(this.position);
if (cards.some(card => !this.filterCard(card, this))) return false;
var num = cards.length; var num = cards.length;
for (var i = 0; i < cards.length; i++) { for (var i = 0; i < cards.length; i++) {
if (!lib.filter.cardDiscardable(cards[i], this.player, this)) num--; if (!lib.filter.cardDiscardable(cards[i], this.player, this)) num--;
@ -4776,6 +4778,14 @@ export class Player extends HTMLDivElement {
if (next.filterCard == undefined) next.filterCard = lib.filter.all; if (next.filterCard == undefined) next.filterCard = lib.filter.all;
if (next.selectCard == undefined) next.selectCard = [1, 1]; if (next.selectCard == undefined) next.selectCard = [1, 1];
if (next.ai == undefined) next.ai = get.unuseful3; if (next.ai == undefined) next.ai = get.unuseful3;
next.autochoose = function () {
if (!this.forced) return false;
if (typeof this.selectCard == "function") return false;
if (this.complexCard || this.complexSelect || this.filterOk) return false;
var cards = this.player.getCards(this.position);
if (cards.some(card => !this.filterCard(card, this))) return false;
return get.select(this.selectCard)[0] >= this.player.countCards(this.position);
};
next.setContent("chooseCard"); next.setContent("chooseCard");
next._args = Array.from(arguments); next._args = Array.from(arguments);
return next; return next;

View File

@ -349,7 +349,7 @@ export const otherMenu = function (/** @type { boolean | undefined } */ connectM
} }
} }
const str = const str =
versionResult > 0 versionResult < 0
? `有新版本${description.name}可用,是否下载?` ? `有新版本${description.name}可用,是否下载?`
: `本地版本${lib.version}高于或等于github版本${description.name},是否强制下载?`; : `本地版本${lib.version}高于或等于github版本${description.name},是否强制下载?`;
const str2 = description.body; const str2 = description.body;
@ -454,7 +454,7 @@ export const otherMenu = function (/** @type { boolean | undefined } */ connectM
const result = await asyncFilter(files.flat(), async v => { const result = await asyncFilter(files.flat(), async v => {
return game.promises.readFile(v.path).then(data => { return game.promises.readFile(v.path).then(data => {
return v.size != data.byteLength; return v.size != data.byteLength;
}) }).catch(()=>true)
}).then(arr => arr.map((v) => v.path)); }).then(arr => arr.map((v) => v.path));
console.log("需要更新的文件有:", result); console.log("需要更新的文件有:", result);