require_relative 'app/services/game_api_client'
require 'pp'

client = GameApiClient.new
# Get initial state
puts "Fetching initial state..."
initial_state_full = client.api_game_initial_state
if initial_state_full.nil?
  puts "Failed to fetch initial state"
  exit
end

game_state = initial_state_full["game_state"]
puts "Game state fetched. Game ID: #{game_state['game_id']}"

# Test possible orders
puts "\nTesting api_calculate_possible_orders(game_state)..."
begin
  orders = client.api_calculate_possible_orders(game_state)
  if orders
    puts "Success! Number of locations with orders: #{orders['possible_orders']&.keys&.size}"
  else
    puts "Failed! Returned nil."
  end
rescue ArgumentError => e
  puts "Caught ArgumentError: #{e.message}"
rescue => e
  puts "Caught unexpected error: #{e.class} - #{e.message}"
end

# Test with 2 arguments
puts "\nTesting api_calculate_possible_orders(game_state, 'FRANCE')..."
orders = client.api_calculate_possible_orders(game_state, 'FRANCE')
if orders
  puts "Success! Power: #{orders['power']}"
else
  puts "Failed! Returned nil."
end
