FreeKill/qml/Pages/RoomElement/InvisibleCardArea.qml
notify 162b3af505 Use skill (#25)
* distance & snatch

* distance & snatch - clean

* fix: client.alive_players

* room:askForCardChosen(todo: snatch)

* add skill to players(uncomplete)

* ui of skill btn

* expand pile(not completed)

* Use card2 (#23)

* snatch (todo: owner_map)

* owner_map

* remove too many snatch

* update

* call active skill's functions

* use zhiheng

* Qt6 (#24)

* use qt6

* android compiling

* remove version number of qml import

* correct anti-sql injection; update deprecated code

* add fkparse as submodule

* link fkparse, and write simple functions

* adjust ui

* adjust layout for photos; fix qml warning

* android problem fix (partially)

* move ico

* update copy_assets

* update logic for ok/cancel btn
2022-09-14 13:01:10 +08:00

112 lines
2.6 KiB
QML

import QtQuick
Item {
property var cards: []
property int length: 0
property var pendingInput: []
property bool checkExisting: false
id: root
function add(inputs)
{
let card;
if (inputs instanceof Array) {
for (let i = 0; i < inputs.length; i++) {
card = inputs[i];
pendingInput.push(card);
cards.push(card.toData());
}
if (checkExisting)
length = cards.length;
else
length += inputs.length;
} else {
pendingInput.push(inputs);
cards.push(inputs.toData());
if (checkExisting)
length = cards.length;
else
length++;
}
}
function _contains(cid)
{
if (!checkExisting)
return true;
for (let i = 0; i < cards.length; i++)
{
if (cards[i].cid === cid)
return true;
}
return false;
}
function remove(outputs)
{
let component = Qt.createComponent("CardItem.qml");
if (component.status !== Component.Ready)
return [];
let parentPos = roomScene.mapFromItem(root, 0, 0);
let card;
let items = [];
for (let i = 0; i < outputs.length; i++) {
if (_contains(outputs[i])) {
let state = JSON.parse(Backend.callLuaFunction("GetCardData", [outputs[i]]))
state.x = parentPos.x;
state.y = parentPos.y;
state.opacity = 0;
card = component.createObject(roomScene, state);
card.x -= card.width / 2;
card.x += (i - outputs.length / 2) * 15;
card.y -= card.height / 2;
items.push(card);
if (checkExisting) {
//@to-do: remove it from cards
cards.splice(i, 1);
i--;
}
}
}
if (checkExisting)
length = cards.length;
else
length -= outputs.length;
return items;
}
function updateCardPosition(animated)
{
let i, card;
if (animated) {
let parentPos = roomScene.mapFromItem(root, 0, 0);
for (i = 0; i < pendingInput.length; i++) {
card = pendingInput[i];
card.origX = parentPos.x - card.width / 2 + ((i - pendingInput.length / 2) * 15);
card.origY = parentPos.y - card.height / 2;
card.origOpacity = 0;
card.destroyOnStop();
}
for (i = 0; i < pendingInput.length; i++)
pendingInput[i].goBack(true);
} else {
for (i = 0; i < pendingInput.length; i++) {
card = pendingInput[i];
card.x = parentPos.x - card.width / 2;
card.y = parentPos.y - card.height / 2;
card.opacity = 1;
card.destroy();
}
}
pendingInput = [];
}
}