darts-scorer-core

node v5.12.0
version: 1.0.0
endpointsharetweet
var dartsScorerCore = require("darts-scorer-core"); dartsScorerCore = dartsScorerCore.default || dartsScorerCore; var player1 = new dartsScorerCore.Player('Adam'); var player2 = new dartsScorerCore.Player('Eve'); var gameOptions = { startingPoints: 201 }; var game = new dartsScorerCore.games.Darts501Game([player1, player2], gameOptions); console.log('Game ' + game.startingPoints); game.throw(10); game.throw(15, 2); game.throw(20, 3); console.log(game.currentPlayer + ' throws ' + game.currentRound); console.log(game.currentPlayer + ' points: ' + game.currentPlayerTotalPoints); game.nextPlayer(); game.throw(1); game.throw(18, 2); game.throw(19, 3); console.log(game.currentPlayer + ' throws ' + game.currentRound); console.log(game.currentPlayer + ' points: ' + game.currentPlayerTotalPoints); game.nextPlayer(); console.log('Current round: ' + game.currentRoundNumber); console.log(game.currentPlayer + ' checkout hints:', checkoutHints()); game.throw(14, 3); game.throw(19); game.throw(20, 2); console.log(game.currentPlayer + ' points: ' + game.currentPlayerTotalPoints); console.log(game.currentPlayer.winner ? game.currentPlayer + ' is WINNER' : ''); // helper functions: function throwsLeft() { return game.throwsPerRound - game.currentRound.size; } function checkoutHints() { var hints = game.getCheckoutHint(game.currentPlayerTotalPoints, throwsLeft()); return hints.length ? hints[0].join('-') : []; } game;
Loading…

no comments

    sign in to comment