Read Olympiad fight with script

For each fight, you can retrieve 4 information:

  • arena number,
  • first player,
  • second player
  • match status [In progress, Counting In Progress, Terminate]

So, transform your webhook scripts like a real pro!

uses SysUtils, Classes;

type
  TMatchInfo = record
    firstPlayer: string;
    secondPlayer: string;
    arena: string;
    status: string;
  end;

function GetOlyMatches(): array of TMatchInfo;
var
  text, delimiter, part: String;
  matches: array of TMatchInfo;
  p, count: Integer;
  tfPlayer, tsPlayer, tArena, tStatus: String;
begin
  count := 0;
  SetLength(matches, 22);
  text := Engine.DlgText;
  delimiter := '">';

  while Pos(delimiter, text) > 0 do
  begin
    p := Pos(delimiter, text);
    part := Copy(text, 1, p - 1);
    
    if (Pos(' : ', part) > 0) then
    begin
      tArena := part.Split(' ')[0];
      tfPlayer := part.Split(' ')[2];
      tsPlayer := part.Split('&nbsp;')[4].Split('<')[0];

      if (Pos('(&$907;)', part) > 0) then
        tStatus := 'Counting In Progress'
      else if (Pos('(&$829;)', part) > 0) then
        tStatus := 'In Progress'
      else if (Pos('(&$908;)', part) > 0) then
        tStatus := 'Terminate'
      else
        tStatus := 'Unknown';
      
      with matches[count] do begin
        arena := tArena;
        firstPlayer := tfPlayer;
        secondPlayer := tsPlayer;
        status := tStatus;
      end;
      Inc(count);
    end;

    Delete(text, 1, p + Length(delimiter) - 1);
  end;
  SetLength(matches,count);
  Result := matches;
end;

var
  matchList: array of TMatchInfo;
  i: Integer;
begin
  matchList := GetOlyMatches();
  for i := 0 to High(matchList) do
  begin
    print(Format('%s, %s VS %s. Game Status: %s',
      [
       matchList[i].arena,
       matchList[i].firstPlayer,
       matchList[i].secondPlayer,
       matchList[i].status
      ]));
  end;
end.

Author: Velmsun