package app.mar.game.challenges;

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

import java.io.Serializable;

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

    public Indice(JSONObject root)
    {
        try {
            mPenality = (float) root.getDouble("penality");
        } catch (JSONException e) {
        }
    }



    public static Indice fromJSONObject(JSONObject root)
    {
        String type=null;
        try {
            type = root.getString("type");
        } catch (JSONException e) {
        }
        if(type.compareToIgnoreCase("text")==0) return new TextIndice(root);
        else if(type.compareToIgnoreCase("geo")==0) return new GeoIndice(root);
        else return null;
    }

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

    public float getPenality() {
        return mPenality;
    }
}
