/*
    This program 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.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    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 this program.  If not, see <https://www.gnu.org/licenses/>.
 */

package macampcorp.macamp.game;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;

import macampcorp.macamp.exceptions.BadConfigFileException;

public class Indice implements Serializable {
    protected  float mPenality=-1;
    protected  boolean mIsDiscovered=false;
    protected String mText="";

    public Indice(JSONObject root)
    {
        try {
            mPenality = (float) root.getDouble("penality");
        } catch (JSONException e) {
            throw new BadConfigFileException("(Indice) Bad parameter 'penality'");
        }


        try {
            mText = root.getString("text");
        } catch (JSONException e) {
            e.printStackTrace();
            throw new BadConfigFileException("(Indice) Bad parameter 'text'");
        }
    }

    public String getText() {
        return mText;
    }


    public static Indice fromJSONObject(JSONObject root)
    {
        return new Indice(root);
    }

    public boolean isDiscovered() { return mIsDiscovered; }
    public void     discover() { mIsDiscovered=true; }

    public float getPenality() {
        return mPenality;
    }
}
