This repository has been archived by the owner on Jun 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Most of the match logic is finished and working
- Loading branch information
1 parent
7bc5be8
commit 591fa1b
Showing
16 changed files
with
262 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,16 @@ | ||
class Match < ActiveRecord::Base | ||
|
||
def validate | ||
errors.add_to_base "You must specify different robots to battle!" if first_bot_id == second_bot_id | ||
end | ||
|
||
def bot1_final_score | ||
final = first_bot_round1_score + first_bot_round2_score + first_bot_round3_score | ||
return final | ||
end | ||
|
||
def bot2_final_score | ||
final = second_bot_round1_score + second_bot_round2_score + second_bot_round3_score | ||
return final | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
- @sumobots = Sumobot.find(:all) | ||
= form_for(@match) do |f| | ||
- if @match.errors.any? | ||
#error_explanation | ||
%h2 | ||
= pluralize(@match.errors.count, "error") | ||
prohibited this match from being saved: | ||
|
||
%ul | ||
- @match.errors.full_messages.each do |msg| | ||
%li= msg | ||
|
||
.field | ||
= f.select("first_bot_id", @sumobots.collect {|bot| [bot.botname, bot.id] }) | ||
%b= " Vs. " | ||
= f.select("second_bot_id", @sumobots.collect {|bot| [bot.botname, bot.id] }) | ||
.actions | ||
= f.submit |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
%h1 Listing matches | ||
|
||
%table | ||
%tr | ||
%th First bot | ||
%th Second bot | ||
%th Status | ||
%th | ||
%th | ||
%th | ||
|
||
- @matches.each do |match| | ||
- first_bot = Sumobot.find(match.first_bot_id) | ||
- second_bot = Sumobot.find(match.second_bot_id) | ||
%tr | ||
%td= first_bot.botname | ||
%td= second_bot.botname | ||
%td | ||
- if match.winning_bot then | ||
= "#{Sumobot.find(match.winning_bot).botname} Won" | ||
- if match.winning_bot == match.first_bot_id then | ||
= "#{match.bot1_final_score} - #{match.bot2_final_score}" | ||
- else | ||
= "#{match.bot2_final_score} - #{match.bot1_final_score}" | ||
- elsif match.start then | ||
In Progress | ||
- else | ||
= "Round #{match.round} Not Started" | ||
%td= link_to 'Show', match | ||
- if can? :manage, match then | ||
%td= link_to 'Edit', edit_match_path(match) | ||
%td= link_to 'Destroy', match, :confirm => 'Are you sure?', :method => :delete | ||
|
||
%br | ||
|
||
= link_to 'New Match', new_match_path |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
%h1 Create a quick match | ||
|
||
= render :partial => 'form' | ||
|
||
= link_to 'Back', matches_path |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.