From 304b018b577196b282fe645eed8f3df35cf4fc8f Mon Sep 17 00:00:00 2001 From: Giora Simchoni Date: Sun, 10 Sep 2017 13:49:10 +0300 Subject: [PATCH] Fix last character of password bug --- R/initializeGame.R | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/R/initializeGame.R b/R/initializeGame.R index 598e3d4..945f597 100644 --- a/R/initializeGame.R +++ b/R/initializeGame.R @@ -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 = ""))) @@ -333,6 +333,7 @@ initializeGame <- function(playerLevel) { return(FALSE) } } + isPasswordCorrect <- function(inputPwd) { inputPwdSplit <- strsplit(inputPwd, "")[[1]] identical(inputPwdSplit, game$pwd) @@ -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 ",