New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

acey-deucey-game-engine

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

acey-deucey-game-engine - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

tests/get-acey-deucey.test.js

33

lib/get-acey-deucey.js
"use strict";
const _ = require("lodash");
function getAceyDeucey(diceRoll) {
const aceyDeucey = {};
diceRoll.forEach(function(roll) {
if (roll === 1 && !aceyDeucey.hasOne) {
aceyDeucey.hasOne = true;
} else if (roll === 2 && !aceyDeucey.hasTwo) {
aceyDeucey.hasTwo = true;
} else if (!aceyDeucey.doublesVal) {
aceyDeucey.doublesVal = roll;
} else {
aceyDeucey.isAceyDeucey = false;
if (diceRoll.length !== 3) {
if (diceRoll.length === 2 && _.includes(diceRoll, 1) && _.includes(diceRoll, 2)) {
const err = new Error("This acey deucey roll does not have a doubles value");
err.diceRoll = diceRoll;
throw err;
}
});
aceyDeucey.isAceyDeucey = false;
return aceyDeucey;
}
aceyDeucey.hasOne = _.includes(diceRoll, 1);
aceyDeucey.hasTwo = _.includes(diceRoll, 2);
if (aceyDeucey.hasOne && aceyDeucey.hasTwo) {
const doubles = diceRoll.slice(0);
doubles.splice(_.indexOf(doubles, 1), 1);
doubles.splice(_.indexOf(doubles, 2), 1);
aceyDeucey.doublesVal = doubles[0];
aceyDeucey.isAceyDeucey = true;
} else {
aceyDeucey.isAceyDeucey = false;
}
return aceyDeucey;

@@ -17,0 +30,0 @@ }

@@ -13,3 +13,3 @@ "use strict";

if (diceRoll.length > 2) {
const aceyDeucey = getAceyDeucey(diceRoll);

@@ -19,3 +19,3 @@ if (aceyDeucey.isAceyDeucey === false) {

}
const sortedAceyDeuceyRoll = _.sortBy(diceRoll);

@@ -22,0 +22,0 @@ _(3).range().forEach(() => sortedAceyDeuceyRoll.push(aceyDeucey.doublesVal));

{
"name": "acey-deucey-game-engine",
"version": "1.1.1",
"version": "1.1.2",
"description": "a game engine for the backgammon variant acey deucey",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -86,5 +86,5 @@ "use strict";

} catch (error) {
t.equal(error.proposedMoves, invalidTurn, "error.proposedMove is the same as the invalid move");
t.equal(error.gameState, gameState, "error.gameState is the same as the gameState");
t.equal(error.diceRoll, diceRoll, "error.diceRoll is the same as the diceRoll");
t.deepEqual(error.proposedMoves, invalidTurn, "error.proposedMoves is the same as the invalid move");
t.deepEqual(error.gameState, gameState, "error.gameState is the same as the gameState");
t.deepEqual(error.diceRoll, diceRoll, "error.diceRoll is the same as the diceRoll");
}

@@ -91,0 +91,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc