Browse files

Added code to process/handle Bye rounds

  • Loading branch information...
1 parent cf3de38 commit b042e4a0903834ccad445c079c39e83d3eda15ab @zombieCraig zombieCraig committed Apr 10, 2011
View
23 app/controllers/matches_controller.rb
@@ -176,6 +176,29 @@ def grant_point
format.html { redirect_to(@match) }
format.xml { head :ok }
end
+ end
+ def process_bye
+ @match = Match.find(params[:id])
+ if @match
+ if @match.second_bot_from_match == -1 then
+ @match.update_attributes(:winning_bot => @match.first_bot_id)
+ nextmatch = Match.find(:first, :conditions => {:first_bot_from_match => @match.id})
+ if nextmatch then
+ nextmatch.update_attributes(:first_bot_id => @match.first_bot_id)
+ else
+ nextmatch = Match.find(:first, :conditions => {:second_bot_from_match => @match.id})
+ if nextmatch then
+ nextmatch.update_attributes(:second_bot_id => @match.first_bot_id)
+ else
+ puts "TODO: Game done, assign winnners"
+ end
+ end
+ end
+ end
+ respond_to do |format|
+ format.html { redirect_to(@match) }
+ format.xml { head :ok }
+ end
end
end
View
19 app/views/matches/show.html.haml
@@ -7,23 +7,32 @@
= Sumobot.find(@match.first_bot_id).botname
- else
= "TBD"
- Versus
- - if @match.second_bot_id
- = Sumobot.find(@match.second_bot_id).botname
+ - if @match.second_bot_from_match == -1
+ Bye Round
- else
- = "TBD"
+ Versus
+ - if @match.second_bot_id
+ = Sumobot.find(@match.second_bot_id).botname
+ - else
+ = "TBD"
- if @match.tournament_id then
%b
= link_to "Tournament Match", tournament_path(@match.tournament_id)
%br
+- if @match.second_bot_from_match == -1
+ %p
+ This is a bye match and is just a place holder
+ %p
+ =link_to "Process Bye", :action => "process_bye"
+
- if @match.winning_bot then
%b
= Sumobot.find(@match.winning_bot).botname
Wins!!
-- else
+- elsif not @match.second_bot_from_match == -1
%table
%tr
%td
View
5 app/views/tournaments/_tournament_botmatch.html.haml
@@ -4,7 +4,10 @@
= link_to bot.botname, match_path(match)
- else
%del
- = link_to bot.botname, match_path(match)
+ - if bot.is_a? Sumobot
+ = link_to bot.botname, match_path(match)
+ - else
+ = bot
- else
- if bot.is_a? Sumobot then
= link_to bot.botname, match_path(match)
View
1 config/routes.rb
@@ -25,6 +25,7 @@
match "/team_approvals/:id/reject" => "team_approvals#reject"
match "/matches/:id/start_round" => "matches#start_round"
match "/matches/:id/grant_point" => "matches#grant_point"
+ match "/matches/:id/process_bye" => "matches#process_bye"
match "/hackerspaces/:id/join" => "hackerspaces#join"
# The priority is based upon order of creation:

0 comments on commit b042e4a

Please sign in to comment.