nodejs npm redis-pvp-ranking
nodejs + redis [实现游戏内的pvp排行榜排行]
做过两次pvp排行榜 自己想着还是写一个npm吧,以后再写pvp的时候,直接使用就好了。 NPM
var ranking = require('../index');
var config = require('./config.json');
var rankingManager = new ranking(config);
console.log('rankingManager-->>',rankingManager);
var async = require('async');
async.waterfall([
function (cb) {
rankingManager.getTopRanking(10, function (err,data) {
console.log('get top ranking->',err,data);
cb();
});
},
function (cb) {
rankingManager.addToRanking('robot_3', function (err,data) {
console.log('add to ranking ->',err,data);
cb();
});
},
function (cb) {
rankingManager.getTopRanking(10, function (err,data) {
console.log('get top ranking->',err,data);
cb();
});
},
function (cb) {
rankingManager.changeRankingOfTwoPlayer('robot_1002','robot_1001', function (err,data) {
console.log('change ranking ->',err,data);
cb();
});
},
function (cb) {
rankingManager.getTopRanking(10, function (err,data) {
console.log('get top ranking->',err,data);
cb();
});
}
], function (err) {
console.log(err);
});