text: {"filter":false,"title":"game.c","tooltip":"/LaunchCode/game.c","undoManager":{"mark":99,"position":99,"stack":[[{"start":{"row":0,"column":0},"end":{"row":50,"column":115},"action":"insert","lines":["$ ./game","* * * DUNGEON QUEST * * *","","You find yourself in a dungeon ruled by dark magic","Try to escape and reach The Altar of Yezzeron without dying!","But before you arrive, you must boost your Zorph Wisdom to at least level 3,","...or else the Dieties of The Altar of Yezzeron will not accept you!","","Current Status: ","You are 3 miles away from The Altar of Yezzeron","Your health is at 100 percent","Your Zorph Wisdom is at level 1","","You continue walking through dark corridors...","","You health is slowly waning...","","Suddenly you discover a potion on the ground!","Do you want to drink it? (y/n)","y","A devilish sickness comes over you...","","Current Status: ","You are 2 miles away from The Altar of Yezzeron","Your health is at 55 percent","Your Zorph Wisdom is at level 1","","You continue walking through dark corridors...","","You health is slowly waning...","","Suddenly you discover a potion on the ground!","Do you want to drink it? (y/n)","y","You feel your powers growing!","","Current Status: ","You are 1 miles away from The Altar of Yezzeron","Your health is at 45 percent","Your Zorph Wisdom is at level 2","","You continue walking through dark corridors...","","You health is slowly waning...","","Suddenly you discover a potion on the ground!","Do you want to drink it? (y/n)","y","You feel your powers growing!","","You reach The Altar of Yezzeron! The Dieties welcome you to their ethereal realm, and you join them in immortality!"],"id":1}],[{"start":{"row":0,"column":0},"end":{"row":50,"column":115},"action":"remove","lines":["$ ./game","* * * DUNGEON QUEST * * *","","You find yourself in a dungeon ruled by dark magic","Try to escape and reach The Altar of Yezzeron without dying!","But before you arrive, you must boost your Zorph Wisdom to at least level 3,","...or else the Dieties of The Altar of Yezzeron will not accept you!","","Current Status: ","You are 3 miles away from The Altar of Yezzeron","Your health is at 100 percent","Your Zorph Wisdom is at level 1","","You continue walking through dark corridors...","","You health is slowly waning...","","Suddenly you discover a potion on the ground!","Do you want to drink it? (y/n)","y","A devilish sickness comes over you...","","Current Status: ","You are 2 miles away from The Altar of Yezzeron","Your health is at 55 percent","Your Zorph Wisdom is at level 1","","You continue walking through dark corridors...","","You health is slowly waning...","","Suddenly you discover a potion on the ground!","Do you want to drink it? (y/n)","y","You feel your powers growing!","","Current Status: ","You are 1 miles away from The Altar of Yezzeron","Your health is at 45 percent","Your Zorph Wisdom is at level 2","","You continue walking through dark corridors...","","You health is slowly waning...","","Suddenly you discover a potion on the ground!","Do you want to drink it? (y/n)","y","You feel your powers growing!","","You reach The Altar of Yezzeron! The Dieties welcome you to their ethereal realm, and you join them in immortality!"],"id":2},{"start":{"row":0,"column":0},"end":{"row":133,"column":0},"action":"insert","lines":["/**"," * game.c"," *"," */","","#include <cs50.h>","#include <stdio.h>","#include <time.h>","#include <stdlib.h>","#include <string.h>","","#define DESTINATION \"The Altar of Yezzeron\"","#define SKILL \"Zorph Wisdom\"","#define SKILL_GOAL 3","","// TODO","// define a struct type called player","","bool checkGameOver(player p);","void reportStatus(player p);","void discoverPotion(player* p);","","int main(void) ","{","    // intro text","    printf(\"* * * DUNGEON QUEST * * *\\n\\n\");","    printf(\"You find yourself in a dungeon ruled by dark magic\\n\");","    printf(\"Try to escape and reach %s without dying!\\n\", DESTINATION);","    printf(\"But before you arrive, you must boost your %s to at least level %i,\\n\", SKILL, SKILL_GOAL);","    printf(\"...or else the Dieties of %s will not accept you!\\n\\n\", DESTINATION);","","    // provide a seed to the random number generator (don't worry about understanding this)","    srand(time(NULL));","","    // initialize the player","    player p = { 100, 3, 1 };","","    // continue looping forever until Game Over","    while (true)","    {","        if (checkGameOver(p))","        {","            // stop if we hit Game Over","            return 0;","        }","","        reportStatus(p);","","        printf(\"You continue walking through dark corridors...\\n\");","        p.distance -= 1;","        GetString();","","        printf(\"You health is slowly waning...\\n\");","        p.health -= 10;","        GetString();","","        discoverPotion(&p);","    }","}","","/** "," * Returns true if the player has run out of health or reached the destination, else false"," * If the game did end, also prints an appropriate message, depending on the outcome"," */","bool checkGameOver(player p)","{","    if (p.health <= 0)","    {","        printf(\"Your last vestiges of health have deteriorated. You waste away in the loneliness of the Dungeon!\\n\");","        printf(\"Game Over\\n\");","        return true;","    }","    else if (p.distance <= 0)","    {","        if (p.skill >= SKILL_GOAL)","        {","            printf(\"You reach %s! The Dieties welcome you to their ethereal realm, and you join them in immortality!\\n\", DESTINATION);","        }","        else ","        {","            printf(\"You reach %s, but your %s is not developed enough.\\n\", DESTINATION, SKILL);","            printf(\"The Dieties condemn you, mortal, to another twenty years in the Dungeon!\\n\");","            printf(\"Game Over\\n\");","        }","        return true;","    }","","    return false;","}","","/**"," * Prints a status report to the console, informing the user of how they are doing "," */","void reportStatus(player p)","{","    printf(\"Current Status: \\n\");","    printf(\"You are %i miles away from %s\\n\", p.distance, DESTINATION);","    printf(\"Your health is at %i percent\\n\", p.health);","    printf(\"Your %s is at level %i\\n\\n\", SKILL, p.skill);","    GetString();","}","","/**"," * Allows user the option to drink a magic potion"," * If so, randomly decides whether the potion had a \"good\" effect or \"bad\", and updates the player model accordingly"," */","void discoverPotion(player* p)","{","    printf(\"Suddenly you discover a potion on the ground!\\n\");","    printf(\"Do you want to drink it? (y/n)\\n\");","","    // do drink if user types \"y\", otherwise don't drink","    bool userDecidesToDrink = strcmp(GetString(), \"y\") == 0;","    if (userDecidesToDrink)","    {","        // flip a coin to determine if the potion was helpful or harmful","        int r = rand();","        if (r % 2 == 0)","        {","            // good potion. increase skill","            p->skill++;","            printf(\"You feel your powers growing!\\n\");","            GetString();","        }","        else ","        {","            // evil potion. decrease health","            p->health -= 35;","            printf(\"A devilish sickness comes over you...\\n\");","            GetString();","        }","    }","}",""]}],[{"start":{"row":132,"column":1},"end":{"row":133,"column":0},"action":"remove","lines":["",""],"id":3}],[{"start":{"row":16,"column":37},"end":{"row":17,"column":0},"action":"insert","lines":["",""],"id":4}],[{"start":{"row":17,"column":0},"end":{"row":17,"column":1},"action":"insert","lines":["t"],"id":5}],[{"start":{"row":17,"column":1},"end":{"row":17,"column":2},"action":"insert","lines":["y"],"id":6}],[{"start":{"row":17,"column":2},"end":{"row":17,"column":3},"action":"insert","lines":["p"],"id":7}],[{"start":{"row":17,"column":3},"end":{"row":17,"column":4},"action":"insert","lines":["e"],"id":8}],[{"start":{"row":17,"column":4},"end":{"row":17,"column":5},"action":"insert","lines":["d"],"id":9}],[{"start":{"row":17,"column":5},"end":{"row":17,"column":6},"action":"insert","lines":["e"],"id":10}],[{"start":{"row":17,"column":6},"end":{"row":17,"column":7},"action":"insert","lines":["f"],"id":11}],[{"start":{"row":17,"column":7},"end":{"row":17,"column":8},"action":"insert","lines":[" "],"id":12}],[{"start":{"row":17,"column":8},"end":{"row":17,"column":9},"action":"insert","lines":["s"],"id":13}],[{"start":{"row":17,"column":9},"end":{"row":17,"column":10},"action":"insert","lines":["t"],"id":14}],[{"start":{"row":17,"column":10},"end":{"row":17,"column":11},"action":"insert","lines":["r"],"id":15}],[{"start":{"row":17,"column":11},"end":{"row":17,"column":12},"action":"insert","lines":["u"],"id":16}],[{"start":{"row":17,"column":12},"end":{"row":17,"column":13},"action":"insert","lines":["t"],"id":17}],[{"start":{"row":17,"column":12},"end":{"row":17,"column":13},"action":"remove","lines":["t"],"id":18}],[{"start":{"row":17,"column":12},"end":{"row":17,"column":13},"action":"insert","lines":["c"],"id":19}],[{"start":{"row":17,"column":13},"end":{"row":17,"column":14},"action":"insert","lines":["t"],"id":20}],[{"start":{"row":17,"column":14},"end":{"row":17,"column":15},"action":"insert","lines":[" "],"id":21}],[{"start":{"row":17,"column":15},"end":{"row":17,"column":16},"action":"insert","lines":["p"],"id":22}],[{"start":{"row":17,"column":16},"end":{"row":17,"column":17},"action":"insert","lines":["l"],"id":23}],[{"start":{"row":17,"column":17},"end":{"row":17,"column":18},"action":"insert","lines":["a"],"id":24}],[{"start":{"row":17,"column":18},"end":{"row":17,"column":19},"action":"insert","lines":["y"],"id":25}],[{"start":{"row":17,"column":19},"end":{"row":17,"column":20},"action":"insert","lines":["e"],"id":26}],[{"start":{"row":17,"column":20},"end":{"row":17,"column":21},"action":"insert","lines":["r"],"id":27}],[{"start":{"row":17,"column":20},"end":{"row":17,"column":21},"action":"remove","lines":["r"],"id":28}],[{"start":{"row":17,"column":19},"end":{"row":17,"column":20},"action":"remove","lines":["e"],"id":29}],[{"start":{"row":17,"column":18},"end":{"row":17,"column":19},"action":"remove","lines":["y"],"id":30}],[{"start":{"row":17,"column":17},"end":{"row":17,"column":18},"action":"remove","lines":["a"],"id":31}],[{"start":{"row":17,"column":16},"end":{"row":17,"column":17},"action":"remove","lines":["l"],"id":32}],[{"start":{"row":17,"column":16},"end":{"row":17,"column":17},"action":"insert","lines":["l"],"id":33}],[{"start":{"row":17,"column":17},"end":{"row":17,"column":18},"action":"insert","lines":["a"],"id":34}],[{"start":{"row":17,"column":18},"end":{"row":17,"column":19},"action":"insert","lines":["y"],"id":35}],[{"start":{"row":17,"column":19},"end":{"row":17,"column":20},"action":"insert","lines":["e"],"id":36}],[{"start":{"row":17,"column":20},"end":{"row":17,"column":21},"action":"insert","lines":["r"],"id":37}],[{"start":{"row":17,"column":21},"end":{"row":17,"column":22},"action":"insert","lines":[" "],"id":38}],[{"start":{"row":17,"column":22},"end":{"row":17,"column":23},"action":"insert","lines":["{"],"id":39}],[{"start":{"row":17,"column":23},"end":{"row":19,"column":1},"action":"insert","lines":["","    ","}"],"id":40}],[{"start":{"row":19,"column":1},"end":{"row":20,"column":0},"action":"insert","lines":["",""],"id":41}],[{"start":{"row":20,"column":0},"end":{"row":20,"column":1},"action":"insert","lines":[" "],"id":42}],[{"start":{"row":20,"column":0},"end":{"row":20,"column":1},"action":"remove","lines":[" "],"id":43}],[{"start":{"row":20,"column":0},"end":{"row":21,"column":0},"action":"insert","lines":["",""],"id":44}],[{"start":{"row":21,"column":0},"end":{"row":21,"column":1},"action":"insert","lines":["p"],"id":45}],[{"start":{"row":21,"column":1},"end":{"row":21,"column":2},"action":"insert","lines":["l"],"id":46}],[{"start":{"row":21,"column":2},"end":{"row":21,"column":3},"action":"insert","lines":["a"],"id":47}],[{"start":{"row":21,"column":3},"end":{"row":21,"column":4},"action":"insert","lines":["y"],"id":48}],[{"start":{"row":21,"column":4},"end":{"row":21,"column":5},"action":"insert","lines":["e"],"id":49}],[{"start":{"row":21,"column":5},"end":{"row":21,"column":6},"action":"insert","lines":["r"],"id":50}],[{"start":{"row":21,"column":6},"end":{"row":21,"column":7},"action":"insert","lines":[";"],"id":51}],[{"start":{"row":18,"column":4},"end":{"row":18,"column":5},"action":"insert","lines":["i"],"id":52}],[{"start":{"row":18,"column":5},"end":{"row":18,"column":6},"action":"insert","lines":["n"],"id":53}],[{"start":{"row":18,"column":6},"end":{"row":18,"column":7},"action":"insert","lines":["t"],"id":54}],[{"start":{"row":18,"column":7},"end":{"row":18,"column":8},"action":"insert","lines":[" "],"id":55}],[{"start":{"row":18,"column":8},"end":{"row":18,"column":9},"action":"insert","lines":["h"],"id":56}],[{"start":{"row":18,"column":9},"end":{"row":18,"column":10},"action":"insert","lines":["e"],"id":57}],[{"start":{"row":18,"column":10},"end":{"row":18,"column":11},"action":"insert","lines":["a"],"id":58}],[{"start":{"row":18,"column":11},"end":{"row":18,"column":12},"action":"insert","lines":["l"],"id":59}],[{"start":{"row":18,"column":12},"end":{"row":18,"column":13},"action":"insert","lines":["t"],"id":60}],[{"start":{"row":18,"column":13},"end":{"row":18,"column":14},"action":"insert","lines":["h"],"id":61}],[{"start":{"row":18,"column":14},"end":{"row":18,"column":15},"action":"insert","lines":[";"],"id":62}],[{"start":{"row":18,"column":15},"end":{"row":19,"column":0},"action":"insert","lines":["",""],"id":63},{"start":{"row":19,"column":0},"end":{"row":19,"column":4},"action":"insert","lines":["    "]}],[{"start":{"row":19,"column":4},"end":{"row":19,"column":5},"action":"insert","lines":["i"],"id":64}],[{"start":{"row":19,"column":5},"end":{"row":19,"column":6},"action":"insert","lines":["n"],"id":65}],[{"start":{"row":19,"column":6},"end":{"row":19,"column":7},"action":"insert","lines":["t"],"id":66}],[{"start":{"row":19,"column":7},"end":{"row":19,"column":8},"action":"insert","lines":[" "],"id":67}],[{"start":{"row":19,"column":8},"end":{"row":19,"column":9},"action":"insert","lines":["s"],"id":68}],[{"start":{"row":19,"column":9},"end":{"row":19,"column":10},"action":"insert","lines":["k"],"id":69}],[{"start":{"row":19,"column":10},"end":{"row":19,"column":11},"action":"insert","lines":["i"],"id":70}],[{"start":{"row":19,"column":11},"end":{"row":19,"column":12},"action":"insert","lines":["l"],"id":71}],[{"start":{"row":19,"column":12},"end":{"row":19,"column":13},"action":"insert","lines":["l"],"id":72}],[{"start":{"row":19,"column":13},"end":{"row":19,"column":14},"action":"insert","lines":[";"],"id":73}],[{"start":{"row":19,"column":14},"end":{"row":20,"column":0},"action":"insert","lines":["",""],"id":74},{"start":{"row":20,"column":0},"end":{"row":20,"column":4},"action":"insert","lines":["    "]}],[{"start":{"row":20,"column":4},"end":{"row":20,"column":5},"action":"insert","lines":["i"],"id":75}],[{"start":{"row":20,"column":5},"end":{"row":20,"column":6},"action":"insert","lines":["n"],"id":76}],[{"start":{"row":20,"column":6},"end":{"row":20,"column":7},"action":"insert","lines":["t"],"id":77}],[{"start":{"row":20,"column":7},"end":{"row":20,"column":8},"action":"insert","lines":[" "],"id":78}],[{"start":{"row":20,"column":8},"end":{"row":20,"column":9},"action":"insert","lines":["d"],"id":79}],[{"start":{"row":20,"column":9},"end":{"row":20,"column":10},"action":"insert","lines":["i"],"id":80}],[{"start":{"row":20,"column":10},"end":{"row":20,"column":11},"action":"insert","lines":["s"],"id":81}],[{"start":{"row":20,"column":11},"end":{"row":20,"column":12},"action":"insert","lines":["t"],"id":82}],[{"start":{"row":20,"column":12},"end":{"row":20,"column":13},"action":"insert","lines":["a"],"id":83}],[{"start":{"row":20,"column":13},"end":{"row":20,"column":14},"action":"insert","lines":["n"],"id":84}],[{"start":{"row":20,"column":14},"end":{"row":20,"column":15},"action":"insert","lines":["c"],"id":85}],[{"start":{"row":20,"column":15},"end":{"row":20,"column":16},"action":"insert","lines":["e"],"id":86}],[{"start":{"row":20,"column":16},"end":{"row":20,"column":17},"action":"insert","lines":[";"],"id":87}],[{"start":{"row":19,"column":8},"end":{"row":19,"column":13},"action":"remove","lines":["skill"],"id":88},{"start":{"row":19,"column":8},"end":{"row":19,"column":9},"action":"insert","lines":["d"]}],[{"start":{"row":19,"column":9},"end":{"row":19,"column":10},"action":"insert","lines":["i"],"id":89}],[{"start":{"row":19,"column":10},"end":{"row":19,"column":11},"action":"insert","lines":["s"],"id":90}],[{"start":{"row":19,"column":11},"end":{"row":19,"column":12},"action":"insert","lines":["t"],"id":91}],[{"start":{"row":19,"column":12},"end":{"row":19,"column":13},"action":"insert","lines":["a"],"id":92}],[{"start":{"row":19,"column":13},"end":{"row":19,"column":14},"action":"insert","lines":["n"],"id":93}],[{"start":{"row":19,"column":14},"end":{"row":19,"column":15},"action":"insert","lines":["c"],"id":94}],[{"start":{"row":19,"column":15},"end":{"row":19,"column":16},"action":"insert","lines":["e"],"id":95}],[{"start":{"row":20,"column":8},"end":{"row":20,"column":16},"action":"remove","lines":["distance"],"id":96},{"start":{"row":20,"column":8},"end":{"row":20,"column":9},"action":"insert","lines":["s"]}],[{"start":{"row":20,"column":9},"end":{"row":20,"column":10},"action":"insert","lines":["k"],"id":97}],[{"start":{"row":20,"column":10},"end":{"row":20,"column":11},"action":"insert","lines":["i"],"id":98}],[{"start":{"row":20,"column":11},"end":{"row":20,"column":12},"action":"insert","lines":["l"],"id":99}],[{"start":{"row":20,"column":12},"end":{"row":20,"column":13},"action":"insert","lines":["l"],"id":100}]]},"ace":{"folds":[],"scrolltop":238.5,"scrollleft":0,"selection":{"start":{"row":20,"column":13},"end":{"row":20,"column":13},"isBackwards":false},"options":{"guessTabSize":true,"useWrapMode":false,"wrapToView":true},"firstLineState":{"row":16,"state":"start","mode":"ace/mode/c_cpp"}},"timestamp":1458596786430,"hash":"58cf82639673329371ba2ec758e87414c4b98537"}