Compare commits
6 Commits
feature/ta
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 7f1c31f67e | |||
| 4f436a3d3f | |||
| 752fe00910 | |||
| 2d29d35f96 | |||
| ec290eb18b | |||
| 958d3bc245 |
@ -8,7 +8,7 @@ grid.__index = grid
|
|||||||
--- adds a value to the grid
|
--- adds a value to the grid
|
||||||
--- @param value any
|
--- @param value any
|
||||||
function grid:add(value)
|
function grid:add(value)
|
||||||
grid[tostring(value.position)] = value
|
self.__grid[tostring(value.position)] = value
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param position Vec3
|
--- @param position Vec3
|
||||||
|
|||||||
@ -40,6 +40,7 @@ end
|
|||||||
function level:update(dt)
|
function level:update(dt)
|
||||||
utils.each(self.deadIds, function(id)
|
utils.each(self.deadIds, function(id)
|
||||||
self.characters[id] = nil
|
self.characters[id] = nil
|
||||||
|
self.turnOrder:remove(id)
|
||||||
end)
|
end)
|
||||||
self.deadIds = {}
|
self.deadIds = {}
|
||||||
|
|
||||||
|
|||||||
@ -117,4 +117,29 @@ function turnOrder:add(id)
|
|||||||
self.actedQueue:insert(id) -- новые персонажи по умолчанию попадают в очередь следующего хода
|
self.actedQueue:insert(id) -- новые персонажи по умолчанию попадают в очередь следующего хода
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Удалить персонажа из очереди хода (например, при смерти)
|
||||||
|
--- @param id Id
|
||||||
|
function turnOrder:remove(id)
|
||||||
|
if self.current == id then
|
||||||
|
self.current = self.pendingQueue:pop()
|
||||||
|
if not self.current then
|
||||||
|
self:endRound()
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local function filterQueue(q, targetId)
|
||||||
|
local newQ = PriorityQueue.new(initiativeComparator)
|
||||||
|
for _, val in ipairs(q.data) do
|
||||||
|
if val ~= targetId then
|
||||||
|
newQ:insert(val)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return newQ
|
||||||
|
end
|
||||||
|
|
||||||
|
self.actedQueue = filterQueue(self.actedQueue, id)
|
||||||
|
self.pendingQueue = filterQueue(self.pendingQueue, id)
|
||||||
|
end
|
||||||
|
|
||||||
return { new = new }
|
return { new = new }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user