From deb867215a5d86094c71f768538c8006e2e29672 Mon Sep 17 00:00:00 2001 From: Screemonster Date: Fri, 10 Feb 2017 00:14:10 +0000 Subject: [PATCH] QoL on abandoned crate puzzle --- code/modules/mining/abandonedcrates.dm | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/code/modules/mining/abandonedcrates.dm b/code/modules/mining/abandonedcrates.dm index 9585a4965bc..a017476af32 100644 --- a/code/modules/mining/abandonedcrates.dm +++ b/code/modules/mining/abandonedcrates.dm @@ -148,11 +148,19 @@ return user << "The crate is locked with a Deca-code lock." - var/input = input(user, "Enter [codelen] digits.", "Deca-Code Lock", "") as text + var/input = input(usr, "Enter [codelen] digits. All digits must be unique.", "Deca-Code Lock", "") as text if(!Adjacent(user)) return + var/list/sanitised = list() + var/sanitycheck = 1 + for(var/i=1,i<=length(input),i++) //put the guess into a list + sanitised += text2num(copytext(input,i,i+1)) + for(var/i=1,i<=(length(input)-1),i++) //compare each digit in the guess to all those following it + for(var/j=(i+1),j<=length(input),j++) + if(sanitised[i] == sanitised[j]) + sanitycheck = null //if a digit is repeated, reject the input - if(input == null || length(input) != codelen) + if(input == null || sanitycheck == null || length(input) != codelen) user << "You leave the crate alone." else if(check_input(input)) user << "The crate unlocks!" @@ -203,6 +211,9 @@ else if(lastattempt[i] in code_contents) ++cows code_contents -= lastattempt[i] - user << "Last code attempt had [bulls] correct digits at correct positions and [cows] correct digits at incorrect positions." + var/previousattempt = null //convert back to string for readback + for(var/i in 1 to codelen) + previousattempt = addtext(previousattempt, lastattempt[i]) + user << "Last code attempt, [previousattempt], had [bulls] correct digits at correct positions and [cows] correct digits at incorrect positions." return ..()