From 278e7ce4c64e8a2cf1c2b1f772cc4e1a5b3e0f46 Mon Sep 17 00:00:00 2001 From: notify Date: Thu, 28 Dec 2023 12:11:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=B8=E6=88=8F=E6=97=B6=E9=95=BF=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=20(#302)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 修复和完善qml mark * 修复国战野心家放副将 * [需要编译] 统计游戏时长功能 * 后台也开始记录注册时间和上次上线的时间 * 现在会将屏蔽玩家保存到本地并标红提示 --- Fk/Cheat/PlayerDetail.qml | 10 ++ Fk/Config.qml | 3 + Fk/LobbyElement/PersonalSettings.qml | 31 +++++ Fk/Logic.js | 4 + Fk/Pages/Room.qml | 2 +- Fk/PhotoElement/MarkArea.qml | 9 +- Fk/RoomElement/CardItem.qml | 2 + Fk/RoomElement/ChooseGeneralBox.qml | 3 +- Fk/RoomElement/GeneralCardItem.qml | 20 +-- Fk/RoomElement/Photo.qml | 2 +- docs/misc/calcDailyLogin.sh | 29 +++++ docs/misc/history.txt | 127 +++++++++++++++++++ docs/misc/qsgs/01-history.txt | 122 ++++++++++++++++++ docs/misc/server_admin.md | 23 ++++ image/card/general/card-back.png | Bin 0 -> 9042 bytes lua/client/client.lua | 16 ++- lua/client/client_util.lua | 13 +- lua/client/i18n/en_US.lua | 2 + lua/client/i18n/zh_CN.lua | 3 + lua/core/player.lua | 2 + lua/fk_ex.lua | 4 +- lua/server/request.lua | 2 + lua/server/serverplayer.lua | 7 +- server/init.sql | 7 + src/core/player.cpp | 8 +- src/core/player.h | 4 + src/server/room.cpp | 28 +++- src/server/server.cpp | 183 +++++++++++++-------------- src/server/server.h | 8 +- src/server/serverplayer.cpp | 17 +++ src/server/serverplayer.h | 9 ++ src/swig/player.i | 3 + 32 files changed, 573 insertions(+), 130 deletions(-) create mode 100755 docs/misc/calcDailyLogin.sh create mode 100644 docs/misc/history.txt create mode 100644 docs/misc/qsgs/01-history.txt create mode 100644 docs/misc/server_admin.md create mode 100644 image/card/general/card-back.png diff --git a/Fk/Cheat/PlayerDetail.qml b/Fk/Cheat/PlayerDetail.qml index f600fe3c..a582a993 100644 --- a/Fk/Cheat/PlayerDetail.qml +++ b/Fk/Cheat/PlayerDetail.qml @@ -92,6 +92,7 @@ Flickable { config.blockedUsersChanged(); } } + MetroButton { text: Backend.translate("Kick From Room") visible: !roomScene.isStarted && roomScene.isOwner @@ -168,11 +169,20 @@ Flickable { const total = gamedata[0]; const win = gamedata[1]; const run = gamedata[2]; + const totalTime = gamedata[3]; const winRate = (win / total) * 100; const runRate = (run / total) * 100; playerGameData.text = total === 0 ? Backend.translate("Newbie") : Backend.translate("Win=%1 Run=%2 Total=%3").arg(winRate.toFixed(2)) .arg(runRate.toFixed(2)).arg(total); + + const h = (totalTime / 3600).toFixed(2); + const m = Math.floor(totalTime / 60); + if (m < 100) { + playerGameData.text += " " + Backend.translate("TotalGameTime: %1 min").arg(m); + } else { + playerGameData.text += " " + Backend.translate("TotalGameTime: %1 h").arg(h); + } } const data = JSON.parse(Backend.callLuaFunction("GetPlayerSkills", [id])); diff --git a/Fk/Config.qml b/Fk/Config.qml index 013c07f4..1d5c079c 100644 --- a/Fk/Config.qml +++ b/Fk/Config.qml @@ -50,6 +50,7 @@ QtObject { property bool observing: false property bool replaying: false property list blockedUsers: [] + property int totalTime: 0 // FIXME: only for notifying onDisabledGeneralsChanged: { disableGeneralSchemes[disableSchemeIdx] = disabledGenerals; @@ -89,6 +90,7 @@ QtObject { disabledGenerals = conf.disabledGenerals ?? []; disableGeneralSchemes = conf.disableGeneralSchemes ?? [ disabledGenerals ]; disableSchemeIdx = conf.disableSchemeIdx ?? 0; + blockedUsers = conf.blockedUsers ?? []; } function saveConf() { @@ -117,6 +119,7 @@ QtObject { conf.disabledGenerals = disabledGenerals; conf.disableGeneralSchemes = disableGeneralSchemes; conf.disableSchemeIdx = disableSchemeIdx; + conf.blockedUsers = blockedUsers; Backend.saveConf(JSON.stringify(conf, undefined, 2)); } diff --git a/Fk/LobbyElement/PersonalSettings.qml b/Fk/LobbyElement/PersonalSettings.qml index 0543eff7..70bba354 100644 --- a/Fk/LobbyElement/PersonalSettings.qml +++ b/Fk/LobbyElement/PersonalSettings.qml @@ -10,6 +10,37 @@ Item { width: bg.width height: bg.height + Rectangle { + x: 84; y: 31.6 + height: 20 + width: childrenRect.width + 48 + + gradient: Gradient { + orientation: Gradient.Horizontal + GradientStop { position: 0.7; color: "#AA3598E8" } + GradientStop { position: 1.0; color: "transparent" } + } + Text { + text: { + config.totalTime; + const gamedata = JSON.parse(Backend.callLuaFunction("GetPlayerGameData", [Self.id])); + const totalTime = gamedata[3]; + const h = (totalTime / 3600).toFixed(2); + const m = Math.floor(totalTime / 60); + if (m < 100) { + return Backend.translate("TotalGameTime: %1 min").arg(m); + } else { + return Backend.translate("TotalGameTime: %1 h").arg(h); + } + } + x: 12; y: 1 + font.family: fontLibian.name + font.pixelSize: 16 + color: "white" + //style: Text.Outline + } + } + Image { id: bg x: -32 diff --git a/Fk/Logic.js b/Fk/Logic.js index 15a011ea..01eebe73 100644 --- a/Fk/Logic.js +++ b/Fk/Logic.js @@ -194,3 +194,7 @@ callbacks["ServerMessage"] = (jsonData) => { callbacks["ShowToast"] = (j) => toast.show(j); callbacks["InstallKey"] = (j) => Backend.installAESKey(); + +callbacks["AddTotalGameTime"] = (jsonData) => { + config.totalTime++; +} diff --git a/Fk/Pages/Room.qml b/Fk/Pages/Room.qml index 6f717f1b..33c5b52c 100644 --- a/Fk/Pages/Room.qml +++ b/Fk/Pages/Room.qml @@ -1276,7 +1276,7 @@ Item { gameData = JSON.parse(Backend.callLuaFunction("GetPlayerGameData", [item.id])); } catch (e) { console.log(e); - gameData = [0, 0, 0]; + gameData = [0, 0, 0, 0]; } if (item.id > 0) { datalist.push({ diff --git a/Fk/PhotoElement/MarkArea.qml b/Fk/PhotoElement/MarkArea.qml index f4e5ed0c..8a1d625a 100644 --- a/Fk/PhotoElement/MarkArea.qml +++ b/Fk/PhotoElement/MarkArea.qml @@ -75,10 +75,10 @@ Item { if (close_br === -1) return; const mark_type = mark_name.slice(2, close_br); - const _data = (mark_extra); - let data = JSON.parse(Backend.callLuaFunction("GetQmlMark", [mark_type, mark_name, JSON.stringify(_data)])); + const _data = mark_extra; + let data = JSON.parse(Backend.callLuaFunction("GetQmlMark", [mark_type, mark_name, _data, root.parent?.playerid])); if (data && data.qml_path) { - params.data = _data; + params.data = JSON.parse(_data); roomScene.startCheat("../../" + data.qml_path, params); } return; @@ -122,7 +122,8 @@ Item { const close_br = mark.indexOf(']'); if (close_br !== -1) { const mark_type = mark.slice(2, close_br); - const _data = JSON.parse(Backend.callLuaFunction("GetQmlMark", [mark_type, mark, JSON.stringify(data)])); + data = JSON.stringify(data); + const _data = JSON.parse(Backend.callLuaFunction("GetQmlMark", [mark_type, mark, data, root.parent?.playerid])); if (_data && _data.text) { special_value = _data.text; } diff --git a/Fk/RoomElement/CardItem.qml b/Fk/RoomElement/CardItem.qml index 31537b3f..bd9cdc9f 100644 --- a/Fk/RoomElement/CardItem.qml +++ b/Fk/RoomElement/CardItem.qml @@ -227,6 +227,7 @@ Item { anchors.horizontalCenter: parent.horizontalCenter y: 90 scale: 1.25 + z: 1 } Rectangle { @@ -234,6 +235,7 @@ Item { anchors.fill: parent color: Qt.rgba(0, 0, 0, 0.5) opacity: 0.7 + z: 2 } Text { diff --git a/Fk/RoomElement/ChooseGeneralBox.qml b/Fk/RoomElement/ChooseGeneralBox.qml index 34825c95..ba5d2a6f 100644 --- a/Fk/RoomElement/ChooseGeneralBox.qml +++ b/Fk/RoomElement/ChooseGeneralBox.qml @@ -228,7 +228,8 @@ GraphicsBox { } root.choicesChanged(); - fightButton.enabled = (choices.length == choiceNum); + fightButton.enabled = (choices.length == choiceNum) && + (needSameKingdom ? isHegPair(selectedItem[0], selectedItem[1]) : true); for (i = 0; i < generalCardList.count; i++) { item = generalCardList.itemAt(i); diff --git a/Fk/RoomElement/GeneralCardItem.qml b/Fk/RoomElement/GeneralCardItem.qml index 290882c0..70bac4e5 100644 --- a/Fk/RoomElement/GeneralCardItem.qml +++ b/Fk/RoomElement/GeneralCardItem.qml @@ -29,14 +29,14 @@ CardItem { suit: "" number: 0 footnote: "" - card.source: SkinBank.getGeneralPicture(name) + card.source: known ? SkinBank.getGeneralPicture(name) : (SkinBank.GENERALCARD_DIR + 'card-back') glow.color: "white" //Engine.kingdomColor[kingdom] // FIXME: 藕!! property bool heg: name.startsWith('hs__') || name.startsWith('ld__') || name.includes('heg__') Image { - source: SkinBank.GENERALCARD_DIR + "border" + source: known ? (SkinBank.GENERALCARD_DIR + "border") : "" } Image { @@ -44,7 +44,7 @@ CardItem { width: 34; fillMode: Image.PreserveAspectFit transformOrigin: Item.TopLeft source: SkinBank.getGeneralCardDir(kingdom) + kingdom - visible: detailed + visible: detailed && known } Image { @@ -52,14 +52,14 @@ CardItem { transformOrigin: Item.TopLeft width: 34; fillMode: Image.PreserveAspectFit source: subkingdom ? SkinBank.getGeneralCardDir(subkingdom) + subkingdom : "" - visible: detailed + visible: detailed && known } Row { x: 34 y: 4 spacing: 1 - visible: detailed && !heg + visible: detailed && known && !heg Repeater { id: hpRepeater model: (!heg) ? ((hp > 5 || hp !== maxHp) ? 1 : hp) : 0 @@ -106,7 +106,7 @@ CardItem { x: 34 y: 3 spacing: 0 - visible: detailed && heg + visible: detailed && known && heg Repeater { id: hegHpRepeater model: heg ? ((hp > 7 || hp !== maxHp) ? 1 : Math.ceil(hp / 2)) : 0 @@ -140,7 +140,7 @@ CardItem { } Shield { - visible: shieldNum > 0 && detailed + visible: shieldNum > 0 && detailed && known anchors.right: parent.right anchors.top: parent.top anchors.topMargin: hpRepeater.model > 4 ? 16 : 0 @@ -154,7 +154,7 @@ CardItem { x: 2 y: lineCount > 6 ? 30 : 34 text: name !== "" ? Backend.translate(name) : "nil" - visible: Backend.translate(name).length <= 6 && detailed + visible: Backend.translate(name).length <= 6 && detailed && known color: "white" font.family: fontLibian.name font.pixelSize: 18 @@ -169,7 +169,7 @@ CardItem { rotation: 90 transformOrigin: Item.BottomLeft text: Backend.translate(name) - visible: Backend.translate(name).length > 6 && detailed + visible: Backend.translate(name).length > 6 && detailed && known color: "white" font.family: fontLibian.name font.pixelSize: 18 @@ -177,7 +177,7 @@ CardItem { } Rectangle { - visible: pkgName !== "" && detailed + visible: pkgName !== "" && detailed && known height: 16 width: childrenRect.width + 4 anchors.bottom: parent.bottom diff --git a/Fk/RoomElement/Photo.qml b/Fk/RoomElement/Photo.qml index 641643f7..7c111b94 100644 --- a/Fk/RoomElement/Photo.qml +++ b/Fk/RoomElement/Photo.qml @@ -531,7 +531,7 @@ Item { anchors.topMargin: 2 font.pixelSize: 16 - text: screenName + text: (config.blockedUsers && config.blockedUsers.includes(screenName) ? Backend.translate(" ") : "") + screenName glow.radius: 8 } diff --git a/docs/misc/calcDailyLogin.sh b/docs/misc/calcDailyLogin.sh new file mode 100755 index 00000000..dfa71f08 --- /dev/null +++ b/docs/misc/calcDailyLogin.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# 用于统计新月杀日活的脚本,可以写入定时任务。 + +# 我自己是把数据库文件在这个目录创了符号链接,总之确保这里存在那个数据库,可以手动cd +# cd ~ + +SQLITE_CMD="sqlite3 users.db -readonly -list -batch -bail -cmd " +SEL_REG="SELECT count() FROM usergameinfo WHERE date(registerTime, 'unixepoch', 'localtime') >= date('now', 'localtime', 'start of day') AND date(registerTime, 'unixepoch', 'localtime') < date('now', 'localtime', 'start of day', '+1 days');" +SEL_LOG="SELECT count() FROM usergameinfo WHERE date(lastLoginTime, 'unixepoch', 'localtime') >= date('now', 'localtime', 'start of day') AND date(lastLoginTime, 'unixepoch', 'localtime') < date('now', 'localtime', 'start of day', '+1 days');" + +i=0 +# 数据库可能被锁定,需要循环 +false # 令$?为1,不知道怎么写do while循环 +while [ 0 -ne $? ]; do + sleep 0.3 + i=$[i+1] + if [ $i -ge 30 ]; then exit; fi + REG_COUNT=$($SQLITE_CMD "$SEL_REG" < /dev/null) +done + +false +while [ 0 -ne $? ]; do + sleep 0.3 + i=$[i+1] + if [ $i -ge 30 ]; then exit; fi + LOG_COUNT=$($SQLITE_CMD "$SEL_LOG" < /dev/null) +done + +echo "$(date +'%Y-%m-%d'),${REG_COUNT},${LOG_COUNT}" >> loginInfo.csv diff --git a/docs/misc/history.txt b/docs/misc/history.txt new file mode 100644 index 00000000..615e34c2 --- /dev/null +++ b/docs/misc/history.txt @@ -0,0 +1,127 @@ +新月杀记事本 by Notify + +在协力开发新月杀时(当然了,包括创文件夹之前)我也有在考据神杀的各种历史。总感觉以后新月杀也会自然而然走到需要考据的那一步呢,不如直接把一些琐事记载于此,方便想了解的人直接观看。 + +总而言之,开写吧,我还要整合一下从立项至今的各种事情。以后这里估计成月度总结.txt了。 + +2022年 +======================= + +* 1月~2月 + +在此之前我主要在制作太阳神三国杀2015版的lua拓展包。在几经重构后终于放弃了神杀,和 Ho-spair(下称惑神) 共商新的Qt三国杀大计。当时提出的就是继承太阳神三国杀的精神,继续开源并使用Qt和Lua开发。当然了都是用最新版,太阳神卡在Qt 5.5了才导致维护困难。 + +新的三国杀游戏名曰FreeKill。因为目标是做便于各种拓展的平台,所以一开始就决定把各种拓展包排除到本体仓库之外,游戏只自带标准包。 + +* 12月 + +在与惑神协力了一年后,新游戏大体框架初步落成。两人分工明确,我做Qt通信、UI以及一些别的底层细节相关,惑神对规则集比较熟悉,做了游戏逻辑的主体。同时解决了Windows和安卓平台的编译问题。这个月内也完成了绝大多数卡牌。为了便于吸引神杀Luaer,拓展格式也是采用非常接近神杀的语法。 + + - 五谷丰登妥协成所有人各摸一张。属于是最初的特色( + +当时差不多就是白天做完了之后晚上和惑神开1v1测试。刚好我双11捡了个新客服务器,就拿来搭建联机用了。因为有了安卓版所以联机游玩也方便多了。游戏卡牌都是慢慢开发的,很多卡牌连效果都没有,但是可以用出去(除了少一张手牌外无事发生)。 + +2023年 +======================= + +* 1月~2月 + +继续开发,基本完成标准包武将技能、标准包装备卡等。给Linux写了个PKGBUILD,当然估计只有我自己在用。以及新月杀最重要的在线更新功能也是此时做的,这个功能出来之后游戏基本也称之为挺好拓展的了。最后差不多告成,在大约2月中旬时候发布了v0.0.1版本(因为种种原因该版本不在git tag中了)。 + +最初的宣传贴发在太阳神三国杀吧 (https://tieba.baidu.com/p/8265967671) 。不知为何(可能因为手机能玩吧)这个几乎啥也没有的版本吸引了一些无名杀玩家,于是有了第一波小引流。 + +在不断的催促之下做了一个完全随机的AI系统来糊弄玩家。(为什么都不来联机呢,服务器就在那啊)并在月底踩点最后一天发出v0.0.2版。 + +v0.0.1版本使用小米logo生成器做了个橘色的“fk”图标,开屏欢迎图是凰舞九天*关银屏(FreeKill 自由-开放-拓展) + +* 3月 + +没人联机的原因也很简单,只有标包谁玩啊!刚好游戏不是有在线更新拓展包功能吗,于是第一个拓展包joy (https://gitee.com/notify-ctrl/joy) 产生。当时游戏虽然本身功能非常不齐全,但是做点简单的武将还是可以的。 + +首先加入战场的是:刘焉、留赞、戏志才、界徐盛。这四位打标包属于是难以评价了。过几天后v0.0.3发布,随之惑神在joy中加入了麴义和王基。 + +借助joy包和自动更新机制,我进一步在神杀群宣传。终于3月24日RalphR((=゚ω゚)ノ R神!为R神欢呼!)加入了新月杀拓展的开发中。后面的不用多说,R神成为最核心的拓展开发者之一,为FreeKill拓展更多官方武将。 + + - 顺便一提,在joy时期,他最先添加的是周宣、朱建平、曹金玉、张嫙。然而当时joy里面的都是手杀和OL的强将,新杀阴间一进来属于是降维打击了,可谓是早早奠定了FreeKill阴间横行的基调呀…… + +3月26日nyutanislavsky(nyutan,下称Nyu神。膜Nyu神!)提交了一个海外服的仓库链接。与joy包自由散漫的添加热门武将不同,海外服包专注于海外服。 + +因为人太少了,就做了斗地主模式。2月底引来的玩家也基本只是看个热闹,此时的基调就是偶尔联机打打斗地主了,在线峰值3人。除了开发者们外,最活跃的玩家当属星空之遥了。(其实也没多活跃,服务器基本没人玩) + +为了进一步拉拢新人参与拓展开发,FreeKill项目文档启动。(是的就是这个docs文件夹)然而我的文笔实在让R神吐槽看不懂 = = + +* 4月 + +超级妖梦厨加入开发中,主要是做自己的mod,但也会来帮忙做一些本体代码。 + +vup杀选择了FreeKill来继续发展。这也成为了计划转向FreeKill的第一个神杀mod。正因为是第一个导致我经常干涉拓展开发者他的进度如何。 + +这个月基本没啥,联机仍处于日活不足10人的状态,大家也都在慢慢开发新功能、新代码。这个月凑得出军八了,我记得江水澄秋和马蹄糕是很活跃的玩家。 + +因为人数不多,这阶段无论是版本更新还是重启服务器都挺随心所欲的。 + +* 5月 + +还是维持着不温不火的状态直到v0.1.9版本。这期间人少,对局风格偏向于群内局。(阴间全ban,对局算比较平衡,除了国际服李彦和呼除泉这俩阴间我因为不认识忘记ban了) + +为了更加便于吸引新玩家,我们决定给项目取一个中文名字,几经讨论最后确定为新月杀。与此同时还添加了密码房、观战之类的设施,修了很多恶性bug,在R神和Nyu神的爆肝之下武将进度也十分喜人,最终做出了感觉适合引流的v0.2.0版本。 + +果不其然,视频发出去之后就吸引了不少路人,服务器达到二三十多、后来乃至上百人在线。然而这也给v0.2.0暴露了一大堆问题: + - 房间列表自动刷新导致根本点不到想进入的房间 + - 进房没有准备机制,人满自动开 + - 逃跑不惩罚,一桌军八6个逃跑(最开始的话人很少,大家都挺守规矩) + - 之前把阴间全ban了,而路人爱玩阴间,导致那些将根本没怎么测试bug巨多 + - 防误触的长按Quit按钮对于路人而言属于是反人类了(怎么全都在半路Quit啊) + +问题归问题,服务器刚刚满20在线的时候,开发组里面简单像是庆祝一样。后来人越来越多,暴露的问题也使开发组从庆祝转向忙碌的修bug。 + + > 辛苦R神了,被各种反馈张嫙的bug改到吐 + +ken神(神杀幻天漫杀设计开发者)加入FreeKill并着手制作自己的拓展包。 + +v0.2.0的logo是白底上一个黑色的“殺”字,右上角蓝色的“新月”。开屏图片改为一舞倾城*貂蝉(新月杀 自由-开放-拓展) + +* 6月 + +因为涌入的无素质玩家太多,一些老玩家气的暂时不玩了。同时0.2.0在人很多的情况下体验特别差,此时急需一个船新版本修复种种问题。 + +在几天赶工之下一个舒适很多的0.2.1版本发出来了。进房准备、踢人、ban人啥的都有了,然而并没有逃跑惩罚(但是有逃跑提示),导致逃跑过多的问题暴露的更严重了。此时引流也停止了(视频被拿下),当时图一热闹的玩家也各玩各的去了,服务器在线人数在四五十人左右。 + +月初这几天值得一提的玩家就是荀令君了,凭一己之力在群里了发起了“菜鸟玩家配不配玩游戏”大讨论。讨论以我赶工开发出ban人功能并把他ban了告终。 + + > 其实我最开始的时候还是想珍惜每个活跃玩家的,荀令君虽然态度跋扈了点但玩的比较多,所以我很多地方偏袒着他。然而他最后开始对R神进行人身攻击了,那我也只好手下不留情了。玩免费游戏还辱骂用爱发电的开发者是绝对无法忍受的。 + +不断涌入的玩家也加大了服务器的负担,因此了然提供了服务器用来分担压力,后来发展为私服。 + +原本为国战做准备的双将被玩家发现可以在身份局使用。令人绝望的双阴风潮就此展开了。双阴没启动多久就被朱建平+东海龙王的组合毁掉了,但其实没多少人在意。 + +在v0.2.3后我也意识到必须优化一下RAM占用了,于是大改了底层逻辑。妖梦厨也发力做了很多新功能。然而由于缺乏测试导致接下来推出的0.2.4版出了毁灭般的巨大bug,上线1小时后不得不回退到0.2.3。受到指责并进一步挂测试服仔仔细细测试之后(笑死根本没几个人测,主服多好玩)推出终于稳定的0.2.5版。 + +ken神离开。 + +* 7月 + +逃跑惩罚终于上线,武将也越来越接近全扩,是时候引一波新人了。有玩家自发的发视频进行了引流。这下引得更大了,服务器峰值在线达到450人左右,加群的玩家就更不必说了。(然而我时不时就说服务器最多塞300人下去)在如此大的人流面前视频被连忙删除,与此同时二群建立,一群很快就满了。 + +玩家“闪”达到了三千多局斗地主,成为全服第一个大将军。 + +* 8月 + +0.3.0上线。 + +0.3.0又改了logo和开屏图画,logo是蓝色渐变底和白色“杀”字,开屏图片改为乐蔡文姬。 + +* 9月 + +* 10月 + +* 11月 + +* 12月 + +时隔一个多月终于更新了0.4.0版本。UI大改,增加更多利好联机的功能。 + +R神离开。 + +2024年 +===================== diff --git a/docs/misc/qsgs/01-history.txt b/docs/misc/qsgs/01-history.txt new file mode 100644 index 00000000..81152dc0 --- /dev/null +++ b/docs/misc/qsgs/01-history.txt @@ -0,0 +1,122 @@ +太阳神三国杀的历史整合 by Notify + +参考:git提交记录、萌娘百科、贴吧(地址能贴就贴) 鸣谢:蛇履虫 + +太阳神三国杀作为老牌开源三国杀和新月杀的启发项目,截止到新月杀新建文件夹开始(2022),已经有十多年的历史了。在这漫漫时间长河之中,随着……算了不知道写啥,总之关于其发展史的资料似乎很有欠缺,只能从各种只言片语中搜寻到少数。或许新月杀也会有这么被遗忘的一天吧,故创建此文件整合一下太阳神三国杀的历史,以及记载新月杀的发展史。 + +纵观神杀十来年的历史,大致可以分为以下几个阶段:初代(v1)、v2、v2国战、v3。本文姑且尝试按照编年(尽量精确到月份)来对这些事情进行一些梳理。 + +v1篇 +====================== + +* 2010年 + +原作者Moligaloo(亦称太阳神上,下称神上)于6月13日启动了QSanguosha项目。9月27日,神上在三国杀吧发布了“三国杀Q”的首个版本。并同时公布了github上的源码地址。在这一版中,已经实现了全部的标准版武将、部分风包武将和火包武将、军争扩展。震惊三国杀界。然而美中不足的是无法单机游戏(没有AI),只能和其他小伙伴联机对战。 + +2010年10月1日,为了和英文名QSanguosha对应,名称改为“Q三国杀”。新增四张“屎”牌,成为神杀的经典之作。 + +2010年10月4日,Q三国杀改名为太阳神三国杀,英文名保持不变,建立了官方QQ群,招贤纳士。同时hypercross等大拿开始参与源码维护。 + +2010年11月3日,太阳神三国杀新增了剧情模式:官渡之战,以及当时开始流行的双将模式。新增“欢乐”卡牌包,将“屎”独立出来。 + +2010年11月14日,新增林包武将和剩余火包武将。此时风林火仅剩风包的坑爹三将()未完成。 + +2010年12月9日,因为新美工苦力的加盟,神杀迎来了全新的界面,同时作者对系统功能和部分结算流程进行了优化。新增武将小乔(测试版)和全部神武将。 + +2010年12月26日,圣诞版发布。这是神杀首个正式命名的版本。主要更新:创建了神杀特色DIY武将包“倚天”,收录一些作者喜欢的设计和玩家投稿的特色设计。本次新增两将:初版神曹操魏武帝和张儁乂(倚天包武将用姓+字来避免和官方重复)。同时还有测试版杨修(和风包坑爹三将齐名的坑爹将)。 + +* 2011年 + +2011年1月31日,贺岁版发布。因为AI师donle等人的加盟,本版首次实现了单机AI,玩家终于可以独自虐电脑了群里求联机的也开始减少了。倚天包新增贺岁两将:曹冲和夏侯涓。欢乐包新增四大天灾牌(各种效果的延时锦囊)。为了接下来的比赛,推出竞赛模式。然而就用了一次 + +2011年3月8日,红颜版发布。新增武将周泰、倚天包新增红颜三将:(待补充)。神杀举办第一次大型活动也是目前唯一一次“红颜百合赛”,参赛选手联机对战“红颜模式”。第一名奖励30QB第一名获得者为宇文天启。 + +2011年3月12日,植树节补丁发布。 + +2011年4月5日,清明版发布。新增武将SP公孙瓒、SP袁术、一将成名,倚天包新增清明三将:(待补充)。卡牌新增带技能坐骑猴子一只。 + +2011年5月8日,春晖版发布。 + +2011年6月6日,端午版发布。 + +2011年7月18日,归心版发布。 + +2011年8月6日,鹊桥版发布。 + +2011年9月12日,中秋版发布。 + +2011年11月13日,赤壁版发布。新增武将包“智包”(神杀爱好者共同设计、严格测试后发布的第一个武将包之前的倚天包武将那都是走关系出的) + +* 2012年 + +2012年1月22日,除夕版发布。 + +2012年4月5日,踏青版发布。 + +2012年7月15日,涅槃版发布。因新程序员加盟导致此版架构发生重大变动,开发组内部争议颇大,原作者调停无果停止更新。 + +* 2013年 + +2013年1月12日,雪霁版发布。代码架构衔接踏青版,由宇文天启接手开发,天子会工作室负责配音工作,将大批配音更换为独家版(而不是照搬三国杀OL)。但因为开发仓促,新开发者对架构不熟等原因,出现了很多问题和bug,以至于接下来一段时间几乎每天都在更新修复补丁。 + +2013年2月8日,金蛇版发布。更新了三国杀新出的武将和模式,修复了上一版的绝大部分bug,程序开始趋于稳定。 + +2013年7月1日,鬼隐系列从其之一更到其之六。鬼隐谐音归隐,预示太阳神三国杀停止更新。 + +v2篇 +====================== + +神杀于2012年分裂为两派开发团队。后被称作V1和V2,他们之间的分歧主要在于创作理念和发展方向上。原创派(V1)倾向于将神杀逐步打造成一个脱离游卡三国杀的原创游戏,也就是不再和三国杀官方推出的氪金将、坑爹设计妥协,并发展自己的原创武将、原创游戏模式等。官方派(V2,最初称为新神杀)则正好相反,他们倾向于将包括界面、武将、游戏风格全部朝着官方(三国杀OL)靠拢,打造成一个高仿的无氪金版的三国杀游戏。 + +当然结果也很明显,原创派虽然愿望很美好,但操作难度大,人员流失严重,不久就死了。而官方派因为素材获取容易,制作相对简单,玩家更容易吸引,所以只要三国杀不死,则新神杀就不死。时代证明了这条路的正确性。 + +神杀两派之间没有什么深仇大恨,而且随着时光的流逝,他们最开始起争端的那些人都陆续结婚生子,淡出业界了。留下的,还有一些依然在努力为神杀续命的人。 + +从此神杀身份版的主线就是v2了,之后也不断有老人淡出、新人加入,直到今天仍保持着活力。 + +程序上而言,v2是基于v1的Fork版本,二者朝着不同的方向发展。 + +* 2012~2015 + +Mogara进行开发维护。于20150926版停止更新。 + +* 2015~2018 + +2015之后就是由各路网友自发维护了,难以尽述。 + +这几年主要由youko1316(亦称ZY)(膜拜)基于Lua拓展功能为神杀陆续添加新武将,代表性的就是extra.lua。 + +ZY: https://tieba.baidu.com/p/4186274993 +Ho-spair: https://tieba.baidu.com/p/5991537372 + +* 2019~2020 + +ZY在2020年6月1日更新了最后一版(熊孩子版),从此遁入无尽的鸽中~ + +zeroOna的更新: https://tieba.baidu.com/p/6256073021 +还记得一位C开头的大神更了个几千楼,但找不到了 + +* 2020~2022 + +继ZY之后由叫什么啊你妹(妹神!)重新基于v2最终版(即20150926版)的源码,使用C++语言在源码层面重新增加新武将。 + +妹神: https://tieba.baidu.com/p/7004744263 + +* 2023 + + + +v2国战篇 +====================== + +https://tieba.baidu.com/p/3166370825 + +v3 +====================== + +积弊已久的神杀v2终于在2015年被开发组宣布停止更新,但Mogara同时也提出了新的神杀v3开发企划,让玩家继续充满期待。 + +当初的通告贴: https://tieba.baidu.com/p/4041729081 +我的考据贴: https://tieba.baidu.com/p/8620367665 + +最终于2016年不了了之。 diff --git a/docs/misc/server_admin.md b/docs/misc/server_admin.md new file mode 100644 index 00000000..344db58c --- /dev/null +++ b/docs/misc/server_admin.md @@ -0,0 +1,23 @@ +服主小技巧 +===================== + +本文件夹下的 calcDailyLogin.sh 是统计日活的脚本,可以将其设为定时任务。 + +注意时不时备份数据库。数据库只是单个sqlite文件而已,直接cp即可。 + +使用sqlite命令行之前可以使用.mode markdown命令将sqlite输出设为markdown格式,方便复制粘贴到配置中。 + +常用sql语句 +----------------- + +```sql +-- 统计某个模式胜率前20名的玩家 +SELECT * FROM playerWinRate WHERE mode="m_1v2_mode" AND total > 400 ORDER BY winRate DESC LIMIT 20; + +-- 统计某个模式胜率前20名的武将 +SELECT * FROM generalWinRate WHERE mode="m_1v2_mode" AND total > 400 ORDER BY winRate DESC LIMIT 20; + +-- 统计游玩时长排行 +SELECT usergameinfo.id, totalGameTime AS 'Time (sec)', round(totalGameTime/3600.0, 2)||" h" AS ' ', name AS Name FROM usergameinfo, userinfo WHERE userinfo.id = usergameinfo.id GROUP BY usergameinfo.id ORDER BY totalGameTime DESC LIMIT 10; +``` + diff --git a/image/card/general/card-back.png b/image/card/general/card-back.png new file mode 100644 index 0000000000000000000000000000000000000000..38b5bda99686ec44b9edfb2e6a2a13ac8200ff83 GIT binary patch literal 9042 zcmV-YBdy$tP)Px#32;bRa{vGf6951U699Letd0Nx0{~D=R7C&)0Qca@ z_~X*_*T5420u})R_1wY&008*$@b=!v*4oz$00H;l&Ghi_+T7jq+Q;|e!qU~!^xVx5 z00H{v*YnJ;>cgn=)4cTFywTOy`R(W%0s-L0w%gdr>f_MX)5P%C#rfmS?Z~g_;@$7h zwz|Z|w7%XDr(Zt=d+XH(5CUvp5(fo!NISxw6@2`v+cW0C_o|~Yfh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_}1x>#$kC7T*yH+g??gQA9ZQ01;otVHTO8UZT}0( zwYccyaup^1LeH%Ph7%V?ijdjx`F2*}*kJ{cs*9JprR|zKMR8eAh4^uh)%W+PGvea+ zNx6J+ad>!mVWZW$zHZ?+qfzs(cejL2C!5XEWkMLUYnH+OBio_BMel5O_-?#4qEp^$ zYailbd$Aae%H<}*q)hj97_#HwRViSQXi9VmMBD9S8v%L;+Su~I|A1PxwO)1-yYv08 z?Qr;~aK9f8hnM%Zt_aA#n4;|O?@#HS++(l~f3ISS$BHR?w4nb%2Y%M7?dG3O>x8#gLcRFn%c4g<^t&AO9Uk>c0&6AIt@Bu%#2M_W%F@07*qoM6N<$ Ef+M<7H~;_u literal 0 HcmV?d00001 diff --git a/lua/client/client.lua b/lua/client/client.lua index 138c355a..2c52ff47 100644 --- a/lua/client/client.lua +++ b/lua/client/client.lua @@ -286,8 +286,9 @@ fk.client_callback["AddPlayer"] = function(jsonData) -- jsonData: [ int id, string screenName, string avatar ] -- when other player enter the room, we create clientplayer(C and lua) for them local data = json.decode(jsonData) - local id, name, avatar = data[1], data[2], data[3] + local id, name, avatar, time = data[1], data[2], data[3], data[5] local player = fk.ClientInstance:addPlayer(id, name, avatar) + player:addTotalGameTime(time) local p = ClientPlayer:new(player) table.insert(ClientInstance.players, p) table.insert(ClientInstance.alive_players, p) @@ -920,6 +921,18 @@ fk.client_callback["UpdateGameData"] = function(jsonData) ClientInstance:notifyUI("UpdateGameData", jsonData) end +fk.client_callback["AddTotalGameTime"] = function(jsonData) + local data = json.decode(jsonData) + local player, time = data[1], data[2] + player = ClientInstance:getPlayerById(player) + if player then + player.player:addTotalGameTime(time) + if player == Self then + ClientInstance:notifyUI("AddTotalGameTime", jsonData) + end + end +end + fk.client_callback["StartGame"] = function(jsonData) local c = ClientInstance c.record = { @@ -946,6 +959,7 @@ fk.client_callback["StartGame"] = function(jsonData) p.player:getScreenName(), p.player:getAvatar(), true, + p.player:getTotalGameTime(), }, }) end diff --git a/lua/client/client_util.lua b/lua/client/client_util.lua index f8e552b2..7b0bd104 100644 --- a/lua/client/client_util.lua +++ b/lua/client/client_util.lua @@ -650,19 +650,21 @@ end function GetPlayerGameData(pid) local c = ClientInstance local p = c:getPlayerById(pid) - if not p then return "[0, 0, 0]" end + if not p then return "[0, 0, 0, 0]" end local raw = p.player:getGameData() local ret = {} for _, i in fk.qlist(raw) do table.insert(ret, i) end + table.insert(ret, p.player:getTotalGameTime()) return json.encode(ret) end function SetPlayerGameData(pid, data) local c = ClientInstance local p = c:getPlayerById(pid) - p.player:setGameData(table.unpack(data)) + local total, win, run = table.unpack(data) + p.player:setGameData(total, win, run) table.insert(data, 1, pid) ClientInstance:notifyUI("UpdateGameData", json.encode(data)) end @@ -735,13 +737,14 @@ function PoxiFeasible(poxi_type, selected, data, extra_data) return json.encode(poxi.feasible(selected, data, extra_data)) end -function GetQmlMark(mtype, name, value) +function GetQmlMark(mtype, name, value, p) local spec = Fk.qml_marks[mtype] if not spec then return "{}" end + p = ClientInstance:getPlayerById(p) value = json.decode(value) return json.encode { - qml_path = spec.qml_path, - text = spec.how_to_show(name, value) + qml_path = type(spec.qml_path) == "function" and spec.qml_path(name, value, p) or spec.qml_path, + text = spec.how_to_show(name, value, p) } end diff --git a/lua/client/i18n/en_US.lua b/lua/client/i18n/en_US.lua index 49be024c..1da0ad40 100644 --- a/lua/client/i18n/en_US.lua +++ b/lua/client/i18n/en_US.lua @@ -68,6 +68,8 @@ Fk:loadTranslationTable({ --["Newbie"] = "新手保护ing", ["Win=%1 Run=%2 Total=%3"] = "Win=%1% Run=%2% Total=%3", ["Win=%1\nRun=%2\nTotal=%3"] = "Win: %1%\nRun: %2%\nTotal: %3", + ["TotalGameTime: %1 min"] = "Played: %1 minutes", + ["TotalGameTime: %1 h"] = "Played: %1 hours", ["Ban List"] = "Ban character scheme", ["List"] = "Scheme", diff --git a/lua/client/i18n/zh_CN.lua b/lua/client/i18n/zh_CN.lua index 567470a8..a3e64f5a 100644 --- a/lua/client/i18n/zh_CN.lua +++ b/lua/client/i18n/zh_CN.lua @@ -65,10 +65,13 @@ Fk:loadTranslationTable{ ["Give Shoe"] = "拖鞋", ["Block Chatter"] = "屏蔽发言", ["Unblock Chatter"] = "解除屏蔽", + [" "] = '[已屏蔽] ', ["Kick From Room"] = "踢出房间", ["Newbie"] = "新手保护ing", ["Win=%1 Run=%2 Total=%3"] = "胜率%1% 逃率%2% 总场次%3", ["Win=%1\nRun=%2\nTotal=%3"] = "胜率: %1%\n逃率: %2%\n总场次: %3", + ["TotalGameTime: %1 min"] = "已游玩: %1 分钟", + ["TotalGameTime: %1 h"] = "已游玩: %1 小时", ["Ban List"] = "禁将方案", ["List"] = "方案", diff --git a/lua/core/player.lua b/lua/core/player.lua index 9ee0e6af..4e86703b 100644 --- a/lua/core/player.lua +++ b/lua/core/player.lua @@ -942,6 +942,8 @@ end ---@param ignoreFromKong? boolean ---@param ignoreToKong? boolean function Player:canPindian(to, ignoreFromKong, ignoreToKong) + if self == to then return false end + if self:isKongcheng() and not ignoreFromKong then return false end diff --git a/lua/fk_ex.lua b/lua/fk_ex.lua index aa9f94bc..8d94de46 100644 --- a/lua/fk_ex.lua +++ b/lua/fk_ex.lua @@ -606,5 +606,5 @@ end ---@class QmlMarkSpec ---@field name string ----@field qml_path string ----@field how_to_show function(name: string, value?: any): string? +---@field qml_path string | fun(name: string, value?: any, player?: Player): string +---@field how_to_show fun(name: string, value?: any, player?: Player): string? diff --git a/lua/server/request.lua b/lua/server/request.lua index 7c87d1cf..329aa148 100644 --- a/lua/server/request.lua +++ b/lua/server/request.lua @@ -18,6 +18,8 @@ local function tellRoomToObserver(self, player) p.id, p._splayer:getScreenName(), p._splayer:getAvatar(), + false, + p._splayer:getTotalGameTime(), }) end diff --git a/lua/server/serverplayer.lua b/lua/server/serverplayer.lua index 5966320e..2a86b2f0 100644 --- a/lua/server/serverplayer.lua +++ b/lua/server/serverplayer.lua @@ -321,11 +321,6 @@ function ServerPlayer:reconnect() local room = self.room self.serverplayer:setState(fk.Player_Online) - self:doNotify("Setup", json.encode{ - self.id, - self._splayer:getScreenName(), - self._splayer:getAvatar(), - }) self:doNotify("EnterLobby", "") self:doNotify("EnterRoom", json.encode{ #room.players, room.timeout, room.settings, @@ -339,6 +334,8 @@ function ServerPlayer:reconnect() p.id, p._splayer:getScreenName(), p._splayer:getAvatar(), + false, + p._splayer:getTotalGameTime(), }) end self:doNotify("RoomOwner", json.encode{ room.room:getOwner():getId() }) diff --git a/server/init.sql b/server/init.sql index acd3e7f8..59c8bf04 100644 --- a/server/init.sql +++ b/server/init.sql @@ -25,6 +25,13 @@ CREATE TABLE IF NOT EXISTS banuuid ( uuid VARCHAR(32) ); +CREATE TABLE IF NOT EXISTS usergameinfo ( + id INTEGER PRIMARY KEY, + registerTime INTEGER, -- 时间戳 + lastLoginTime INTEGER, -- 时间戳 + totalGameTime INTEGER -- 单位:秒 +); + CREATE TABLE IF NOT EXISTS friendinfo ( id1 INTEGER, id2 INTEGER, diff --git a/src/core/player.cpp b/src/core/player.cpp index 6f37293a..65685b4f 100644 --- a/src/core/player.cpp +++ b/src/core/player.cpp @@ -3,7 +3,7 @@ #include "player.h" Player::Player(QObject *parent) - : QObject(parent), id(0), state(Player::Invalid), ready(false), + : QObject(parent), id(0), state(Player::Invalid), totalGameTime(0), ready(false), totalGames(0), winCount(0), runCount(0) {} Player::~Player() {} @@ -26,6 +26,12 @@ void Player::setAvatar(const QString &avatar) { emit avatarChanged(); } +int Player::getTotalGameTime() const { return totalGameTime; } + +void Player::addTotalGameTime(int toAdd) { + totalGameTime += toAdd; +} + Player::State Player::getState() const { return state; } QString Player::getStateString() const { diff --git a/src/core/player.h b/src/core/player.h index 1072cb41..8acee08b 100644 --- a/src/core/player.h +++ b/src/core/player.h @@ -31,6 +31,9 @@ public: QString getAvatar() const; void setAvatar(const QString &avatar); + int getTotalGameTime() const; + void addTotalGameTime(int toAdd); + State getState() const; QString getStateString() const; void setState(State state); @@ -58,6 +61,7 @@ private: int id; QString screenName; // screenName should not be same. QString avatar; + int totalGameTime; State state; bool ready; bool died; diff --git a/src/server/room.cpp b/src/server/room.cpp index 4e96f636..1a811c14 100644 --- a/src/server/room.cpp +++ b/src/server/room.cpp @@ -151,6 +151,7 @@ void Room::addPlayer(ServerPlayer *player) { jsonData << player->getScreenName(); jsonData << player->getAvatar(); jsonData << player->isReady(); + jsonData << player->getTotalGameTime(); doBroadcastNotify(getPlayers(), "AddPlayer", JsonArray2Bytes(jsonData)); } @@ -179,6 +180,7 @@ void Room::addPlayer(ServerPlayer *player) { jsonData << p->getScreenName(); jsonData << p->getAvatar(); jsonData << p->isReady(); + jsonData << p->getTotalGameTime(); player->doNotify("AddPlayer", JsonArray2Bytes(jsonData)); jsonData = QJsonArray(); @@ -274,6 +276,7 @@ void Room::removePlayer(ServerPlayer *player) { runner->setId(player->getId()); auto gamedata = player->getGameData(); runner->setGameData(gamedata[0], gamedata[1], gamedata[2]); + runner->addTotalGameTime(player->getTotalGameTime()); // 最后向服务器玩家列表中增加这个人 // 原先的跑路机器人会在游戏结束后自动销毁掉 @@ -543,15 +546,35 @@ void Room::updatePlayerGameData(int id, const QString &mode) { } void Room::gameOver() { + if (!gameStarted) return; gameStarted = false; runned_players.clear(); - // 清理所有状态不是“在线”的玩家 + // 清理所有状态不是“在线”的玩家,增加逃率、游戏时长 auto settings = QJsonDocument::fromJson(this->settings); auto mode = settings["gameMode"].toString(); foreach (ServerPlayer *p, players) { + auto pid = p->getId(); + + if (pid > 0) { + int time = p->getGameTime(); + auto bytes = JsonArray2Bytes({ pid, time }); + doBroadcastNotify(getOtherPlayers(p), "AddTotalGameTime", bytes); + + // 考虑到阵亡已离开啥的,时间得给真实玩家增加 + auto realPlayer = server->findPlayer(pid); + if (realPlayer) { + realPlayer->addTotalGameTime(time); + realPlayer->doNotify("AddTotalGameTime", bytes); + } + + // 摸了,这么写总之不会有问题 + auto info_update = QString("UPDATE usergameinfo SET totalGameTime = " + "IIF(totalGameTime IS NULL, %2, totalGameTime + %2) WHERE id = %1;").arg(pid).arg(time); + ExecSQL(server->getDatabase(), info_update); + } + if (p->getState() != Player::Online) { if (p->getState() == Player::Offline) { - auto pid = p->getId(); addRunRate(pid, mode); // addRunRate(pid, mode); server->temporarilyBan(pid); @@ -572,6 +595,7 @@ void Room::manuallyStart() { foreach (auto p, players) { p->setReady(false); p->setDied(false); + p->startGameTimer(); } gameStarted = true; m_thread->pushRequest(QString("-1,%1,newroom").arg(QString::number(id))); diff --git a/src/server/server.cpp b/src/server/server.cpp index 30c5d98a..e36880ac 100644 --- a/src/server/server.cpp +++ b/src/server/server.cpp @@ -212,9 +212,59 @@ void Server::broadcast(const QString &command, const QString &jsonData) { } } +void Server::sendEarlyPacket(ClientSocket *client, const QString &type, const QString &msg) { + QJsonArray body; + body << -2; + body << (Router::TYPE_NOTIFICATION | Router::SRC_SERVER | + Router::DEST_CLIENT); + body << type; + body << msg; + client->send(JsonArray2Bytes(body)); +} + +bool Server::checkClientVersion(ClientSocket *client, const QString &cver) { + auto client_ver = QVersionNumber::fromString(cver); + auto ver = QVersionNumber::fromString(FK_VERSION); + int cmp = QVersionNumber::compare(ver, client_ver); + if (cmp != 0) { + auto errmsg = QString(); + if (cmp < 0) { + errmsg = QString("[\"server is still on version %%2\",\"%1\"]") + .arg(FK_VERSION, "1"); + } else { + errmsg = QString("[\"server is using version %%2, please update\",\"%1\"]") + .arg(FK_VERSION, "1"); + } + + sendEarlyPacket(client, "ErrorMsg", errmsg); + client->disconnectFromHost(); + return false; + } + return true; +} + +void Server::setupPlayer(ServerPlayer *player, bool all_info) { + // tell the lobby player's basic property + QJsonArray arr; + arr << player->getId(); + arr << player->getScreenName(); + arr << player->getAvatar(); + player->doNotify("Setup", JsonArray2Bytes(arr)); + + if (all_info) { + player->doNotify("SetServerSettings", JsonArray2Bytes({ + getConfig("motd"), + getConfig("hiddenPacks"), + getConfig("enableBots"), + })); + } +} + void Server::processNewConnection(ClientSocket *client) { auto addr = client->peerAddress(); qInfo() << addr << "connected"; + + // check ban ip auto result = SelectFromDatabase( db, QString("SELECT * FROM banip WHERE ip='%1';").arg(addr)); @@ -229,13 +279,7 @@ void Server::processNewConnection(ClientSocket *client) { } if (!errmsg.isEmpty()) { - QJsonArray body; - body << -2; - body << (Router::TYPE_NOTIFICATION | Router::SRC_SERVER | - Router::DEST_CLIENT); - body << "ErrorMsg"; - body << errmsg; - client->send(JsonArray2Bytes(body)); + sendEarlyPacket(client, "ErrorMsg", errmsg); qInfo() << "Refused banned IP:" << addr; client->disconnectFromHost(); return; @@ -245,13 +289,7 @@ void Server::processNewConnection(ClientSocket *client) { [client]() { qInfo() << client->peerAddress() << "disconnected"; }); // network delay test - QJsonArray body; - body << -2; - body << (Router::TYPE_NOTIFICATION | Router::SRC_SERVER | - Router::DEST_CLIENT); - body << "NetworkDelayTest"; - body << public_key; - client->send(JsonArray2Bytes(body)); + sendEarlyPacket(client, "NetworkDelayTest", public_key); // Note: the client should send a setup string next connect(client, &ClientSocket::message_got, this, &Server::processRequest); client->timerSignup.start(30000); @@ -278,40 +316,14 @@ void Server::processRequest(const QByteArray &msg) { if (!valid) { qWarning() << "Invalid setup string:" << msg; - QJsonArray body; - body << -2; - body << (Router::TYPE_NOTIFICATION | Router::SRC_SERVER | - Router::DEST_CLIENT); - body << "ErrorMsg"; - body << "INVALID SETUP STRING"; - client->send(JsonArray2Bytes(body)); + sendEarlyPacket(client, "ErrorMsg", "INVALID SETUP STRING"); client->disconnectFromHost(); return; } QJsonArray arr = String2Json(doc[3].toString()).array(); - auto client_ver = QVersionNumber::fromString(arr[3].toString()); - auto ver = QVersionNumber::fromString(FK_VERSION); - int cmp = QVersionNumber::compare(ver, client_ver); - if (cmp != 0) { - QJsonArray body; - body << -2; - body << (Router::TYPE_NOTIFICATION | Router::SRC_SERVER | - Router::DEST_CLIENT); - body << "ErrorMsg"; - body - << (cmp < 0 - ? QString("[\"server is still on version %%2\",\"%1\"]") - .arg(FK_VERSION, "1") - : QString( - "[\"server is using version %%2, please update\",\"%1\"]") - .arg(FK_VERSION, "1")); - - client->send(JsonArray2Bytes(body)); - client->disconnectFromHost(); - return; - } + if (!checkClientVersion(client, arr[3].toString())) return; auto uuid = arr[4].toString(); auto result2 = QJsonArray({1}); @@ -321,13 +333,7 @@ void Server::processRequest(const QByteArray &msg) { } if (!result2.isEmpty()) { - QJsonArray body; - body << -2; - body << (Router::TYPE_NOTIFICATION | Router::SRC_SERVER | - Router::DEST_CLIENT); - body << "ErrorMsg"; - body << "you have been banned!"; - client->send(JsonArray2Bytes(body)); + sendEarlyPacket(client, "ErrorMsg", "you have been banned!"); qInfo() << "Refused banned UUID:" << uuid; client->disconnectFromHost(); return; @@ -352,13 +358,7 @@ void Server::handleNameAndPassword(ClientSocket *client, const QString &name, auto aes_bytes = decrypted_pw.first(32); // tell client to install aes key - QJsonArray body; - body << -2; - body << (Router::TYPE_NOTIFICATION | Router::SRC_SERVER | - Router::DEST_CLIENT); - body << "InstallKey"; - body << ""; - client->send(JsonArray2Bytes(body)); + sendEarlyPacket(client, "InstallKey", ""); client->installAESKey(aes_bytes); decrypted_pw.remove(0, 32); @@ -367,20 +367,8 @@ void Server::handleNameAndPassword(ClientSocket *client, const QString &name, } if (md5 != md5_str) { - QJsonArray body; - body << -2; - body << (Router::TYPE_NOTIFICATION | Router::SRC_SERVER | - Router::DEST_CLIENT); - body << "ErrorMsg"; - body << "MD5 check failed!"; - client->send(JsonArray2Bytes(body)); - - body.removeLast(); - body.removeLast(); - body << "UpdatePackage"; - body << Pacman->getPackSummary(); - client->send(JsonArray2Bytes(body)); - + sendEarlyPacket(client, "ErrorMsg", "MD5 check failed!"); + sendEarlyPacket(client, "UpdatePackage", Pacman->getPackSummary()); client->disconnectFromHost(); return; } @@ -415,6 +403,10 @@ void Server::handleNameAndPassword(ClientSocket *client, const QString &name, ExecSQL(db, sql_reg); result = SelectFromDatabase(db, sql_find); // refresh result obj = result[0].toObject(); + + auto info_update = QString("INSERT INTO usergameinfo (id, registerTime) VALUES (%1, %2);").arg(obj["id"].toString().toInt()).arg(QDateTime::currentSecsSinceEpoch()); + ExecSQL(db, info_update); + passed = true; } else { obj = result[0].toObject(); @@ -454,11 +446,7 @@ void Server::handleNameAndPassword(ClientSocket *client, const QString &name, } if (room && !room->isLobby()) { - player->doNotify("SetServerSettings", JsonArray2Bytes({ - getConfig("motd"), - getConfig("hiddenPacks"), - getConfig("enableBots"), - })); + setupPlayer(player, true); room->pushRequest(QString("%1,reconnect").arg(id)); } else { // 懒得处理掉线玩家在大厅了!踢掉得了 @@ -479,15 +467,23 @@ void Server::handleNameAndPassword(ClientSocket *client, const QString &name, if (passed) { // update lastLoginIp + int id = obj["id"].toString().toInt(); + beginTransaction(); auto sql_update = QString("UPDATE userinfo SET lastLoginIp='%1' WHERE id=%2;") .arg(client->peerAddress()) - .arg(obj["id"].toString().toInt()); + .arg(id); ExecSQL(db, sql_update); - auto uuid_update = QString("REPLACE INTO uuidinfo (id, uuid) VALUES (%1, '%2');").arg(obj["id"].toString().toInt()).arg(uuid_str); + auto uuid_update = QString("REPLACE INTO uuidinfo (id, uuid) VALUES (%1, '%2');").arg(id).arg(uuid_str); ExecSQL(db, uuid_update); + // 来晚了,有很大可能存在已经注册但是表里面没数据的人 + ExecSQL(db, QString("INSERT OR IGNORE INTO usergameinfo (id) VALUES (%1);").arg(id)); + auto info_update = QString("UPDATE usergameinfo SET lastLoginTime=%2 where id=%1;").arg(id).arg(QDateTime::currentSecsSinceEpoch()); + ExecSQL(db, info_update); + endTransaction(); + // create new ServerPlayer and setup ServerPlayer *player = new ServerPlayer(lobby()); player->setSocket(client); @@ -497,35 +493,23 @@ void Server::handleNameAndPassword(ClientSocket *client, const QString &name, connect(player, &Player::stateChanged, this, &Server::onUserStateChanged); player->setScreenName(name); player->setAvatar(obj["avatar"].toString()); - player->setId(obj["id"].toString().toInt()); + player->setId(id); if (players.count() <= 10) { broadcast("ServerMessage", tr("%1 logged in").arg(player->getScreenName())); } players.insert(player->getId(), player); - // tell the lobby player's basic property - QJsonArray arr; - arr << player->getId(); - arr << player->getScreenName(); - arr << player->getAvatar(); - player->doNotify("Setup", JsonArray2Bytes(arr)); + setupPlayer(player); - player->doNotify("SetServerSettings", JsonArray2Bytes({ - getConfig("motd"), - getConfig("hiddenPacks"), - getConfig("enableBots"), - })); + auto result = SelectFromDatabase(db, QString("SELECT totalGameTime FROM usergameinfo WHERE id=%1;").arg(id)); + auto time = result[0].toObject()["totalGameTime"].toString().toInt(); + player->addTotalGameTime(time); + player->doNotify("AddTotalGameTime", JsonArray2Bytes({ id, time })); lobby()->addPlayer(player); } else { qInfo() << client->peerAddress() << "lost connection:" << error_msg; - QJsonArray body; - body << -2; - body << (Router::TYPE_NOTIFICATION | Router::SRC_SERVER | - Router::DEST_CLIENT); - body << "ErrorMsg"; - body << error_msg; - client->send(JsonArray2Bytes(body)); + sendEarlyPacket(client, "ErrorMsg", error_msg); client->disconnectFromHost(); return; } @@ -572,8 +556,15 @@ void Server::onUserStateChanged() { if (!room || room->isLobby() || room->isAbandoned()) { return; } + auto state = player->getState(); room->doBroadcastNotify(room->getPlayers(), "NetStateChanged", QString("[%1,\"%2\"]").arg(player->getId()).arg(player->getStateString())); + + if (state == Player::Online) { + player->resumeGameTimer(); + } else { + player->pauseGameTimer(); + } } RSA *Server::initServerRSA() { diff --git a/src/server/server.h b/src/server/server.h index 477a1f05..61b02088 100644 --- a/src/server/server.h +++ b/src/server/server.h @@ -67,7 +67,7 @@ public slots: private: friend class Shell; ServerSocket *server; - QUdpSocket *udpSocket; + QUdpSocket *udpSocket; // 服务器列表页面显示服务器信息用 Room *m_lobby; QMap rooms; @@ -89,6 +89,12 @@ private: QJsonObject config; void readConfig(); + // 用于确定建立连接之前与客户端通信,连接后用doNotify + void sendEarlyPacket(ClientSocket *client, const QString &type, const QString &msg); + bool checkClientVersion(ClientSocket *client, const QString &ver); + + // 某玩家刚刚连入之后,服务器告诉他关于他的一些基本信息 + void setupPlayer(ServerPlayer *player, bool all_info = true); void handleNameAndPassword(ClientSocket *client, const QString &name, const QString &password, const QString &md5_str, const QString &uuid_str); void processDatagram(const QByteArray &msg, const QHostAddress &addr, uint port); diff --git a/src/server/serverplayer.cpp b/src/server/serverplayer.cpp index 637a9f1c..34089ad5 100644 --- a/src/server/serverplayer.cpp +++ b/src/server/serverplayer.cpp @@ -124,3 +124,20 @@ void ServerPlayer::setThinking(bool t) { m_thinking = t; m_thinking_mutex.unlock(); } + +void ServerPlayer::startGameTimer() { + gameTime = 0; + gameTimer.start(); +} + +void ServerPlayer::pauseGameTimer() { + gameTime += gameTimer.elapsed() / 1000; +} + +void ServerPlayer::resumeGameTimer() { + gameTimer.start(); +} + +int ServerPlayer::getGameTime() { + return gameTime + (getState() == Player::Online ? gameTimer.elapsed() / 1000 : 0); +} diff --git a/src/server/serverplayer.h b/src/server/serverplayer.h index 16361c01..c9b0a10a 100644 --- a/src/server/serverplayer.h +++ b/src/server/serverplayer.h @@ -43,6 +43,12 @@ public: bool thinking(); void setThinking(bool t); + + void startGameTimer(); + void pauseGameTimer(); + void resumeGameTimer(); + int getGameTime(); + signals: void disconnected(); void kicked(); @@ -58,6 +64,9 @@ private: QString requestCommand; QString requestData; + + int gameTime; // 在这个房间的有效游戏时长(秒) + QElapsedTimer gameTimer; }; #endif // _SERVERPLAYER_H diff --git a/src/swig/player.i b/src/swig/player.i index df7120de..93b3bc53 100644 --- a/src/swig/player.i +++ b/src/swig/player.i @@ -23,6 +23,9 @@ public: QString getAvatar() const; void setAvatar(const QString &avatar); + int getTotalGameTime() const; + void addTotalGameTime(int toAdd); + State getState() const; void setState(State state);