Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

Commit

Permalink
Added code to process/handle Bye rounds
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieCraig committed Apr 10, 2011
1 parent cf3de38 commit b042e4a
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 6 deletions.
23 changes: 23 additions & 0 deletions app/controllers/matches_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 14 additions & 5 deletions app/views/matches/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion app/views/tournaments/_tournament_botmatch.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit b042e4a

Please sign in to comment.