using System;

namespace NeonGridRPG
{
    public class CyberProgram
    {
        private string progName;
        private int dataDamage;
        private int ramCost;
        private string statusEffect;

        public CyberProgram(string name, int damage, int cost, string effect)
        {
            this.progName = name;
            this.dataDamage = damage;
            this.ramCost = cost;
            this.statusEffect = effect;
        }

        public string GetName() { return progName; }
        public int GetDamage() { return dataDamage; }
        public int GetCost() { return ramCost; }
        public string GetEffect() { return statusEffect; }
    }

    public class CyberOperative
    {
        private string nosaukums;
        private int integrity;
        private int procPower;
        private int firewall;
        private double overclock;

        public CyberOperative(string nosaukums, int integrity, int procPower, int firewall, double overclock)
        {
            this.nosaukums = nosaukums;
            this.integrity = integrity;
            this.procPower = procPower;
            this.firewall = firewall;
            this.overclock = overclock;
        }

        public string GetNosaukums() { return nosaukums; }

        public void ExecuteProgram(CyberOperative target, CyberProgram program)
        {
            Console.WriteLine($"\n {this.nosaukums} mēģina palaist '{program.GetName()}' pret {target.GetNosaukums()} ");

            if (this.procPower >= program.GetCost())
            {
                double totalDamage = (program.GetDamage() * this.overclock) - target.firewall;
                
                if (totalDamage < 0) totalDamage = 0;

                this.procPower -= program.GetCost();
                target.integrity -= (int)Math.Round(totalDamage);

                Console.WriteLine($"IZPILDE: {target.GetNosaukums()} saņem {(int)Math.Round(totalDamage)} sistēmas bojājumus!");
                Console.WriteLine($"{this.nosaukums} atlikusī jauda: {this.procPower} RAM.");
                Console.WriteLine($"{target.GetNosaukums()} atlikusī integritāte: {target.integrity} HP.");

                ApplyStatusEffect(this, target,program);
            }
            else
            {
                Console.WriteLine($"KĻŪDA: {this.nosaukums} nepietiek Skaitļošanas Jaudas (RAM)!");
            }
        }

        private void ApplyStatusEffect(CyberOperative caster, CyberOperative enemy, CyberProgram program)
        {
           // Šeit nākotnē būs loģika, kas uzliek "Glitch" vai "Drain" efektus
            // Console.WriteLine($"[Sistēmas paziņojums: Uzlikts efekts {program.GetEffect()}]");
        }
        

        public void PrintStatus()
        {
            Console.WriteLine($"Spēlētājs: {nosaukums}  HP: {integrity}  MP: {procPower}  DEF: {firewall}  AMP: x{overclock}");
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("NeonGrid: KiberKarš");

            CyberOperative neonGamer = new CyberOperative("NeonGamer", 150, 300, 10, 1.5);
            CyberOperative anonTyper = new CyberOperative("AnonTyper", 250, 100, 40, 1.1);

            CyberProgram neuralShock = new CyberProgram("NeuralShock", 60, 50, "Glitch");
            CyberProgram dataLeech = new CyberProgram("DataLeech", 35, 20, "Drain");

            Console.WriteLine("\nSPĒLĒTĀJI ");
            neonGamer.PrintStatus();
            anonTyper.PrintStatus();

            Console.WriteLine("\n PIEEJAMĀS MAĢIJAS ");
            Console.WriteLine($"- {neuralShock.GetName()}: Bāzes DMG {neuralShock.GetDamage()}, Maksa {neuralShock.GetCost()} RAM, Efekts: {neuralShock.GetEffect()}");
            Console.WriteLine($"- {dataLeech.GetName()}: Bāzes DMG {dataLeech.GetDamage()}, Maksa {dataLeech.GetCost()} RAM, Efekts: {dataLeech.GetEffect()}");

            Console.WriteLine("\nSākas Spēle");
            
            neonGamer.ExecuteProgram(anonTyper, neuralShock);

            anonTyper.ExecuteProgram(neonGamer, dataLeech);

            neonGamer.ExecuteProgram(anonTyper, dataLeech);

            anonTyper.ExecuteProgram(neonGamer, neuralShock);
            
            anonTyper.ExecuteProgram(neonGamer, neuralShock);

            Console.WriteLine("\nBeigas");
            Console.ReadLine();
        }
    }
}