61 lines
1.2 KiB
Plaintext
61 lines
1.2 KiB
Plaintext
// ----- Project theme -----
|
||
#import "variables.typ": theme, theme-var
|
||
|
||
// ----- The ubiquitous ddlvl macro -----
|
||
#let ddlvl(n, plus: false) = {
|
||
let star = text(fill: black, size: 1.3em)[#theme-var("star")]
|
||
let empty-star = text(
|
||
fill: white,
|
||
size: 1.3em,
|
||
stroke: 0.6pt + black,
|
||
)[#theme-var("star")]
|
||
|
||
let plus = if plus {
|
||
"+"
|
||
} else {
|
||
""
|
||
}
|
||
if n == 0 {
|
||
empty-star
|
||
} else if n < 0 {
|
||
[−#ddlvl(-n)]
|
||
} else if n > 6 {
|
||
[#plus#n#theme-var("star")]
|
||
} else {
|
||
plus + star * n
|
||
}
|
||
}
|
||
|
||
// ----- Difficulty level macro -----
|
||
#let difficulty-stars(difficulty, max: 5) = {
|
||
for i in range(max) {
|
||
if difficulty >= i + 1 {
|
||
text(size: 9pt, fill: theme.dark-gold)[
|
||
#theme-var("progress-full")
|
||
]
|
||
} else if difficulty >= i + 0.5 {
|
||
text(size: 9pt, fill: theme.dark-gold)[
|
||
#theme-var("progress-half")
|
||
]
|
||
} else {
|
||
text(size: 9pt, fill: theme.border)[
|
||
#theme-var("progress-void")
|
||
]
|
||
}
|
||
}
|
||
}
|
||
// ----- Resistance level -----
|
||
#let resist(n) = {
|
||
if n == 0 {
|
||
"( )"
|
||
} else if n < -4 {
|
||
"(" + str(-n) + [--] + ")"
|
||
} else if n < 0 {
|
||
"(" + [--] * -n + ")"
|
||
} else if n > 4 {
|
||
"(" + str(n) + "+)"
|
||
} else {
|
||
"(" + "+" * n + ")"
|
||
}
|
||
}
|