Created
March 23, 2009 10:14
-
-
Save dekart/83497 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
named_scope :victims_for, Proc.new{|attacker| | |
{ | |
:conditions => [ | |
%{ | |
(level BETWEEN :low_level AND :high_level) AND | |
characters.id NOT IN ( | |
SELECT fights.victim_id FROM fights WHERE attacker_id = :attacker_id AND winner_id = :attacker_id AND fights.created_at > :time_limit | |
) AND | |
characters.id != :attacker_id | |
}, | |
{ | |
:low_level => attacker.level, | |
:high_level => attacker.level + 2, | |
:attacker_id => attacker.id, | |
:time_limit => 1.hour.ago | |
} | |
], | |
:include => :user | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment