defmodule CobblemonUiWeb.BattleComponents do
use CobblemonUiWeb, :html
attr :battle, :map, required: true
attr :player_id, :string, required: true
def battle_panel(assigns) do
~H"""
Active Battle
VS
<%= for actor <- @battle.actors do %>
<%= if actor.type == "player" do %>
<.icon name="hero-user" class="size-3.5 text-primary" />
<% else %>
<.icon name="hero-cpu-chip" class="size-3.5 text-warning" />
<% end %>
{actor.name}
{actor.type}
<%= for poke <- actor.active_pokemon do %>
{poke.species}
Lv.{poke.level}
{poke.hp}/{poke.max_hp}
"bg-base-content/20"
poke.hp / poke.max_hp > 0.5 -> "bg-success"
poke.hp / poke.max_hp > 0.2 -> "bg-warning"
true -> "bg-error"
end
]}
style={"width: #{if poke.max_hp > 0, do: Float.round(poke.hp / poke.max_hp * 100, 1), else: 0}%"}
/>
<% end %>
<% end %>
"""
end
end