added simple service duration selector
This commit is contained in:
@ -58,6 +58,7 @@ func select_workspace(workspace):
|
||||
return
|
||||
rpc("networked_select_workspace", workspace.get_path(), current_client.get_path())
|
||||
#workspace.add_client(current_client)
|
||||
current_client.show_time_selector()
|
||||
current_client = null
|
||||
#rpc("end_turn")
|
||||
|
||||
|
@ -12,6 +12,6 @@ func get_icon(x):
|
||||
|
||||
func set_service(_service):
|
||||
service = _service
|
||||
$Label.text = str(Data.service_prices[service])
|
||||
$Label.text = "$" + str(Data.service_prices[service])
|
||||
$Label.visible = true
|
||||
$"Icon1".region_rect = Rect2(get_icon(service), 0, 32, 32)
|
||||
|
@ -3,14 +3,11 @@ extends Card
|
||||
|
||||
signal time_slots_selected
|
||||
|
||||
enum difficulties {EASY, MEDIUM, HARD}
|
||||
|
||||
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")
|
||||
var title = "New Task"
|
||||
var difficulty = difficulties.EASY
|
||||
var initial_stress = 0
|
||||
var turns_left = 4
|
||||
var time_slots = [true, true, false, true]
|
||||
@ -18,7 +15,10 @@ var icon_list = []
|
||||
var medium_threshold := 5
|
||||
var good_threshold := 8
|
||||
var satisfaction := 1
|
||||
var watch_on := false
|
||||
@export var pip_sprites: Array[TextureRect] = []
|
||||
@export var time_button_sprites: Array[TextureRect] = []
|
||||
@export var time_hovered_sprites: Array[TextureRect] = []
|
||||
|
||||
|
||||
func _ready():
|
||||
@ -30,6 +30,18 @@ func _ready():
|
||||
pip_sprites.append($front/pip7)
|
||||
pip_sprites.append($front/pip8)
|
||||
pip_sprites.append($front/pip9)
|
||||
icon_list.append($front/Bonus1)
|
||||
icon_list.append($front/Bonus2)
|
||||
icon_list.append($front/Bonus3)
|
||||
icon_list.append($front/Bonus4)
|
||||
time_button_sprites.append($watch/time1)
|
||||
time_button_sprites.append($watch/time2)
|
||||
time_button_sprites.append($watch/time3)
|
||||
time_button_sprites.append($watch/time4)
|
||||
time_hovered_sprites.append($watch/time_hovered1)
|
||||
time_hovered_sprites.append($watch/time_hovered2)
|
||||
time_hovered_sprites.append($watch/time_hovered3)
|
||||
time_hovered_sprites.append($watch/time_hovered4)
|
||||
|
||||
|
||||
func _process(delta):
|
||||
@ -37,40 +49,17 @@ func _process(delta):
|
||||
slide(delta)
|
||||
|
||||
|
||||
func setup(_title, _initial_stress, _time_slots, _services, _medium, _good):
|
||||
func setup(_title, _initial_stress, _time_slots, _services):
|
||||
if _title != "":
|
||||
title = _title
|
||||
initial_stress = _initial_stress
|
||||
time_slots = _time_slots
|
||||
medium_threshold = _medium
|
||||
good_threshold = _good
|
||||
for x in pip_sprites.size():
|
||||
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
|
||||
if time_slots[0] == true:
|
||||
$"Control/1turn".visible = true
|
||||
if time_slots[1] == true:
|
||||
$"Control/2turn".visible = true
|
||||
if time_slots[2] == true:
|
||||
$"Control/3turn".visible = true
|
||||
if time_slots[3] == true:
|
||||
$"Control/4turn".visible = true
|
||||
services = []
|
||||
if _services != null and _services != []:
|
||||
services.append_array(_services)
|
||||
match services.size():
|
||||
2, 3:
|
||||
difficulty = difficulties.EASY
|
||||
4, 5:
|
||||
difficulty = difficulties.MEDIUM
|
||||
6, 7:
|
||||
difficulty = difficulties.HARD
|
||||
for x in time_button_sprites.size():
|
||||
if time_slots[x] == true:
|
||||
time_button_sprites[x].visible = true
|
||||
$front/Slice1.visible = false
|
||||
$front/Slice2.visible = false
|
||||
$front/Slice3.visible = false
|
||||
@ -85,65 +74,50 @@ func setup(_title, _initial_stress, _time_slots, _services, _medium, _good):
|
||||
$front/Slice4.visible = true
|
||||
$front/Title.text = str(title)
|
||||
$"front/Initial Stress".text = str(initial_stress)
|
||||
for x in icon_list:
|
||||
x.queue_free()
|
||||
icon_list = []
|
||||
match difficulty:
|
||||
difficulties.EASY:
|
||||
$easy.visible = true
|
||||
var array_of_bullshit = []
|
||||
array_of_bullshit.append($easy/Standard)
|
||||
array_of_bullshit.append($easy/Great1)
|
||||
array_of_bullshit.append($easy/Great2)
|
||||
for x in array_of_bullshit:
|
||||
var instance = icon_prefab.instantiate()
|
||||
icon_list.append(instance)
|
||||
x.add_child(instance)
|
||||
difficulties.MEDIUM:
|
||||
$medium.visible = true
|
||||
var array_of_bullshit = []
|
||||
array_of_bullshit.append($medium/Standard)
|
||||
array_of_bullshit.append($medium/Good1)
|
||||
array_of_bullshit.append($medium/Good2)
|
||||
array_of_bullshit.append($medium/Great1)
|
||||
array_of_bullshit.append($medium/Great2)
|
||||
for x in array_of_bullshit:
|
||||
var instance = icon_prefab.instantiate()
|
||||
icon_list.append(instance)
|
||||
x.add_child(instance)
|
||||
difficulties.HARD:
|
||||
$hard.visible = true
|
||||
var array_of_bullshit = []
|
||||
array_of_bullshit.append($hard/Standard)
|
||||
array_of_bullshit.append($hard/Poor1)
|
||||
array_of_bullshit.append($hard/Poor2)
|
||||
array_of_bullshit.append($hard/Good1)
|
||||
array_of_bullshit.append($hard/Good2)
|
||||
array_of_bullshit.append($hard/Great1)
|
||||
array_of_bullshit.append($hard/Great2)
|
||||
for x in array_of_bullshit:
|
||||
var instance = icon_prefab.instantiate()
|
||||
icon_list.append(instance)
|
||||
x.add_child(instance)
|
||||
for x in icon_list.size():
|
||||
if x < services.size():
|
||||
icon_list[x].set_service(services[x])
|
||||
else:
|
||||
icon_list[x].visible = false
|
||||
for x in services.size():
|
||||
if x == 0:
|
||||
continue
|
||||
icon_list[x - 1].set_service(services[x])
|
||||
icon_list[x - 1].visible = true
|
||||
good_threshold = 10 - (5 - services.size())
|
||||
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
|
||||
|
||||
|
||||
func show_time_selector():
|
||||
$Control.visible = true
|
||||
watch_on = true
|
||||
$watch.visible = true
|
||||
|
||||
|
||||
func update_counter():
|
||||
$"Background/Turns Left Counter".text = str(turns_left)
|
||||
$"front/Turns Left Counter".text = str(turns_left)
|
||||
|
||||
|
||||
func _on_turn_pressed(num):
|
||||
turns_left = num
|
||||
update_counter()
|
||||
$Control.visible = false
|
||||
$watch.visible = false
|
||||
watch_on = false
|
||||
time_slots_selected.emit()
|
||||
|
||||
|
||||
@ -155,3 +129,20 @@ func turn_front():
|
||||
func turn_back():
|
||||
$back.visible = true
|
||||
$front.visible = false
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
func _on_watch_segment_mouse_exited(extra_arg_0: int) -> void:
|
||||
for sprite in time_hovered_sprites:
|
||||
sprite.visible = false
|
||||
|
||||
|
||||
func _on_watch_segment_input_event(viewport: Node, event: InputEvent, shape_idx: int, extra_arg_0: int) -> void:
|
||||
if event is InputEventMouseButton and event.pressed:
|
||||
_on_turn_pressed(extra_arg_0 + 1)
|
||||
|
@ -73,7 +73,6 @@ func load_deck():
|
||||
bool_array.append(bool(x))
|
||||
for x in value.slice(5, value.size()):
|
||||
int_array.append(int(x))
|
||||
card_instance.setup(key, int(value[0]), bool_array, int_array)
|
||||
card_instance.position = Vector2(-927, -176)
|
||||
card_instance.scale = Vector2(1.288, 1.288)
|
||||
card_instance.turn_front()
|
||||
@ -83,6 +82,7 @@ func load_deck():
|
||||
card_array[selected_card].visible = false
|
||||
selected_card = card_array.size() - 1
|
||||
add_child(card_instance)
|
||||
card_instance.setup(key, int(value[0]), bool_array, int_array)
|
||||
$Control/LineEdit.text = "task " + str(card_count)
|
||||
count_traits()
|
||||
$card_count.text = str(selected_card + 1) + "/" + str(card_array.size())
|
||||
@ -111,13 +111,6 @@ func count_traits():
|
||||
var difficulty_counts = [0, 0, 0]
|
||||
var symbol_counts = [0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
for card in card_array:
|
||||
match card.difficulty:
|
||||
0:
|
||||
difficulty_counts[0] += 1
|
||||
1:
|
||||
difficulty_counts[1] += 1
|
||||
2:
|
||||
difficulty_counts[2] += 1
|
||||
for x in 10:
|
||||
if x == 0:
|
||||
continue
|
||||
@ -145,10 +138,6 @@ func determine_card():
|
||||
services.append($Control/ItemList3.selected)
|
||||
if $Control/ItemList4.selected > 0:
|
||||
services.append($Control/ItemList4.selected)
|
||||
if $Control/ItemList5.selected > 0:
|
||||
services.append($Control/ItemList5.selected)
|
||||
if $Control/ItemList6.selected > 0:
|
||||
services.append($Control/ItemList6.selected)
|
||||
card.append_array(services)
|
||||
return card
|
||||
|
||||
@ -176,7 +165,6 @@ func generate_card_from_buttons():
|
||||
if card == null:
|
||||
return
|
||||
var card_instance = card_scene.instantiate()
|
||||
card_instance.setup(str($Control/LineEdit.text), card[0], card.slice(1, 5), card.slice(5, card.size()))
|
||||
card_instance.position = Vector2(-926, -176)
|
||||
card_instance.scale = Vector2(1.288, 1.288)
|
||||
card_instance.turn_front()
|
||||
@ -186,6 +174,7 @@ func generate_card_from_buttons():
|
||||
card_array[selected_card].visible = false
|
||||
selected_card = card_array.size() - 1
|
||||
add_child(card_instance)
|
||||
card_instance.setup(str($Control/LineEdit.text), card[0], card.slice(1, 5), card.slice(5, card.size()))
|
||||
$Control/LineEdit.text = "task " + str(card_count)
|
||||
count_traits()
|
||||
$card_count.text = str(selected_card + 1) + "/" + str(card_array.size())
|
||||
|
@ -72,8 +72,8 @@ func _load_clients():
|
||||
bool_array.append(bool(x))
|
||||
for x in value.slice(5, value.size()):
|
||||
int_array.append(int(x))
|
||||
card_instance.setup(key, int(value[0]), bool_array, int_array)
|
||||
add_child(card_instance)
|
||||
card_instance.setup(key, int(value[0]), bool_array, int_array)
|
||||
client_deck.place(card_instance)
|
||||
client_deck.shuffle()
|
||||
|
||||
|
Reference in New Issue
Block a user