This commit is contained in:
YoumuKon 2024-04-02 20:00:30 +08:00
parent 0d2dd3a623
commit 9b02623992
3 changed files with 30 additions and 6 deletions

View File

@ -1220,12 +1220,11 @@ callbacks["AskForYuqi"] = (jsonData) => {
box.yuqi_type = type; box.yuqi_type = type;
box.areaNames = area_names; box.areaNames = area_names;
box.pilecards = card_data; box.pilecards = card_data;
box.result = card_items;
box.extra_data = extra_data; box.extra_data = extra_data;
box.cancelable = cancelable; box.cancelable = cancelable;
box.cards = carditems; box.cards = carditems;
box.arrangeCards(); box.initializeCards();
roomScene.popupBox.moveToCenter(); roomScene.popupBox.moveToCenter();
box.cardsSelected.connect((ids) => { box.cardsSelected.connect((ids) => {
replyToServer(JSON.stringify(ids)); replyToServer(JSON.stringify(ids));

View File

@ -119,7 +119,7 @@ GraphicsBox {
const _pile = result[i]; const _pile = result[i];
const box = pile.cardsArea; const box = pile.cardsArea;
const pos = mapFromItem(pile, box.x, box.y); const pos = mapFromItem(pile, box.x, box.y);
const posid = _pile.indexOf(card.cid) const posid = _pile.indexOf(card)
if (posid !== -1) { if (posid !== -1) {
from = i; from = i;
orig = posid; orig = posid;
@ -128,14 +128,17 @@ GraphicsBox {
if (Math.abs(card.y - pos.y) <= spacing / 2) { if (Math.abs(card.y - pos.y) <= spacing / 2) {
to = i to = i
} }
console.log(pos.x, pos.y);
console.log(card.x, card.y);
console.log(from, to);
if (from !== null && to !== null) { if (from !== null && to !== null) {
if (pilecards[to].indexOf(card.cid) === -1 && !lcall("YuqiEntryFilter", root.yuqi_type, card.cid, from, to, if (pilecards[to].indexOf(card) === -1 && !lcall("YuqiEntryFilter", root.yuqi_type, card.cid, from, to,
result_cards, root.extra_data) ) break; result_cards, root.extra_data) ) break;
result[from].splice(orig, 1) result[from].splice(orig, 1)
for (j = 0; j < result[0].length; j++) { for (j = 0; j < result[0].length; j++) {
let _card = result[orig][i] let _card = result[orig][i]
if (Math.abs(card.x - _card.x) <= card.width / 2) { if (Math.abs(card.x - _card.x) <= card.width / 2) {
result[to].splice(j, 0, card.cid); result[to].splice(j, 0, card);
break; break;
} }
} }
@ -145,6 +148,28 @@ GraphicsBox {
arrangeCards(); arrangeCards();
} }
function initializeCards() {
result = new Array(areaNames.length);
let i;
for (i = 0; i < result.length; i++){
result[i] = [];
}
let card;
let j = 0;
for (i = 0; i < cardsItem.count; i++) {
card = cardsItem.itemAt(i);
console.log(pilecards[j]);
if (i < pilecards[j].length) {
result[j].push(card);
} else {
j++;
}
}
arrangeCards();
}
function arrangeCards() { function arrangeCards() {
let i, j; let i, j;
let card, box, pos, pile; let card, box, pos, pile;

View File

@ -84,7 +84,7 @@ local control = fk.CreateActiveSkill{
for _, pid in ipairs(effect.tos) do for _, pid in ipairs(effect.tos) do
local to = room:getPlayerById(pid) local to = room:getPlayerById(pid)
p(room:askForYuqi(from, "test", { p(room:askForYuqi(from, "test", {
{"牌堆顶", table.slice(room.draw_pile, 1, 5)}, {"牌堆顶", table.slice(room.draw_pile, 1, 7)},
{"你自己", {}}, {"你自己", {}},
{"对方", {}}, {"对方", {}},
}, to.hp, true)) }, to.hp, true))