-
-
Save dekart/5891709 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
CLAN_ID = 1 | |
clan = Clan.find(CLAN_ID) | |
character_ids = ClanMember.connection.select_values( | |
ClanMember.send(:sanitize_sql, ["SELECT character_id FROM clan_members WHERE clan_id = :clan", :clan => clan.id]) | |
) | |
position = 0 | |
Character.transaction do | |
Character.order("level DESC").find(character_ids, :lock => true).each do |character| | |
position += 1 | |
if character_ids.size <= 20 && position <= 10 | |
character.chips += 2 | |
elsif character_ids.size > 20 && position <= 20 | |
character.chips += 2 | |
else | |
character.chips += 1 | |
end | |
character.save! | |
end | |
clan.chips = 0 | |
clan.save! | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment