using GTANetworkAPI;
using ReallifeGamemode.Server.Entities;
using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Finance;
using ReallifeGamemode.Server.Models;
using ReallifeGamemode.Server.Services;
using ReallifeGamemode.Server.Util;
using System.Linq;

namespace ReallifeGamemode.Server.Commands
{
    class UserCommands : Script
    {

        [Command("car", "~m~Benutzung: ~s~/car")]
        public void CmdUserCar(Client player)
        {
            if (!player.IsLoggedIn()) return;
            if (!player.IsInVehicle) return;

            Vehicle pVeh = player.Vehicle;

            if (pVeh.GetServerVehicle() is ServerVehicle veh)
            {
                if (player.GetUser().IsAdmin(AdminLevel.SUPPORTER))
                {
                    ChatService.SendMessage(player, "~m~" + ((VehicleHash)pVeh.Model) + " | " + veh.ToString() + " | Farbe 1: " + pVeh.PrimaryColor + " | Farbe 2: " + pVeh.SecondaryColor + " | ID: " + pVeh.Handle.Value);
                    return;
                }
            }
            ChatService.SendMessage(player, "~m~" + ((VehicleHash)pVeh.Model) + " | Farbe 1: " + pVeh.PrimaryColor + " | Farbe 2: " + pVeh.SecondaryColor + " | ID: " + pVeh.Handle.Value);
        }

        [Command("paycheck", "~m~Benutzung: ~s~/paycheck")]
        public void CmdUserPaycheck(Client client)
        {
          
                User user = client.GetUser();
            if (Economy.Paychecks.ContainsKey(user.Id))
            {
                ChatService.SendMessage(client, "~g~[PAYCHECK] -------------------------------------------------------");
                ChatService.SendMessage(client, "~g~[PAYCHECK]~s~ Lohn : ~g~+$" + Economy.Paychecks[user.Id].Wage);
                ChatService.SendMessage(client, "~g~[PAYCHECK]~s~ Finanzhilfe : ~g~+$" + (int)Economy.Paychecks[user.Id].FinancialHelp);
                ChatService.SendMessage(client, "~g~[PAYCHECK]~s~ Fahrzeugsteuer : ~r~-$" + Economy.Paychecks[user.Id].VehicleTaxation);
                ChatService.SendMessage(client, "~g~[PAYCHECK]~s~ Grundsteuer (Haus) : ~r~-$" + Economy.Paychecks[user.Id].PropertyTaxation);
                ChatService.SendMessage(client, "~g~[PAYCHECK]~s~ Einkommen Steuer : ~r~" + (int)(Economy.Paychecks[user.Id].FinancialInterest * 100) + " %");
                ChatService.SendMessage(client, "");
                ChatService.SendMessage(client, "~g~[PAYCHECK]~s~ Ausgaben : ~r~-$" + (Economy.Paychecks[user.Id].Wage - Economy.Paychecks[user.Id].Amount));
                ChatService.SendMessage(client, "~g~[PAYCHECK] -------------------------------------------------------");
            }
        }
    }
}
