---
# System prepended metadata

title: Untitled

---

The server will run as follows:

    parse the command line, validate parameters, initialize other modules
    makeMap(map.txt)
    while (gold != 0)
        if (player joins)
            sendMap(playerID)
            if (player input name)
                mapPlayerCreate(playerID)
            else
                mapSpectatorCreate
        listen for player movements
        if (keystroke received)
            if (call updateMap == true) //keystroke actually changes map state
                call sendMap to each player
    send end of game message

    where *makeMap*
        takes in map.txt filepath
        reads into a map object
        randomly selects gold_pile positions and amounts (while obeying spec constants) and stores in map's goldPositions array
        return map object    

    where *updateMap*
        if (call parseKeystroke(playerID, keystroke) == true) // is valid
            move player by altering map
            update player struct's position values

            if (player touches gold)
                update gold struct's values
                update player struct's gold value

            return true;

        return false;

    where *mapPlayerCreate*
        if (numPlayers < maxPlayers)
            create a new player struct from playerID (the player's name)
            add to map's array of player structs
