bug fix (#239)
- 修复了人人主公框+无主公酱报错的bug - 修复了random(n)不返回表的bug - 为table添加connect(不改变输入数组的连接各数组)方法及其IfNeed版本(包括insertTable) - 修复了有死人不能喝酒的bug
This commit is contained in:
parent
24a8020d1e
commit
48bb6ac999
|
@ -245,6 +245,33 @@ function table:insertIfNeed(element)
|
|||
end
|
||||
end
|
||||
|
||||
-- similar to table.insertTable but insertIfNeed inside
|
||||
function table:insertTableIfNeed(list)
|
||||
for _, e in ipairs(list) do
|
||||
table.insertIfNeed(self, e)
|
||||
end
|
||||
end
|
||||
|
||||
---@generic T
|
||||
---@return T[]
|
||||
function table.connect(...)
|
||||
local ret = {}
|
||||
for _, v in ipairs({...}) do
|
||||
table.insertTable(ret, v)
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
---@generic T
|
||||
---@return T[]
|
||||
function table.connectIfNeed(...)
|
||||
local ret = {}
|
||||
for _, v in ipairs({...}) do
|
||||
table.insertTableIfNeed(ret, v)
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
---@generic T
|
||||
---@param self T[]
|
||||
---@param n integer|nil
|
||||
|
@ -252,7 +279,7 @@ end
|
|||
function table:random(n)
|
||||
local n0 = n
|
||||
n = n or 1
|
||||
if #self == 0 then return nil end
|
||||
if #self == 0 then return n0 ~= nil and {} or nil end
|
||||
local tmp = {table.unpack(self)}
|
||||
local ret = {}
|
||||
while n > 0 and #tmp > 0 do
|
||||
|
|
|
@ -91,6 +91,11 @@ function GameLogic:chooseGenerals()
|
|||
if lord ~= nil then
|
||||
room.current = lord
|
||||
local generals = {}
|
||||
local lordlist = {}
|
||||
local lordpools = {}
|
||||
table.insertTable(generals, Fk:getGeneralsRandomly(generalNum, Fk:getAllGenerals(), table.map(generals, function (g)
|
||||
return g.name
|
||||
end)))
|
||||
if room.settings.gameMode == "aaa_role_mode" then
|
||||
for _, general in pairs(Fk:getAllGenerals()) do
|
||||
if (not general.hidden and not general.total_hidden) and
|
||||
|
@ -100,18 +105,17 @@ function GameLogic:chooseGenerals()
|
|||
not table.find(generals, function(g)
|
||||
return g.trueName == general.trueName
|
||||
end) then
|
||||
table.insert(generals, general)
|
||||
table.insert(lordlist, general)
|
||||
end
|
||||
end
|
||||
generals = table.random(generals, 3)
|
||||
lordlist = table.random(lordlist, 3) or {}
|
||||
end
|
||||
table.insertTable(generals, Fk:getGeneralsRandomly(generalNum, Fk:getAllGenerals(), table.map(generals, function (g)
|
||||
return g.name
|
||||
end)))
|
||||
for i = 1, #generals do
|
||||
generals[i] = generals[i].name
|
||||
end
|
||||
lord_generals = room:askForGeneral(lord, generals, n)
|
||||
lordpools = table.simpleClone(generals)
|
||||
table.insertTable(lordpools, table.map(lordlist, function(g) return g.name end))
|
||||
lord_generals = room:askForGeneral(lord, lordpools, n)
|
||||
local lord_general, deputy
|
||||
if type(lord_generals) == "table" then
|
||||
deputy = lord_generals[2]
|
||||
|
|
|
@ -83,12 +83,12 @@ local analepticSkill = fk.CreateActiveSkill{
|
|||
max_turn_use_time = 1,
|
||||
mod_target_filter = function(self, to_select, selected, user, card, distance_limited)
|
||||
return self:withinTimesLimit(Fk:currentRoom():getPlayerById(to_select), Player.HistoryTurn, card, "analeptic", Fk:currentRoom():getPlayerById(to_select)) and
|
||||
not table.find(Fk:currentRoom().players, function(p)
|
||||
not table.find(Fk:currentRoom().alive_players, function(p)
|
||||
return p.dying
|
||||
end)
|
||||
end,
|
||||
can_use = function(self, player, card)
|
||||
return self:modTargetFilter(player.id, Util.DummyTable, player.id, card)
|
||||
return self:withinTimesLimit(player, Player.HistoryTurn, card, "analeptic", player)
|
||||
end,
|
||||
on_use = function(self, room, use)
|
||||
if not use.tos or #TargetGroup:getRealTargets(use.tos) == 0 then
|
||||
|
|
|
@ -362,7 +362,7 @@ heg = fk.CreateGameMode{
|
|||
maxPlayer = 8,
|
||||
rule = heg_rule,
|
||||
logic = heg_getlogic,
|
||||
countInFunc = Util.FalseFunc
|
||||
is_counted = Util.FalseFunc
|
||||
}
|
||||
|
||||
Fk:loadTranslationTable{
|
||||
|
|
|
@ -1165,6 +1165,9 @@ local role_mode = fk.CreateGameMode{
|
|||
name = "aaa_role_mode", -- just to let it at the top of list
|
||||
minPlayer = 2,
|
||||
maxPlayer = 8,
|
||||
is_counted = function(self, room)
|
||||
return #room.players >= 5
|
||||
end,
|
||||
surrender_func = function(self, playedTime)
|
||||
local roleCheck = false
|
||||
local roleText = ""
|
||||
|
|
|
@ -125,7 +125,7 @@ local peachSkill = fk.CreateActiveSkill{
|
|||
name = "peach_skill",
|
||||
mod_target_filter = function(self, to_select)
|
||||
return Fk:currentRoom():getPlayerById(to_select):isWounded() and
|
||||
not table.find(Fk:currentRoom().players, function(p)
|
||||
not table.find(Fk:currentRoom().alive_players, function(p)
|
||||
return p.dying
|
||||
end)
|
||||
end,
|
||||
|
|
|
@ -1,4 +1,17 @@
|
|||
TestExppattern = {
|
||||
testUtil = function()
|
||||
local table1 = {1, 3, 5, 8}
|
||||
local table2 = {2, 3, 5, 7}
|
||||
p(table1)
|
||||
p(table2)
|
||||
p(table.connect(table1, table2))
|
||||
p(table1)
|
||||
p(table2)
|
||||
p(table.connectIfNeed(table1, table2))
|
||||
p(table1)
|
||||
p(table2)
|
||||
end,
|
||||
|
||||
testMatchExp = function()
|
||||
local exp1 = Exppattern:Parse("slash,jink")
|
||||
lu.assertTrue(exp1:matchExp("peack,jink"))
|
||||
|
|
Loading…
Reference in New Issue