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;
    }
}
