game.asyncDraw改为async函数,修改周妃的良姻技能作为测试
This commit is contained in:
parent
80a0b2df63
commit
a2d78f873b
|
@ -458,9 +458,8 @@ game.import("character", function () {
|
||||||
},
|
},
|
||||||
direct: true,
|
direct: true,
|
||||||
usable: 1,
|
usable: 1,
|
||||||
content() {
|
async content(event, trigger, player) {
|
||||||
"step 0";
|
const { result: { bool, targets } } = await player
|
||||||
player
|
|
||||||
.chooseTarget(
|
.chooseTarget(
|
||||||
get.prompt("olliangyin"),
|
get.prompt("olliangyin"),
|
||||||
"选择一名其他角色,你与其各摸一张牌",
|
"选择一名其他角色,你与其各摸一张牌",
|
||||||
|
@ -479,32 +478,32 @@ game.import("character", function () {
|
||||||
return 3 * att;
|
return 3 * att;
|
||||||
return att;
|
return att;
|
||||||
});
|
});
|
||||||
"step 1";
|
if (bool) {
|
||||||
if (result.bool) {
|
const target = targets[0];
|
||||||
var target = result.targets[0];
|
|
||||||
event.target = target;
|
event.target = target;
|
||||||
player.logSkill("olliangyin", target);
|
player.logSkill("olliangyin", target);
|
||||||
game.asyncDraw([player, target].sortBySeat());
|
await game.asyncDraw([player, target].sortBySeat());
|
||||||
} else event.finish();
|
}
|
||||||
"step 2";
|
else return;
|
||||||
game.delayx();
|
await game.asyncDelayx();
|
||||||
var num = player.getExpansions("olkongsheng").length;
|
let num = player.getExpansions("olkongsheng").length;
|
||||||
var check = function (player) {
|
let check = player => {
|
||||||
if (!player.isIn() || player.isHealthy()) return false;
|
if (!player.isIn() || player.isHealthy()) return false;
|
||||||
return player.countCards("h") == num;
|
return player.countCards("h") == num;
|
||||||
};
|
};
|
||||||
|
const { target } = event;
|
||||||
if (check(player) || check(target)) {
|
if (check(player) || check(target)) {
|
||||||
var choiceList = [
|
const choiceList = [
|
||||||
"令自己回复1点体力",
|
"令自己回复1点体力",
|
||||||
"令" + get.translation(target) + "回复1点体力",
|
"令" + get.translation(target) + "回复1点体力",
|
||||||
];
|
];
|
||||||
var choices = [];
|
const choices = [];
|
||||||
if (check(player)) choices.push("选项一");
|
if (check(player)) choices.push("选项一");
|
||||||
else choiceList[0] = '<span style="opacity:0.5">' + choiceList[0] + "</span>";
|
else choiceList[0] = '<span style="opacity:0.5">' + choiceList[0] + "</span>";
|
||||||
if (check(target)) choices.push("选项二");
|
if (check(target)) choices.push("选项二");
|
||||||
else choiceList[1] = '<span style="opacity:0.5">' + choiceList[1] + "</span>";
|
else choiceList[1] = '<span style="opacity:0.5">' + choiceList[1] + "</span>";
|
||||||
choices.push("cancel2");
|
choices.push("cancel2");
|
||||||
player
|
const { result : { control } } = await player
|
||||||
.chooseControl(choices)
|
.chooseControl(choices)
|
||||||
.set("choiceList", choiceList)
|
.set("choiceList", choiceList)
|
||||||
.set("prompt", "良姻:是否令一名角色回复体力?")
|
.set("prompt", "良姻:是否令一名角色回复体力?")
|
||||||
|
@ -520,10 +519,9 @@ game.import("character", function () {
|
||||||
if (eff2 > 0) return "选项二";
|
if (eff2 > 0) return "选项二";
|
||||||
return "cancel2";
|
return "cancel2";
|
||||||
});
|
});
|
||||||
} else event.finish();
|
if (control == "选项一") await player.recover();
|
||||||
"step 3";
|
else if (control == "选项二") await target.recover();
|
||||||
if (result.control == "选项一") player.recover();
|
}
|
||||||
else if (result.control == "选项二") target.recover();
|
|
||||||
},
|
},
|
||||||
group: "olliangyin_gain",
|
group: "olliangyin_gain",
|
||||||
subSkill: {
|
subSkill: {
|
||||||
|
@ -547,90 +545,86 @@ game.import("character", function () {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
usable: 1,
|
usable: 1,
|
||||||
content() {
|
async content(event, trigger, player) {
|
||||||
"step 0";
|
|
||||||
if (
|
if (
|
||||||
!player.countCards("he") ||
|
!player.countCards("he") ||
|
||||||
!game.hasPlayer(function (current) {
|
!game.hasPlayer(current => current != player &&
|
||||||
return current != player && current.countCards("he") > 0;
|
current.countCards("he") > 0)
|
||||||
})
|
) return;
|
||||||
)
|
const { result: { bool, targets, cards } } = await player.chooseCardTarget({
|
||||||
event.finish();
|
prompt: get.prompt("olliangyin"),
|
||||||
else
|
prompt2: "弃置一张牌,并令一名其他角色也弃置一张牌",
|
||||||
player.chooseCardTarget({
|
position: "he",
|
||||||
prompt: get.prompt("olliangyin"),
|
filterCard: lib.filter.cardDiscardable,
|
||||||
prompt2: "弃置一张牌,并令一名其他角色也弃置一张牌",
|
filterTarget(card, player, target) {
|
||||||
position: "he",
|
return target != player && target.countCards("he") > 0;
|
||||||
filterCard: lib.filter.cardDiscardable,
|
},
|
||||||
filterTarget(card, player, target) {
|
ai1(card) {
|
||||||
return target != player && target.countCards("he") > 0;
|
let player = _status.event.player;
|
||||||
},
|
if (_status.event.me) {
|
||||||
ai1(card) {
|
if (get.position(card) === _status.event.me)
|
||||||
let player = _status.event.player;
|
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 5 - get.value(card);
|
||||||
return 0;
|
},
|
||||||
}
|
ai2(target) {
|
||||||
return 5 - get.value(card);
|
let player = _status.event.player,
|
||||||
},
|
att = get.attitude(player, target);
|
||||||
ai2(target) {
|
if (att > 0 && (_status.event.me || target.isHealthy())) return -att;
|
||||||
let player = _status.event.player,
|
if (
|
||||||
att = get.attitude(player, target);
|
att > 0 &&
|
||||||
if (att > 0 && (_status.event.me || target.isHealthy())) return -att;
|
(target.countCards("he") > target.hp ||
|
||||||
if (
|
target.hasCard(function (card) {
|
||||||
att > 0 &&
|
return get.value(card, target) <= 0;
|
||||||
(target.countCards("he") > target.hp ||
|
}, "e"))
|
||||||
target.hasCard(function (card) {
|
)
|
||||||
return get.value(card, target) <= 0;
|
return att;
|
||||||
}, "e"))
|
return -att;
|
||||||
)
|
},
|
||||||
return att;
|
me: (() => {
|
||||||
return -att;
|
if (
|
||||||
},
|
player.isHealthy() ||
|
||||||
me: (function () {
|
get.recoverEffect(player, player, _status.event.player) <= 0
|
||||||
if (
|
)
|
||||||
player.isHealthy() ||
|
|
||||||
get.recoverEffect(player, player, _status.event.player) <= 0
|
|
||||||
)
|
|
||||||
return false;
|
|
||||||
let ph = player.countCards("h"),
|
|
||||||
num = player.getExpansions("olkongsheng").length;
|
|
||||||
if (ph === num) {
|
|
||||||
if (player.hasSkillTag("noh")) return "h";
|
|
||||||
return "e";
|
|
||||||
}
|
|
||||||
if (ph - 1 === num) return "h";
|
|
||||||
return false;
|
return false;
|
||||||
})(),
|
let ph = player.countCards("h"),
|
||||||
});
|
num = player.getExpansions("olkongsheng").length;
|
||||||
"step 1";
|
if (ph === num) {
|
||||||
if (result.bool) {
|
if (player.hasSkillTag("noh")) return "h";
|
||||||
var target = result.targets[0];
|
return "e";
|
||||||
|
}
|
||||||
|
if (ph - 1 === num) return "h";
|
||||||
|
return false;
|
||||||
|
})(),
|
||||||
|
});
|
||||||
|
if (bool) {
|
||||||
|
const target = targets[0];
|
||||||
event.target = target;
|
event.target = target;
|
||||||
player.logSkill("olliangyin_gain", target);
|
player.logSkill("olliangyin_gain", target);
|
||||||
player.discard(result.cards);
|
await player.discard(cards);
|
||||||
target.chooseToDiscard("he", true);
|
await target.chooseToDiscard("he", true);
|
||||||
} else event.finish();
|
}
|
||||||
"step 2";
|
else return;
|
||||||
game.delayx();
|
await game.asyncDelayx();
|
||||||
var num = player.getExpansions("olkongsheng").length;
|
let num = player.getExpansions("olkongsheng").length;
|
||||||
var check = function (player) {
|
let check = player => {
|
||||||
if (!player.isIn() || player.isHealthy()) return false;
|
if (!player.isIn() || player.isHealthy()) return false;
|
||||||
return player.countCards("h") == num;
|
return player.countCards("h") == num;
|
||||||
};
|
};
|
||||||
|
const { target } = event;
|
||||||
if (check(player) || check(target)) {
|
if (check(player) || check(target)) {
|
||||||
var choiceList = [
|
const choiceList = [
|
||||||
"令自己回复1点体力",
|
"令自己回复1点体力",
|
||||||
"令" + get.translation(target) + "回复1点体力",
|
"令" + get.translation(target) + "回复1点体力",
|
||||||
];
|
];
|
||||||
var choices = [];
|
const choices = [];
|
||||||
if (check(player)) choices.push("选项一");
|
if (check(player)) choices.push("选项一");
|
||||||
else choiceList[0] = '<span style="opacity:0.5">' + choiceList[0] + "</span>";
|
else choiceList[0] = '<span style="opacity:0.5">' + choiceList[0] + "</span>";
|
||||||
if (check(target)) choices.push("选项二");
|
if (check(target)) choices.push("选项二");
|
||||||
else choiceList[1] = '<span style="opacity:0.5">' + choiceList[1] + "</span>";
|
else choiceList[1] = '<span style="opacity:0.5">' + choiceList[1] + "</span>";
|
||||||
choices.push("cancel2");
|
choices.push("cancel2");
|
||||||
player
|
const { result: { control } } = await player
|
||||||
.chooseControl(choices)
|
.chooseControl(choices)
|
||||||
.set("choiceList", choiceList)
|
.set("choiceList", choiceList)
|
||||||
.set("prompt", "良姻:是否令一名角色回复体力?")
|
.set("prompt", "良姻:是否令一名角色回复体力?")
|
||||||
|
@ -648,10 +642,9 @@ game.import("character", function () {
|
||||||
if (eff2 > 0) return "选项二";
|
if (eff2 > 0) return "选项二";
|
||||||
return "cancel2";
|
return "cancel2";
|
||||||
});
|
});
|
||||||
} else event.finish();
|
if (control == "选项一") await player.recover();
|
||||||
"step 3";
|
else if (control == "选项二") await target.recover();
|
||||||
if (result.control == "选项一") player.recover();
|
}
|
||||||
else if (result.control == "选项二") target.recover();
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -7491,16 +7491,17 @@ export class Game {
|
||||||
* @param { { drawDeck: boolean } } [drawDeck]
|
* @param { { drawDeck: boolean } } [drawDeck]
|
||||||
* @param { boolean } [bottom]
|
* @param { boolean } [bottom]
|
||||||
*/
|
*/
|
||||||
asyncDraw(players, num, drawDeck, bottom) {
|
async asyncDraw(players, num, drawDeck, bottom) {
|
||||||
return players.forEach((value, index) => {
|
for (let index = 0; index < players.length; index++) {
|
||||||
|
const value = players[index];
|
||||||
let num2 = 1;
|
let num2 = 1;
|
||||||
if (typeof num == "number") num2 = num;
|
if (typeof num == "number") num2 = num;
|
||||||
else if (Array.isArray(num)) num2 = num[index];
|
else if (Array.isArray(num)) num2 = num[index];
|
||||||
else if (typeof num == "function") num2 = num(value);
|
else if (typeof num == "function") num2 = num(value);
|
||||||
if (drawDeck && drawDeck.drawDeck) value.draw(num2, false, drawDeck);
|
if (drawDeck && drawDeck.drawDeck) await value.draw(num2, false, drawDeck);
|
||||||
else if (bottom) value.draw(num2, "nodelay", "bottom");
|
else if (bottom) await value.draw(num2, "nodelay", "bottom");
|
||||||
else value.draw(num2, "nodelay");
|
else await value.draw(num2, "nodelay");
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param { Player[] } players
|
* @param { Player[] } players
|
||||||
|
|
Loading…
Reference in New Issue