2015-09-04 14:39:44 +02:00
|
|
|
local function bitset(flags, bit)
|
|
|
|
-- TODO: use bit32 when we no longer have to consider lua 5.1 compatibility
|
|
|
|
local x = flags % (bit*2)
|
|
|
|
return x >= bit
|
|
|
|
end
|
2015-08-31 11:19:16 +02:00
|
|
|
|
|
|
|
local function curse(file)
|
|
|
|
for line in file:lines() do
|
|
|
|
f = get_faction(line)
|
|
|
|
if not f then
|
|
|
|
print("no such faction: " .. line)
|
2015-09-06 13:20:37 +02:00
|
|
|
elseif not bitset(f.flags, 16) then
|
2015-08-31 11:19:16 +02:00
|
|
|
print("cursing " .. tostring(f))
|
|
|
|
f.flags = f.flags + 16
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local cursed = {}
|
|
|
|
|
|
|
|
function cursed.init()
|
|
|
|
local f = io.open("cursed.txt", "r")
|
|
|
|
if f then
|
|
|
|
print("found cursed.txt")
|
|
|
|
curse(f)
|
2016-09-11 19:28:25 +02:00
|
|
|
f:close()
|
2015-08-31 11:19:16 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return cursed
|