Skip to content

Commit 1234d0a

Browse files
authored
storybook: Refactor building list of authors (#2054)
Factor out the code that turns ["a", "b", "c"] into "a, b and c". Add an Easter egg.
1 parent c87f543 commit 1234d0a

1 file changed

Lines changed: 29 additions & 12 deletions

File tree

scenes/menus/storybook/components/storybook_page.gd

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,50 @@ var quest: Quest = preload("uid://dwl8letaanhhi"):
1818
@onready var play_button: Button = %PlayButton
1919

2020

21-
func _set_quest(new_quest: Quest) -> void:
22-
quest = new_quest
21+
# This is an in-joke/Easter egg for the Endless Access team
22+
func _chadify(name: String) -> String:
23+
if name != "Justin Bourque":
24+
return name
2325

24-
if not is_node_ready():
25-
return
26+
var options := [
27+
name,
28+
"Chad Bourque",
29+
"Eric Bourque",
30+
]
31+
return options.pick_random()
2632

27-
title.text = quest.title.strip_edges()
28-
description.text = quest.description.strip_edges()
2933

30-
match quest.authors.size():
34+
func _make_author_list() -> String:
35+
var names := quest.authors.map(_chadify)
36+
match names.size():
3137
0:
32-
authors.text = ""
38+
return ""
3339
1:
34-
authors.text = "A story by " + quest.authors[0]
40+
return "A story by " + names[0]
3541
_:
36-
authors.text = (
42+
return (
3743
" "
3844
. join(
3945
[
4046
"A story by",
41-
", ".join(quest.authors.slice(0, -1)),
47+
", ".join(names.slice(0, -1)),
4248
"and",
43-
quest.authors[-1],
49+
names[-1],
4450
]
4551
)
4652
)
4753

54+
55+
func _set_quest(new_quest: Quest) -> void:
56+
quest = new_quest
57+
58+
if not is_node_ready():
59+
return
60+
61+
title.text = quest.title.strip_edges()
62+
description.text = quest.description.strip_edges()
63+
authors.text = _make_author_list()
64+
4865
if quest.affiliation:
4966
authors.text += " of " + quest.affiliation
5067

0 commit comments

Comments
 (0)