goto-bus-stop/recanalyst

No resignTime exists on any player objects: .aoe2record

jduyon opened this issue · 3 comments

I'm trying to use recanalyst to find the players that resigned in an HD game (and whether or not they were the owner).

I wrote a little script to do this for a recorded game given from the command line. The script just looks for the first person to resign and checks if player->owner. It doesn't check the team of the player who resigned.

(A usage for this script is:
php examples/get_resigned.php some_recorded_game.aoe2record; echo $?;

require __DIR__ . '/../vendor/autoload.php';
use RecAnalyst\RecordedGame;

$filename = $argv[1];
$rec = new RecordedGame($filename);

// EXIT 0 means you did not resign
// EXIT 1 means you did resign
// EXIT 2 means could not find anyone who resigned

// Go through each of the chat messages, search for if the chat message is:
// "<player> resigned" and player is owner.
foreach ($rec->body()->chatMessages as $chat) {
    if ($chat->player && $chat->player->owner && $chat->msg === 'resigned') {
        exit(1);
    }
}
foreach ($rec->body()->chatMessages as $chat) {
    if ($chat->player && $chat->msg === 'resigned'){
        exit(0);
    }
}

// Go through each of the players and search for resignTime + player is owner
foreach($rec->players() as $player){
  if($player->resignTime && $player->owner){
    exit(1);
  }
  elseif ($player->resignTime){
    exit(0);
  }
}
exit(2);

no_resign_times_HD.zip

This is the attached AOE2HD game zipped (I own the expansions, but I dont think this was an expansion game).

Hmm… Resignation times are determined by reading Resign actions from the recorded game body, but it looks like that game doesn't contain a Resign action.
(Perhaps AoE saves the game before the resign action is processed?)

I don't think resign times are actually saved anywhere in the recorded game, so I'm not sure if there's anything we can do about this :(

Ah, that makes sense. I played back the rec and didn't see any resignations in the chat or in game.