LaihoE / demoparser

Counter-Strike 2 replay parser for Python and JavaScript
MIT License
306 stars 31 forks source link

parseEvent 'round_end' returning undefined reason and winner #157

Open tiagorigoletto opened 7 months ago

tiagorigoletto commented 7 months ago

Hello, I was testing your example for finding clutches in a demo, and I bumped on the following issue:

Running let round_ends = parseEvent(pathToDemo, 'round_end')

Returns

round_ends: [
  {
    event_name: 'round_end',
    reason: null,
    round: 1,
    tick: 0,
    winner: null
  },
  {
    event_name: 'round_end',
    reason: 'bomb_exploded',
    round: 2,
    tick: 9451,
    winner: 'T'
  },

The reason and winner for the first round are missing, but they appear incorrectly in the second round instead. I encountered this issue on all 3 maps from the Copenhagen Major's final.

Awesome library by the way, thanks for putting it together.

Halva773 commented 3 months ago

As far as I understand, this happens for several reasons:

  1. Restart of the round (There can be many empty values in round ended and not only in 1 round)
  2. I also found that if a knife round is played, then it is also taken into account in this dataframe

I write in python, so I don't know how to fix it in js. In Python it looks like this:

df = parser.parse_event("round_end", other=["total_rounds_played", 'round_win_status'])
df = df[df.winner.isna() == False].drop_duplicates(subset='total_rounds_played', keep='last').reset_index()

Principle: first you delete empty values, and then duplicates (according to the total_rounds_played parameter), where you leave only the last value (if total_rounds_played = 1 more than 1 time, then you need to leave only the last one, since it is correctly relevant) If something is unclear, then ask GPT to rewrite the code in js and figure it out