I am trying to read the last line from a command prompt as I have another program running which will play a game and in the end echo if I am the winner, loser or we went to a draw. I have this sample code:
Edit: the section "------" isjust an example of what I am trying to achieve. Basically I want to read the line saying e.g. "Player: me win the game!" or "The game was a draw!" so the line was trying to indicate what I want to scan through the line and check if it contains either win, draw else it's a loss
@set win=0
@set draw=0
@set lose=0
@set loopcount=10
:loop
C:\battlesnakeCLI\battlesnake.exe play -W 11 -H 11 --name me --url http://localhost/api/gamev2 --name other --url http://localhost/api/gametest
------
if line.contains("win")
set /a win=win+1
else if (line.contains("draw")
set /a draw=draw+1
else
set /a lose=lose+1
------
set /a loopcount=loopcount-1
if %loopcount%==0 goto exitloop
goto loop
:exitloop
@ECHO Wins: %win% & echo:Draws: %draw% & echo:Losses:%lose%
pause