Created
May 9, 2012 07:41
-
-
Save marocchino/2642728 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
banners = [ | |
priority:10 | |
, | |
priority:10 | |
, | |
priority:20 | |
, | |
priority:30 | |
, | |
priority:40 | |
] | |
banner = do (banners)-> | |
total = [] | |
for banner,i in banners | |
for _ in [1..banner.priority] | |
total.push i | |
banners[total[Math.floor(Math.random() * total.length)]] | |
console.log banner |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cyluss횽의 코드에서 몇개 훔쳐왔음!