feat: implement popping nms

This commit is contained in:
insects 2025-03-10 23:39:05 +01:00
parent ce5d327ca2
commit 5c721eb08c
16 changed files with 1397 additions and 70 deletions

View file

@ -0,0 +1,48 @@
<main id="nm-list">
<% APP_DATA[instance.zone.to_sym][:nms].each do |nm| %>
<% is_popped = instance.pops.any? { |pop| pop.name == nm[:name].parameterize } %>
<section class="<%= class_names(popped: is_popped) %>">
<div>
<img src="<%= "/#{nm[:element]}.png" %>" alt="<%= nm[:element] %>" width="30" />
</div>
<div class="meta">
<h3 class="nm-info">
<span class="badge">LV<%= nm[:level].to_s.rjust(2, "0") %></span>
<%= nm[:name] %>
<% if nm[:weather] %>
<img src="/<%= nm[:weather] %>.png" title="during <%= nm[:weather] %> only" width="15" />
<% end %>
</h3>
<div class="spawn-info">
«
<strong><%= nm[:spawned_by][:name] %></strong>
<% if nm[:spawned_by][:night_only] %>
<span title="only at night">🌙</span>
<% end %>
<% if nm[:spawned_by][:weather] %>
<img src="/<%= nm[:spawned_by][:weather] %>.png" title="during <%= nm[:spawned_by][:weather] %> only" width="15" />
<% end %>
<small class="badge">LV<%= nm[:spawned_by][:level].to_s.rjust(2, "0") %></small>
</div>
</div>
<div></div>
<div class="button">
<% if is_popped %>
<button
class="action reset"
hx-post="/reset?instance=<%= @instance.public_id %>&nm=<%= nm[:name].parameterize %>"
hx-target="#nm-list"
>Reset</button>
<% else %>
<button
class="action"
hx-post="/pop?instance=<%= @instance.public_id %>&nm=<%= nm[:name].parameterize %>"
hx-target="#nm-list"
>Pop</button>
<% end %>
</div>
</section>
<% end %>
</main>

View file

@ -4,37 +4,4 @@
<%= render partial: "zone_img", locals: { zone: @instance.zone, alt: @instance.zone, title: @instance.zone.upcase_first } %>
</header>
<main class="nm-list">
<% APP_DATA[@instance.zone.to_sym][:nms].each do |nm| %>
<section class="<%= nm[:element] %>">
<div>
<img src="<%= "/#{nm[:element]}.png" %>" alt="<%= nm[:element] %>" width="30" />
</div>
<div class="meta">
<h3 class="nm-info">
<span class="badge">LV<%= nm[:level].to_s.rjust(2, "0") %></span>
<%= nm[:name] %>
<% if nm[:weather] %>
<img src="/<%= nm[:weather] %>.png" title="during <%= nm[:weather] %> only" width="15" />
<% end %>
</h3>
<div class="spawn-info">
«
<strong><%= nm[:spawned_by][:name] %></strong>
<% if nm[:spawned_by][:night_only] %>
<span title="only at night">🌙</span>
<% end %>
<% if nm[:spawned_by][:weather] %>
<img src="/<%= nm[:spawned_by][:weather] %>.png" title="during <%= nm[:spawned_by][:weather] %> only" width="15" />
<% end %>
<small class="badge">LV<%= nm[:spawned_by][:level].to_s.rjust(2, "0") %></small>
</div>
</div>
<div></div>
<div>
<button class="action">Pop</button>
</div>
</section>
<% end %>
</main>
<%= render partial: "list", locals: { instance: @instance } %>