Module:View/Expedition
Documentation for this module may be created at Module:View/Expedition/doc
local _ = require('Module:Core')
local view = require('Module:View')
local data = require('Module:Data/Expedition')
local backgrounds = {
[0] = 'EDEDED',
[1] = 'EDEDED',
[2] = 'EDEDD5',
[3] = 'CFE8E8',
[4] = 'C5E6D5',
[5] = 'D3D3EB',
}
local template = [=[|-
|style="${style}"|{{tooltip|${id}|ID number as displayed in the game}}
|style="${style}"|{{tooltip|${name}|${details}}}
|style="${style}"|{{tooltip|${time}|Time required for expedition}}
|style="${style}"|{{tooltip|${hq}|Admiral experience gained upon completion from this expedition}}
|style="${style}"|{{tooltip|${ship}|Ship experience gained upon completion from this expedition}}
|style="${style}"|{{tooltip|${fuel}|Base resources gain from expedition (at 100% ratio)}}
|style="${style}"|{{tooltip|${ammo}|Base resources gain from expedition (at 100% ratio)}}
|style="${style}"|{{tooltip|${steel}|Base resources gain from expedition (at 100% ratio)}}
|style="${style}"|{{tooltip|${bauxite}|Base resources gain from expedition (at 100% ratio)}}
|style="${style}"|${item1}
|style="${style}"|${item2}]=]
local function formatTime(time)
return math.floor(time / 60) .. ':' .. time % 60
end
local function render(args)
local id = args.explicit.id
local e = _.ifindBy(data, function(e) return e.disp_no == id end)
return _.format{
template,
style = string.format('text-align: center; height: 35px; background: #%s; color:#000', backgrounds[e.maparea_id] or backgrounds[0]),
id = id,
name = e.name,
details = e.details,
time = formatTime(e.time),
hq = args.explicit.hq,
ship = args.explicit.ship,
fuel = args.explicit.fuel,
ammo = args.explicit.ammo,
steel = args.explicit.steel,
bauxite = args.explicit.bauxite,
item1 = args.explicit.item1,
item2 = args.explicit.item2,
}
end
local test = { explicit = { id = '01' } }
return view(render, test)