From de9b6eeaf0e963ab8cf52c60d9ec5528029d77c8 Mon Sep 17 00:00:00 2001
From: AndrewMurrell
Date: Wed, 23 Apr 2014 19:00:26 -0400
Subject: Trivial tournament controller change.
---
app/controllers/tournaments_controller.rb | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb
index 03dc5b8..fde8980 100644
--- a/app/controllers/tournaments_controller.rb
+++ b/app/controllers/tournaments_controller.rb
@@ -146,7 +146,8 @@ class TournamentsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def tournament_params
- params.require(:tournament).permit(:game, :game_id, :status, :name, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :sampling_method)
+ permitted = [:game, :game_id, :status, :name, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :sampling_method]
+ params.require(:tournament).permit(permitted)
end
def is_owner?(object)
--
cgit v1.2.3-54-g00ecf
From dc5d239caa5ae4c08b272c8cba1a2e5d7b6f1ebf Mon Sep 17 00:00:00 2001
From: AndrewMurrell
Date: Wed, 23 Apr 2014 19:22:36 -0400
Subject: updated seeds for RPS
---
db/seeds.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/db/seeds.rb b/db/seeds.rb
index e0c2800..7b8709c 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -12,7 +12,7 @@ Server.create(default_user_permissions: p[:join_tournament] | p[:create_pm])
Game.create(name: "League of Legends",min_players_per_team: 5, max_players_per_team: 5, min_teams_per_match: 2, max_teams_per_match: 2, set_rounds: nil, randomized_teams: true, sampling_method: "Manual,Double Blind,RiotAPI")
Game.create(name: "Chess", min_players_per_team: 1, max_players_per_team: 1, min_teams_per_match: 2, max_teams_per_match: 2, set_rounds: nil, randomized_teams: true, sampling_method: "Manual,Double Blind")
Game.create(name: "Hearthstone", min_players_per_team: 1, max_players_per_team: 1, min_teams_per_match: 2, max_teams_per_match: 2, set_rounds: 1, randomized_teams: false, sampling_method: "Manual,Double Blind")
-Game.create(name: "Rock, Paper, Scissors", min_players_per_team: 1, max_players_per_team: 3, min_teams_per_match: 1, max_teams_per_match: nil, set_rounds: nil, randomized_teams: false, sampling_method: "Manual,Double Blind")
+Game.create(name: "Rock, Paper, Scissors", min_players_per_team: 1, max_players_per_team: 3, min_teams_per_match: 2, max_teams_per_match: 2, set_rounds: nil, randomized_teams: false, sampling_method: "Manual,Double Blind")
Game.find_by_name("League of Legends").settings.create(name: "Map", default: "Summoners Rift", type_opt: "Summoners Rift,Twisted Treeline,Crystal Scar,Haunted Abyss", description: "Select a map to play on.", vartype: 5, display_order: 1)
Game.find_by_name("League of Legends").settings.create(name: "Pick Type", type_opt: "Blind Pick,Draft", description: "Select a pick type.", vartype: 5, display_order: 2)
--
cgit v1.2.3-54-g00ecf
From 734729119cbc31e847fd46609b598573f365bdc4 Mon Sep 17 00:00:00 2001
From: Luke Shumaker
Date: Wed, 23 Apr 2014 19:32:28 -0400
Subject: tournaments: unify params[:game] and params[:tournament][:game_id]
---
app/controllers/tournaments_controller.rb | 8 ++++++--
app/views/tournaments/_selected.html.erb | 9 ++++-----
app/views/tournaments/new.html.erb | 2 +-
3 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb
index 03dc5b8..3835a59 100644
--- a/app/controllers/tournaments_controller.rb
+++ b/app/controllers/tournaments_controller.rb
@@ -32,7 +32,11 @@ class TournamentsController < ApplicationController
# GET /tournaments/new
def new
@games = Game.all
- @tournament = Tournament.new(game: Game.find_by_id(params[:game]))
+ if params[:tournament]
+ @tournament = Tournament.new(game: Game.find(params[:tournament][:game_id]))
+ else
+ @tournament = Tournament.new()
+ end
end
# GET /tournaments/1/edit
@@ -146,7 +150,7 @@ class TournamentsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def tournament_params
- params.require(:tournament).permit(:game, :game_id, :status, :name, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :sampling_method)
+ params.require(:tournament).permit(:game_id, :status, :name, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :sampling_method)
end
def is_owner?(object)
diff --git a/app/views/tournaments/_selected.html.erb b/app/views/tournaments/_selected.html.erb
index 4efd17a..9240c49 100644
--- a/app/views/tournaments/_selected.html.erb
+++ b/app/views/tournaments/_selected.html.erb
@@ -2,18 +2,17 @@
<%= render "common/error_messages", :target => @tournament %>
<%= f.hidden_field(:game_id) %>
- <% @game = Game.find(params[:game]) %>
<% @tournament.attributes.each do |name, value| %>
<% if (name == "id") or (name =~ /.*_at$/) or (name == "game_id") or (name == "status") or (name == "set_rounds") %>
<% next %>
<% end %>
<%= f.label name %>
- <% unless @game.attributes[name].nil? %>
+ <% unless @tournament.game.attributes[name].nil? %>
<% if name == "sampling_method" %>
- <%= f.select( name, @game.sampling_method.split(',') ) %>
+ <%= f.select( name, @tournament.game.sampling_method.split(',') ) %>
<% else %>
- <%= f.text_field(name, :value => @game.attributes[name] ) %>
+ <%= f.text_field(name, :value => @tournament.game.attributes[name] ) %>
<% end %>
<% else %>
<%= f.text_field name %>
@@ -22,7 +21,7 @@
<% end %>
<%= fields_for "tournament[settings]", @tournament.settings do |setting_fields| %>
- <% @game.settings.each do |setting| %>
+ <% @tournament.game.settings.each do |setting| %>
<%= setting_fields.label setting.name %>
diff --git a/app/views/tournaments/new.html.erb b/app/views/tournaments/new.html.erb
index 8c74068..66149fe 100644
--- a/app/views/tournaments/new.html.erb
+++ b/app/views/tournaments/new.html.erb
@@ -1,7 +1,7 @@
New Tournament
<%= form_tag(new_tournament_path, method: "get") do %>
- <%= select_tag('game',
+ <%= select_tag('tournament[game_id]',
options_from_collection_for_select(@games, 'id', 'name', @tournament.game.nil? || @tournament.game.id),
:prompt => "Select a Game Type") %>
<%= submit_tag("Select", :class => "btn btn-success btn-xs") %>
--
cgit v1.2.3-54-g00ecf
From d0ff792fa930a322f38338bd4de86712eca6eea9 Mon Sep 17 00:00:00 2001
From: Luke Shumaker
Date: Wed, 23 Apr 2014 19:32:53 -0400
Subject: tournaments_controller: permit game settings through
---
app/controllers/tournaments_controller.rb | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb
index 3835a59..b276368 100644
--- a/app/controllers/tournaments_controller.rb
+++ b/app/controllers/tournaments_controller.rb
@@ -150,7 +150,12 @@ class TournamentsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def tournament_params
- params.require(:tournament).permit(:game_id, :status, :name, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :sampling_method)
+ permitted = [:game_id, :status, :name, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :sampling_method]
+ if params[:tournament][:game_id]
+ game = Game.find(params[:tournament][:game_id])
+ permitted.push(:settings => game.settings.collect{|s| s.name})
+ end
+ params.require(:tournament).permit(permitted)
end
def is_owner?(object)
--
cgit v1.2.3-54-g00ecf
From a55838983eb101e6f2d6dc3a4a03f5b0d4f36c04 Mon Sep 17 00:00:00 2001
From: Luke Shumaker
Date: Wed, 23 Apr 2014 20:03:25 -0400
Subject: ignore vim swap files
---
.gitignore | 1 +
lib/scoring/.FibonacciPeerWithBlowout.rb.swp | Bin 12288 -> 0 bytes
2 files changed, 1 insertion(+)
delete mode 100644 lib/scoring/.FibonacciPeerWithBlowout.rb.swp
diff --git a/.gitignore b/.gitignore
index 830e151..c9926d1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,3 +24,4 @@ nohup.out
*#
.#*
.nfs*
+.*.swp
diff --git a/lib/scoring/.FibonacciPeerWithBlowout.rb.swp b/lib/scoring/.FibonacciPeerWithBlowout.rb.swp
deleted file mode 100644
index 49504ab..0000000
Binary files a/lib/scoring/.FibonacciPeerWithBlowout.rb.swp and /dev/null differ
--
cgit v1.2.3-54-g00ecf
From ae97abc3f47a7209ef8367a5781ca72ada90ddec Mon Sep 17 00:00:00 2001
From: Luke Shumaker
Date: Wed, 23 Apr 2014 20:05:30 -0400
Subject: clean up lib/scoring
---
lib/scoring/fibonacci_peer_with_blowout.rb | 29 +++++++++++++++++------------
lib/scoring/marginal_peer.rb | 24 ++++++++++++------------
lib/scoring/scoring_algorithm.rb | 6 ------
lib/scoring/winner_takes_all.rb | 28 ++++++++++++++++------------
4 files changed, 45 insertions(+), 42 deletions(-)
delete mode 100644 lib/scoring/scoring_algorithm.rb
diff --git a/lib/scoring/fibonacci_peer_with_blowout.rb b/lib/scoring/fibonacci_peer_with_blowout.rb
index 19ac9a7..8043fb7 100644
--- a/lib/scoring/fibonacci_peer_with_blowout.rb
+++ b/lib/scoring/fibonacci_peer_with_blowout.rb
@@ -1,16 +1,21 @@
-require 'ScoringAlgorithm'
-
-class FibonacciPeerWithBlowout < ScoringAlgorithm
+module Scoring
+ module FibonacciPeerWithBlowout
+ def stats_needed
+ return [:votes]
+ end
- def self.score(match, interface)
- match.players.each do |player|
- scores[player.user_name] = scoreUser(interface.getStatistic(match, player, :votes), match.win?(player), match.blowout)
+ def score(match, interface)
+ scores = {}
+ match.players.each do |player|
+ scores[player.user_name] = score_user(interface.get_statistic(match, player, :votes), match.win?(player), match.blowout)
+ end
+ scores
end
- scores
- end
- def self.scoreUser(votes, win, blowout)
- fibonacci = Hash.new { |h,k| h[k] = k < 2 ? k : h[k-1] + h[k-2] }
- fibonacci[votes+3] + (win ? blowout ? 12 : 10 : blowout ? 5 : 7)
+ private
+ def score_user(votes, win, blowout)
+ fibonacci = Hash.new { |h,k| h[k] = k < 2 ? k : h[k-1] + h[k-2] }
+ fibonacci[votes+3] + (win ? blowout ? 12 : 10 : blowout ? 5 : 7)
+ end
end
-end
\ No newline at end of file
+end
diff --git a/lib/scoring/marginal_peer.rb b/lib/scoring/marginal_peer.rb
index 0e1cfa8..13e1796 100644
--- a/lib/scoring/marginal_peer.rb
+++ b/lib/scoring/marginal_peer.rb
@@ -1,15 +1,15 @@
-require 'ScoringAlgorithm'
-
-class MarginalPeer < ScoringAlgorithm
-
- def self.score(match, interface)
- match.players.each do |player|
- scores[player.user_name] = scoreUser(interface.getStatistic(match, player, rating))
+module Scoring
+ module MarginalPeer
+ def stats_needed
+ return [:rating]
end
- scores
- end
- def self.score(rating)
- rating
+ def score(match, interface)
+ scores = {}
+ match.players.each do |player|
+ scores[player.user_name] = interface.get_statistic(match, player, :rating)
+ end
+ scores
+ end
end
-end
\ No newline at end of file
+end
diff --git a/lib/scoring/scoring_algorithm.rb b/lib/scoring/scoring_algorithm.rb
deleted file mode 100644
index f2afa6f..0000000
--- a/lib/scoring/scoring_algorithm.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-module Scoring
- class ScoringAlgorithm
- def self.score(match, interface)
- end
- end
-end
diff --git a/lib/scoring/winner_takes_all.rb b/lib/scoring/winner_takes_all.rb
index ad2471b..517dfd6 100644
--- a/lib/scoring/winner_takes_all.rb
+++ b/lib/scoring/winner_takes_all.rb
@@ -1,16 +1,20 @@
-require 'ScoringAlgorithm'
-
-class WinnerTakesAll < ScoringAlgorithm
-
- def self.score(match, interface)
- match.players.each do |player|
- scores[player.user_name] = scoreUser(match.win?(player))
+module Scoring
+ module WinnerTakesAll
+ def stats_needed
+ return []
end
- scores
- end
+ def score(match, interface)
+ scores = {}
+ match.players.each do |player|
+ scores[player.user_name] = score_user(match.win?(player))
+ end
+ scores
+ end
- def self.score(win)
- win.nil? ? 0.5 : win ? 1 : 0
+ private
+ def score_user(win)
+ win.nil? ? 0.5 : win ? 1 : 0
+ end
end
-end
\ No newline at end of file
+end
--
cgit v1.2.3-54-g00ecf
From c5e0aeb5a055797fe4f26fb9e6f9e163d5d7f718 Mon Sep 17 00:00:00 2001
From: DavisLWebb
Date: Wed, 23 Apr 2014 20:21:54 -0400
Subject: Updated remote_usernames
---
app/controllers/users_controller.rb | 19 ++++++++++++++++++-
app/models/remote_username.rb | 2 +-
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index c3261b8..68c0743 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -1,5 +1,8 @@
class UsersController < ApplicationController
+ require 'httparty'
+ require 'json'
+
# GET /users
# GET /users.json
@@ -36,7 +39,7 @@ class UsersController < ApplicationController
respond_to do |format|
if @user.save
sign_in @user
- if @user.id == 1
+ if @user.id == daft punk1
# This is the first user, so give them all the power
@user.permissions = 0xFFFFFFFF
@user.save
@@ -74,6 +77,20 @@ class UsersController < ApplicationController
end
end
+ def set_remote
+ game = Game.find_by_name("League of Legends")
+
+ remote_username = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/by-name/#{@name.downcase}?api_key=ad539f86-22fd-474d-9279-79a7a296ac38")
+
+ remote = @user.find_remote_username(game)
+ if remote.nil?
+ @user.remote_username.create(game: game, value: remote_username)
+ else
+ remote.value = remote_username
+ remote.save
+ end
+ end
+
private
# Use callbacks to share common setup or constraints between actions.
def set_user
diff --git a/app/models/remote_username.rb b/app/models/remote_username.rb
index e5d0a8c..c2c3d20 100644
--- a/app/models/remote_username.rb
+++ b/app/models/remote_username.rb
@@ -9,4 +9,4 @@ class RemoteUsername < ActiveRecord::Base
def value=(v)
self.json_value = v.to_json
end
-end
+end
--
cgit v1.2.3-54-g00ecf
From a729106e956e051818bb2d37f1581f3bf3abcefd Mon Sep 17 00:00:00 2001
From: DavisLWebb
Date: Wed, 23 Apr 2014 20:32:58 -0400
Subject: Fixed several user controller errors
---
app/controllers/users_controller.rb | 2 +-
app/views/users/show.html.erb | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 68c0743..cfa5d67 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -39,7 +39,7 @@ class UsersController < ApplicationController
respond_to do |format|
if @user.save
sign_in @user
- if @user.id == daft punk1
+ if @user.id == 1
# This is the first user, so give them all the power
@user.permissions = 0xFFFFFFFF
@user.save
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb
index b85cbda..81eee6f 100644
--- a/app/views/users/show.html.erb
+++ b/app/views/users/show.html.erb
@@ -20,6 +20,14 @@
too single
+
+ <%= label :username %>
+ <%= text_field %>
+
+
+
+
+
Recent Tournaments Played
--
cgit v1.2.3-54-g00ecf