GMZGZXPNSSTUNESB5H63T7RIQQSWILVJYSMJMWOVPL2S7PLYZILAC
-- TODO: bounds checking
local from = arena:getCell(pos)
arena:setCell(pos + dirFromString(direction), self, function()
arena:setCell(pos, from)
end)
arena:setCell(pos, Cell{owner=self.owner})
if arena:hasCell(pos + dirFromString(direction)) then
local from = arena:getCell(pos)
arena:add(pos + dirFromString(direction), self, function()
arena:add(pos, from)
end)
arena:remove(pos, self)
arena:add(pos, Cell{owner=self.owner})
end
-- TODO: don't round
-- TODO: bounds checking
local oldEnergy = self.energy
local cell = Cell{owner=self.owner, core=fun, energy=self.energy * energy}
arena:setCell(pos + dirFromString(direction), cell, function()
self.energy = oldEnergy
end)
self.energy = self.energy * (1 - energy)
-- TODO: don't round, limit energy, type checking
if arena:hasCell(pos + dirFromString(direction)) then
energy = energy or 0.5
local oldEnergy = self.energy
local cell = Cell{owner=self.owner, core=fun, energy=self.energy * energy}
arena:add(pos + dirFromString(direction), cell, function()
self.energy = oldEnergy
end)
self.energy = self.energy * (1 - energy)
end
-- TODO: bounds checking
table.insert(arena:getCell(pos + dirFromString(direction)).data, data)
if arena:hasCell(pos) then
table.insert(arena:getCell(pos + dirFromString(direction)).data, data)
end
table.insert(self.cells[pos.x][pos.y].cells, to)
table.insert(self.cells[pos.x][pos.y].cells, cell)
end
function intermediate:remove(pos, cell)
local cells = self.cells[pos.x][pos.y].cells
for index, checkCell in ipairs(cells) do
if cell == checkCell then
table.remove(cells, index)
break
end
end