2023-04-09 13:35:35 +08:00
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
2022-09-14 13:01:10 +08:00
|
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Layouts
|
|
|
|
|
import Qt5Compat.GraphicalEffects
|
2024-01-25 03:23:29 +08:00
|
|
|
|
import Fk
|
2022-03-23 19:40:28 +08:00
|
|
|
|
|
|
|
|
|
RowLayout {
|
2022-04-30 15:27:56 +08:00
|
|
|
|
id: root
|
2022-03-23 19:40:28 +08:00
|
|
|
|
|
2023-04-27 14:15:08 +08:00
|
|
|
|
property var self
|
2022-04-30 15:27:56 +08:00
|
|
|
|
property alias handcardArea: handcardAreaItem
|
|
|
|
|
|
|
|
|
|
property string pending_skill: ""
|
|
|
|
|
property var pending_card
|
|
|
|
|
property var pendings: [] // int[], store cid
|
|
|
|
|
property int selected_card: -1
|
|
|
|
|
|
2022-09-14 13:01:10 +08:00
|
|
|
|
property alias skillButtons: skillPanel.skill_buttons
|
|
|
|
|
|
|
|
|
|
property var expanded_piles: ({}) // name -> int[]
|
2024-02-04 15:30:27 +08:00
|
|
|
|
property var extra_cards: []
|
2022-09-14 13:01:10 +08:00
|
|
|
|
|
2023-12-10 18:55:16 +08:00
|
|
|
|
property var disabledSkillNames: []
|
|
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
|
signal cardSelected(var card)
|
|
|
|
|
|
2022-09-14 13:01:10 +08:00
|
|
|
|
Item { width: 5 }
|
2022-04-30 15:27:56 +08:00
|
|
|
|
|
|
|
|
|
HandcardArea {
|
|
|
|
|
id: handcardAreaItem
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.preferredHeight: 130
|
2022-09-14 13:01:10 +08:00
|
|
|
|
Layout.alignment: Qt.AlignBottom
|
|
|
|
|
Layout.bottomMargin: 24
|
|
|
|
|
onWidthChanged: updateCardPosition(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SkillArea {
|
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.maximumWidth: width
|
|
|
|
|
Layout.maximumHeight: height
|
|
|
|
|
Layout.alignment: Qt.AlignBottom
|
|
|
|
|
Layout.bottomMargin: 32
|
|
|
|
|
Layout.rightMargin: -16
|
|
|
|
|
id: skillPanel
|
2022-04-30 15:27:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-04-27 14:15:08 +08:00
|
|
|
|
Item {
|
|
|
|
|
width: 175
|
|
|
|
|
height: 233
|
2022-09-14 13:01:10 +08:00
|
|
|
|
Layout.rightMargin: -175 / 8 + (roomArea.width - 175 * 0.75 * 7) / 8
|
2023-04-27 14:15:08 +08:00
|
|
|
|
// handcards: handcardAreaItem.length
|
2022-04-30 15:27:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
|
target: handcardAreaItem
|
|
|
|
|
function onCardSelected(cardId, selected) {
|
|
|
|
|
dashboard.selectCard(cardId, selected);
|
2022-04-14 18:22:00 +08:00
|
|
|
|
}
|
2023-04-27 14:15:08 +08:00
|
|
|
|
function onLengthChanged() {
|
|
|
|
|
self.handcards = handcardAreaItem.length;
|
|
|
|
|
}
|
2022-04-30 15:27:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function disableAllCards() {
|
|
|
|
|
handcardAreaItem.enableCards([]);
|
|
|
|
|
}
|
2022-03-23 19:40:28 +08:00
|
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
|
function unSelectAll(expectId) {
|
|
|
|
|
handcardAreaItem.unselectAll(expectId);
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-26 14:56:07 +08:00
|
|
|
|
function expandPile(pile, extra_ids, extra_footnote) {
|
2023-06-09 17:23:02 +08:00
|
|
|
|
const expanded_pile_names = Object.keys(expanded_piles);
|
2022-09-14 13:01:10 +08:00
|
|
|
|
if (expanded_pile_names.indexOf(pile) !== -1)
|
|
|
|
|
return;
|
|
|
|
|
|
2023-06-09 17:23:02 +08:00
|
|
|
|
const component = Qt.createComponent("../RoomElement/CardItem.qml");
|
|
|
|
|
const parentPos = roomScene.mapFromItem(self, 0, 0);
|
2022-09-14 13:01:10 +08:00
|
|
|
|
|
|
|
|
|
expanded_piles[pile] = [];
|
2024-01-26 14:56:07 +08:00
|
|
|
|
let ids, footnote;
|
2022-09-14 13:01:10 +08:00
|
|
|
|
if (pile === "_equip") {
|
2024-01-26 16:01:41 +08:00
|
|
|
|
ids = self.equipArea.getAllCards().map(e => e.cid);
|
2024-01-26 14:56:07 +08:00
|
|
|
|
footnote = "$Equip";
|
|
|
|
|
} else if (pile === "_extra") {
|
|
|
|
|
ids = extra_ids;
|
2024-02-04 15:30:27 +08:00
|
|
|
|
extra_cards = ids;
|
2024-01-26 14:56:07 +08:00
|
|
|
|
footnote = extra_footnote;
|
2023-03-05 01:28:59 +08:00
|
|
|
|
} else {
|
2024-01-26 14:56:07 +08:00
|
|
|
|
ids = lcall("GetPile", self.playerid, pile);
|
|
|
|
|
footnote = pile;
|
2022-09-14 13:01:10 +08:00
|
|
|
|
}
|
2024-01-26 14:56:07 +08:00
|
|
|
|
ids.forEach(id => {
|
|
|
|
|
const data = lcall("GetCardData", id);
|
|
|
|
|
data.x = parentPos.x;
|
|
|
|
|
data.y = parentPos.y;
|
|
|
|
|
const card = component.createObject(roomScene, data);
|
|
|
|
|
card.footnoteVisible = true;
|
|
|
|
|
card.footnote = luatr(footnote);
|
|
|
|
|
handcardAreaItem.add(card);
|
|
|
|
|
});
|
|
|
|
|
handcardAreaItem.updateCardPosition();
|
2022-09-14 13:01:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function retractPile(pile) {
|
2023-06-09 17:23:02 +08:00
|
|
|
|
const expanded_pile_names = Object.keys(expanded_piles);
|
2022-09-14 13:01:10 +08:00
|
|
|
|
if (expanded_pile_names.indexOf(pile) === -1)
|
|
|
|
|
return;
|
|
|
|
|
|
2023-06-09 17:23:02 +08:00
|
|
|
|
const parentPos = roomScene.mapFromItem(self, 0, 0);
|
2022-09-14 13:01:10 +08:00
|
|
|
|
|
|
|
|
|
delete expanded_piles[pile];
|
|
|
|
|
if (pile === "_equip") {
|
2023-06-09 17:23:02 +08:00
|
|
|
|
const equips = self.equipArea.getAllCards();
|
2022-09-14 13:01:10 +08:00
|
|
|
|
equips.forEach(data => {
|
2023-06-09 17:23:02 +08:00
|
|
|
|
const card = handcardAreaItem.remove([data.cid])[0];
|
2022-09-14 13:01:10 +08:00
|
|
|
|
card.origX = parentPos.x;
|
|
|
|
|
card.origY = parentPos.y;
|
|
|
|
|
card.destroyOnStop();
|
|
|
|
|
card.goBack(true);
|
|
|
|
|
})
|
|
|
|
|
handcardAreaItem.updateCardPosition();
|
2023-03-05 01:28:59 +08:00
|
|
|
|
} else {
|
2024-02-04 15:30:27 +08:00
|
|
|
|
let ids = [];
|
|
|
|
|
if (pile === "_extra") {
|
|
|
|
|
ids = extra_cards;
|
|
|
|
|
extra_cards = [];
|
|
|
|
|
} else {
|
|
|
|
|
ids = lcall("GetPile", self.playerid, pile);
|
|
|
|
|
}
|
2023-03-05 01:28:59 +08:00
|
|
|
|
ids.forEach(id => {
|
2023-06-09 17:23:02 +08:00
|
|
|
|
const card = handcardAreaItem.remove([id])[0];
|
2023-03-05 01:28:59 +08:00
|
|
|
|
card.origX = parentPos.x;
|
|
|
|
|
card.origY = parentPos.y;
|
|
|
|
|
card.destroyOnStop();
|
|
|
|
|
card.goBack(true);
|
|
|
|
|
});
|
|
|
|
|
handcardAreaItem.updateCardPosition();
|
2022-09-14 13:01:10 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-29 18:11:41 +08:00
|
|
|
|
function retractAllPiles() {
|
|
|
|
|
for (let key in expanded_piles) {
|
|
|
|
|
retractPile(key);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-18 21:19:35 +08:00
|
|
|
|
// If cname is set, we are responding card.
|
|
|
|
|
function enableCards(cname) {
|
2023-04-10 15:55:06 +08:00
|
|
|
|
const cardValid = (cid, cname) => {
|
2024-01-25 03:23:29 +08:00
|
|
|
|
let ret = lcall("CardFitPattern", cid, cname);
|
2023-04-10 15:55:06 +08:00
|
|
|
|
|
|
|
|
|
if (ret) {
|
|
|
|
|
if (roomScene.respond_play) {
|
2024-01-25 03:23:29 +08:00
|
|
|
|
ret = ret && !lcall("CardProhibitedResponse", cid);
|
2023-04-10 15:55:06 +08:00
|
|
|
|
} else {
|
2024-01-25 03:23:29 +08:00
|
|
|
|
ret = ret && !lcall("CardProhibitedUse", cid);
|
2023-04-10 15:55:06 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
2023-07-16 15:32:16 +08:00
|
|
|
|
|
2024-01-25 03:23:29 +08:00
|
|
|
|
const pile_data = lcall("GetAllPiles", self.playerid);
|
2023-08-12 00:50:17 +08:00
|
|
|
|
extractWoodenOx();
|
2023-07-16 15:32:16 +08:00
|
|
|
|
|
2024-01-25 03:23:29 +08:00
|
|
|
|
const handleMethod = roomScene.respond_play ? "response" : "use";
|
2022-12-18 21:19:35 +08:00
|
|
|
|
if (cname) {
|
2023-06-09 17:23:02 +08:00
|
|
|
|
const ids = [];
|
|
|
|
|
let cards = handcardAreaItem.cards;
|
2022-12-18 21:19:35 +08:00
|
|
|
|
for (let i = 0; i < cards.length; i++) {
|
2023-09-19 14:27:54 +08:00
|
|
|
|
cards[i].prohibitReason = "";
|
2023-04-10 15:55:06 +08:00
|
|
|
|
if (cardValid(cards[i].cid, cname)) {
|
2022-12-18 21:19:35 +08:00
|
|
|
|
ids.push(cards[i].cid);
|
2023-09-19 14:27:54 +08:00
|
|
|
|
} else {
|
2024-01-25 03:23:29 +08:00
|
|
|
|
const prohibitReason = lcall("GetCardProhibitReason", cards[i].cid,
|
|
|
|
|
handleMethod, cname);
|
2023-09-19 14:27:54 +08:00
|
|
|
|
if (prohibitReason) {
|
|
|
|
|
cards[i].prohibitReason = prohibitReason;
|
|
|
|
|
}
|
2023-04-10 15:55:06 +08:00
|
|
|
|
}
|
2022-12-18 21:19:35 +08:00
|
|
|
|
}
|
2023-04-27 14:15:08 +08:00
|
|
|
|
cards = self.equipArea.getAllCards();
|
2023-01-29 18:11:41 +08:00
|
|
|
|
cards.forEach(c => {
|
2023-09-19 14:27:54 +08:00
|
|
|
|
c.prohibitReason = "";
|
2023-04-10 15:55:06 +08:00
|
|
|
|
if (cardValid(c.cid, cname)) {
|
2023-01-29 18:11:41 +08:00
|
|
|
|
ids.push(c.cid);
|
|
|
|
|
if (!expanded_piles["_equip"]) {
|
|
|
|
|
expandPile("_equip");
|
|
|
|
|
}
|
2023-09-19 14:27:54 +08:00
|
|
|
|
} else {
|
2024-01-25 03:23:29 +08:00
|
|
|
|
const prohibitReason = lcall("GetCardProhibitReason", c.cid,
|
|
|
|
|
handleMethod, cname);
|
2023-09-19 14:27:54 +08:00
|
|
|
|
if (prohibitReason) {
|
|
|
|
|
c.prohibitReason = prohibitReason;
|
|
|
|
|
}
|
2023-01-29 18:11:41 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2023-03-07 10:21:56 +08:00
|
|
|
|
// Must manually analyze pattern here
|
|
|
|
|
let pile_list = cname.split("|")[4];
|
|
|
|
|
if (pile_list && pile_list !== "." && !(pile_data instanceof Array)) {
|
|
|
|
|
pile_list = pile_list.split(",");
|
|
|
|
|
for (let pile_name of pile_list) {
|
|
|
|
|
pile_data[pile_name] && pile_data[pile_name].forEach(cid => {
|
2023-04-10 15:55:06 +08:00
|
|
|
|
if (cardValid(cid, cname)) {
|
2023-03-05 01:28:59 +08:00
|
|
|
|
ids.push(cid);
|
|
|
|
|
if (!expanded_piles[pile_name]) {
|
|
|
|
|
expandPile(pile_name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-18 21:19:35 +08:00
|
|
|
|
handcardAreaItem.enableCards(ids);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-03-07 10:21:56 +08:00
|
|
|
|
|
2023-06-09 17:23:02 +08:00
|
|
|
|
const ids = [], cards = handcardAreaItem.cards;
|
2022-04-30 15:27:56 +08:00
|
|
|
|
for (let i = 0; i < cards.length; i++) {
|
2023-09-19 14:27:54 +08:00
|
|
|
|
cards[i].prohibitReason = "";
|
2024-01-25 03:23:29 +08:00
|
|
|
|
if (lcall("CanUseCard", cards[i].cid, Self.id,
|
|
|
|
|
JSON.stringify(roomScene.extra_data))) {
|
2022-04-30 15:27:56 +08:00
|
|
|
|
ids.push(cards[i].cid);
|
2023-05-28 12:22:43 +08:00
|
|
|
|
} else {
|
|
|
|
|
// cannot use? considering special_skills
|
2024-01-25 03:23:29 +08:00
|
|
|
|
const skills = lcall("GetCardSpecialSkills", cards[i].cid);
|
2023-05-28 12:22:43 +08:00
|
|
|
|
for (let j = 0; j < skills.length; j++) {
|
2023-06-09 17:23:02 +08:00
|
|
|
|
const s = skills[j];
|
2024-01-25 03:23:29 +08:00
|
|
|
|
if (lcall("ActiveCanUse", s, JSON.stringify(roomScene.extra_data))) {
|
2023-05-28 12:22:43 +08:00
|
|
|
|
ids.push(cards[i].cid);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-09-19 14:27:54 +08:00
|
|
|
|
|
|
|
|
|
// still cannot use? show message on card
|
|
|
|
|
if (!ids.includes(cards[i].cid)) {
|
2024-01-25 03:23:29 +08:00
|
|
|
|
const prohibitReason = lcall("GetCardProhibitReason", cards[i].cid,
|
|
|
|
|
"play");
|
2023-09-19 14:27:54 +08:00
|
|
|
|
if (prohibitReason) {
|
|
|
|
|
cards[i].prohibitReason = prohibitReason;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-05-28 12:22:43 +08:00
|
|
|
|
}
|
2022-04-30 15:27:56 +08:00
|
|
|
|
}
|
|
|
|
|
handcardAreaItem.enableCards(ids)
|
2022-09-14 13:01:10 +08:00
|
|
|
|
if (pending_skill === "") {
|
|
|
|
|
cancelButton.enabled = false;
|
|
|
|
|
}
|
2022-04-30 15:27:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function selectCard(cardId, selected) {
|
|
|
|
|
if (pending_skill !== "") {
|
|
|
|
|
if (selected) {
|
|
|
|
|
pendings.push(cardId);
|
|
|
|
|
} else {
|
|
|
|
|
pendings.splice(pendings.indexOf(cardId), 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updatePending();
|
|
|
|
|
} else {
|
|
|
|
|
if (selected) {
|
|
|
|
|
handcardAreaItem.unselectAll(cardId);
|
|
|
|
|
selected_card = cardId;
|
|
|
|
|
} else {
|
|
|
|
|
handcardAreaItem.unselectAll();
|
|
|
|
|
selected_card = -1;
|
2023-12-12 19:07:49 +08:00
|
|
|
|
roomScene.resetPrompt();
|
2022-04-30 15:27:56 +08:00
|
|
|
|
}
|
|
|
|
|
cardSelected(selected_card);
|
2022-03-23 19:40:28 +08:00
|
|
|
|
}
|
2022-04-30 15:27:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-24 14:48:49 +08:00
|
|
|
|
function revertSelection() {
|
|
|
|
|
if (pending_skill !== "") {
|
|
|
|
|
let to_select_cards = handcardAreaItem.cards.filter(cd => {
|
|
|
|
|
if (pendings.indexOf(cd.cid) === -1) {
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
cd.selected = !cd.selected;
|
|
|
|
|
cd.clicked();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
to_select_cards.forEach(cd => {
|
|
|
|
|
if (cd.selectable) {
|
|
|
|
|
cd.selected = !cd.selected;
|
|
|
|
|
cd.clicked();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
|
function getSelectedCard() {
|
|
|
|
|
if (pending_skill !== "") {
|
|
|
|
|
return JSON.stringify({
|
|
|
|
|
skill: pending_skill,
|
|
|
|
|
subcards: pendings
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
return selected_card;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-12 00:50:17 +08:00
|
|
|
|
function extractWoodenOx() {
|
2024-01-25 03:23:29 +08:00
|
|
|
|
const pile_data = lcall("GetAllPiles", self.playerid);
|
|
|
|
|
if (!roomScene.autoPending) {
|
|
|
|
|
// 先屏蔽AskForUseActiveSkill再说,这下只剩使用打出以及出牌阶段了
|
2023-08-12 00:50:17 +08:00
|
|
|
|
for (let name in pile_data) {
|
|
|
|
|
if (name.endsWith("&")) expandPile(name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
|
function updatePending() {
|
2023-06-16 10:58:28 +08:00
|
|
|
|
roomScene.resetPrompt();
|
2022-04-30 15:27:56 +08:00
|
|
|
|
if (pending_skill === "") return;
|
|
|
|
|
|
2023-06-09 17:23:02 +08:00
|
|
|
|
const enabled_cards = [];
|
|
|
|
|
const targets = roomScene.selected_targets;
|
2022-04-30 15:27:56 +08:00
|
|
|
|
|
2022-09-14 13:01:10 +08:00
|
|
|
|
handcardAreaItem.cards.forEach((card) => {
|
2024-01-25 03:23:29 +08:00
|
|
|
|
if (card.selected || lcall("ActiveCardFilter", pending_skill, card.cid,
|
|
|
|
|
pendings, targets))
|
2022-04-30 15:27:56 +08:00
|
|
|
|
enabled_cards.push(card.cid);
|
|
|
|
|
});
|
2023-01-29 18:11:41 +08:00
|
|
|
|
|
2023-06-09 17:23:02 +08:00
|
|
|
|
const cards = self.equipArea.getAllCards();
|
2023-01-29 18:11:41 +08:00
|
|
|
|
cards.forEach(c => {
|
2024-01-25 03:23:29 +08:00
|
|
|
|
if (lcall("ActiveCardFilter", pending_skill, c.cid, pendings, targets)) {
|
2023-01-29 18:11:41 +08:00
|
|
|
|
enabled_cards.push(c.cid);
|
|
|
|
|
if (!expanded_piles["_equip"]) {
|
|
|
|
|
expandPile("_equip");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
2023-03-05 01:28:59 +08:00
|
|
|
|
|
2024-01-26 14:56:07 +08:00
|
|
|
|
let pile = lcall("GetExpandPileOfSkill", pending_skill);
|
|
|
|
|
let pile_ids = pile;
|
|
|
|
|
if (typeof pile === "string") {
|
|
|
|
|
pile_ids = lcall("GetPile", self.playerid, pile);
|
|
|
|
|
} else {
|
|
|
|
|
pile = "_extra";
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-07 10:21:56 +08:00
|
|
|
|
pile_ids.forEach(cid => {
|
2024-01-25 03:23:29 +08:00
|
|
|
|
if (lcall("ActiveCardFilter", pending_skill, cid, pendings, targets)) {
|
2023-03-07 10:21:56 +08:00
|
|
|
|
enabled_cards.push(cid);
|
2023-12-06 21:08:56 +08:00
|
|
|
|
};
|
|
|
|
|
if (!expanded_piles[pile]) {
|
2024-01-26 14:56:07 +08:00
|
|
|
|
expandPile(pile, pile_ids, pending_skill);
|
2023-03-05 01:28:59 +08:00
|
|
|
|
}
|
2023-03-07 10:21:56 +08:00
|
|
|
|
});
|
2023-03-05 01:28:59 +08:00
|
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
|
handcardAreaItem.enableCards(enabled_cards);
|
|
|
|
|
|
2024-01-25 03:23:29 +08:00
|
|
|
|
if (lcall("CanViewAs", pending_skill, pendings)) {
|
2022-04-30 15:27:56 +08:00
|
|
|
|
pending_card = {
|
|
|
|
|
skill: pending_skill,
|
|
|
|
|
subcards: pendings
|
|
|
|
|
};
|
|
|
|
|
cardSelected(JSON.stringify(pending_card));
|
|
|
|
|
} else {
|
|
|
|
|
pending_card = -1;
|
|
|
|
|
cardSelected(pending_card);
|
|
|
|
|
}
|
2024-06-10 15:02:46 +08:00
|
|
|
|
const prompt = lcall("ActiveSkillPrompt", pending_skill, pendings,
|
|
|
|
|
targets);
|
|
|
|
|
if (prompt !== "") {
|
|
|
|
|
roomScene.setPrompt(Util.processPrompt(prompt));
|
|
|
|
|
}
|
2022-04-30 15:27:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function startPending(skill_name) {
|
|
|
|
|
pending_skill = skill_name;
|
|
|
|
|
pendings = [];
|
|
|
|
|
handcardAreaItem.unselectAll();
|
2023-08-12 00:50:17 +08:00
|
|
|
|
retractAllPiles();
|
|
|
|
|
|
2022-09-15 11:17:13 +08:00
|
|
|
|
for (let i = 0; i < skillButtons.count; i++) {
|
2023-06-09 17:23:02 +08:00
|
|
|
|
const item = skillButtons.itemAt(i);
|
2022-09-15 11:17:13 +08:00
|
|
|
|
item.enabled = item.pressed;
|
|
|
|
|
}
|
2022-04-30 15:27:56 +08:00
|
|
|
|
|
2023-09-19 14:27:54 +08:00
|
|
|
|
const cards = handcardAreaItem.cards;
|
|
|
|
|
for (let i = 0; i < cards.length; i++) {
|
|
|
|
|
cards[i].prohibitReason = "";
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
|
updatePending();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function deactivateSkillButton() {
|
2022-09-14 13:01:10 +08:00
|
|
|
|
for (let i = 0; i < skillButtons.count; i++) {
|
2023-08-24 21:37:24 +08:00
|
|
|
|
let item = skillButtons.itemAt(i);
|
|
|
|
|
item.pressed = false;
|
2022-04-30 15:27:56 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function stopPending() {
|
|
|
|
|
pending_skill = "";
|
|
|
|
|
pending_card = -1;
|
|
|
|
|
|
2023-01-29 18:11:41 +08:00
|
|
|
|
retractAllPiles();
|
2022-03-23 19:40:28 +08:00
|
|
|
|
|
2023-08-12 00:50:17 +08:00
|
|
|
|
if (roomScene.state == "playing")
|
|
|
|
|
extractWoodenOx();
|
|
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
|
pendings = [];
|
|
|
|
|
handcardAreaItem.adjustCards();
|
2022-09-14 13:01:10 +08:00
|
|
|
|
handcardAreaItem.unselectAll();
|
2022-04-30 15:27:56 +08:00
|
|
|
|
cardSelected(-1);
|
2023-06-16 10:58:28 +08:00
|
|
|
|
roomScene.resetPrompt();
|
2022-04-30 15:27:56 +08:00
|
|
|
|
}
|
2022-09-14 13:01:10 +08:00
|
|
|
|
|
2023-04-23 21:10:07 +08:00
|
|
|
|
function addSkill(skill_name, prelight) {
|
|
|
|
|
skillPanel.addSkill(skill_name, prelight);
|
2022-09-14 13:01:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-04-23 21:10:07 +08:00
|
|
|
|
function loseSkill(skill_name, prelight) {
|
|
|
|
|
skillPanel.loseSkill(skill_name, prelight);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function prelightSkill(skill_name, prelight) {
|
2023-06-09 17:23:02 +08:00
|
|
|
|
const btns = skillPanel.prelight_buttons;
|
2023-04-23 21:10:07 +08:00
|
|
|
|
for (let i = 0; i < btns.count; i++) {
|
2023-06-09 17:23:02 +08:00
|
|
|
|
const btn = btns.itemAt(i);
|
2023-04-23 21:10:07 +08:00
|
|
|
|
if (btn.orig === skill_name) {
|
|
|
|
|
btn.prelighted = prelight;
|
|
|
|
|
btn.enabled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-09-14 13:01:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-04-30 18:55:59 +08:00
|
|
|
|
function enableSkills(cname, cardResponsing) {
|
2022-12-18 21:19:35 +08:00
|
|
|
|
if (cname) {
|
2023-01-29 18:11:41 +08:00
|
|
|
|
// if cname is presented, we are responding use or play.
|
2023-01-16 19:13:07 +08:00
|
|
|
|
for (let i = 0; i < skillButtons.count; i++) {
|
2023-06-09 17:23:02 +08:00
|
|
|
|
const item = skillButtons.itemAt(i);
|
2023-12-10 18:55:16 +08:00
|
|
|
|
if (disabledSkillNames.includes(item.orig)) {
|
|
|
|
|
item.enabled = false;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-25 03:23:29 +08:00
|
|
|
|
const fitpattern = lcall("SkillFitPattern", item.orig, cname);
|
|
|
|
|
const canresp = lcall("SkillCanResponse", item.orig, cardResponsing);
|
2023-01-29 18:11:41 +08:00
|
|
|
|
item.enabled = fitpattern && canresp;
|
2023-01-16 19:13:07 +08:00
|
|
|
|
}
|
2022-12-18 21:19:35 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
2022-09-14 13:01:10 +08:00
|
|
|
|
for (let i = 0; i < skillButtons.count; i++) {
|
2023-06-09 17:23:02 +08:00
|
|
|
|
const item = skillButtons.itemAt(i);
|
2023-12-10 18:55:16 +08:00
|
|
|
|
if (disabledSkillNames.includes(item.orig)) {
|
|
|
|
|
item.enabled = false;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-25 03:23:29 +08:00
|
|
|
|
item.enabled = lcall("ActiveCanUse", item.orig,
|
|
|
|
|
JSON.stringify(roomScene.extra_data));
|
2022-09-14 13:01:10 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function disableSkills() {
|
2023-12-10 18:55:16 +08:00
|
|
|
|
disabledSkillNames = [];
|
2022-09-14 13:01:10 +08:00
|
|
|
|
for (let i = 0; i < skillButtons.count; i++)
|
|
|
|
|
skillButtons.itemAt(i).enabled = false;
|
|
|
|
|
}
|
2022-12-20 12:51:54 +08:00
|
|
|
|
|
|
|
|
|
function tremble() {
|
2023-04-27 14:15:08 +08:00
|
|
|
|
self.tremble();
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-23 22:18:11 +08:00
|
|
|
|
function updateHandcards() {
|
2024-01-25 03:23:29 +08:00
|
|
|
|
lcall("FilterMyHandcards");
|
2023-06-23 22:18:11 +08:00
|
|
|
|
handcardAreaItem.cards.forEach(v => {
|
2024-01-25 03:23:29 +08:00
|
|
|
|
v.setData(lcall("GetCardData", v.cid));
|
2023-06-23 22:18:11 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-27 14:15:08 +08:00
|
|
|
|
function update() {
|
|
|
|
|
unSelectAll();
|
|
|
|
|
disableSkills();
|
|
|
|
|
|
2023-06-10 23:55:39 +08:00
|
|
|
|
let cards = handcardAreaItem.cards;
|
2023-06-09 17:23:02 +08:00
|
|
|
|
const toRemove = [];
|
2023-04-27 14:15:08 +08:00
|
|
|
|
for (let c of cards) {
|
|
|
|
|
toRemove.push(c.cid);
|
|
|
|
|
c.origY += 30;
|
|
|
|
|
c.origOpacity = 0
|
|
|
|
|
c.goBack(true);
|
|
|
|
|
c.destroyOnStop();
|
|
|
|
|
}
|
|
|
|
|
handcardAreaItem.remove(toRemove);
|
|
|
|
|
|
|
|
|
|
skillPanel.clearSkills();
|
|
|
|
|
|
2024-01-25 03:23:29 +08:00
|
|
|
|
const skills = lcall("GetPlayerSkills", Self.id);
|
2023-04-27 14:15:08 +08:00
|
|
|
|
for (let s of skills) {
|
|
|
|
|
addSkill(s.name);
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-25 03:23:29 +08:00
|
|
|
|
cards = roomScene.drawPile.remove(lcall("GetPlayerHandcards", Self.id));
|
2023-04-27 14:15:08 +08:00
|
|
|
|
handcardAreaItem.add(cards);
|
2022-12-20 12:51:54 +08:00
|
|
|
|
}
|
2022-03-23 19:40:28 +08:00
|
|
|
|
}
|