﻿using System;
using System.Collections.Generic;
using UnityEngine;

public class WortiseReward
{
    public int    amount;
    public string label;
    public bool   success;


    public WortiseReward(bool success, string label, int amount)
    {
        this.amount  = amount;
        this.label   = label;
        this.success = success;
    }


#if UNITY_ANDROID
    static internal WortiseReward FromAndroidJavaObject(AndroidJavaObject obj)
    {
        int    amount  = obj.Call<int>   ("getAmount");
        string label   = obj.Call<string>("getLabel");
        bool   success = obj.Call<bool>  ("getSuccess");

        return new WortiseReward(success, label, amount);
    }
#endif

    static internal WortiseReward FromDictionary(Dictionary<string, object> dic)
    {
        int    amount  = Convert.ToInt32  (dic["amount"]);
        string label   = Convert.ToString (dic["label"]);
        bool   success = Convert.ToBoolean(dic["success"]);

        return new WortiseReward(success, label, amount);
    }
}
