Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions public/hiddenset.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@
<script>
defaultAnimationTime = 400;
currentVariant = Variants.hiddenset;
fastMode = true;
autoComplete = true;
start();
</script>
</body>
Expand Down
37 changes: 37 additions & 0 deletions public/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,40 @@ svg .stripe.purple {
.light .purple.striped {
stroke: #5A1398;
}



.modal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
}

/* Modal Content/Box */
.modal-content {
margin: 15% auto; /* 15% from the top and centered */
padding: 20px;
border: 1px solid #888;
width: 80%; /* Could be more or less, depending on screen size */
background-color: 000000;
}

/* The Close Button */
.close {
color: #aaa;
float: right;
font-size: 28px;
font-weight: bold;
}

.close:hover,
.close:focus {
color: black;
text-decoration: none;
cursor: pointer;
}
13 changes: 10 additions & 3 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,16 @@
</div>
</div>
</div>
<div id="light-dark" class="btn small" style="position:absolute;top:0%;left:0%"></div>

<div id="settings" class="btn small" style="position:absolute;top:0%;left:0%">Settings</div>

<div id="settings-page" class="modal" style="position:absolute;top:0%;left:0%">
<div class="modal-content">
<div id="light-dark" class="btn small" style="position:relative;top:0%;left:0%"></div>
<span id="settings-x" class="close">X</span>
</div>
</div>

<div id="restart" class="btn small" style="position:absolute;top:0%;right:0%">Restart</div>
</div>

Expand All @@ -62,8 +71,6 @@
<script>
defaultAnimationTime = 400;
currentVariant = Variants.set;
fastMode = true;
autoComplete = true;
start();
</script>
</body>
Expand Down
75 changes: 62 additions & 13 deletions public/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ var $restartBig = $('#restartBig')
var $restart = $('#restart')
var $noSet = $('#no-set');
var $checkSet = $('#check-set');
var $settings = $('#settings');
var $close = $('#settings-x');
var $settingspage = $('#settings-page');
var gameOver = false;

function getClockTime() {
Expand Down Expand Up @@ -134,17 +137,6 @@ function newGame() {
}
}

function setColorScheme(colorScheme) {
if (colorScheme == 'light') {
$body.addClass('light').removeClass('dark');
} else if (colorScheme == 'dark') {
$body.addClass('dark').removeClass('light');
}
if (typeof(Storage) !== 'undefined') {
localStorage.setItem('colorscheme', colorScheme);
}
}

function loadGame() {
var gameid = currentVariant.name;
if (typeof(Storage) !== 'undefined' && localStorage.getItem(gameid) != null) {
Expand Down Expand Up @@ -185,6 +177,17 @@ function start() {
}
}

function setColorScheme(colorScheme) {
if (colorScheme == 'light') {
$body.addClass('light').removeClass('dark');
} else if (colorScheme == 'dark') {
$body.addClass('dark').removeClass('light');
}
if (typeof(Storage) !== 'undefined') {
localStorage.setItem('colorscheme', colorScheme);
}
}

function lightDark() {
if ($body.hasClass('light')) {
setColorScheme('dark');
Expand All @@ -193,6 +196,32 @@ function lightDark() {
}
}

function toggleFastMode() {
if (fastMode) {
fastMode = false;
} else {
fastMode = true;
}

print ('setting fast mode ' + fastMode);
if (typeof(Storage) !== 'undefined') {
localStorage.setItem('fastMode', fastMode);
}
}

function toggleAutoComplete() {
if (autoComplete) {
autoComplete = false;
} else {
autoComplete = true;
}

print ('setting auto complete ' + autoComplete);
if (typeof(Storage) !== 'undefined') {
localStorage.setItem('autoComplete', autoComplete);
}
}

function getCardEl(i) {
return $($display.children()[i]);
}
Expand Down Expand Up @@ -389,7 +418,7 @@ function release() {
holdCount -= 1;
}

if (holdCount == 0 && fastMode) {
if (holdCount == 0 && currentVariant.hasFastMode && fastMode) {
checkAndClearSet();
}
}
Expand All @@ -405,7 +434,7 @@ function toggleCard($card) {
}

$card.toggleClass('selected');
if ($card.hasClass('selected') && autoComplete) {
if ($card.hasClass('selected') && currentVariant.hasAutoComplete && autoComplete) {
assistSet(); // only assist when autoComplete & selecting new
}
}
Expand Down Expand Up @@ -439,6 +468,8 @@ $restartBig.on(clickStart, restart);
$checkSet.on(clickStart, checkAndClearSet);

$noSet.on(clickStart, help);
$settings.on(clickStart, function() {$settingspage[0].style.display = "block";});
$close.on(clickStart, function() {$settingspage[0].style.display = "none";});

$body.on('keydown', function(evt) {
if (evt.originalEvent.repeat) {
Expand All @@ -457,6 +488,10 @@ $body.on('keydown', function(evt) {
help();
} else if (evt.shiftKey && code == 'KeyF') {
toggleFullScreen();
} else if (evt.shiftKey && code == 'KeyJ') {
toggleFastMode();
} else if (evt.shiftKey && code == 'KeyK') {
toggleAutoComplete();
} else if (codes.indexOf(code) != -1) {
if (!evt.shiftKey && !evt.ctrlKey && !evt.altKey) {
var i = codes.indexOf(code);
Expand Down Expand Up @@ -491,4 +526,18 @@ if (typeof(Storage) !== 'undefined') {
if (colorscheme != null) {
setColorScheme(colorscheme);
}

var fastMode = localStorage.getItem('fastMode');
if (fastMode == null || fastMode === 'true') {
this.fastMode = true;
} else {
this.fastMode = false;
}

var autoComplete = localStorage.getItem('autoComplete');
if (autoComplete == null || autoComplete === 'true') {
this.autoComplete = true;
} else {
this.autoComplete = false;
}
}
2 changes: 0 additions & 2 deletions public/powerset.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@
<script>
defaultAnimationTime = 400;
currentVariant = Variants.powerset;
fastMode = true;
autoComplete = false;
start();
</script>
</body>
Expand Down
2 changes: 0 additions & 2 deletions public/superset.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@
<script>
defaultAnimationTime = 400;
currentVariant = Variants.superset;
fastMode = false;
autoComplete = false;
start();
</script>
</body>
Expand Down
84 changes: 46 additions & 38 deletions public/variants.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,44 +108,6 @@ function naiveSetFinder(setSize, isSet) {
return findSet;
}

set = {
name: 'Set',
makeDeck: makeStandardDeck,
deal: deal,
isSet: isStandardSet,
findSet: naiveSetFinder(3, isStandardSet),
findNextSet: naiveSetFinder(3, isStandardSet),
tableSize: 12,
tableIncrement: 3,
}

superset = {
name: 'Super Set',
makeDeck: makeStandardDeck,
deal: deal,
isSet: isSuperSet,

findSet: naiveSetFinder(4, isSuperSet),
findNextSet: naiveSetFinder(4, isSuperSet),
tableSize: 9,
tableIncrement: 2,
}

hiddenset = {
name: 'Set',
makeDeck: function() {
var ret = makeStandardDeck();
ret[0].hidden = true;
return ret;
},
deal: deal,
isSet: isStandardSet,
findSet: naiveSetFinder(3, isStandardSet),
findNextSet: naiveSetFinder(3, isStandardSet),
tableSize: 12,
tableIncrement: 3,
}

function makePowerSetDeck() {
var deck = [];
for (var i = 1; i < 64; ++i) {
Expand Down Expand Up @@ -196,6 +158,50 @@ function findPowerSet(cards, previous) {
return best;
}

set = {
name: 'Set',
makeDeck: makeStandardDeck,
deal: deal,
isSet: isStandardSet,
findSet: naiveSetFinder(3, isStandardSet),
findNextSet: naiveSetFinder(3, isStandardSet),
tableSize: 12,
tableIncrement: 3,
hasFastMode: true,
hasAutoComplete: true
}

hiddenset = {
name: 'Hidden Set',
makeDeck: function() {
var ret = makeStandardDeck();
ret[0].hidden = true;
return ret;
},
deal: deal,
isSet: isStandardSet,
findSet: naiveSetFinder(3, isStandardSet),
findNextSet: naiveSetFinder(3, isStandardSet),
tableSize: 12,
tableIncrement: 3,
hasFastMode: true,
hasAutoComplete: true
}

superset = {
name: 'Super Set',
makeDeck: makeStandardDeck,
deal: deal,
isSet: isSuperSet,

findSet: naiveSetFinder(4, isSuperSet),
findNextSet: naiveSetFinder(4, isSuperSet),
tableSize: 9,
tableIncrement: 2,
hasFastMode: false,
hasAutoComplete: false
}

powerset = {
name: 'Power Set',
makeDeck: makePowerSetDeck,
Expand All @@ -205,6 +211,8 @@ powerset = {
findNextSet: findPowerSet,
tableSize: 7,
tableIncrement: 1, // mathematically impossible to have no-set
hasFastMode: true,
hasAutoComplete: false
}

Variants = {
Expand Down