#region

using System;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using log4net;

#endregion

namespace Plus.Core
{
    class ExtraSettings
    {


        public static bool CAMERA_ENABLE = true;
        public static string CAMERA_API = "";
        public static string CAMERA_OUTPUT_PICTURES = "http://mabbo.fr/camera/pictures/";
        public static int CAMERA_PRICECOINS = 20;
        public static bool CAMERA_ALERT = true;
        public static int CAMERA_PRICEDUCKETS = 10;
        public static int CAMERA_PUBLISHPRICE = 10;
        public static string CAMERA_ITEMID = "202030";
        public static string CAMERA_MAXCACHE = "1000";

        public static bool DEBUG_ENABLED = true;
        public static readonly ILog log = LogManager.GetLogger("Plus.Core");

        public static bool RunExtraSettings()
        {
            if (!File.Exists("Settings/extra.ini"))
                return false;
            foreach (var @params in from line in File.ReadAllLines("Settings/extra.ini", Encoding.Default) where !String.IsNullOrWhiteSpace(line) && line.Contains("=") select line.Split('='))
            {
                switch (@params[0])
                {
                    case "camera.photo.purchase.price.coins":
                        CAMERA_PRICECOINS = int.Parse(@params[1]);
                        break;
                    case "camera.photo.purchase.price.duckets":
                        CAMERA_PRICEDUCKETS = int.Parse(@params[1]);
                        break;
                    case "camera.photo.publish.price.duckets":
                        CAMERA_PUBLISHPRICE = int.Parse(@params[1]);
                        break;
                    case "camera.photo.purchase.item_id":
                        CAMERA_ITEMID = @params[1];
                        break;
                    case "camera.api.http":
                        CAMERA_API = @params[1];
                        break;
                    case "camera.output.pictures":
                        CAMERA_OUTPUT_PICTURES = @params[1];
                        break;
                    case "camera.picture.purchase.alert.id":
                        CAMERA_ALERT = @params[1] == "true";
                        break;
                    case "camera.enable":
                        CAMERA_ENABLE = @params[1] == "true";
                        break;
                    case "debug.enabled":
                        DEBUG_ENABLED = @params[1] == "true";
                        break;
                }
            }
            log.Info("» Paramètres -> Chargé !");
            return true;
        }
    }
}