bordello/Scripts/client.gd

129 lines
3.2 KiB
GDScript3
Raw Normal View History

2023-06-06 13:35:20 +10:00
class_name Client
extends Card
signal time_slots_selected
2023-06-06 13:35:20 +10:00
var icon_prefab = preload("res://Scenes/bonus_icon.tscn")
var bad_pip_sprite = preload("res://Assets/bad_pip.png")
var medium_pip_sprite = preload("res://Assets/medium_pip.png")
var good_pip_sprite = preload("res://Assets/good_pip.png")
2023-06-06 13:35:20 +10:00
var title = "New Task"
var initial_stress = 0
var turns_left = 4
var time_slots = [true, true, false, true]
var medium_threshold := 5
var good_threshold := 8
var satisfaction := 1
2023-06-13 19:21:13 +10:00
var watch_on := false
@export var pip_sprites: Array[TextureRect] = []
@export var icon_list: Array[Node2D] = []
2023-06-13 19:21:13 +10:00
@export var time_button_sprites: Array[TextureRect] = []
@export var time_hovered_sprites: Array[TextureRect] = []
2023-07-05 22:19:18 +10:00
@export var watch: TextureRect
2023-06-06 13:35:20 +10:00
func _process(delta):
if sliding:
slide(delta)
2023-06-13 19:21:13 +10:00
func setup(_title, _initial_stress, _time_slots, _services):
2023-06-06 13:35:20 +10:00
if _title != "":
title = _title
initial_stress = _initial_stress
time_slots = _time_slots
services = []
if _services != null and _services != []:
services.append_array(_services)
2023-06-13 19:21:13 +10:00
for x in time_button_sprites.size():
if time_slots[x] == true:
time_button_sprites[x].visible = true
2023-06-06 13:35:20 +10:00
if time_slots[0] == true:
$front/Slice1.visible = true
2023-06-06 13:35:20 +10:00
if time_slots[1] == true:
$front/Slice2.visible = true
2023-06-06 13:35:20 +10:00
if time_slots[2] == true:
$front/Slice3.visible = true
2023-06-06 13:35:20 +10:00
if time_slots[3] == true:
$front/Slice4.visible = true
$front/Title.text = str(title)
$"front/Initial Stress".text = str(initial_stress)
2023-06-13 19:21:13 +10:00
for x in services.size():
if x == 0:
continue
icon_list[x - 1].set_service(services[x])
icon_list[x - 1].visible = true
2023-07-07 21:15:10 +10:00
good_threshold = 10 - (6 - services.size())
2023-06-13 19:21:13 +10:00
medium_threshold = 4
if time_slots[3] == false:
good_threshold -= 1
if time_slots[2] == false:
good_threshold -= 1
if time_slots[1] == false:
good_threshold -= 1
if time_slots[0] == false:
medium_threshold += 1
if time_slots[1] == false:
medium_threshold += 1
if time_slots[2] == false:
medium_threshold += 1
for x in pip_sprites.size() + 2:
if x < 2:
continue
if x >= good_threshold:
pip_sprites[x - 2].texture = good_pip_sprite
if x < good_threshold:
pip_sprites[x - 2].texture = medium_pip_sprite
if x < medium_threshold:
pip_sprites[x - 2].texture = bad_pip_sprite
2023-06-06 13:35:20 +10:00
func show_time_selector():
2023-06-13 19:21:13 +10:00
watch_on = true
2023-07-05 22:19:18 +10:00
watch.visible = true
2023-06-06 13:35:20 +10:00
2023-06-06 13:35:20 +10:00
func update_counter():
2023-06-13 19:21:13 +10:00
$"front/Turns Left Counter".text = str(turns_left)
2023-06-06 13:35:20 +10:00
func _on_turn_pressed(num):
turns_left = num
update_counter()
2023-07-05 22:19:18 +10:00
watch.visible = false
2023-06-13 19:21:13 +10:00
watch_on = false
2023-06-06 13:35:20 +10:00
time_slots_selected.emit()
func turn_front():
$back.visible = false
$front.visible = true
func turn_back():
$back.visible = true
$front.visible = false
2023-06-13 19:21:13 +10:00
2023-07-05 22:19:18 +10:00
func set_satisfaction(num):
satisfaction = 1 + num
$front/ColorRect.position.x = 134 + ((satisfaction - 1) * 20.0)
2023-06-13 19:21:13 +10:00
func _on_watch_segment_mouse_entered(extra_arg_0: int) -> void:
if not watch_on or not time_slots[extra_arg_0]:
return
for x in extra_arg_0 + 1:
time_hovered_sprites[x].visible = true
2023-07-05 22:19:18 +10:00
func _on_watch_segment_mouse_exited(_extra_arg_0: int) -> void:
2023-06-13 19:21:13 +10:00
for sprite in time_hovered_sprites:
sprite.visible = false
2023-07-05 22:19:18 +10:00
func _on_watch_segment_input_event(_viewport: Node, event: InputEvent, _shape_idx: int, extra_arg_0: int) -> void:
2023-06-13 19:21:13 +10:00
if event is InputEventMouseButton and event.pressed:
_on_turn_pressed(extra_arg_0 + 1)