SET win logic (Radix 4)
Verify that the three cards chosen are indeed a SET
by subskybox
HTML
<div id="output"></div>
JavaScript
Colors = {RED : 1, GREEN : 4, PURPLE : 16};
Symbols = {SQUIGGLE : 64, DIAMOND : 256, OVAL : 1024};
Shadings = {SOLID : 4096, STRIPED : 16384, OUTLINED : 65536};
Numbers = {ONE : 262144, TWO : 1048576, THREE : 4194304};
//Check if all the same OR all different.
function isSet() {
return !~([].reduce.call(arguments, (a, b) => a + b, 0).toString(4).indexOf("2"));
}
document.getElementById('output').innerHTML = "isSet: " + isSet(Colors.RED, Colors.GREEN, Colors.PURPLE,
Symbols.SQUIGGLE, Symbols.DIAMOND, Symbols.OVAL,
Shadings.STRIPED, Shadings.STRIPED, Shadings.STRIPED,
Numbers.ONE, Numbers.TWO, Numbers.THREE);