summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndrewMurrell <amurrel@purdue.edu>2014-04-26 22:47:58 -0400
committerAndrewMurrell <amurrel@purdue.edu>2014-04-26 22:47:58 -0400
commitab25aac502a768b6a530ada5c46d6aabe6a56c4c (patch)
treec36e8f6d6fa24f2db907b78b23301fdbd7973b9c /lib
parent2c1e5ab5e7b20dabec9ddb9b34e0cf534afc6d06 (diff)
Added READMEs for scheduling and started seeding in lib.
Diffstat (limited to 'lib')
-rw-r--r--lib/scheduling/README.md13
-rw-r--r--lib/scheduling/elimination.rb25
-rw-r--r--lib/scheduling/roundrobin.rb31
-rw-r--r--lib/seeding/.keep0
-rw-r--r--lib/seeding/README.md3
5 files changed, 49 insertions, 23 deletions
diff --git a/lib/scheduling/README.md b/lib/scheduling/README.md
new file mode 100644
index 0000000..173b7be
--- /dev/null
+++ b/lib/scheduling/README.md
@@ -0,0 +1,13 @@
+Files in this directory should implement the following interface:
+
+ - `initialize(tournament_stage)`
+ construct new Scheduling object from tournament_stage
+
+ - `create_matches`
+ creates all the matches of the current round
+
+ - `finish_match(match)`
+ progresses the match through the schedule
+
+ - `graph`
+ returns a string representation of an svg image of the current stage \ No newline at end of file
diff --git a/lib/scheduling/elimination.rb b/lib/scheduling/elimination.rb
index 074cb5c..4518cff 100644
--- a/lib/scheduling/elimination.rb
+++ b/lib/scheduling/elimination.rb
@@ -33,8 +33,7 @@ module Scheduling
end
end
- def match_finished(match)
- #what in the goddamn fuck does this mean
+ def finish_match(match)
matches = match.tournament_stage.matches_ordered
cur_match_num = matches.invert[match]
unless cur_match_num == 1
@@ -55,17 +54,17 @@ module Scheduling
height = [(matchHeight+50) * logBase**(depth-1) + 100, 500].max;
str = <<-STRING
-<svg version="1.1" baseProfile="full"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:xlink="http://www.w3.org/1999/xlink"
- width="100%" height="#{height}">
- <defs>
- <radialGradient id="gradMatch" cx="50%" cy="50%" r="80%" fx="50%" fy="50%">
- <stop offset="0%" style="stop-color:#fff; stop-opacity:1" />
- <stop offset="100%" style="stop-color:#ccc;stop-opacity:0" />
- </radialGradient>
- </defs>
-STRING
+ <svg version="1.1" baseProfile="full"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ width="100%" height="#{height}">
+ <defs>
+ <radialGradient id="gradMatch" cx="50%" cy="50%" r="80%" fx="50%" fy="50%">
+ <stop offset="0%" style="stop-color:#fff; stop-opacity:1" />
+ <stop offset="100%" style="stop-color:#ccc;stop-opacity:0" />
+ </radialGradient>
+ </defs>
+ STRING
base = 1
pBase = 1
(1..matches.count).each do |i|
diff --git a/lib/scheduling/roundrobin.rb b/lib/scheduling/roundrobin.rb
index e149860..7a9e257 100644
--- a/lib/scheduling/roundrobin.rb
+++ b/lib/scheduling/roundrobin.rb
@@ -14,6 +14,17 @@ module Scheduling
end
end
+ def finish_match(match)
+ #declare winner of match, and store that somehow
+ rotate
+ return "totes worked\n"
+ end
+
+ def graph(current_user)
+ end
+
+ private
+
def create_round_array
#round robin should look like this.
#NOTE: I DO NOT KNOW IF THIS IS HOW TO PROPERLY POPULATE THE ROUND ROBIN ARRAY WITH TEAMS
@@ -28,15 +39,23 @@ module Scheduling
end
end
- #this is called when a round has completed
+ def tournament_stage
+ @tournament_stage
+ end
+
+ def tournament
+ tournament_stage.tournament
+ end
+
def rotate
+ #this is called when a round has completed
+
#remove first team
hold = @team_pairs.shift
#rotate by 1 element
@team_pairs.rotate!
#place first team the front of the array
@team_pairs.unshift(hold)
-
end
def mother_fuckin_winner
@@ -50,14 +69,6 @@ module Scheduling
scores[weiner]
end
- def match_finished(match)
- #declare winner of match, and store that somehow
- rotate
- return "totes worked\n"
- end
- def graph(current_user)
-
- end
end
end
diff --git a/lib/seeding/.keep b/lib/seeding/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/lib/seeding/.keep
diff --git a/lib/seeding/README.md b/lib/seeding/README.md
new file mode 100644
index 0000000..2f12622
--- /dev/null
+++ b/lib/seeding/README.md
@@ -0,0 +1,3 @@
+Files in this directory should implement the following interface:
+
+-