1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +00:00

Working on Pool class

This commit is contained in:
2015-01-26 13:40:25 -05:00
parent e9ff75a0a2
commit ae4b2718b5
5 changed files with 50 additions and 17 deletions

View File

@@ -8,7 +8,7 @@ class StaticPagesController < ApplicationController
@tournament = Tournament.find(params[:tournament])
end
if @tournament
@bouts = @tournament.bouts
@matches = Match.where(tournament_id: @tournament.id)
end
end
def results

31
app/models/pool.rb Normal file
View File

@@ -0,0 +1,31 @@
class Pool
def onePool(wrestlers,weight_id,tournament)
wrestlers.each do |w|
w.isWrestlingThisRound?(1)
end
end
def twoPools(wrestlers)
end
def fourPools(wrestlers)
end
def createMatch(w1,w2,round,tournament)
@match = Match.new
@match.r_id = w1
@match.g_id = w2
@match.round = round
@match.tournament_id = tournament
@match.save
end
end

View File

@@ -7,11 +7,14 @@ class Weight < ActiveRecord::Base
def generatePool
@wrestlers = Wrestler.where(weight_id: self.id)
if self.pools == 1
onePool(@wrestlers)
@pool = Pool.new
@pool.onePool(@wrestlers,self.id,self.tournament_id)
elsif self.pools == 2
@pool = Pool.new
@pool.twoPools(@wrestlers,self.id,self.tournament_id)
elsif self.pools == 4
@pool = Pool.new
@pool.fourPools(@wrestlers,self.id,self.tournament_id)
end
end
@@ -26,16 +29,5 @@ class Weight < ActiveRecord::Base
end
end
def fourPool
end
def onePool(wrestlers)
wrestlers.each do |wrestler|
wrestler.poolNumber = 1
wrestler.save
end
end
end

View File

@@ -2,4 +2,14 @@ class Wrestler < ActiveRecord::Base
belongs_to :school
belongs_to :weight
has_many :matches
def isWrestlingThisRound?(round)
@r_id = Match.where(r_id: self.id, round: round)
@g_id = Match.where(g_id: self.id, round: round)
if @r_id or @g_id
return true
else
return false
end
end
end

View File

@@ -2,7 +2,7 @@
<br>
<br>
<h3>Upcoming Matches</h3>
<% @bouts.each do |m| %>
<%= Wrestler.find(m.w1).weight.max %> Lbs <%= Wrestler.find(m.w1).name %> vs. Some Guy
<% @matches.each do |m| %>
<%= Wrestler.find(m.r_id).weight.max %> Lbs <%= Wrestler.find(m.r_id).name %> vs. <%= Wrestler.find(m.g_id).weight.max %> Lbs <%= Wrestler.find(m.g_id).name %>
<br>
<% end %>