Created
March 20, 2013 22:17
-
-
Save blzaugg/5209040 to your computer and use it in GitHub Desktop.
restroomEtiquette
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function restroomEtiquette(you, restroom) { | |
while (true) { | |
if (you.needToGo === 1) { | |
if (you.okayWithUrinals && restroom.urinalAvailable()) { | |
var urinal = restroom.occupyAvailableUrinal(you); | |
you.evacuate(urinal); | |
urinal.flush(); | |
if (you.madeMess(urinal)) { | |
you.cleanUp(urinal); | |
} | |
break; | |
} | |
else if (restroom.toiletAvailable()) { | |
var toilet = restroom.occupyAvailableToilet(you); | |
if (you.positionPref(toilet) === 'stand') { | |
toilet.liftSeat(); // yes you | |
} | |
you.evacuate(toilet); | |
// if (!toilet.letItMellow('yellow')) { | |
// toilet.flush(); | |
// } | |
toilet.flush(); | |
if (you.madeMess(toilet)) { | |
you.cleanUp(toilet); | |
} | |
break; | |
} | |
else { | |
you.wait(); | |
continue; | |
} | |
} | |
else if (you.needToGo === 2) { | |
if (restroom.toiletAvailable()) { | |
var toilet = restroom.occupyAvailableToilet(you); | |
you.evacuate(toilet); | |
toilet.flush(); | |
if (you.madeMess(toilet)) { | |
you.cleanUp(toilet); | |
} | |
break; | |
} | |
else { | |
you.wait(); | |
continue; | |
} | |
} | |
else if (you.needToGo === 3) { | |
if (restroom.toiletAvailable()) { | |
var toilet = restroom.occupyAvailableToilet(you); | |
you.evacuate(toilet); | |
toilet.flush(); | |
if (you.madeMess(toilet)) { | |
you.cleanUp(toilet); | |
} | |
else { | |
you.cleanUp(toilet); // yes you did | |
} | |
break; | |
} | |
else { | |
you.wait(); | |
continue; | |
} | |
} | |
else { | |
you.hurryHome(); | |
break; | |
} | |
} | |
// if (you.handsSoiled) { | |
// you.washHands(); | |
// } | |
you.washHands(); // you never know | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment