Skip to contents
library(supermetroid)

# other tools
library(tidyverse)
#> ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
#>  dplyr     1.1.2      readr     2.1.4
#>  forcats   1.0.0      stringr   1.5.0
#>  ggplot2   3.4.2      tibble    3.2.1
#>  lubridate 1.9.2      tidyr     1.3.0
#>  purrr     1.0.1     
#> ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
#>  dplyr::filter() masks stats::filter()
#>  dplyr::lag()    masks stats::lag()
#>  Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors

Create a dataframe with splitsio observations of game events, with srcomapi rank and location.

We will join theses elements from speedrun.com data to splits.io data.




# speedrun.com, each row is a player
src_join_df <-
  supermetroid::src_df %>%
  group_by(player_name) %>%
  filter(rank == max(rank)) %>%
  ungroup() %>% 
  select(rank, player_name, date, t_human, country, run_id) %>% 
  rename_with( ~ paste0("src_", .x)) %>% 
  mutate(src_player_name = tolower(src_player_name),
         src_date = ymd(src_date)) %>% 
  filter(!is.na(src_player_name))
#> Warning: There was 1 warning in `mutate()`.
#>  In argument: `src_date = ymd(src_date)`.
#> Caused by warning:
#> !  19 failed to parse.

head(src_join_df)
#> # A tibble: 6 × 6
#>   src_rank src_player_name src_date   src_t_human    src_country src_run_id
#>      <dbl> <chr>           <date>     <chr>          <list>      <chr>     
#> 1        1 shinyzeni       2023-06-20 PT1H12M47S     <chr [1]>   ywrjqd9m  
#> 2        2 zoast           2021-02-24 PT1H12M55S     <chr [1]>   yo75d4dm  
#> 3        3 behemoth87      2021-12-08 PT1H12M55.930S <chr [1]>   m36d0q6m  
#> 4        4 gebbu           2023-05-08 PT1H13M12S     <chr [1]>   m3qo724y  
#> 5        5 static_shock    2023-06-10 PT1H13M58.367S <chr [1]>   m3qrx76y  
#> 6        6 cscottyw        2023-06-27 PT1H14M18S     <chr [1]>   zpw9px8y

# need to debug player id types
splits_df <- sio_df %>% 
  mutate(player_name = as.character(player_name)) %>% 
  left_join(src_join_df, 
          by = c("player_name" = "src_player_name"))

dim(splits_df)
#> [1] 19815    16
head(splits_df)
#>             game_event player_name realtime_start_ms realtime_duration_ms
#> 1           morph ball  anatomecha                 0               200835
#> 2       first missiles  anatomecha            200835                24091
#> 3                bombs  anatomecha            224926               133395
#> 4 first super missiles  anatomecha            358321               231341
#> 5          charge beam  anatomecha            589662               120300
#> 6               spazer  anatomecha            709962                97876
#>   realtime_end_ms realtime_shortest_duration_ms realtime_gold segment_number
#> 1          200835                        200835          TRUE              0
#> 2          224926                         23286         FALSE              1
#> 3          358321                        129371         FALSE              2
#> 4          589662                        227335         FALSE              3
#> 5          709962                        120299         FALSE              4
#> 6          807838                         95884         FALSE              5
#>                             segment_id run_id player_id src_rank   src_date
#> 1 69d90da3-1634-4af4-9096-419a32bedd0a   ato1     89646      501 2023-06-19
#> 2 fad50319-d55b-460e-923a-c416f233daea   ato1     89646      501 2023-06-19
#> 3 089daf0b-64c3-4eec-8902-022335b2b179   ato1     89646      501 2023-06-19
#> 4 2a215dcd-2989-4939-8558-a7215904dfd1   ato1     89646      501 2023-06-19
#> 5 e906991d-e919-47c1-a809-2b4da9b67461   ato1     89646      501 2023-06-19
#> 6 10439232-43c7-4752-afb9-ee23782da4a9   ato1     89646      501 2023-06-19
#>      src_t_human src_country src_run_id
#> 1 PT1H54M45.720S     Denmark   mrl6jg7m
#> 2 PT1H54M45.720S     Denmark   mrl6jg7m
#> 3 PT1H54M45.720S     Denmark   mrl6jg7m
#> 4 PT1H54M45.720S     Denmark   mrl6jg7m
#> 5 PT1H54M45.720S     Denmark   mrl6jg7m
#> 6 PT1H54M45.720S     Denmark   mrl6jg7m
usethis::use_data(splits_df, overwrite=TRUE)