import std/[os, unittest] import test_framework/test_framework import test_framework/battle_result import test_framework/server_manager import test_framework/bot_compiler import test_framework/runner_process const modularBotDir = currentSourcePath().parentDir.parentDir tfAdversaries = currentSourcePath().parentDir.parentDir.parentDir / "common_libs" / "test_framework" / "adversaries" sittingDuck = tfAdversaries / "SittingDuck" # Skip if JARs are missing if not fileExists("/home/davide/Projects/tank-royale/server/build/libs/robocode-tankroyale-server-0.35.5-all.jar") or not fileExists("/home/davide/Projects/tank-royale/runner/examples/lib/robocode-tankroyale-runner.jar"): echo "Skipping: Tank Royale JARs not found" quit(0) suite "ModularBot basic battle": test "beats SittingDuck in 1 round": # Debug: manually compile and check try: let compiledBots = compileBots(@[modularBotDir, sittingDuck]) echo "Compiled bots: ", compiledBots for bot in compiledBots: if fileExists(bot): echo " ✓ ", bot else: echo " ✗ MISSING: ", bot except CatchableError as e: echo "Compilation error: ", e.msg raise # Now run battle with longer timeout for ModularBot boot ensureServer() let stdout = runBattleRunner(getServerUrl(), @[modularBotDir, sittingDuck], 1, 180000, true) echo "" echo "Raw battle runner output:" echo stdout echo "" let r = parseServerOutput(stdout) echo "" echo "=== Battle Result ===" echo "Rounds: ", r.rounds.len echo "Bots: ", r.bots echo "" echo "Final standings:" for result in r.results: echo " ", result.name, ": rank=", result.rank, " score=", result.totalScore, " survived=", result.survivalCount, " first=", result.firstPlaces echo "" echo "Winners: ", r.winners echo "" # Basic checks check r.rounds.len == 1 check r.results.len == 2 check "ModularBot" in r.bots check "SittingDuck" in r.bots # ModularBot should win var modularResult: BotResult for b in r.results: if b.name == "ModularBot": modularResult = b check modularResult.name == "ModularBot" check modularResult.rank == 1 check "ModularBot" in r.winners