redispvpranking

pvp game ranking model


Keywords
pvp, redis
License
ISC
Install
npm install redispvpranking@1.0.2

Documentation

redis-pvp-ranking

$ npm install redispvpranking

addToRanking

添加到排行榜中

changeRankingOfTwoPlayer

交换排行榜中的排行位置

getRankingById

根据ID获取排名

NPM

ioredis: 支持redis集群存储

redislock: PVP 两个对手PK时,将两个人锁定,不允许别的玩家PK。

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);
});