/*
 * Copyright (c) 2021 Ross Cunniff
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
/*** ROUTINE DECLARATIONS ***/

proc
    darkq, ei8, scads, ctake, cdrop, scord, exitg, onlmp;


/*** DEAD-END ROUTINES ***/

proc PROMPT()
{
    Status($ME.loc.sdesc(false), $ME.pscore, Turns);
    "> ";
}

proc cg() {"Can't go that way.\n";}

proc tosml() {"The hole is too small for you to fit through.\n";}

proc dumdir() {"I don't know which direction that is.\n";}

proc tohigh() {"The hole is too high for you to reach.\n";}

proc nothe() {"This section is not implemented yet.\n";}

proc skore()
{
    "You scored ", $ME.pscore, " out of ", $ME.pmax, " possible points.\n";
}


const Rating = {
    "junior beginning",
    "senior beginning",
    "intermediate",
    "expert",
    "junior master",
    "master",
    "senior master",
    "life master",
    "super-stud"
};


proc ratng()
{
    $ME.ratvl = 0;
    if ($ME.pscore) {
	$ME.ratvl = ($ME.pscore * 8) / $ME.pmax;
    }
    "That gives you a ranking of ", Rating[$ME.ratvl], " adventurer.\n";
}


proc ratnx()
{
    if ($ME.ratvl == 8) {
	"CONGRATULATIONS.\n";
	quit();
    }
    $ME.ratvl = $ME.ratvl + 1;
    $ME.ratvl = $ME.ratvl * $ME.pmax;
    $ME.ratvl = $ME.ratvl / 8;
    $ME.ratvl = $ME.ratvl + 1;
    $ME.ratvl = $ME.ratvl - $ME.pscore;
    "To achieve the next higher rating, you need to score ", $ME.ratvl,
	" more points.\n";
}


proc endgame()
{
    Incturn();
    if ($ME.pscore == $ME.pmax) {
        "\tAs you drop the last treasure, the lights come up and you hear ",
        "a voice say, \"CONGRATULATIONS, ADVENTURER.  You have restored the ",
        "museum displays to their former glory.  Now accept the Director's ",
        "thanks, and also his reward!\"\n",
        "\tYou are miraculously transported to a room you have never seen ",
        "before, filled to the top with precious gold and jewels.  The voice ",
        "appears again, saying, \"Your reward is as follows:  you are ",
        "granted the privilege of becoming the new curator of the Museum.",
        "Your first responsibility is to catalog and sort these treasures ",
        "for placement in the Museum.  Your salary is $3.25 per hour.  ",
        "Again, thanks!\"\n",
        "\tThe voice disappears, and you are left alone in the immense room. ",
        "You'd better get to work, for you have a LOT to do!\n";
	Quit();
    }
}