2023-04-09 05:35:35 +00:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2022-09-14 05:01:10 +00:00
|
|
|
import QtQuick
|
2022-04-14 10:22:00 +00:00
|
|
|
import ".."
|
|
|
|
import "../../skin-bank.js" as SkinBank
|
|
|
|
|
|
|
|
/* Layout of EquipArea:
|
|
|
|
* | Treasure |
|
|
|
|
| Weapon |
|
|
|
|
| Armor |
|
|
|
|
| +1 | -1 |
|
|
|
|
+---------------+
|
|
|
|
*/
|
|
|
|
|
|
|
|
Column {
|
2022-04-30 07:27:56 +00:00
|
|
|
height: 88
|
|
|
|
width: 138
|
|
|
|
property int itemHeight: Math.floor(height / 4)
|
|
|
|
property var items: [treasureItem, weaponItem, armorItem, defensiveHorseItem, offensiveHorseItem]
|
|
|
|
property var subtypes: ["treasure", "weapon", "armor", "defensive_horse", "offensive_horse"]
|
|
|
|
property int length: area.length
|
|
|
|
|
|
|
|
InvisibleCardArea {
|
|
|
|
id: area
|
2023-01-29 10:11:41 +00:00
|
|
|
anchors.centerIn: parent
|
2022-04-30 07:27:56 +00:00
|
|
|
checkExisting: true
|
|
|
|
}
|
|
|
|
|
|
|
|
EquipItem {
|
|
|
|
id: treasureItem
|
|
|
|
width: parent.width
|
|
|
|
height: itemHeight
|
|
|
|
opacity: 0
|
|
|
|
}
|
|
|
|
|
|
|
|
EquipItem {
|
|
|
|
id: weaponItem
|
|
|
|
width: parent.width
|
|
|
|
height: itemHeight
|
|
|
|
opacity: 0
|
|
|
|
}
|
|
|
|
|
|
|
|
EquipItem {
|
|
|
|
id: armorItem
|
|
|
|
width: parent.width
|
|
|
|
height: itemHeight
|
|
|
|
opacity: 0
|
|
|
|
}
|
|
|
|
|
|
|
|
Row {
|
|
|
|
width: parent.width
|
|
|
|
height: itemHeight
|
|
|
|
|
|
|
|
Item {
|
|
|
|
width: Math.ceil(parent.width / 2)
|
|
|
|
height: itemHeight
|
|
|
|
|
|
|
|
EquipItem {
|
|
|
|
id: defensiveHorseItem
|
2022-04-14 10:22:00 +00:00
|
|
|
width: parent.width
|
|
|
|
height: itemHeight
|
2022-04-30 07:27:56 +00:00
|
|
|
icon: "horse"
|
2022-04-14 10:22:00 +00:00
|
|
|
opacity: 0
|
2022-04-30 07:27:56 +00:00
|
|
|
}
|
2022-04-14 10:22:00 +00:00
|
|
|
}
|
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
Item {
|
|
|
|
width: Math.floor(parent.width / 2)
|
|
|
|
height: itemHeight
|
2022-04-14 10:22:00 +00:00
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
EquipItem {
|
|
|
|
id: offensiveHorseItem
|
2022-04-14 10:22:00 +00:00
|
|
|
width: parent.width
|
|
|
|
height: itemHeight
|
2022-04-30 07:27:56 +00:00
|
|
|
icon: "horse"
|
2022-04-14 10:22:00 +00:00
|
|
|
opacity: 0
|
2022-04-30 07:27:56 +00:00
|
|
|
}
|
2022-04-14 10:22:00 +00:00
|
|
|
}
|
2022-04-30 07:27:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function add(inputs)
|
|
|
|
{
|
|
|
|
area.add(inputs);
|
|
|
|
|
|
|
|
let card, item;
|
|
|
|
if (inputs instanceof Array) {
|
|
|
|
for (let i = 0; i < inputs.length; i++) {
|
|
|
|
card = inputs[i];
|
|
|
|
item = items[subtypes.indexOf(card.subtype)];
|
|
|
|
item.setCard(card);
|
|
|
|
item.show();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
card = inputs;
|
|
|
|
item = items[subtypes.indexOf(card.subtype)];
|
|
|
|
item.setCard(card);
|
|
|
|
item.show();
|
2022-04-14 10:22:00 +00:00
|
|
|
}
|
2022-04-30 07:27:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function remove(outputs)
|
|
|
|
{
|
|
|
|
let result = area.remove(outputs);
|
|
|
|
for (let i = 0; i < result.length; i++) {
|
|
|
|
let card = result[i];
|
|
|
|
for (let j = 0; j < items.length; j++) {
|
|
|
|
let item = items[j];
|
|
|
|
if (item.cid === card.cid) {
|
|
|
|
item.reset();
|
|
|
|
item.hide();
|
2022-04-14 10:22:00 +00:00
|
|
|
}
|
2022-04-30 07:27:56 +00:00
|
|
|
}
|
2022-04-14 10:22:00 +00:00
|
|
|
}
|
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
return result;
|
|
|
|
}
|
2022-04-14 10:22:00 +00:00
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
function updateCardPosition(animated)
|
|
|
|
{
|
|
|
|
area.updateCardPosition(animated);
|
|
|
|
}
|
2022-09-14 05:01:10 +00:00
|
|
|
|
|
|
|
function getAllCards() {
|
|
|
|
return area.cards;
|
|
|
|
}
|
2022-04-14 10:22:00 +00:00
|
|
|
}
|
2022-03-23 11:40:28 +00:00
|
|
|
|