Created
January 20, 2012 18:11
-
-
Save cybear/1648759 to your computer and use it in GitHub Desktop.
Achievements POC
This file contains hidden or 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
var tools={ | |
consonants:'BCDFGHJKLMNPQRSTVWXZ', | |
vowels:'AEIOUY' | |
}; | |
var achievements=[ | |
{ | |
name:'Seven Stones', | |
description:'Laid all 7 tiles in one word', | |
fn:function(move){return (move.replace(/\s/g,'').length===7)} | |
}, | |
{ | |
name:'Vowel movement', | |
description:'Laid a word with only vowels', | |
fn:function(move){ | |
var c=tools.consonants; | |
for(var i=0;i<c.length;i++) if(move.indexOf(c[i])!==-1) return false; | |
return true; | |
} | |
}, | |
{ | |
name:'Consonant combatant', | |
description:'Laid a word with only consonants', | |
fn:function(move){ | |
var v=tools.vowels; | |
for(var i=0;i<v.length;i++) if(move.indexOf(v[i])!==-1) return false; | |
return true; | |
} | |
} | |
]; | |
function is_achievement(move, board){ | |
var arr=[]; | |
return achievements.filter(function(achievement){ | |
return achievement.fn(move, board); | |
}); | |
} | |
exports.is_achievement=is_achievement; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment