-- Dyna Blaster: what the hall of fame needs from a battle, read from RAM.
--
-- A results plugin (od-unix/netplay_bot.cpp): the lobby's referee asks it at
-- confirmed frames what the game shows, and decides matches from that --
-- a match is won when a bomber's round wins reach the target, and over when
-- the counts go back to zero for the next one. Keyed by Amiga port, the
-- game's own idea of who is who; the lobby maps ports to its players.
--
-- The addresses are playbooks/dynablaster/profile.json's "scores": rounds
-- won per player record (+0x1c), and the "FIGHTING FOR" target, stored as N-1.

local WINS = { [2] = 0x44f24, [3] = 0x44f4c, [1] = 0x44f74, [0] = 0x44f9c }
local TARGET = 0x44efe

function results()
  local wins = {}
  for port, addr in pairs(WINS) do
    wins[port] = ram.u16(addr)
  end
  local target = ram.u16(TARGET)
  return { wins = wins, target = target and (target + 1) or nil }
end
