FreeKill/qml/Pages/RoomElement/GuanxingBox.qml
notify c6d883eccf Standard skills (#48)
* huatuo

* biyue

* gender of player

* let tablepile smaller

* card emotions

* remove getOtherPlayers

* guicai

* skill audio

* card audio

* death audio

* bgm

* damage sound

* local bgm

* add more skill audio

* android: dont link to quickcontrol2

* android: fix ifndef

* yield only when need

* modify cpp according to clazy

* reduce malloc times

* revert yield

* qingguo

* fix back to lobby

* use compact json in cpp

* notifySkillInvoke animation

* util: string2json

* losehp; tablepile fix

* judge result animation

* add scrollbar for logedit

* add lock on waitForReply

* fix: virtual jink has no effect

* tiandu

* fix: duplicated cards when related to equiparea

* ui: disable okcancel when replying

* ui: disable invaild card when responding

* game: skill & card use history

* game: more judge on vsskill's canUse

* luoyi

* login page i18n

* i18n for server error message

* tuxi

* expand equip area when needed

* add footnote to cards from pile

* ui: only filter CanUseCard when playing

* expand equip when responding

* prompt

* prompt for askforchoice

* guanxing

* fix guanxing

* tieqi

* liuli

* doc for trigger skill

* xiaoji

* lianying

* fanjian

* rende

* add skill's subclass

* TODO: add tmd skill functions for other cards

* paoxiao

* qicai

* guose

* yiji (WIP)
2023-01-29 18:11:41 +08:00

133 lines
2.8 KiB
QML

import QtQuick
import QtQuick.Layouts
import ".."
GraphicsBox {
id: root
property var cards: []
property var result: []
property var areaCapacities: []
property var areaNames: []
property int padding: 25
title.text: Backend.translate("Please arrange cards")
width: body.width + padding * 2
height: title.height + body.height + padding * 2
ColumnLayout {
id: body
x: padding
y: parent.height - padding - height
spacing: 20
Repeater {
id: areaRepeater
model: areaCapacities
Row {
spacing: 5
property int areaCapacity: modelData
property string areaName: index < areaNames.length ? qsTr(areaNames[index]) : ""
Repeater {
id: cardRepeater
model: areaCapacity
Rectangle {
color: "#1D1E19"
width: 93
height: 130
Text {
anchors.centerIn: parent
text: areaName
color: "#59574D"
width: parent.width * 0.8
wrapMode: Text.WordWrap
}
}
}
property alias cardRepeater: cardRepeater
}
}
MetroButton {
Layout.alignment: Qt.AlignHCenter
text: Backend.translate("OK")
width: 120
height: 35
onClicked: close();
}
}
Repeater {
id: cardItem
model: cards
CardItem {
x: index
y: -1
cid: modelData.cid
name: modelData.name
suit: modelData.suit
number: modelData.number
draggable: true
onReleased: arrangeCards();
}
}
function arrangeCards() {
result = new Array(areaCapacities.length);
let i;
for (i = 0; i < result.length; i++)
result[i] = [];
let card, j, area, cards, stay;
for (i = 0; i < cardItem.count; i++) {
card = cardItem.itemAt(i);
stay = true;
for (j = areaRepeater.count - 1; j >= 0; j--) {
area = areaRepeater.itemAt(j);
cards = result[j];
if (cards.length < areaCapacities[j] && card.y >= area.y) {
cards.push(card);
stay = false;
break;
}
}
if (stay)
result[0].push(card);
}
for(i = 0; i < result.length; i++)
result[i].sort((a, b) => a.x - b.x);
let box, pos, pile;
for (j = 0; j < areaRepeater.count; j++) {
pile = areaRepeater.itemAt(j);
for (i = 0; i < result[j].length; i++) {
box = pile.cardRepeater.itemAt(i);
pos = mapFromItem(pile, box.x, box.y);
card = result[j][i];
card.origX = pos.x;
card.origY = pos.y;
card.goBack(true);
}
}
}
function getResult() {
let ret = [];
result.forEach(t => {
let t2 = [];
t.forEach(v => t2.push(v.cid));
ret.push(t2);
});
return ret;
}
}