/**
 * This file is part of Mrogue.
 *
 * Mrogue is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Mrogue is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 */
"use strict";

(() => {
    var HelpState = function(manager, game) {
        this.manager = manager;
        this.game = game;
        this.name = "Help";
        this.doesOwnRendering = true;

        this.text = [
            "Mrogue is a free and open source roguelike played directly in the browser. It focuses on simplicity and avoiding unnecessary complexity and aims to",
            "introduce various concepts from the role-playing game genre to the roguelike genre. The goal of Mrogue is to find the Amulet of Yendor on the 7th",
            "floor of the dungeon.",
            "",
            { color: { r: 243, g: 247, b: 54 }, text: "MOVEMENT AND EXPLORING" },
            "You can move your character around using the arrow keys, hjkl or the numpad. Mrogue uses 4 direction movement. In the dungeon you will also find",
            "wells that you can drink from. These will restore or increase some of your attributes.",
            "",
            { color: { r: 243, g: 247, b: 54 }, text: "ITEMS AND INVENTORY" },
            "You can access your inventory by pressing the 'i' key. There you can see all the items your character is currently carrying. If you wish to drop an",
            "item, press the 'd' key. You can also use items by pressing the 'e' key. You can find items in the dungeon as well as on bodies of creatures you've",
            "slain. Pick up these items by standing on them and pressing the 'p' key.",
            "",
            { color: { r: 243, g: 247, b: 54 }, text: "COMBAT AND ATTRIBUTES" },
            "There's two types of combat in Mrogue; melee and magical. You can attack a creature by simply moving into them. The damage you will do depends on your",
            "current power level which you gain by attacking creatures.",
            "",
            "Magical combat...",
            "",
            "Your character has three attributes; health, energy and power. The health attribute represents the amount of damage you can take before dying. Energy",
            "is used to cast spells and automatically restores. The last attribute, power, increases the damage you do in melee combat as well as the effectiveness",
            "of your spells."
        ];
    };

    HelpState.prototype = new State();

    HelpState.prototype.input = function(key, event) {
        switch(key) {
            // ?, Escape - Close the help screen
            case "escape":
                this.manager.switchState("player");
                break;
        }
    };
    /**
     * @param {CanvasRenderingContext2D} context
     */
    HelpState.prototype.render = function(renderer) {
        for(var i = 0; i < this.text.length; i++) {
            if(typeof this.text[i] !== "string") {
                renderer.queue(0, i, [ {
                    foreground: this.text[i].color,
                    characters: this.text[i].text
                } ]);
            } else {
                renderer.queue(0, i, [ {
                    foreground: { r: 199, g: 199, b: 199 },
                    characters: this.text[i]
                } ]);
            }
        }
    };

    window.HelpState = HelpState;
})();
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Mrogue.  If not, see <http://www.gnu.org/licenses/>.