Last active
August 29, 2015 14:26
-
-
Save seyna/2874f7871d069367d2f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in app/controllers/family_controller.rb | |
# | |
# find out if there is prize remained to draw | |
prize_remained_count = 65 - Lotterywinner.where(:prize_id => 1).size if pid == 1 | |
prize_remained_count = 0 if pid == 2 | |
prize_remained_count = 0 if pid == 3 | |
prize_remained_count = 0 if pid == 4 | |
if @user.puzzlepieces.where(:puzzle_id => pid).map(&:position_number).uniq.size == 8 | |
if (cur<<position_number).uniq.size == 9 && prize_remained_count > 0 # important | |
position_number = [1,1,1,1,1,1,1,1,1,2,2,2,3,4,5,5,5,6,7,8,9].sample(1).first | |
position_number = [1,2,3,4,5,6,7,8,9].sample(1).first if pid == 1 | |
else | |
position_number = cur.pop.sample(1).first | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment