fortunes_foundation/checkpoint.lua

40 lines
785 B
Lua
Raw Permalink Normal View History

2024-02-10 06:35:55 +00:00
checkpoint=klass()
function checkpoint:init(board,card)
self.card=card
self.slots={}
self.wells={}
for s=1,#board.slots do
local cnt={}
for c in all(board.slots[s].contents) do
add(cnt,c)
end
self.slots[s]=cnt
end
for w=1,#board.wells do
local cnt={}
for c in all(board.wells[w].contents) do
add(cnt,c)
end
self.wells[w]=cnt
end
end
function checkpoint:apply(board)
for s=1,#board.slots do
while #board.slots[s].contents>0 do
deli(board.slots[s].contents)
end
for i in all(self.slots[s]) do
add(board.slots[s].contents,i)
end
end
for w=1,#board.wells do
while #board.wells[w].contents>0 do
deli(board.wells[w].contents)
end
for i in all(self.wells[w]) do
add(board.wells[w].contents,i)
end
end
2024-02-14 23:55:00 +00:00
board.cursor:drop_grab()
2024-02-10 06:35:55 +00:00
end