From 89d31e3bdb9bd7cb9381d361afceb524f0e6de01 Mon Sep 17 00:00:00 2001 From: tpart Date: Wed, 28 Aug 2024 21:37:24 +0200 Subject: Add bot count limit --- client/menu/lobby.gd | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/client/menu/lobby.gd b/client/menu/lobby.gd index 44afe9cf..7d1e3af7 100644 --- a/client/menu/lobby.gd +++ b/client/menu/lobby.gd @@ -17,6 +17,7 @@ extends Control class_name Lobby +const MAX_BOT_COUNT_PER_TYPE: int = 16 const PLAYER = preload("res://menu/lobby/player.tscn") var map_count @@ -116,14 +117,11 @@ func select_map(i: int): map_list_container.get_child(i).grab_focus() func increase_bot_count(algo_id: String): - bot_counts[algo_id] = bot_counts[algo_id] + 1 + bot_counts[algo_id] = clampi(bot_counts[algo_id] + 1, 0, MAX_BOT_COUNT_PER_TYPE) update_bot_reset_text(algo_id) func decrease_bot_count(algo_id: String): - var new_count = bot_counts[algo_id] - 1 - if new_count < 0: - return - bot_counts[algo_id] = new_count + bot_counts[algo_id] = clampi(bot_counts[algo_id] - 1, 0, MAX_BOT_COUNT_PER_TYPE) update_bot_reset_text(algo_id) func reset_bot_count(algo_id: String): -- cgit v1.2.3-70-g09d2