change ruleset
This commit is contained in:
+15
-151
@@ -56,15 +56,6 @@ func _process(delta):
|
||||
if multiplayer.is_server() and game_started:
|
||||
if turn_based_mode:
|
||||
rpc("sync_turn_index", current_turn_index)
|
||||
else:
|
||||
pass
|
||||
#bot_move_timer += delta
|
||||
#if bot_move_timer >= BOT_MOVE_INTERVAL:
|
||||
#bot_move_timer = 0.0
|
||||
#var current_bots = bots.duplicate()
|
||||
#for bot_id in current_bots:
|
||||
#if not moving_bots.get(bot_id, false):
|
||||
#move_bot(bot_id)
|
||||
|
||||
func setup_action_buttons():
|
||||
move_button.pressed.connect(func(): set_action_state(ActionState.MOVING))
|
||||
@@ -123,14 +114,17 @@ func set_action_state(new_state):
|
||||
return
|
||||
|
||||
current_action_state = new_state
|
||||
local_player_character.clear_highlights()
|
||||
local_player_character.clear_playerboard_highlights()
|
||||
if not local_player_character.is_bot:
|
||||
local_player_character.clear_highlights()
|
||||
local_player_character.clear_playerboard_highlights()
|
||||
|
||||
match new_state:
|
||||
ActionState.MOVING:
|
||||
local_player_character.highlight_movement_range()
|
||||
if not local_player_character.is_bot:
|
||||
local_player_character.highlight_movement_range()
|
||||
ActionState.GRABBING:
|
||||
local_player_character.highlight_adjacent_cells()
|
||||
if not local_player_character.is_bot:
|
||||
local_player_character.highlight_adjacent_cells()
|
||||
if local_player_character.has_item_at_current_position():
|
||||
local_player_character.highlighted_cells.append(local_player_character.current_position)
|
||||
local_player_character.enhanced_gridmap.set_cell_item(
|
||||
@@ -138,12 +132,15 @@ func set_action_state(new_state):
|
||||
local_player_character.enhanced_gridmap.hover_item
|
||||
)
|
||||
ActionState.PUTTING:
|
||||
local_player_character.highlight_occupied_playerboard_slots()
|
||||
if not local_player_character.is_bot:
|
||||
local_player_character.highlight_occupied_playerboard_slots()
|
||||
ActionState.RANDOMIZING:
|
||||
local_player_character.highlight_random_valid_cells()
|
||||
if not local_player_character.is_bot:
|
||||
local_player_character.highlight_random_valid_cells()
|
||||
ActionState.ARRANGING:
|
||||
show_arrangement_ui()
|
||||
local_player_character.highlight_occupied_playerboard_slots()
|
||||
if not local_player_character.is_bot:
|
||||
local_player_character.highlight_occupied_playerboard_slots()
|
||||
|
||||
func update_button_states():
|
||||
if not local_player_character or local_player_character.is_in_group("Bots"):
|
||||
@@ -166,8 +163,6 @@ func update_button_states():
|
||||
randomize_button.disabled = local_player_character.has_performed_action
|
||||
arrange_button.disabled = not local_player_character.has_items_in_playerboard()
|
||||
|
||||
|
||||
|
||||
func _on_playerboard_slot_clicked(event, slot_index):
|
||||
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
|
||||
if not local_player_character:
|
||||
@@ -273,9 +268,8 @@ func add_player_character(peer_id):
|
||||
update_playerboard_ui()
|
||||
|
||||
func add_bot(bot_id):
|
||||
if multiplayer.is_server():
|
||||
rpc("create_bot", bot_id)
|
||||
#moving_bots[bot_id] = false
|
||||
rpc("create_bot", bot_id)
|
||||
|
||||
|
||||
@rpc("call_local")
|
||||
func create_bot(bot_id):
|
||||
@@ -376,8 +370,6 @@ func next_turn():
|
||||
if multiplayer.is_server() and turn_based_mode:
|
||||
current_turn_index = (current_turn_index + 1) % players.size()
|
||||
rpc("set_current_turn", players[current_turn_index])
|
||||
#if players[current_turn_index] in bots:
|
||||
#move_bot(players[current_turn_index])
|
||||
|
||||
func request_next_turn():
|
||||
if multiplayer.is_server():
|
||||
@@ -409,131 +401,3 @@ func end_current_turn():
|
||||
if multiplayer.is_server():
|
||||
next_turn()
|
||||
rpc("sync_turn_index", current_turn_index)
|
||||
|
||||
#func move_bot(bot_id):
|
||||
#if not multiplayer.is_server() or moving_bots.get(bot_id, false):
|
||||
#return
|
||||
#
|
||||
#var bot = get_node_or_null(str(bot_id))
|
||||
#if not is_instance_valid(bot) or bot.is_player_moving:
|
||||
#moving_bots.erase(bot_id)
|
||||
#return
|
||||
#
|
||||
#if bot.action_points <= 0:
|
||||
#if turn_based_mode:
|
||||
#moving_bots[bot_id] = false
|
||||
#end_current_turn()
|
||||
#else:
|
||||
#bot.action_points = 2
|
||||
#bot.has_moved_this_turn = false
|
||||
#bot.has_performed_action = false
|
||||
#moving_bots[bot_id] = false
|
||||
#await get_tree().create_timer(0.5).timeout
|
||||
#move_bot(bot_id)
|
||||
#return
|
||||
#
|
||||
#moving_bots[bot_id] = true
|
||||
#await get_tree().create_timer(0.5).timeout
|
||||
#
|
||||
#if not is_instance_valid(bot):
|
||||
#moving_bots.erase(bot_id)
|
||||
#return
|
||||
#
|
||||
#var best_move = evaluate_bot_move(bot)
|
||||
#execute_bot_move(bot, bot_id, best_move)
|
||||
|
||||
#func execute_bot_move(bot, bot_id, move):
|
||||
#match move.action:
|
||||
#"arrange":
|
||||
#if bot.action_points >= 2:
|
||||
#bot.arrange_playerboard_item(bot.find_best_arrangement_slot())
|
||||
#bot.action_points -= 2
|
||||
#moving_bots[bot_id] = false
|
||||
#if bot.action_points > 0 or not turn_based_mode:
|
||||
#move_bot(bot_id)
|
||||
#elif turn_based_mode:
|
||||
#end_current_turn()
|
||||
#
|
||||
#"grab", "put":
|
||||
#var success = bot.grab_item(move.position) if move.action == "grab" else bot.put_item(move.position)
|
||||
#if success:
|
||||
#bot.action_points -= 1
|
||||
#moving_bots[bot_id] = false
|
||||
#if bot.action_points > 0 or not turn_based_mode:
|
||||
#move_bot(bot_id)
|
||||
#elif turn_based_mode:
|
||||
#end_current_turn()
|
||||
#
|
||||
#"move":
|
||||
#if is_instance_valid(bot) and bot.action_points >= 1:
|
||||
#var path = bot.enhanced_gridmap.find_path(Vector2(bot.current_position), Vector2(move.position))
|
||||
#if path.size() > 1:
|
||||
#path.pop_front()
|
||||
#var trimmed_path = path.slice(0, bot.movement_range)
|
||||
#bot.rotate_towards_target(move.position)
|
||||
#bot.move_bot_along_path(trimmed_path, bot_id)
|
||||
#bot.action_points -= 1
|
||||
#else:
|
||||
#moving_bots[bot_id] = false
|
||||
#if bot.action_points > 0 or not turn_based_mode:
|
||||
#move_bot(bot_id)
|
||||
#elif turn_based_mode:
|
||||
#end_current_turn()
|
||||
#else:
|
||||
#moving_bots[bot_id] = false
|
||||
#if bot.action_points > 0 or not turn_based_mode:
|
||||
#move_bot(bot_id)
|
||||
#elif turn_based_mode:
|
||||
#end_current_turn()
|
||||
#
|
||||
#_:
|
||||
#moving_bots[bot_id] = false
|
||||
#if turn_based_mode:
|
||||
#end_current_turn()
|
||||
#else:
|
||||
#move_bot(bot_id)
|
||||
|
||||
#func evaluate_bot_move(bot: Node) -> Dictionary:
|
||||
#if not is_instance_valid(bot) or bot.action_points <= 0:
|
||||
#return { "action": "none", "position": Vector2i.ZERO, "value": -1 }
|
||||
#
|
||||
#var moves = []
|
||||
#
|
||||
#if bot.action_points >= 2 and bot.check_playerboard_arrangement(bot):
|
||||
#moves.append({ "action": "arrange", "position": bot.current_position, "value": 20 })
|
||||
#
|
||||
#if bot.action_points >= 1:
|
||||
#var put_position = bot.find_best_put_position(bot)
|
||||
#if put_position != Vector2i(-1, -1):
|
||||
#moves.append({ "action": "put", "position": put_position, "value": 18 })
|
||||
#
|
||||
#if bot.action_points >= 1 and not bot.playerboard_is_full():
|
||||
#var grab_position = bot.find_best_grab_position()
|
||||
#if grab_position != Vector2i(-1, -1):
|
||||
#moves.append({ "action": "grab", "position": grab_position, "value": 15 })
|
||||
#
|
||||
#if bot.action_points >= 1 and not bot.has_moved_this_turn:
|
||||
#var random_pos = bot.find_random_valid_position_in_range()
|
||||
#if random_pos != bot.current_position:
|
||||
#moves.append({ "action": "move", "position": random_pos, "value": 5 })
|
||||
#
|
||||
#moves.sort_custom(func(a, b): return a.value > b.value)
|
||||
#return moves[0] if moves.size() > 0 else { "action": "none", "position": bot.current_position, "value": 0 }
|
||||
|
||||
#func bot_movement_completed(bot_id):
|
||||
#if not multiplayer.is_server():
|
||||
#return
|
||||
#
|
||||
#moving_bots[bot_id] = false
|
||||
#var bot = get_node_or_null(str(bot_id))
|
||||
#
|
||||
#if not is_instance_valid(bot):
|
||||
#moving_bots.erase(bot_id)
|
||||
#return
|
||||
#
|
||||
#if bot.action_points > 0 or not turn_based_mode:
|
||||
#await get_tree().create_timer(0.5).timeout
|
||||
#if is_instance_valid(bot):
|
||||
#move_bot(bot_id)
|
||||
#else:
|
||||
#end_current_turn()
|
||||
|
||||
Reference in New Issue
Block a user