From 09669fb7c74c57027c5ad1ede7c3811c39569085 Mon Sep 17 00:00:00 2001 From: jamal Date: Mon, 13 Oct 2014 22:56:40 -0400 Subject: [PATCH] Fix some logic errors with captains --- app/models/gather.rb | 4 ++-- app/models/gatherer.rb | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/models/gather.rb b/app/models/gather.rb index ac1e4ae..e00ca80 100644 --- a/app/models/gather.rb +++ b/app/models/gather.rb @@ -131,7 +131,7 @@ class Gather < ActiveRecord::Base end def check_status - if status_changed? and status == STATE_PICKING and !self.captain1 + if status_changed? and status == STATE_PICKING g = Gather.new g.category = self.category g.save @@ -148,7 +148,7 @@ class Gather < ActiveRecord::Base end def check_captains - if status == STATE_RUNNING and is_ready? or admin + if status == STATE_RUNNING or status == STATE_VOTING and is_ready? or admin self.turn = 1 self.status = STATE_PICKING gatherers.each do |gatherer| diff --git a/app/models/gatherer.rb b/app/models/gatherer.rb index 45133c8..cd43687 100644 --- a/app/models/gatherer.rb +++ b/app/models/gatherer.rb @@ -161,7 +161,8 @@ class Gatherer < ActiveRecord::Base end end return false unless team.nil? \ - and ((gather.captain1.user == cuser and gather.turn == 1) or (gather.captain2.user == cuser and gather.turn == 2)) + and ((gather.captain1 != nil and gather.captain1.user == cuser and gather.turn == 1) \ + 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 == 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