-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpile_foundation.lua
46 lines (38 loc) · 1.03 KB
/
pile_foundation.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
-- class Foundation, derived from Pile
local Pile = require 'pile'
---@class (exact) Foundation : Pile
---@field __index Foundation
---@field new function
local Foundation = {}
Foundation.__index = Foundation
setmetatable(Foundation, {__index = Pile})
function Foundation.new(o)
o.category = 'Foundation'
o.fanType = 'FAN_NONE'
o.moveType = 'MOVE_NONE'
o = Pile.prepare(o)
table.insert(_G.BAIZE.piles, o)
table.insert(_G.BAIZE.foundations, o)
return setmetatable(o, Foundation)
end
-- vtable functions
---@return string | nil
function Foundation:acceptTailError(tail)
if #tail > 1 then
return 'Cannot move more than one card to a Foundation'
end
-- BUG FIX added 2022-11-28
if #self.cards == #_G.BAIZE.deck / #_G.BAIZE.foundations then
return 'The Foundation is full'
end
-- /BUG FIX
return _G.BAIZE.script:tailAppendError(self, tail)
end
function Foundation:tailTapped(tail)
-- do nothing
end
---@return integer
function Foundation:unsortedPairs()
return 0
end
return Foundation