1
0
mirror of https://gitlab.com/Deukhoofd/BattleSim.git synced 2025-09-02 00:47:19 +00:00
BattleSim/server/elo.coffee
2016-02-01 23:19:30 +01:00

14 lines
376 B
CoffeeScript

elo = require('elo-rank')()
createPlayer = ->
{rating: 1000}
calculate = (player, matches, options = {}) ->
playerRating = player.rating
for {opponent, score} in matches
expected = elo.getExpected(playerRating, opponent.rating)
playerRating = elo.updateRating(expected, score, playerRating)
{rating: playerRating}
module.exports = {createPlayer, calculate}