_.each(findedWords, function(wordObj) {
   var temp = [];
   _.each(_.invert(wordObj.letters), function(letter) {
     letter = letter.split(',').join('');
     temp.push(letter);
   });
   results.push('6'+ temp.join('') + '7');
   temp.unshift(wordObj.word);
   resultsForPrint.push(temp);
 });
Example #2
0
 setTimeout(function() {
     if(!_.isNull(this.game)) {
         if(this.game.found.length > 0) {
             var winner = _.invert(this.game.scores)[_.max(this.game.scores)];
             event.reply('GAME OVER. THE WINNER IS ' + winner.toUpperCase() + ' WITH ' + this.game.scores[winner]);
             event.reply(this.game.solutions.length - this.game.found.length + ' solutions remained.'); 
         } else {
             event.reply('NO SOLUTIONS FOUND. YOU ARE ALL RUBBISH.');
         }
         this.game = null;
     }
 }.bind(this), 40000);
Example #3
0
    this.listener = function(event) {
        if(!_.isNull(this.game) && this.game.channel === event.channel.name) {
            if(_.include(this.game.solutions, event.message) && !_.include(this.game.found, event.message)) {
                if(!_.has(this.game.scores, event.user)) this.game.scores[event.user] = 0;
                this.game.scores[event.user]++;
                this.game.found.push(event.message);
                event.reply(event.user + ': ' + event.message.toUpperCase() + ' IS CORRECT. ' + 
                    this.game.found.length + '/' + this.game.solutions.length + ' WORDS FOUND');

                if(this.game.found.length === this.game.solutions.length) {
                    var winner = _.invert(this.game.scores)[_.max(this.game.scores)];
                    event.reply('ALL WORDS FOUND. THE WINNER IS ' + winner.toUpperCase() + ' WITH ' + this.game.scores[winner]);
                    this.game = null;
                }
            }
        }
    }.bind(this);
Example #4
0
console.log(_.isEqual(moe, clone));//true
//判断对象类型以下都为空
console.log(_.isEmpty({})); //如果object里没包含任何东西,将返回true
console.log(_.isArray([1,2,3]));
console.log(_.isObject({}));
console.log((function(){ return _.isArguments(arguments); })(1, 2, 3));
console.log(_.isFunction(console.log));
console.log(_.isString("moe"));
console.log(_.isNumber(8.4 * 5));
console.log(_.isFinite(-101));
console.log(_.isBoolean(true));
console.log(_.isDate(new Date()));
console.log(_.isNaN(NaN));
console.log(_.isNull(null));
console.log(_.isUndefined(undefined));

// invert _.invert(object)
// 返回一个object的副本,并且里面的键和值是对调的,要使之有效,必须确保object里所有的值都是唯一的且可以序列号成字符串
console.log(_.invert({a:'b', c:'d', e:'f'})); // { b: 'a', d: 'c', f: 'e' }

// pairs _.pairs(object)
// 把一个对象转换成一个[key, value]形式的数组
console.log(_.pairs({one:1, two:2, three: 3})); // [ [ 'one', 1 ], [ 'two', 2 ], [ 'three', 3 ] ]

// values _.values(object)
// 获取object对象的所有属性值
console.log(_.values({one:1, two:2, three:3})); // [ 1, 2, 3 ]

// keys _.keys(object)
// 获取object对象的所有属性名
console.log(_.keys({one:1, two:2, three:3})); //[ 'one', 'two', 'three' ]