mirror of
https://github.com/ENSL/ensl.org.git
synced 2025-02-03 23:11:04 +00:00
Revert "Fix some logic errors with captains"
Revert "Change Gather style to volunteer captains" This reverts commitsfb7d361
,d8134ca
, andebd60d1
.
This commit is contained in:
parent
eee227cef5
commit
d6e0a5d1d1
9 changed files with 21 additions and 106 deletions
|
@ -63,22 +63,6 @@ class GathersController < ApplicationController
|
||||||
redirect_to @gather
|
redirect_to @gather
|
||||||
end
|
end
|
||||||
|
|
||||||
def captain
|
|
||||||
raise AccessError unless @gatherer
|
|
||||||
|
|
||||||
if @gather.captain1.nil? and @gather.captain2 != @gatherer
|
|
||||||
@gather.update_attribute :captain1, @gatherer
|
|
||||||
elsif @gather.captain2.nil? and @gather.captain1 != @gatherer
|
|
||||||
@gather.update_attribute :captain2, @gatherer
|
|
||||||
elsif @gatherer == @gather.captain1
|
|
||||||
@gather.update_attribute :captain1, nil
|
|
||||||
elsif @gatherer == @gather.captain2
|
|
||||||
@gather.update_attribute :captain2, nil
|
|
||||||
end
|
|
||||||
|
|
||||||
redirect_to @gather
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def get_gather
|
def get_gather
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
module GathersHelper
|
module GathersHelper
|
||||||
def render_gather
|
def render_gather
|
||||||
if @gather.status == Gather::STATE_RUNNING
|
if @gather.status == Gather::STATE_RUNNING
|
||||||
if @gather.is_full? and !@gather.is_ready? and @gather.captain1 != @gatherer and @gather.captain2 != @gatherer
|
|
||||||
headers['Gather'] = 'full'
|
|
||||||
else
|
|
||||||
headers['Gather'] = 'running'
|
headers['Gather'] = 'running'
|
||||||
end
|
|
||||||
|
|
||||||
render partial: 'running', layout: false
|
render partial: 'running', layout: false
|
||||||
elsif @gather.status == Gather::STATE_VOTING
|
elsif @gather.status == Gather::STATE_VOTING
|
||||||
|
|
|
@ -89,17 +89,6 @@ class Gather < ActiveRecord::Base
|
||||||
5
|
5
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_full?
|
|
||||||
return gatherers.count == Gather::FULL
|
|
||||||
end
|
|
||||||
|
|
||||||
def is_ready?
|
|
||||||
if is_full? and !captain1.nil? and !captain2.nil?
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
false
|
|
||||||
end
|
|
||||||
|
|
||||||
def first
|
def first
|
||||||
Gather.where(:category_id => category_id).order("id ASC").first
|
Gather.where(:category_id => category_id).order("id ASC").first
|
||||||
end
|
end
|
||||||
|
@ -131,10 +120,12 @@ class Gather < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_status
|
def check_status
|
||||||
if status_changed? and status == STATE_PICKING
|
if status_changed? and status == STATE_PICKING and !self.captain1
|
||||||
g = Gather.new
|
g = Gather.new
|
||||||
g.category = self.category
|
g.category = self.category
|
||||||
g.save
|
g.save
|
||||||
|
self.captain1 = self.gatherers.most_voted[1]
|
||||||
|
self.captain2 = self.gatherers.most_voted[0]
|
||||||
if self.gather_maps.count > 1
|
if self.gather_maps.count > 1
|
||||||
self.map1 = self.gather_maps.ordered[0]
|
self.map1 = self.gather_maps.ordered[0]
|
||||||
self.map2 = self.gather_maps.ordered[1]
|
self.map2 = self.gather_maps.ordered[1]
|
||||||
|
@ -148,7 +139,7 @@ class Gather < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_captains
|
def check_captains
|
||||||
if status == STATE_RUNNING or status == STATE_VOTING and is_ready? or admin
|
if captain1_id_changed? or captain2_id_changed? or admin
|
||||||
self.turn = 1
|
self.turn = 1
|
||||||
self.status = STATE_PICKING
|
self.status = STATE_PICKING
|
||||||
gatherers.each do |gatherer|
|
gatherers.each do |gatherer|
|
||||||
|
@ -160,13 +151,6 @@ class Gather < ActiveRecord::Base
|
||||||
gatherer.update_attributes(:team => nil, :skip_callbacks => true)
|
gatherer.update_attributes(:team => nil, :skip_callbacks => true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Create a new shout msgs when the gather is full
|
|
||||||
Shoutmsg.new({
|
|
||||||
:shoutable_type => self.class.to_s,
|
|
||||||
:shoutable_id => self.id,
|
|
||||||
:text => I18n.t(:gather_start_shout)
|
|
||||||
}).save
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ class Gatherer < ActiveRecord::Base
|
||||||
validates :confirm, :acceptance => true, :unless => Proc.new {|gatherer| gatherer.user.gatherers.count >= 5}
|
validates :confirm, :acceptance => true, :unless => Proc.new {|gatherer| gatherer.user.gatherers.count >= 5}
|
||||||
validate :validate_username
|
validate :validate_username
|
||||||
|
|
||||||
after_create :start_gather, :if => Proc.new {|gatherer| gatherer.gather.is_ready?}
|
after_create :start_gather, :if => Proc.new {|gatherer| gatherer.gather.gatherers.count == Gather::FULL}
|
||||||
after_create :notify_gatherers, :if => Proc.new {|gatherer| gatherer.gather.gatherers.count == Gather::NOTIFY}
|
after_create :notify_gatherers, :if => Proc.new {|gatherer| gatherer.gather.gatherers.count == Gather::NOTIFY}
|
||||||
after_update :change_turn, :unless => Proc.new {|gatherer| gatherer.skip_callbacks == true}
|
after_update :change_turn, :unless => Proc.new {|gatherer| gatherer.skip_callbacks == true}
|
||||||
after_destroy :cleanup_votes
|
after_destroy :cleanup_votes
|
||||||
|
@ -118,12 +118,6 @@ class Gatherer < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def cleanup_votes
|
def cleanup_votes
|
||||||
if gather.captain1_id == id
|
|
||||||
gather.update_attribute :captain1, nil
|
|
||||||
elsif gather.captain2_id == id
|
|
||||||
gather.update_attribute :captain2, nil
|
|
||||||
end
|
|
||||||
|
|
||||||
gather.map_votes.all(:conditions => {:user_id => user_id}).each { |g| g.destroy }
|
gather.map_votes.all(:conditions => {:user_id => user_id}).each { |g| g.destroy }
|
||||||
gather.server_votes.all(:conditions => {:user_id => user_id}).each { |g| g.destroy }
|
gather.server_votes.all(:conditions => {:user_id => user_id}).each { |g| g.destroy }
|
||||||
gather.gatherer_votes.all(:conditions => {:user_id => user_id}).each { |g| g.destroy }
|
gather.gatherer_votes.all(:conditions => {:user_id => user_id}).each { |g| g.destroy }
|
||||||
|
@ -161,8 +155,7 @@ class Gatherer < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return false unless team.nil? \
|
return false unless team.nil? \
|
||||||
and ((gather.captain1 != nil and gather.captain1.user == cuser and gather.turn == 1) \
|
and ((gather.captain1.user == cuser and gather.turn == 1) or (gather.captain2.user == cuser and gather.turn == 2))
|
||||||
or (gather.captain2 != nil and gather.captain2.user == cuser and gather.turn == 2))
|
|
||||||
return false if gather.turn == 1 and gather.gatherers.team(1).count == 2 and gather.gatherers.team(2).count < 3
|
return false if gather.turn == 1 and gather.gatherers.team(1).count == 2 and gather.gatherers.team(2).count < 3
|
||||||
return false if gather.turn == 2 and gather.gatherers.team(1).count < 4 and gather.gatherers.team(2).count == 3
|
return false if gather.turn == 2 and gather.gatherers.team(1).count < 4 and gather.gatherers.team(2).count == 3
|
||||||
return false if gather.turn == 1 and gather.gatherers.team(1).count == 4 and gather.gatherers.team(2).count < 5
|
return false if gather.turn == 1 and gather.gatherers.team(1).count == 4 and gather.gatherers.team(2).count < 5
|
||||||
|
|
|
@ -17,6 +17,7 @@ class Shoutmsg < ActiveRecord::Base
|
||||||
attr_protected :id, :created_at, :updated_at, :user_id
|
attr_protected :id, :created_at, :updated_at, :user_id
|
||||||
|
|
||||||
validates_length_of :text, :in => 1..100
|
validates_length_of :text, :in => 1..100
|
||||||
|
validates_presence_of :user
|
||||||
|
|
||||||
scope :recent,
|
scope :recent,
|
||||||
:include => :user,
|
:include => :user,
|
||||||
|
|
|
@ -9,13 +9,6 @@
|
||||||
<li<% if gatherer.status > 0 %> class="away"<% end %>>
|
<li<% if gatherer.status > 0 %> class="away"<% end %>>
|
||||||
<%= flag gatherer.user.country %>
|
<%= flag gatherer.user.country %>
|
||||||
<%= namelink gatherer.user %>
|
<%= namelink gatherer.user %>
|
||||||
|
|
||||||
<% if gatherer == @gather.captain1 or gatherer == @gather.captain2 %>
|
|
||||||
<span class="captain">
|
|
||||||
<%= icon('star') %>
|
|
||||||
</span>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<% if cuser and cuser.admin? %>
|
<% if cuser and cuser.admin? %>
|
||||||
<%= link_to gatherer, method: :delete, class: 'delete' do %>
|
<%= link_to gatherer, method: :delete, class: 'delete' do %>
|
||||||
<%= icon 'times' %>
|
<%= icon 'times' %>
|
||||||
|
|
|
@ -2,28 +2,15 @@
|
||||||
<% if @gather.status == Gather::STATE_RUNNING %>
|
<% if @gather.status == Gather::STATE_RUNNING %>
|
||||||
|
|
||||||
<% if @gatherer and @gatherer.can_destroy? cuser %>
|
<% if @gatherer and @gatherer.can_destroy? cuser %>
|
||||||
<% if Gather::FULL == @gather.gatherers.length %>
|
|
||||||
<p>Gather is full but we are waiting on commanders. If you would like to command, please use the button below.</p>
|
|
||||||
<% else %>
|
|
||||||
<p>Gather running, <%= Gather::FULL - @gather.gatherers.length %> more needed.</p>
|
<p>Gather running, <%= Gather::FULL - @gather.gatherers.length %> more needed.</p>
|
||||||
<% end %>
|
<%= link_to 'Leave Gather', @gatherer, confirm: 'Are you sure?', method: :delete, class: 'button tiny' %>
|
||||||
|
|
||||||
<%= form_tag "/gathers/captain/#{@gather.id}" do %>
|
|
||||||
<%= submit_tag (@gather.captain1 == @gatherer or @gather.captain2 == @gatherer) ? 'Stop Commanding' : 'Command a Team', class: 'button tiny leave-gather' %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<%= link_to 'Leave Gather', @gatherer, confirm: 'Are you sure?', method: :delete, class: 'button tiny leave-gather' %>
|
|
||||||
|
|
||||||
<% elsif (g = Gatherer.new(gather: @gather, user: cuser)).can_create?(cuser) %>
|
<% elsif (g = Gatherer.new(gather: @gather, user: cuser)).can_create?(cuser) %>
|
||||||
<%= form_for g do |f| %>
|
<%= form_for g do |f| %>
|
||||||
<%= f.hidden_field :gather_id %>
|
<%= f.hidden_field :gather_id %>
|
||||||
<%= f.hidden_field :user_id %>
|
<%= f.hidden_field :user_id %>
|
||||||
|
|
||||||
<% if Gather::FULL == @gather.gatherers.length %>
|
|
||||||
<p>Gather is full but we are waiting on commanders. If you would like to command, please use the button below.</p>
|
|
||||||
<% else %>
|
|
||||||
<p>Gather running, <%= Gather::FULL - @gather.gatherers.length %> more needed.</p>
|
<p>Gather running, <%= Gather::FULL - @gather.gatherers.length %> more needed.</p>
|
||||||
<% end %>
|
|
||||||
<p>
|
<p>
|
||||||
You can download custom maps via the
|
You can download custom maps via the
|
||||||
<%= link_to "Steam Workshop", "http://steamcommunity.com/workshop/browse?searchtext=&childpublishedfileid=0§ion=items&appid=4920&browsesort=trend&requiredtags%5B%5D=level" %>.
|
<%= link_to "Steam Workshop", "http://steamcommunity.com/workshop/browse?searchtext=&childpublishedfileid=0§ion=items&appid=4920&browsesort=trend&requiredtags%5B%5D=level" %>.
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<div id="jplayer"></div>
|
<div id="jplayer"></div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var gather_focus = true;
|
|
||||||
var played = false;
|
var played = false;
|
||||||
var leave_confirm = true;
|
var leave_confirm = true;
|
||||||
<% if @gatherer and @gatherer.can_destroy? cuser %>
|
<% if @gatherer and @gatherer.can_destroy? cuser %>
|
||||||
|
@ -22,8 +21,6 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var gatherAlertInterval;
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$.PeriodicalUpdater("/gathers/" + <%= @gather.id %> + ".js", {
|
$.PeriodicalUpdater("/gathers/" + <%= @gather.id %> + ".js", {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
|
@ -31,21 +28,8 @@
|
||||||
minTimeout: 5000,
|
minTimeout: 5000,
|
||||||
maxTimeout: 15000,
|
maxTimeout: 15000,
|
||||||
success: function(response, text, request) {
|
success: function(response, text, request) {
|
||||||
if (request.getResponseHeader('Gather') == 'full') {
|
if (request.getResponseHeader('Gather') == 'voting') {
|
||||||
// Play notification while we wait on captains
|
if (!played) {
|
||||||
if (!gatherAlertInterval) {
|
|
||||||
$('#jplayer').jPlayer({
|
|
||||||
ready: function() {
|
|
||||||
$(this).jPlayer('setMedia', {mp3: '/sounds/gather-alert.mp3'}).jPlayer("play");
|
|
||||||
},
|
|
||||||
loop: false
|
|
||||||
});
|
|
||||||
gatherAlertInterval = setInterval(function() { $("#jplayer").jPlayer("play"); }, 10000);
|
|
||||||
}
|
|
||||||
} else if (request.getResponseHeader('Gather') == 'picking' && !played) {
|
|
||||||
played = true
|
|
||||||
|
|
||||||
if (!gather_focus) {
|
|
||||||
$("#jplayer").jPlayer({
|
$("#jplayer").jPlayer({
|
||||||
ready: function() {
|
ready: function() {
|
||||||
$(this).jPlayer("setMedia", {
|
$(this).jPlayer("setMedia", {
|
||||||
|
@ -64,10 +48,11 @@
|
||||||
volume: 0.6,
|
volume: 0.6,
|
||||||
swfPath: "/flash"
|
swfPath: "/flash"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
played = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (response.length > 10) {
|
else if (response.length > 10) {
|
||||||
clearInterval(gatherAlertInterval);
|
|
||||||
$("#jplayer").jPlayer("stop");
|
$("#jplayer").jPlayer("stop");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,7 +81,6 @@
|
||||||
var afk_timeout;
|
var afk_timeout;
|
||||||
var afk_time = 1000 * 60 * 15; // 15 minutes
|
var afk_time = 1000 * 60 * 15; // 15 minutes
|
||||||
$(window).blur(function() {
|
$(window).blur(function() {
|
||||||
gather_focus = false;
|
|
||||||
afk_timeout = setTimeout(function() {
|
afk_timeout = setTimeout(function() {
|
||||||
if (gatherer_id > 0) {
|
if (gatherer_id > 0) {
|
||||||
afk = true;
|
afk = true;
|
||||||
|
@ -106,12 +90,6 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
$(window).focus(function() {
|
$(window).focus(function() {
|
||||||
gather_focus = true;
|
|
||||||
|
|
||||||
if (played) {
|
|
||||||
$("#jplayer").jPlayer("stop");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (afk) {
|
if (afk) {
|
||||||
updateGathererStatus('active');
|
updateGathererStatus('active');
|
||||||
$.get("/gathers/" + <%= @gather.id %> + ".js");
|
$.get("/gathers/" + <%= @gather.id %> + ".js");
|
||||||
|
@ -157,11 +135,11 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="info">
|
<div class="info">
|
||||||
<h6>Commanders</h6>
|
<h6>Captains</h6>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Players choose to become commanders</li>
|
<li>Vote for the <strong>best</strong> players</li>
|
||||||
<li>Commanders will pick team players</li>
|
<li>Captain 1 = 2nd most voted</li>
|
||||||
<li>Gather will not start without commanders</li>
|
<li>Captain 2 = 1st most voted</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ en:
|
||||||
contests_join: "Team successfully joined contest."
|
contests_join: "Team successfully joined contest."
|
||||||
contests_contester_update: "Contester was successfully updated."
|
contests_contester_update: "Contester was successfully updated."
|
||||||
gather_create: "New Gather was started successfully."
|
gather_create: "New Gather was started successfully."
|
||||||
gather_start_shout: "The gather is full and commanders are picking teams."
|
|
||||||
gathers_join: "You have joined the Gather."
|
gathers_join: "You have joined the Gather."
|
||||||
gathers_user_pick: "You have successfully selected a player for your team."
|
gathers_user_pick: "You have successfully selected a player for your team."
|
||||||
gatherers_update: "Gather player successfully updated."
|
gatherers_update: "Gather player successfully updated."
|
||||||
|
|
Loading…
Reference in a new issue