-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCheatCodes.gd
48 lines (38 loc) · 1.65 KB
/
CheatCodes.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
extends Node
const REWARD_MARKER_SCENE = preload("res://Reward/RewardMarker.tscn")
func _unhandled_input(event):
if not OS.is_debug_build():
return
if event.is_action_released("game_over", true):
Events.game_over.emit()
if event.is_action_released("round_over", true):
Events.round_complete.emit()
if event.is_action_released("reset_hand"):
await $'../Hand'.clear()
$'../Hand'.refill_hand()
if event.is_action_released("add_redraw_bonus"):
var marker: RewardMarker = REWARD_MARKER_SCENE.instantiate()
marker.reward = Reward.RedrawCard.new()
marker.color = random_reward_color()
add_child(marker)
Events.receive_reward.emit(marker)
if event.is_action_released("add_play_again_bonus"):
var marker = REWARD_MARKER_SCENE.instantiate()
marker.reward = Reward.PlayAgain.new()
marker.color = random_reward_color()
add_child(marker)
Events.receive_reward.emit(marker)
if event.is_action_pressed("toggle_debug_view"):
$'../Deck'.visible = not $'../Deck'.visible
if event.is_action_pressed("screenshot"):
var image = get_viewport().get_texture().get_image()
var timestamp = Time.get_datetime_dict_from_system()
var userdir = OS.get_system_dir(OS.SYSTEM_DIR_DOCUMENTS)
var filename = userdir + "/screenshot_" + str(timestamp.year) + "-" + str(timestamp.month) + "-" + str(timestamp.day) + "_" + str(timestamp.hour) + "-" + str(timestamp.minute) + "-" + str(timestamp.second) + ".png"
print("saving ", filename)
var result = image.save_png(filename)
if result != OK:
printerr("Error saving screenshot:", result)
func random_reward_color():
var colors = [ColorPalette.RED, ColorPalette.BLUE]
return colors[randi() % colors.size()]