using Godot;
using System.Linq;

public partial class CharacterSelectUpdateService : Control
{
   public override void _Ready()
   {
      base._Ready();
   }
   public void OnCapricornSelected(Player player)
   {
      var allPortraits = GetNode<Control>($"P{player.PlayerNumber}").GetChildren().OfType<TextureRect>();
      foreach (var bg in allPortraits)
         bg.Hide();

      var node = GetNode<TextureRect>($"P{player.PlayerNumber}/CapBG");
      node.Show();
   }

   public void OnPiscesSelected(Player player)
   {
      var allPortraits = GetNode<Control>($"P{player.PlayerNumber}").GetChildren().OfType<TextureRect>();
      foreach (var bg in allPortraits)
         bg.Hide();

      var node = GetNode<TextureRect>($"P{player.PlayerNumber}/PiscesBG");
      node.Show();
   }

   public void OnSagittariusSelected(Player player)
   {
      var allPortraits = GetNode<Control>($"P{player.PlayerNumber}").GetChildren().OfType<TextureRect>();
      foreach (var bg in allPortraits)
         bg.Hide();

      var node = GetNode<TextureRect>($"P{player.PlayerNumber}/SagBG");
      node.Show();
   }

   public void OnScorpioSelected(Player player)
   {
      var allPortraits = GetNode<Control>($"P{player.PlayerNumber}").GetChildren().OfType<TextureRect>();
      foreach (var bg in allPortraits)
         bg.Hide();

      var node = GetNode<TextureRect>($"P{player.PlayerNumber}/ScorpioBG");
      node.Show();
   }

   public void ClearPlayerBGs(Player player)
   {
      var allPortraits = GetNode<Control>($"P{player.PlayerNumber}").GetChildren().OfType<TextureRect>();
      foreach (var bg in allPortraits)
         bg.Hide();
   }
}
