summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Gemfile.lock6
-rw-r--r--app/controllers/matches_controller.rb57
-rw-r--r--app/models/tournament.rb1
-rw-r--r--app/models/user.rb2
-rw-r--r--app/views/matches/index.html.erb90
-rw-r--r--app/views/matches/show.html.erb20
6 files changed, 115 insertions, 61 deletions
diff --git a/Gemfile.lock b/Gemfile.lock
index b894f81..fd03576 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -31,9 +31,6 @@ GEM
bootstrap-sass (3.1.1.0)
sass (~> 3.2)
builder (3.1.4)
- byebug (2.7.0)
- columnize (~> 0.3)
- debugger-linecache (~> 1.2)
coffee-rails (4.0.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
@@ -41,8 +38,6 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.7.0)
- columnize (0.3.6)
- debugger-linecache (1.2.0)
delayed_job (4.0.0)
activesupport (>= 3.0, < 4.1)
delayed_job_active_record (4.0.0)
@@ -135,7 +130,6 @@ PLATFORMS
DEPENDENCIES
bcrypt-ruby (= 3.1.2)
bootstrap-sass
- byebug
coffee-rails (~> 4.0.0)
delayed_job_active_record
httparty
diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb
index f196978..93b5514 100644
--- a/app/controllers/matches_controller.rb
+++ b/app/controllers/matches_controller.rb
@@ -9,10 +9,11 @@ class MatchesController < ApplicationController
def index
@matches = @tournament.matches
- # width of SVG
- @width = 300 * (Math.log2(@matches.count).floor + 1);
+ # depth of SVG tree
+ @depth = Math.log2(@matches.count).floor+1;
# height of SVG
@height = 200 * 2**Math.log2(@matches.count).floor + 100;
+ @h_sector = 2**(@depth-1)+1
end
# For compatability with the router assumptions made by ApplicationController#check_permission
@@ -21,24 +22,20 @@ class MatchesController < ApplicationController
tournament_matches_path(@tournament)
end
- def get_riot_info
- if signed_in?
+ def get_riot_info
+ if signed_in?
+ pull = "Kaceytron"
#current user information
- response = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/by-name/#{current_user.user_name}?api_key=ad539f86-22fd-474d-9279-79a7a296ac38")
+ response = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/by-name/#{pull.downcase}?api_key=ad539f86-22fd-474d-9279-79a7a296ac38")
- id = response["#{current_user.user_name.downcase}"]['id']
+ id = response["#{pull.downcase}"]['id']
#recent game information
- recent = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/game/by-summoner/#{response["#{current_user.user_name.downcase}"]['id']}/recent?api_key=ad539f86-22fd-474d-9279-79a7a296ac38")
+ recent = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/game/by-summoner/#{response["#{pull.downcase}"]['id']}/recent?api_key=ad539f86-22fd-474d-9279-79a7a296ac38")
game_id = recent["games"][0]["gameId"]
- #remote_user_id = 6651654651354
- #remove_user_name = TeslasMind
- #How to Add
- #how do I access
-
#members of most recent game id's
player1 = recent["games"][0]["fellowPlayers"][0]["summonerId"]
player2 = recent["games"][0]["fellowPlayers"][1]["summonerId"]
@@ -121,8 +118,8 @@ class MatchesController < ApplicationController
@purp = purple
@blue = blue
- end #end if
- end #end def
+ end #end if
+ end #end def
# GET /matches/1
# GET /matches/1.json
@@ -150,7 +147,10 @@ class MatchesController < ApplicationController
if (@match.status == 1)
@scores = @match.scores
end
-
+ file_blue = "blue.yaml"
+ file_purple = "purple.yaml"
+ @blue2 = YAML.load_file(file_blue)
+ @purp2 = YAML.load_file(file_purple)
end
@@ -185,13 +185,36 @@ class MatchesController < ApplicationController
@match.status = 2;
respond_to do |format|
if @match.save
- format.html { redirect_to tournament_match_path(@tournament, @match), notice: 'Scores submitted' }
+ format.html { redirect_to tournament_match_path(@tournament, @match), notice: 'Scores Submitted' }
format.json { head :no_content }
else
format.html { redirect_to @tournament, notice: "You don't have permission to start this match." }
format.json { render json: "Permission denied", status: :forbidden }
end
- end
+ end
+ when "finish"
+ @match.status = 3
+ respond_to do |format|
+ if @match.save
+ format.html { redirect_to tournament_match_path(@tournament, @match), notice: 'Peer Review Submitted' }
+ format.json { head :no_content }
+ else
+ format.html { redirect_to @tournament, notice: "You don't have permission to start this match." }
+ format.json { render json: "Permission denied", status: :forbidden }
+ end
+ end
+ when "reset"
+ @match.status = 0
+ respond_to do |format|
+ if @match.save
+ format.html { redirect_to tournament_match_path(@tournament, @match), notice: 'Match Status Reset to 0' }
+ format.json { head :no_content }
+ else
+ format.html { redirect_to @tournament, notice: "You don't have permission to start this match." }
+ format.json { render json: "Permission denied", status: :forbidden }
+ end
+ end
+
else
respond_to do |format|
format.html { redirect_to @tournament, notice: "Invalid action", status: :unprocessable_entity }
diff --git a/app/models/tournament.rb b/app/models/tournament.rb
index 67f994d..10d7b30 100644
--- a/app/models/tournament.rb
+++ b/app/models/tournament.rb
@@ -61,7 +61,6 @@ class Tournament < ActiveRecord::Base
end
end
-
def keys
@tournament.preferences_raw.all.collect { |x| x.name }
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 0446b35..3407355 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -111,7 +111,7 @@ class User < ActiveRecord::Base
# VALID_USER_NAME checks to make sure a user's user_name
# is in the proper format.
- VALID_USER_NAME_REG = /\A[a-zA-Z0-9\-]+\z/
+ VALID_USER_NAME_REG = /\A[a-zA-Z0-9 _\-]+\z/
# The following lines put a user account through a series of
# validations in order to make sure all of their information
diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb
index 052d176..1941179 100644
--- a/app/views/matches/index.html.erb
+++ b/app/views/matches/index.html.erb
@@ -37,8 +37,19 @@
<div id="match-tree">
<SVG version="1.1"
baseProfile="full"
- width="<%= @width %>" height="<%= @height = [@height, 500].max %>"
+ width="100%" height="<%= @height = [@height, 500].max %>"
xmlns="http://www.w3.org/2000/svg">
+ <% lastrx = 0
+ lastry = 0
+ lastrh = 0
+ lastrw = 0 %>
+ <defs>
+ <radialGradient id="gradMatch" cx="50%" cy="50%" r="50%" fx="50%" fy="50%">
+ <stop offset="0%" style="stop-color:#ffd281;
+ stop-opacity:0" />
+ <stop offset="100%" style="stop-color:#EEA236;stop-opacity:1" />
+ </radialGradient>
+ </defs>
<script type="text/ecmascript"><![CDATA[
function redirect(i){
window.location.replace("<%= request.original_url %>"+"/"+i);
@@ -46,39 +57,54 @@
]]>
</script>
<% (1..@matches.count).each do |i| %>
- <g id="svg-match-<%= i %>" onmouseover="dispStats(<%= i %>)" onclick="redirect(<%= @matches[i-1].id %>)" cursor="pointer">
- <rect height="120px" width="213px"
- x="<%= @width - (i-1)*50 - 250*(Math.log2(i).floor+1) %>"
- y="<%= (@height/(Math.log2(i).floor+2)) - 60 + 250*(i - 2**(Math.log2(i).floor)) %>"
- fill="#ffd281"
- rx="20px"
- stroke-width="2"
- <% case @matches[i-1].status %>
- <% when 0 %>
- <% if @matches[i-1].teams.count < @tournament.min_teams_per_match %>
- stroke="red"
- fill-opacity="0.6"
- <% else %>
- stroke="green"
- <% end %>
- <% when 1 %>
- stroke="orange"
- <% when 2 %>
- stroke="yellow"
- <% when 3 %>
- stroke="grey"
- <% end %>
+ <g id="svg-match-<%= i %>" onclick="redirect(<%= @matches[i-1].id %>)" cursor="pointer">
+ <rect height="<%= rh = 100/(2**(@depth-1)+1) - 5 %>%"
+ width="<%= rw = 100/(@depth+1) - 5 %>%"
+ x="<%= rx = 50/(@depth+1) + 100/(@depth+1)*(@depth-(Math.log2(i).ceil+1)) %>%"
+ y="<%= ry = ( 100/(2**(Math.log2(i).floor+1))) %>%"
+ fill="url(#gradMatch)"
+ rx="5px"
+ stroke-width="2"
+ <% case @matches[i-1].status %>
+ <% when 0 %>
+ <% if @matches[i-1].teams.count < @tournament.min_teams_per_match %>
+ stroke="red"
+ fill-opacity="0.6"
+ <% else %>
+ stroke="green"
+ <% end %>
+ <% when 1 %>
+ stroke="orange"
+ <% when 2 %>
+ stroke="yellow"
+ <% when 3 %>
+ stroke="grey"
+ <% end %>
/>
+ <rect width="<%= rw-5 %>%" height="<%= rh/4 %>%" x="<%= rx + 2.5 %>%" y="<%= ry + 4 %>%" fill="white" stroke="black" />
+ <text x="<%= rx + rw/4 %>%" y="<%= ry + 10 %>%" font-size="<%= rh %>">
+ <% if @matches[i-1].teams.first %>
+ Team <%= @matches[i-1].teams.first.id %>
+ <% end %>
+ </text>
+ <text x="<%= rx + rw/2 - 2 %>%" y="<%= ry + 16 %>%" font-size="<%= rh %>"> VS </text>
+
+ <rect width="<%= rw-5 %>%" height="<%= rh/4 %>%" x="<%= rx + 2.5 %>%" y="<%= ry + 17 %>%" fill="white" stroke="black" />
+ <text x="<%= rx + rw/4 %>%" y="<%= ry + 23 %>%" font-size="<%= rh %>">
+ <% if @matches[i-1].teams[1] %>
+ Team <%= @matches[i-1].teams[1].id %>
+ <% end %>
+ </text>
+
+ <% if i > 1 %>
+ <line x1="<%= rx+rw %>%" y1="<%= ry+rh/2 %>%" x2="<%= lastrx %>%" y2="<%= lastry+lastrh/2 %>%" stroke="black" stroke-width="2" >
+ <% end %>
+ <% lastrx = rx
+ lastry = ry
+ lastrh = rh
+ lastrw = rw %>
</g>
- <% if i > 1 %>
- <line
- stroke="black"
- x1="<%= @width - (i-2)*50 - 250*(Math.log2(i-1).floor+1) %>"
- y1="<%= (@height/(Math.log2(i-1).floor+2)) - 60 + 250*((i-1) - 2**(Math.log2(i-1).floor)) + 60 %>"
- x2="<%= @width - (i-1)*50 - 250*(Math.log2(i).floor+1) + 213 %>"
- y2="<%= (@height/(Math.log2(i).floor+2)) - 60 + 250*(i - 2**(Math.log2(i).floor)) + 60 %>"
- />
- <% end %>
+
<% end %>
</SVG>
</div>
diff --git a/app/views/matches/show.html.erb b/app/views/matches/show.html.erb
index 109aa70..cd30926 100644
--- a/app/views/matches/show.html.erb
+++ b/app/views/matches/show.html.erb
@@ -26,6 +26,7 @@
Note:- The change of status from 1 to 2 is coming from League Data Pull (RIOT API)
-->
+
<% if (@match.status== 0) || !@tournament.players.include?(current_user) %>
<% @match.teams.each do |team| %>
<ol>
@@ -37,7 +38,7 @@
<!--
- This is what the Players and the Hosts of the tournament will view when the Match Status is 0
+ This is what the Players and the Hosts of the tournament will view when the Match Status is 1
-->
<% elsif (@match.status==1) %>
<% if @tournament.hosts.include?(current_user) && @scores.empty? %>
@@ -87,7 +88,16 @@
<% if team.users.include?(current_user) %>
<ol id="boxes" class="sortable">
<% team.users.collect{|u| u.user_name}.each do |k| %>
- <li><%= k %></li>
+ <li><%= k%>
+ <br>
+ <% if (@tournament.game_id == 1) %>
+ <%= if @blue2["#{k}"] == nil
+ "Level: #{@purp2["#{k}"]["level"]} K/D/A: #{@purp2["#{k}"]["championsKilled"]}/#{@purp2["#{k}"]["numDeaths"]}/#{@purp2["#{k}"]["assists"]} Gold:#{@purp2["#{k}"]["goldEarned"]}"
+ else
+ "Level: #{@blue2["#{k}"]["level"]} K/D/A: #{@blue2["#{k}"]["championsKilled"]}/#{@blue2["#{k}"]["numDeaths"]}/#{@blue2["#{k}"]["assists"]} Gold:#{@blue2["#{k}"]["goldEarned"]}"
+ end %>
+ <% end %>
+ </li>
<% end %>
</ol>
<% end %>
@@ -104,7 +114,7 @@
</p>
<% end %>
-<% if @tournament.hosts.include?(current_user) %>
+<% if @tournament.players.include?(current_user) %>
<br />
<div id="host">
<%= form_tag(tournament_match_path(@tournament, @match), method: "put") do %>
@@ -118,9 +128,11 @@
<% when 2 %>
<input type="hidden" name="update_action" value="finish">
<%= submit_tag("End Match") %>
+ <% when 3 %>
+ <input type="hidden" name="update_action" value="reset">
+ <%= submit_tag("Reset Status") %>
<% end %>
<% end %>
-
</div>
<% end %>