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
|
2023-05-19 10:08:36 +08:00
|
|
|
import Fk
|
|
|
|
import Fk.RoomElement
|
2022-04-14 18:22:00 +08:00
|
|
|
|
|
|
|
/* Layout of EquipArea:
|
|
|
|
* | Treasure |
|
|
|
|
| Weapon |
|
|
|
|
| Armor |
|
|
|
|
| +1 | -1 |
|
|
|
|
+---------------+
|
|
|
|
*/
|
|
|
|
|
|
|
|
Column {
|
2023-06-10 02:18:51 +08:00
|
|
|
height: 70
|
2022-04-30 15:27:56 +08:00
|
|
|
width: 138
|
2023-06-10 02:18:51 +08:00
|
|
|
property int itemHeight: treasureItem.name === "" ? height / 3 : height / 4
|
2022-04-30 15:27:56 +08:00
|
|
|
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 18:11:41 +08:00
|
|
|
anchors.centerIn: parent
|
2022-04-30 15:27:56 +08:00
|
|
|
checkExisting: true
|
|
|
|
}
|
|
|
|
|
|
|
|
EquipItem {
|
|
|
|
id: treasureItem
|
|
|
|
width: parent.width
|
2023-06-10 02:18:51 +08:00
|
|
|
height: name === "" ? 0 : itemHeight
|
2022-04-30 15:27:56 +08:00
|
|
|
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 18:22:00 +08:00
|
|
|
width: parent.width
|
|
|
|
height: itemHeight
|
2022-04-30 15:27:56 +08:00
|
|
|
icon: "horse"
|
2022-04-14 18:22:00 +08:00
|
|
|
opacity: 0
|
2022-04-30 15:27:56 +08:00
|
|
|
}
|
2022-04-14 18:22:00 +08:00
|
|
|
}
|
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
Item {
|
|
|
|
width: Math.floor(parent.width / 2)
|
|
|
|
height: itemHeight
|
2022-04-14 18:22:00 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
EquipItem {
|
|
|
|
id: offensiveHorseItem
|
2022-04-14 18:22:00 +08:00
|
|
|
width: parent.width
|
|
|
|
height: itemHeight
|
2022-04-30 15:27:56 +08:00
|
|
|
icon: "horse"
|
2022-04-14 18:22:00 +08:00
|
|
|
opacity: 0
|
2022-04-30 15:27:56 +08:00
|
|
|
}
|
2022-04-14 18:22:00 +08:00
|
|
|
}
|
2022-04-30 15:27:56 +08: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 18:22:00 +08:00
|
|
|
}
|
2022-04-30 15:27:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function remove(outputs)
|
|
|
|
{
|
2023-06-09 17:23:02 +08:00
|
|
|
const result = area.remove(outputs);
|
2022-04-30 15:27:56 +08:00
|
|
|
for (let i = 0; i < result.length; i++) {
|
2023-06-09 17:23:02 +08:00
|
|
|
const card = result[i];
|
2022-04-30 15:27:56 +08:00
|
|
|
for (let j = 0; j < items.length; j++) {
|
2023-06-09 17:23:02 +08:00
|
|
|
const item = items[j];
|
2022-04-30 15:27:56 +08:00
|
|
|
if (item.cid === card.cid) {
|
|
|
|
item.reset();
|
|
|
|
item.hide();
|
2022-04-14 18:22:00 +08:00
|
|
|
}
|
2022-04-30 15:27:56 +08:00
|
|
|
}
|
2022-04-14 18:22:00 +08:00
|
|
|
}
|
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
return result;
|
|
|
|
}
|
2022-04-14 18:22:00 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
function updateCardPosition(animated)
|
|
|
|
{
|
|
|
|
area.updateCardPosition(animated);
|
|
|
|
}
|
2022-09-14 13:01:10 +08:00
|
|
|
|
|
|
|
function getAllCards() {
|
|
|
|
return area.cards;
|
|
|
|
}
|
2022-04-14 18:22:00 +08:00
|
|
|
}
|