feat: show time until pop cooldown ends

This commit is contained in:
insects 2025-03-11 00:11:27 +01:00
parent 9ff401bdfd
commit cee4129e65
3 changed files with 40 additions and 3 deletions

12
.idea/dataSources.xml generated Normal file
View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="postgres@localhost" uuid="4e7da72c-e595-4685-b8cd-d84bbeeb87bd">
<driver-ref>postgresql</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
<jdbc-url>jdbc:postgresql://localhost:5432/postgres</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>

View file

@ -108,3 +108,20 @@ section .meta {
padding-top: 10px;
padding-bottom: 10px;
}
.progress-container {
width: 50%;
display: inline-block;
background-color: tomato;
height: 10px;
position: relative;
}
.progress-bar {
background-color: #63f0fd;
height: 10px;
display: inline-block;
position: absolute;
top: 0;
left: 0;
}

View file

@ -1,6 +1,6 @@
<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 } %>
<% is_popped = instance.pops.filter { |pop| (Time.current - 120.minutes) <= pop.created_at }.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" />
@ -23,10 +23,18 @@
<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>
<% if is_popped %>
<% pop = instance.pops.find { |pop| pop.name == nm[:name].parameterize } %>
<% mins = ActiveSupport::Duration.build(Time.current - pop.created_at) %>
» <%= (120.minutes - mins).in_minutes.floor %>m
<span class="progress-container">
<span class="progress-bar" style="width: <%= (mins.in_minutes / 120) * 100 %>%"></span>
</span>
<% end %>
</div>
<div class="button">
<% if is_popped %>
<button