Skip to content

Commit

Permalink
Merge branch 'PR-Branch'
Browse files Browse the repository at this point in the history
  • Loading branch information
adeFuLoDgu committed Oct 27, 2024
2 parents 71bd701 + 08f011e commit 26a2890
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 101 deletions.
4 changes: 2 additions & 2 deletions character/extra/skill.js
Original file line number Diff line number Diff line change
Expand Up @@ -4705,7 +4705,7 @@ const skills = {
if (result.bool) {
var card = result.cards[0];
var num = get.number(card);
if ([1, 11, 12, 13].includes(num)) {
if (typeof get.strNumber(num) === "string") {
if (lib.filter.canBeGained(card, player, target)) player.gain(card, target, "give", "bySelf");
} else if (lib.filter.canBeDiscarded(card, player, target)) target.discard(card);
} else event.finish();
Expand Down Expand Up @@ -4909,7 +4909,7 @@ const skills = {
audio: 2,
mod: {
cardname(card, player) {
if (player.storage.yuheng && [1, 11, 12, 13].includes(card.number)) {
if (player.storage.yuheng && typeof get.strNumber(card.number) === "string") {
var list = ["rezhiheng", "jiexun", "reanxu"];
for (var i of list) {
if (!player.storage.yuheng.includes(i)) return;
Expand Down
2 changes: 1 addition & 1 deletion character/jsrg/skill.js
Original file line number Diff line number Diff line change
Expand Up @@ -11231,7 +11231,7 @@ const skills = {
} else break;
} else break;
}
} else if (numx < num) {
} else {
await player.drawTo(num);
player.addTempSkill("jsrgcuibing_keji");
}
Expand Down
8 changes: 4 additions & 4 deletions character/sixiang/skill.js
Original file line number Diff line number Diff line change
Expand Up @@ -1405,24 +1405,24 @@ const skills = {
aiValue: (player, card, val) => {
if (card.name == "wuxie") return 0;
var num = get.number(card);
if ([1, 11, 12, 13].includes(num)) return 0;
if (typeof get.strNumber(num) === "string") return 0;
},
aiUseful: (player, card, val) => {
if (card.name == "wuxie") return 0;
var num = get.number(card);
if ([1, 11, 12, 13].includes(num)) return 0;
if (typeof get.strNumber(num) === "string") return 0;
},
aiOrder: (player, card, order) => {
var num = get.number(card);
if ([1, 11, 12, 13].includes(num)) return 0;
if (typeof get.strNumber(num) === "string") return 0;
return order;
},
},
trigger: {
player: "useCard",
},
filter(event, player) {
return [1, 11, 12, 13].includes(get.number(event.card));
return typeof get.strNumber(get.number(event.card)) === "string";
},
forced: true,
async content(event, trigger, player) {
Expand Down
8 changes: 4 additions & 4 deletions character/sp/skill.js
Original file line number Diff line number Diff line change
Expand Up @@ -5459,17 +5459,17 @@ const skills = {
aiValue: (player, card, val) => {
if (card.name == "wuxie") return 0;
var num = get.number(card);
if ([1, 11, 12, 13].includes(num)) return val * 1.1;
if (typeof get.strNumber(num) === "string") return val * 1.1;
},
aiUseful: (player, card, val) => {
if (card.name == "wuxie") return 0;
var num = get.number(card);
if ([1, 11, 12, 13].includes(num)) return val * 1.1;
if (typeof get.strNumber(num) === "string") return val * 1.1;
},
aiOrder: (player, card, order) => {
if (get.name(card) == "sha" && player.hasSkill("oltuishi_unlimit")) order += 9;
var num = get.number(card);
if ([1, 11, 12, 13].includes(num)) order += 3;
if (typeof get.strNumber(num) === "string") order += 3;
return order;
},
},
Expand All @@ -5489,7 +5489,7 @@ const skills = {
.indexOf(event) >= 2
);
}
return [1, 11, 12, 13].includes(get.number(event.card));
return typeof get.strNumber(get.number(event.card)) === "string";
},
forced: true,
content: function () {
Expand Down
50 changes: 23 additions & 27 deletions character/tw/skill.js
Original file line number Diff line number Diff line change
Expand Up @@ -637,13 +637,16 @@ const skills = {
},
filter(event, player) {
if (!event.gaintag.includes("twciyin")) return false;
const cards = player.getExpansions("twciyin");
const history = game.getAllGlobalHistory("everything", evt => evt.name == "twciyin_heart" && evt.player == player);
const limit = history.map(evt => evt.cost_data).flat();
return (cards.length % 3 == 0 || event.cards.length > 2) && (!limit.includes("选项一") || (!limit.includes("选项二") && player.countCards("h") < player.maxHp));
return !limit.includes("选项一") || (!limit.includes("选项二") && player.countCards("h") < player.maxHp);
},
getIndex(event, player) {
const history = game.getAllGlobalHistory("everything", evt => evt.name == "twciyin_heart" && evt.player == player);
const limit = history.map(evt => evt.cost_data).flat();
return Math.floor(player.getExpansions("twciyin").length / 3) - limit.length;
},
async cost(event, trigger, player) {
const goon = player.getExpansions("twciyin").length > 5;
const history = game.getAllGlobalHistory("everything", evt => evt.name == "twciyin_heart" && evt.player == player);
const limit = history.map(evt => evt.cost_data).flat();
const choices = [];
Expand All @@ -652,30 +655,23 @@ const skills = {
else choiceList[0] = '<span style="opacity:0.5;">' + choiceList[0] + "</span>";
if (!limit.includes("选项二") && player.countCards("h") < player.maxHp) choices.push("选项二");
else choiceList[1] = '<span style="opacity:0.5;">' + choiceList[1] + "</span>";
if (goon && !history.length && choices.length == 2) {
event.result = {
bool: true,
cost_data: choices,
};
} else {
const control =
choices.length == 1
? choices[0]
: await player
.chooseControl(choices)
.set("prompt", get.prompt("twciyin"))
.set("choiceList", choiceList)
.set("ai", () => {
const player = get.player(),
num = player.maxHp - player.countCards("h");
return get.recoverEffect(player, player, player) > get.effect(player, { name: "draw" }, player, player) * num ? "选项一" : "选项二";
})
.forResultControl();
event.result = {
bool: true,
cost_data: [control],
};
}
const control =
choices.length == 1
? choices[0]
: await player
.chooseControl(choices)
.set("prompt", get.prompt("twciyin"))
.set("choiceList", choiceList)
.set("ai", () => {
const player = get.player(),
num = player.maxHp - player.countCards("h");
return get.recoverEffect(player, player, player) > get.effect(player, { name: "draw" }, player, player) * num ? "选项一" : "选项二";
})
.forResultControl();
event.result = {
bool: true,
cost_data: [control],
};
},
async content(event, trigger, player) {
if (event.cost_data.includes("选项一")) {
Expand Down
17 changes: 1 addition & 16 deletions character/xianding/skill.js
Original file line number Diff line number Diff line change
Expand Up @@ -4751,22 +4751,7 @@ const skills = {
trigger.targets = [player, ...trigger.targets.remove(player)];
evtx.targets = [player, ...evtx.targets.remove(player)];
evtx.triggeredTargets4 = [player, ...evtx.triggeredTargets4.remove(player)];
player
.when({
global: "eventNeutralized",
target: ["useCardToBegin", "useCardToExcluded", "useCardToIgnored"],
})
.filter((evt, _, name) => {
if (evt.getParent().targets.length <= 1) return false;
if (name === "evtNeutralized") {
if (evt._neutralize_event.type != "card" || evt.type != "card") return false;
return evt._neutralize_event.card === trigger.card;
}
return evt.getParent() == trigger.getParent();
})
.then(() => {
player.draw(trigger.getParent().targets.length - 1);
});
await player.draw(evtx.targets.length - 1);
},
},
dczengou: {
Expand Down
46 changes: 16 additions & 30 deletions noname/get/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2777,10 +2777,7 @@ export class Get extends GetCompatible {
}
}
if ((str.suit && str.number) || str.isCard) {
var cardnum = get.number(str, false) || "";
if ([1, 11, 12, 13].includes(cardnum)) {
cardnum = { 1: "A", 11: "J", 12: "Q", 13: "K" }[cardnum];
}
var cardnum = get.strNumber(get.number(str, false), true) || "";
if (arg == "viewAs" && str.viewAs != str.name && str.viewAs) {
str2 += "(" + get.translation(str) + ")";
} else {
Expand Down Expand Up @@ -2847,40 +2844,29 @@ export class Get extends GetCompatible {
/**
* 返回数字在扑克牌中的表示形式
* @param { number } num
* @param { boolean } [forced] 未获取点数字母对应元素时是否返回字符串格式
* @returns { string }
*/
strNumber(num) {
switch (num) {
case 1:
return "A";
case 11:
return "J";
case 12:
return "Q";
case 13:
return "K";
default:
return num.toString();
}
strNumber(num, forced) {
if (typeof num !== "number") return;
let result = lib.numstrList.get(num);
if (result === undefined && forced) result = num.toString();
return result;
}
/**
* 返回扑克牌中的表示形式对应的数字
* @param { string } str
* @param { boolean } [forced] 未获取字母点数对应元素时是否返回数字格式
* @returns { number }
*/
numString(str) {
switch (str) {
case "A":
return 1;
case "J":
return 11;
case "Q":
return 12;
case "K":
return 13;
default:
return parseInt(str);
}
numString(str, forced) {
if (typeof str !== "string") return;
let result = lib.numstrList.entries().reduce((map, list) => {
map[list[1]] = list[0];
return map;
}, {})[str];
if (result === undefined && forced) result = parseInt(str);
return result;
}
/**
* 将阿拉伯数字转换为中文的表达形式
Expand Down
18 changes: 1 addition & 17 deletions noname/library/element/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,23 +311,7 @@ export class Card extends HTMLDivElement {
var info = lib.card[card[2]];
var cardnum = card[1] || "";
if (parseInt(cardnum) == cardnum) cardnum = parseInt(cardnum);
if (cardnum > 0 && cardnum < 14) {
cardnum = [
"A",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"J",
"Q",
"K",
][cardnum - 1];
}
cardnum = get.strNumber(cardnum, true) || "";
if (this.name) {
this.classList.remove("epic");
this.classList.remove("legend");
Expand Down
7 changes: 7 additions & 0 deletions noname/library/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13502,6 +13502,13 @@ export class Library {
},
},
};
//为lib.numstrList属性set数字对应花色,即可在get.strNumber和get.numString中获取使用
numstrList = new Map([
[1, "A"],
[11, "J"],
[12, "Q"],
[13, "K"],
]);
suit = ["club", "spade", "diamond", "heart"];
suits = ["club", "spade", "diamond", "heart", "none"];
color = {
Expand Down

0 comments on commit 26a2890

Please sign in to comment.