package app.mar.game.challenges;

import android.app.Activity;

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

import app.mar.activities.QRCodeFragment;
import app.mar.game.Game;
import app.mar.game.Resource;

public class QRCodeTreasure extends Treasure {

    protected String mQRValue;
    protected String mBadQRMessage;
    protected String mResource;
    public static final int REQUEST_CODE=2003;

    public int getResultCode() { return REQUEST_CODE; }

    public QRCodeTreasure(Game g, JSONObject root, Activity a) {
        super(root, QRCodeFragment.class);

        try {
            mQRValue = root.getString("qr_value");
            mBadQRMessage = root.getString("bad_message");
            mResource = root.getString("resource");
            g.registerResource(mResource, a);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }


    public String getQRValue() {
        return mQRValue;
    }

    public String getBadQRMessage() {
        return mBadQRMessage;
    }

    public String getmResourceName()
    {
        return mResource;
    }

    public Resource getResource(Game g)
    {
        return g.findResource(mResource);
    }
}
