get_kick_point <- function(rcl) { output <- rcl |> dplyr::filter(command=="kick") |> dplyr::mutate( x = args |> stringr::str_extract("[0-9\\-\\.]+"), l1 = args |> stringr::str_remove(x), y = l1 |> stringr::str_extract("[0-9\\-\\.]+"), unum = as.numeric(unum) ) |> dplyr::select( step, team, unum, command, x, y, ) return(output) } read_referee <- function(path_rcl) { referee <- path_rcl |> readr::read_lines() |> tibble::as_tibble() |> dplyr::mutate( step = value |> stringr::str_extract("\\d+"), command = value |> stringr::str_extract("referee [a-zA-Z0-9_]*")|> stringr::str_remove("referee "), step = as.numeric(step), ) |> dplyr::select( step, command, ) %>% tidyr::drop_na() return(referee) } read_goal <- function(referee,name){ goal <- referee |> dplyr::filter(stringr::str_detect(command, "goal_[rl]_[0-9]+")) |> dplyr::mutate( side = command |> stringr::str_remove("goal_") |> stringr::str_extract("[rl]"), score = command |> stringr::str_remove("goal_[rl]_") |> stringr::str_extract("[0-9]+") , ) |> dplyr::inner_join(name,by="side") |> dplyr::select( step, name, score, ) %>% tidyr::drop_na() return(goal) } before_goal <- function(kick_log,goal_step,goal_team){ playlist <- kick_log %>% dplyr::arrange(desc(step)) %>% dplyr::filter( step > goal_step -100, step < goal_step, team == goal_team, ) } get_goal_playlist <- function(kick_log,goal){ if(length(goal$step)<1){ return(NA) } i <- 1 output <- before_goal(kick_log,goal$step[i],goal$name[i]) i<- i+1 while(i <= length(goal$step)){ # print(i) i_list <- before_goal(kick_log,goal$step[i],goal$name[i]) output <- output |> bind_rows(i_list) i<- i+1 } # for(i in goal$step){ # i_list <- before_goal(kick_log,goal$step[i],goal$name[i]) # output <- output |> bind_rows(i_list) # print(i) # } return(output) } convert_ball_acg_and_rcl <- function(rcg,rcl){ output <- dplyr::inner_join(rcg,rcl,by="step") return(output) } get_dribble_point <- function(log_data){ output <- log_data %>% filter(dribble==TRUE,pass==FALSE) return(output) } get_pass_point <- function(log_data){ output <- log_data %>% filter(pass==TRUE) return(output) }