Skip to content

Instantly share code, notes, and snippets.

@cybear
Created January 20, 2012 18:11
Show Gist options
  • Save cybear/1648759 to your computer and use it in GitHub Desktop.
Save cybear/1648759 to your computer and use it in GitHub Desktop.
Achievements POC
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