From 1c1447d84ea17055e4a920ba0cbf1376dad27513 Mon Sep 17 00:00:00 2001 From: Lexzach Date: Fri, 21 Mar 2025 18:43:29 -0400 Subject: [PATCH] fixed several bugs --- godot/main_scenes/game.tscn | 3 +++ godot/scripts/ai.gd | 2 +- godot/scripts/gamemaster.gd | 17 +++++++++++------ godot/scripts/globalvars.gd | 2 +- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/godot/main_scenes/game.tscn b/godot/main_scenes/game.tscn index 6759b84..553ebbd 100644 --- a/godot/main_scenes/game.tscn +++ b/godot/main_scenes/game.tscn @@ -106,6 +106,9 @@ context_menu_enabled = false emoji_menu_enabled = false shortcut_keys_enabled = false middle_mouse_paste_enabled = false +deselect_on_focus_loss_enabled = false drag_and_drop_selection_enabled = false +flat = true +caret_blink = true [connection signal="text_submitted" from="UI/PanelContainer/VBoxContainer/HBoxContainer/ANSWER" to="." method="_on_answer_text_submitted"] diff --git a/godot/scripts/ai.gd b/godot/scripts/ai.gd index 38b29e0..242b970 100644 --- a/godot/scripts/ai.gd +++ b/godot/scripts/ai.gd @@ -31,7 +31,7 @@ func _physics_process(_delta: float) -> void: is_correct = true if randf() > 0.05 else false else: wait_time = randi_range(60,350) - is_correct = true if randf() > 0.1 else false + is_correct = true if randf() > 0.15 else false currently_executing = true elif clock > wait_time: diff --git a/godot/scripts/gamemaster.gd b/godot/scripts/gamemaster.gd index ba7a312..711008a 100644 --- a/godot/scripts/gamemaster.gd +++ b/godot/scripts/gamemaster.gd @@ -7,19 +7,23 @@ func _determine_seconds_left() -> float: return difficulty_calc if difficulty_calc >= 3.0 else 3.0 func _on_answer_text_submitted(_new_text: String) -> void: - if GLOBALVARS.current_solution == (%ANSWER.text).to_int(): + if GLOBALVARS.current_solution == (%ANSWER.text).to_int() and (%ANSWER.text).is_valid_int(): GLOBALVARS.selected_player = (GLOBALVARS.selected_player+1)%4 - GLOBALVARS.difficulty+=1 + while GLOBALVARS.selected_player not in GLOBALVARS.players_remaining: + GLOBALVARS.selected_player = (GLOBALVARS.selected_player+1)%4 + + GLOBALVARS.difficulty+=.5 GLOBALVARS.seconds_left = _determine_seconds_left() _generate_question() - %ANSWER.text = "" else: %RULE_ENFORCEMENT.explode() cooldown = 60 GLOBALVARS.rotation_paused = true GLOBALVARS.players_remaining.erase(GLOBALVARS.selected_player) get_node("players/player_%s" % GLOBALVARS.selected_player).queue_free() - + + %ANSWER.text = "" + func _generate_question() -> void: # 0 - add # 1 - subtract @@ -48,7 +52,7 @@ func _generate_question() -> void: y = randi_range(1,100) @warning_ignore('integer_division') - GLOBALVARS.current_solution = x/y + GLOBALVARS.current_solution = int(x/y) %QUESTION.text = "%s %s %s = " % [x,GLOBALVARS.current_operand,y] @@ -77,7 +81,8 @@ func _physics_process(_delta: float) -> void: if len(GLOBALVARS.players_remaining) > 1 and 0 in GLOBALVARS.players_remaining: while GLOBALVARS.selected_player not in GLOBALVARS.players_remaining: GLOBALVARS.selected_player = (GLOBALVARS.selected_player+1)%4 - _generate_question() + + _generate_question() elif 0 in GLOBALVARS.players_remaining: pass # WIN CONDITION else: diff --git a/godot/scripts/globalvars.gd b/godot/scripts/globalvars.gd index c0c6110..da30da9 100644 --- a/godot/scripts/globalvars.gd +++ b/godot/scripts/globalvars.gd @@ -2,7 +2,7 @@ extends Node var selected_player:int = 0 var seconds_left:float = 0.0 -var difficulty:int = 1 +var difficulty:float = 1.0 var rotation_paused:bool = false var players_remaining:Array = [0,1,2,3] var current_solution:int