修复武将牌堆回流 (role mode下) (#325)

This commit is contained in:
notify 2024-02-27 16:33:00 +08:00 committed by GitHub
parent 4d94ee8a93
commit 726602873e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 22 additions and 37 deletions

View File

@ -14,21 +14,11 @@ ___
新月杀FreeKill是一款开源的三国杀游戏但其目的不在于补完官方所有武将而是着力于提供一个最适合DIY的框架。 新月杀FreeKill是一款开源的三国杀游戏但其目的不在于补完官方所有武将而是着力于提供一个最适合DIY的框架。
___
## 项目文档 ## 项目文档
[新月杀文档](https://qsgs-fans.github.io/FreeKill/usr/index.html) https://fkbook-all-in-one.readthedocs.io/
### 依赖的库
以下是新月杀运行所必不可少的依赖库:
* [![](https://img.shields.io/badge/qt6-50D160?style=for-the-badge&logo=qt&logoColor=white)](https://www.qt.io)
* [![](https://img.shields.io/badge/lua5.4-030380?style=for-the-badge&logo=lua)](https://www.lua.org)
* [![](https://img.shields.io/badge/sqlite3-7ABEEA?style=for-the-badge&logo=sqlite)](https://www.sqlite.org)
* [![](https://img.shields.io/badge/libgit2-FFFFFF?style=for-the-badge&logo=git)](https://www.libgit2.org)
* [![](https://img.shields.io/badge/openssl-721412?style=for-the-badge&logo=openssl)](https://www.openssl.org)
新月杀在编译过程中需要用到cmake, flex, bison, swig。
___ ___
@ -46,7 +36,7 @@ ___
## 如何构建 ## 如何构建
关于如何从头构建新月杀,详见[编译教程](https://qsgs-fans.github.io/FreeKill/inner/01-compile.html)。 https://fkbook-all-in-one.readthedocs.io/zh-cn/latest/develop/02-env.html
___ ___

View File

@ -1508,17 +1508,22 @@ end
--- 把武将牌塞回去(……) --- 把武将牌塞回去(……)
---@param g string[] @ 武将名数组 ---@param g string[] @ 武将名数组
---@param position? string @位置top/bottom默认bottom ---@param position? string @位置top/bottom/random默认random
---@return boolean @ 是否成功 ---@return boolean @ 是否成功
function Room:returnToGeneralPile(g, position) function Room:returnToGeneralPile(g, position)
position = position or "bottom" position = position or "random"
assert(position == "top" or position == "bottom") assert(position == "top" or position == "bottom" or position == "random")
if position == "bottom" then if position == "bottom" then
table.insertTable(self.general_pile, g) table.insertTable(self.general_pile, g)
elseif position == "top" then elseif position == "top" then
while #g > 0 do while #g > 0 do
table.insert(self.general_pile, 1, table.remove(g)) table.insert(self.general_pile, 1, table.remove(g))
end end
elseif position == "random" then
while #g > 0 do
table.insert(self.general_pile, math.random(1, #self.general_pile),
table.remove(g))
end
end end
return true return true

View File

@ -1132,17 +1132,12 @@ local role_getlogic = function()
lord_general = lord_generals lord_general = lord_generals
lord_generals = {lord_general} lord_generals = {lord_general}
end end
generals = table.filter(generals, function(g)
return not table.find(lord_generals, function(lg)
return Fk.generals[lg].trueName == Fk.generals[g].trueName
end)
end)
room:returnToGeneralPile(generals) room:returnToGeneralPile(generals)
local index = 1
while index <= #room.general_pile do
local ret = {}
for _, gname in ipairs(lord_generals) do
if room.general_pile[index] == gname or Fk.generals[room.general_pile[index]].trueName == Fk.generals[gname].trueName then
table.insert(ret, table.remove(room.general_pile, index))
end
end
if #ret == 0 then index = index + 1 end
end
room:setPlayerGeneral(lord, lord_general, true) room:setPlayerGeneral(lord, lord_general, true)
room:askForChooseKingdom({lord}) room:askForChooseKingdom({lord})
@ -1231,17 +1226,12 @@ local role_getlogic = function()
p.default_reply = "" p.default_reply = ""
end end
generals = table.filter(generals, function(g)
return not table.find(selected, function(lg)
return Fk.generals[lg].trueName == Fk.generals[g].trueName
end)
end)
room:returnToGeneralPile(generals) room:returnToGeneralPile(generals)
local index = 1
while index <= #room.general_pile do
local ret = {}
for _, gname in ipairs(selected) do
if room.general_pile[index] == gname or Fk.generals[room.general_pile[index]].trueName == Fk.generals[gname].trueName then
table.insert(ret, table.remove(room.general_pile, index))
end
end
if #ret == 0 then index = index + 1 end
end
room:askForChooseKingdom(nonlord) room:askForChooseKingdom(nonlord)
end end