Skip to content

Commit

Permalink
Fix last character of password bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Giora Simchoni committed Sep 10, 2017
1 parent cd86ec0 commit 304b018
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions R/initializeGame.R
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ initializeGame <- function(playerLevel) {
game$dragonSeen <- TRUE
message("Look through the Tower window.")
message("A magnificent dragon is flying your way. You thought the stories weren't true...")
message("\nThe R Dragon!\n She is landing with all her glory on the Castle roof. She is asking you:")
message("\nThe R Dragon!\nShe is landing with all her glory on the Castle roof. She is asking you:")
}
message("\"What is the password?\"")
message(paste0("pwd is: ", paste0(game$pwd, collapse = "")))
Expand All @@ -333,6 +333,7 @@ initializeGame <- function(playerLevel) {
return(FALSE)
}
}

isPasswordCorrect <- function(inputPwd) {
inputPwdSplit <- strsplit(inputPwd, "")[[1]]
identical(inputPwdSplit, game$pwd)
Expand Down Expand Up @@ -596,9 +597,11 @@ initializeGame <- function(playerLevel) {
message(paste0("There's something written on the ",
game$currentRoom$object[[game$object_idx]]$name,
". Look at the plot window."))
game$pwdExposedIdx <- c(game$pwdExposedIdx,
sample(setdiff(1:length(game$pwd),
game$pwdExposedIdx), 1))
nextPwdIdx <- ifelse(length(game$pwdExposedIdx) == length(game$pwd) - 1,
setdiff(1:length(game$pwd), game$pwdExposedIdx),
sample(setdiff(1:length(game$pwd),
game$pwdExposedIdx), 1))
game$pwdExposedIdx <- c(game$pwdExposedIdx, nextPwdIdx)
game$plotPwd()
} else if (objType == "tip") {
message(paste0("There's something written on the ",
Expand Down

0 comments on commit 304b018

Please sign in to comment.