using System;
using System.Collections.Generic;
using System.Text;

namespace ModernLangToolsApp
{
    public delegate void CouncilChangedDelegate(string message);
    public class JediCouncil
    {
        List<Jedi> members = new List<Jedi>();

        public JediCouncil() { }

        public void Add(Jedi newJedi){
            members.Add(newJedi);

            CouncilChanged?.Invoke("Új taggal bővültünk");
        }

        public void Remove()
        {
            members.RemoveAt(members.Count - 1);

            if (members.Count == 0)
            {
                CouncilChanged?.Invoke("A tanács elesett!");
            }
            else {
                CouncilChanged?.Invoke("Zavart érzek az erőben");
            }
                
        }

        private bool IsLowMidiCount(Jedi j)
        {
            return j.MidiChlorianCount < 530;
        }

        public List<Jedi> GetLowMidiCount_Delegate()
        {
            List<Jedi> returns = members.FindAll(IsLowMidiCount);

            return returns;
        }

        public List<Jedi> GetLowMidiCount_Lambda()
        {
            return members.FindAll(j => j.MidiChlorianCount < 503);
        }

        public event CouncilChangedDelegate CouncilChanged;
    }
}
