修更多小bug
This commit is contained in:
notify 2023-07-01 23:14:30 +08:00 committed by GitHub
parent fd270a2edb
commit cee3ec279d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 35 additions and 17 deletions

View File

@ -29,7 +29,7 @@ callbacks["ServerDetected"] = (j) => {
} }
callbacks["GetServerDetail"] = (j) => { callbacks["GetServerDetail"] = (j) => {
const [addr, ver, icon, desc, capacity, count] = JSON.parse(j); const [ver, icon, desc, capacity, count, addr] = JSON.parse(j);
const serverDialog = mainStack.currentItem.serverDialog; const serverDialog = mainStack.currentItem.serverDialog;
if (!serverDialog) { if (!serverDialog) {
return; return;

View File

@ -19,6 +19,7 @@ Item {
Item { Item {
height: 64 height: 64
width: serverList.width - 48 width: serverList.width - 48
clip: true
RowLayout { RowLayout {
anchors.fill: parent anchors.fill: parent
@ -31,16 +32,26 @@ Item {
source: favicon source: favicon
} }
Text { ColumnLayout {
text: serverIP Layout.fillWidth: true
} Text {
Layout.fillWidth: true
horizontalAlignment: Text.AlignLeft
text: serverIP
font.bold: true
}
Text { Text {
text: description Layout.fillWidth: true
horizontalAlignment: Text.AlignLeft
text: description
textFormat: TextEdit.RichText
}
} }
Text { Text {
text: online + "/" + capacity text: online + "/" + capacity
font.pixelSize: 30
} }
} }
@ -357,7 +368,8 @@ Item {
const [ver, icon, desc, capacity, count] = data; const [ver, icon, desc, capacity, count] = data;
for (let i = 0; i < serverModel.count; i++) { for (let i = 0; i < serverModel.count; i++) {
const item = serverModel.get(i); const item = serverModel.get(i);
if (addr.endsWith(item.serverIP)) { // endsWithIPv6ip const ip = item.serverIP;
if (addr.endsWith(ip)) { // endsWithIPv6ip
item.description = FkVersion === ver ? desc : "Ver " + ver; item.description = FkVersion === ver ? desc : "Ver " + ver;
item.favicon = icon; item.favicon = icon;
item.online = count.toString(); item.online = count.toString();
@ -376,7 +388,7 @@ Item {
description: qsTr("Server not up"), description: qsTr("Server not up"),
online: "-", online: "-",
capacity: "-", capacity: "-",
favicon: "https://img1.imgtp.com/2023/07/01/DGUdj8eu.png", favicon: "",
}); });
Backend.getServerInfo(key); Backend.getServerInfo(key);
} }

View File

@ -47,12 +47,14 @@ local sendCardEmotionAndLog = function(room, cardUseEvent)
-- when this function is called, card is already in PlaceTable and no filter skill is applied. -- when this function is called, card is already in PlaceTable and no filter skill is applied.
-- So filter this card manually here to get 'real' use.card -- So filter this card manually here to get 'real' use.card
local card = _card local card = _card
---[[
if not _card:isVirtual() then if not _card:isVirtual() then
local temp = { card = _card } local temp = { card = _card }
Fk:filterCard(_card.id, room:getPlayerById(from), temp) Fk:filterCard(_card.id, room:getPlayerById(from), temp)
card = temp.card card = temp.card
end end
cardUseEvent.card = card cardUseEvent.card = card
--]]
playCardEmotionAndSound(room, room:getPlayerById(from), card) playCardEmotionAndSound(room, room:getPlayerById(from), card)
room:doAnimate("Indicate", { room:doAnimate("Indicate", {

View File

@ -1501,8 +1501,6 @@ function Room:handleUseCardReply(player, data)
Self = player Self = player
local c = skill:viewAs(selected_cards) local c = skill:viewAs(selected_cards)
if c then if c then
self:useSkill(player, skill, Util.DummyFunc)
local use = {} ---@type CardUseStruct local use = {} ---@type CardUseStruct
use.from = player.id use.from = player.id
use.tos = {} use.tos = {}
@ -1515,6 +1513,9 @@ function Room:handleUseCardReply(player, data)
use.card = c use.card = c
skill:beforeUse(player, use) skill:beforeUse(player, use)
self:useSkill(player, skill, Util.DummyFunc)
return use return use
end end
end end
@ -1538,6 +1539,7 @@ function Room:handleUseCardReply(player, data)
if #use.tos == 0 then if #use.tos == 0 then
use.tos = nil use.tos = nil
end end
Fk:filterCard(card, player)
use.card = Fk:getCardById(card) use.card = Fk:getCardById(card)
return use return use
end end

View File

@ -203,7 +203,7 @@ local fireAttackSkill = fk.CreateActiveSkill{
local to = room:getPlayerById(cardEffectEvent.to) local to = room:getPlayerById(cardEffectEvent.to)
if to:isKongcheng() then return end if to:isKongcheng() then return end
local showCard = room:askForCard(to, 1, 1, false, self.name, false, nil, "#fire_attack-show:" .. from.id)[1] local showCard = room:askForCard(to, 1, 1, false, self.name, false, ".|.|.|hand", "#fire_attack-show:" .. from.id)[1]
to:showCards(showCard) to:showCards(showCard)
showCard = Fk:getCardById(showCard) showCard = Fk:getCardById(showCard)

View File

@ -39,7 +39,6 @@ Server::Server(QObject *parent) : QObject(parent) {
&Server::processNewConnection); &Server::processNewConnection);
udpSocket = new QUdpSocket(this); udpSocket = new QUdpSocket(this);
udpSocket->bind(9527);
connect(udpSocket, &QUdpSocket::readyRead, connect(udpSocket, &QUdpSocket::readyRead,
this, &Server::readPendingDatagrams); this, &Server::readPendingDatagrams);
@ -95,6 +94,7 @@ Server::~Server() {
bool Server::listen(const QHostAddress &address, ushort port) { bool Server::listen(const QHostAddress &address, ushort port) {
bool ret = server->listen(address, port); bool ret = server->listen(address, port);
udpSocket->bind(port);
isListening = ret; isListening = ret;
return ret; return ret;
} }
@ -632,13 +632,14 @@ void Server::readPendingDatagrams() {
void Server::processDatagram(const QByteArray &msg, const QHostAddress &addr, uint port) { void Server::processDatagram(const QByteArray &msg, const QHostAddress &addr, uint port) {
if (msg == "fkDetectServer") { if (msg == "fkDetectServer") {
udpSocket->writeDatagram("me", addr, port); udpSocket->writeDatagram("me", addr, port);
} else if (msg == "fkGetDetail") { } else if (msg.startsWith("fkGetDetail,")) {
udpSocket->writeDatagram(JsonArray2Bytes(QJsonArray({ udpSocket->writeDatagram(JsonArray2Bytes(QJsonArray({
FK_VERSION, FK_VERSION,
getConfig("iconUrl"), getConfig("iconUrl"),
getConfig("description"), getConfig("description"),
getConfig("capacity"), getConfig("capacity"),
players.count(), players.count(),
msg.sliced(12).constData(),
})), addr, port); })), addr, port);
} }
udpSocket->flush(); udpSocket->flush();

View File

@ -337,7 +337,7 @@ void QmlBackend::detectServer() {
void QmlBackend::getServerInfo(const QString &address) { void QmlBackend::getServerInfo(const QString &address) {
QString addr = "127.0.0.1"; QString addr = "127.0.0.1";
ushort port = 9527u; ushort port = 9527u;
static const char *ask_str = "fkGetDetail"; static const char *ask_str = "fkGetDetail,";
if (address.contains(QChar(':'))) { if (address.contains(QChar(':'))) {
QStringList texts = address.split(QChar(':')); QStringList texts = address.split(QChar(':'));
@ -347,8 +347,10 @@ void QmlBackend::getServerInfo(const QString &address) {
addr = address; addr = address;
} }
udpSocket->writeDatagram(ask_str, QByteArray ask(ask_str);
strlen(ask_str), ask.append(address.toLatin1());
udpSocket->writeDatagram(ask, ask.size(),
QHostAddress(addr), port); QHostAddress(addr), port);
} }
@ -364,7 +366,6 @@ void QmlBackend::readPendingDatagrams() {
emit notifyUI("ServerDetected", addr.toString()); emit notifyUI("ServerDetected", addr.toString());
} else { } else {
auto arr = QJsonDocument::fromJson(data).array(); auto arr = QJsonDocument::fromJson(data).array();
arr.prepend(addr.toString());
emit notifyUI("GetServerDetail", JsonArray2Bytes(arr)); emit notifyUI("GetServerDetail", JsonArray2Bytes(arr));
} }
} }