; SPDX-FileCopyrightText: 2023 Jummit
;
; SPDX-License-Identifier: GPL-3.0-or-later
(local colors [4 9])
(local kinds [:link :virus :fire-wall :404 :virus-check :line-boost])
(local icons {:link 260
:virus 261
:fire-wall 258
:404 257
:virus-check 256
:line-boost 259})
(local terminals [:fire-wall :404 :virus-check :line-boost])
(fn draw-cards [entities]
"System which draws cards"
(each [_ entity (ipairs entities)]
(case entity
{:card {: owner : kind :open true} : x : y}
(let [x (or entity.screen-x x)
y (or entity.screen-y y)]
(_G.rect (+ x 1) y 9 12 (. (if entity.selected [5 10] colors) owner))
(_G.spr 262 x y 6 1 0 0 2 2)
(_G.spr (. icons kind) (+ x 2) (+ y 2) 6))
{:card {: owner} : x : y}
(_G.spr (+ 262 (* owner 2)) (or entity.screen-x x) (or entity.screen-y y)
0 1 0 0 2 2))
(case entity {:card {:border true} : x : y}
(_G.spr 296 x y 6 1 0 0 2 2))))
{: icons : kinds : draw-cards : terminals}