Closed maciej-pomykala closed 4 years ago
Instead of this:
if (!checkA & !checkB & !checkC) {
core function code
}
else if (checkA) errorA
else if (checkB) errorB
else if (checkC) errorC
do
if (checkA) errorA
if (checkB) errorB
if (checkC) errorC
core function code
_Originally posted by @adrian-golian in https://github.com/Blef-team/blef_game_engine/pull/60#issuecomment-615933859_
Btw, there are some weird things happening in https://github.com/Blef-team/blef_game_engine/blob/9cc0062754d68e0353b2a80e4e8c5e4498eae475/api/endpoints.R#L164
game_path <- get_path(game_uuid)
if(file.exists(game_path)) {
current_r <- readRDS(game_path)$round_number
if (round == -1 | round == current_r) {
r <- current_r
game <- readRDS(get_path(game_uuid))
} else {
r <- as.numeric(round)
game <- readRDS(get_path(game_uuid, r))
}
Why assign game_path
when you're not using it. You can just do file.exists(get_path(game_uuid))
From what I udnerstand, you would have been pleased to look at this commit
Edit: the commit changes the join
endpoint, I'll do the same thing for the state endpoint and the other endpoints
Current
if
andelse
statements reduce clarity