Add games to players

This commit is contained in:
Evan Burkey 2025-02-03 15:29:47 -08:00
parent 181e878316
commit eecdae6c16
2 changed files with 30 additions and 0 deletions

View File

@ -1,5 +1,9 @@
class PlayerController < ApplicationController
def show
@player = Player.find(params[:id])
@games = Game.where(winner: @player.name).or(Game.where(loser: @player.name))
@player.alternate_players.each do |alt|
@games += Game.where(winner: alt.name).or(Game.where(loser: alt.name))
end
end
end

View File

@ -38,5 +38,31 @@
<h2>Alt Status</h2>
<p><%= @player.name %> is set as an alt of <%= link_to @player.main_name, player_path(@player.main_player) %></p>
<% end %>
<h2>Games</h2>
<% if @games.any? %>
<div class="table">
<div class="row header">
<div class="cell">Time</div>
<div class="cell">Wager</div>
<div class="cell">Winner</div>
<div class="cell">High Roll</div>
<div class="cell">Loser</div>
<div class="cell">Low Roll</div>
<div class="cell">Payout</div>
</div>
<% @games.each do |game| %>
<div class="row">
<div class="cell" data-title="Time"><%= Time.at(game.timestamp).strftime("%Y-%m-%d %H:%M:%S") %></div>
<div class="cell" data-title="Wager"><%= game.wager %></div>
<div class="cell" data-title="Winner"><%= game.winner %></div>
<div class="cell" data-title="High Roll"><%= game.high_roll %></div>
<div class="cell" data-title="Loser"><%= game.loser %></div>
<div class="cell" data-title="Low Roll"><%= game.low_roll %></div>
<div class="cell" data-title="Payout"><%= game.payout %></div>
</div>
<% end %>
</div>
<% end %>
<a href="/">Leaderboard</a>
</div>