diff --git a/HyperSet/.idea/HyperSet.iml b/HyperSet/.idea/HyperSet.iml
new file mode 100644
index 0000000..c956989
--- /dev/null
+++ b/HyperSet/.idea/HyperSet.iml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HyperSet/.idea/misc.xml b/HyperSet/.idea/misc.xml
new file mode 100644
index 0000000..28a804d
--- /dev/null
+++ b/HyperSet/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HyperSet/.idea/modules.xml b/HyperSet/.idea/modules.xml
new file mode 100644
index 0000000..7b839fc
--- /dev/null
+++ b/HyperSet/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HyperSet/.idea/workspace.xml b/HyperSet/.idea/workspace.xml
new file mode 100644
index 0000000..e99d458
--- /dev/null
+++ b/HyperSet/.idea/workspace.xml
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1591174032513
+
+
+ 1591174032513
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HyperSet/card.php b/HyperSet/card.php
new file mode 100644
index 0000000..f048680
--- /dev/null
+++ b/HyperSet/card.php
@@ -0,0 +1,18 @@
+ $value) {
+ $this->{$attribute} = $value;
+ }
+
+ $deck->cards[] = $this;
+ }
+}
\ No newline at end of file
diff --git a/HyperSet/cardAttributes.php b/HyperSet/cardAttributes.php
new file mode 100644
index 0000000..6b2679c
--- /dev/null
+++ b/HyperSet/cardAttributes.php
@@ -0,0 +1,17 @@
+color = $color;
+ $this->shape = $shape;
+ $this->fill = $fill;
+ $this->number = $number;
+ $this->id = $id;
+}
+}
\ No newline at end of file
diff --git a/HyperSet/css/style.css b/HyperSet/css/style.css
new file mode 100644
index 0000000..3da4320
--- /dev/null
+++ b/HyperSet/css/style.css
@@ -0,0 +1,79 @@
+* {
+ box-sizing: border-box;
+}
+
+body {
+ font-family: Arial, sans-serif;
+ text-align: center;
+}
+
+h1 {
+ font-size: 40px;
+}
+
+.submit {
+ margin-top: 2em;
+ font-size: 16px;
+ padding: 1em 3em;
+ background: #BADA55;
+ color: #000;
+}
+
+.submit:disabled {
+ background: #C5DA83;
+ color: #666;
+}
+
+.wrapper {
+ width: 1080px;
+ margin: 0 auto;
+}
+
+.card {
+ display: inline-block;
+ width: 245px;
+ margin-right: 5px;
+ height: 200px;
+ border: 2px solid #ccc;
+}
+.card:hover {
+ border-color: #e2e2e2;
+}
+
+.selected {
+ background: #eee;
+}
+
+.game-board {
+ width: 1000px;
+ margin: 0 auto;
+}
+
+.shape {
+ display: inline-block;
+ width: 70px;
+ height: 200px;
+ -webkit-mask-repeat: no-repeat;
+ -webkit-mask-position: 15px;
+}
+.diamond {
+ -webkit-mask-image: url('../images/diamond.png');
+}
+.wave {
+ -webkit-mask-image: url('../images/wave.png');
+}
+.oval {
+ -webkit-mask-image: url('../images/oval.png');
+}
+
+.green {
+ background: green;
+}
+.red {
+ background: red;;
+}
+.purple {
+ background: violet;
+}
+
+/*solution pour avoir l'image en rainure ou vide a voir dans le css*/
\ No newline at end of file
diff --git a/HyperSet/deck.php b/HyperSet/deck.php
new file mode 100644
index 0000000..2662a56
--- /dev/null
+++ b/HyperSet/deck.php
@@ -0,0 +1,62 @@
+createDeck();
+ }
+
+ private function createDeck() {
+ // need one card of each combo of color/shape/fill/number
+ $colors = array('green', 'red', 'purple');
+ $shapes = array('oval', 'diamond', 'wave');
+ $fills = array('filled', 'shaded', 'empty');
+ $numbers = array(1, 2, 3);
+
+ $index = 1;
+
+ foreach ($colors as $color) {
+ foreach ($shapes as $shape) {
+ foreach ($fills as $fill) {
+ foreach ($numbers as $number) {
+ $cardAttributes = new CardAttributes($color, $shape, $fill, $number, $index);
+ $card = new Card($cardAttributes, $this);
+ $index++;
+ }
+ }
+ }
+
+ }
+
+ }
+
+ public function removeSet($cards) {
+
+ }
+
+ private function shuffle() {
+ shuffle($this->cards);
+ }
+
+
+
+ public function deal() {
+ // shuffle the deck
+ $this->shuffle();
+
+ // remove 12 cards from the top and return them
+ $dealtCards = array_chop($this->cards, 12);
+ return $dealtCards;
+ }
+
+ public function threeMore() {
+ return array_chop($this->cards, 3);
+ }
+
+}
\ No newline at end of file
diff --git a/HyperSet/functions.php b/HyperSet/functions.php
new file mode 100644
index 0000000..e32db6d
--- /dev/null
+++ b/HyperSet/functions.php
@@ -0,0 +1,7 @@
+deck = $deck;
+ }
+
+ public function start() {
+
+ // call the deck's deal function and return the cards dealt
+ return $this->deck->deal();
+
+ }
+}
\ No newline at end of file
diff --git a/HyperSet/images/diamond.png b/HyperSet/images/diamond.png
new file mode 100644
index 0000000..3805d19
Binary files /dev/null and b/HyperSet/images/diamond.png differ
diff --git a/HyperSet/images/oval.png b/HyperSet/images/oval.png
new file mode 100644
index 0000000..7d9a873
Binary files /dev/null and b/HyperSet/images/oval.png differ
diff --git a/HyperSet/images/wave.png b/HyperSet/images/wave.png
new file mode 100644
index 0000000..1cb0cb0
Binary files /dev/null and b/HyperSet/images/wave.png differ
diff --git a/HyperSet/index.html b/HyperSet/index.html
new file mode 100644
index 0000000..a39cced
--- /dev/null
+++ b/HyperSet/index.html
@@ -0,0 +1,21 @@
+
+
+
+
+
+ Set
+
+
+
+
+
+
(TEST) Set
+
Find sets.
+
Sets found: 0
+
+
+
+
+
+
+
diff --git a/HyperSet/player.php b/HyperSet/player.php
new file mode 100644
index 0000000..a785c06
--- /dev/null
+++ b/HyperSet/player.php
@@ -0,0 +1,14 @@
+score += $points;
+}
+}
\ No newline at end of file
diff --git a/HyperSet/set.js b/HyperSet/set.js
new file mode 100644
index 0000000..010c81e
--- /dev/null
+++ b/HyperSet/set.js
@@ -0,0 +1,202 @@
+var Game = {
+ cards: [],
+ selected: [],
+ score: 0,
+ $board: $('[data-display="game-board"]'),
+ $score: $('[data-display="score"]'),
+
+ deal: function() {
+ var self = this;
+
+ // ajax request to get initial set of cards
+ var dealRequest = $.ajax({
+ url: 'set.php?action=deal',
+ type: 'GET',
+ dataType: 'json',
+ success: function(data) {
+ self.cards = data;
+ self.displayCards.call(self);
+ self.setCardListeners();
+ self.setPageListeners();
+ }
+ });
+ },
+
+ displayCards: function() {
+ var self = this;
+
+ $.each(this.cards, function(index, card){
+ var cardNode = $('');
+ cardNode.addClass('card');
+ $(cardNode).data({
+ 'id': card.id,
+ 'shape': card.shape,
+ 'color': card.color,
+ 'number': card.number
+ });
+
+ var shapeNode = $('
');
+ shapeNode.addClass('shape ' + card.color + ' ' + card.shape + ' ' + card.fill);
+
+
+ for (var i = 0; i < card.number; i++) {
+ cardNode.append(shapeNode.clone());
+ }
+ self.$board.append(cardNode);
+
+ // display 4 cards per row
+ if ((index+1) % 4 === 0) {
+ self.$board.append($(''));
+ }
+ });
+ },
+
+ setCardListeners: function() {
+ var self = this;
+
+ // what happens when a card is clicked:
+ this.$board.on('click', '.card', function(e) {
+ e.stopImmediatePropagation();
+ var card = e.currentTarget;
+
+ // if card is new, add it, otherwise remove it
+ var ids = $.map(self.selected, function(el) { return $(el).data("id");});
+ if (ids.indexOf($(card).data('id')) >= 0) {
+ self.deselectCard(card);
+ } else {
+ self.selectCard(card);
+ }
+
+ if (self.selected.length === 3) {
+ self.silentSubmission();
+ }
+ });
+ },
+
+ setPageListeners: function() {
+ var self = this;
+
+ // if the user clicks on the page outside the game board, clear selected
+ $(document).on('click', function() {
+ self.clearSelections.call(self);
+ });
+ },
+
+ selectCard: function(card) {
+ $(card).addClass('selected');
+ this.selected.push(card);
+
+ if (this.selected.length > 3) {
+ var removed = this.selected.shift();
+ $(removed).removeClass('selected');
+ }
+
+ },
+
+ deselectCard: function(card) {
+ var self = this;
+ var index = self.selected.indexOf(card);
+ if (index > -1) {
+ self.selected.splice(index, 1);
+ }
+ $(card).removeClass('selected');
+ },
+
+ clearSelections: function() {
+ $.each(this.selected, function(index, card) {
+ $(card).removeClass('selected');
+ });
+ this.selected = [];
+ },
+
+ validateSet: function() {
+ var self = this;
+
+ var colors = $.map(self.selected, function(el) { return $(el).data("color");});
+ var shapes = $.map(self.selected, function(el) { return $(el).data("shape"); });
+ var numbers = $.map(self.selected, function(el) { return $(el).data("number"); });
+
+
+ return (self.isSet(colors) && self.isSet(shapes) && self.isSet(numbers));
+ },
+
+ isSet: function(arr) {
+ // a set means the attributes are either all the same or all different
+ var reduced = $.unique(arr);
+ return (reduced.length === 1 || reduced.length === 3);
+ },
+
+ silentSubmission: function() {
+ var valid = this.validateSet();
+ if (valid) {
+ this.submitSet();
+ }
+ },
+
+ submitSet: function() {
+ var self = this;
+ var ids = $.map(self.selected, function(el) { return $(el).data("id");});
+
+ // ajax request to get initial set of cards
+ var newCardRequest = $.ajax({
+ url: 'set.php?action=submit',
+ type: 'GET',
+ dataType: 'json',
+ success: function(data) {
+ self.clearCards(ids);
+ // to do - implement game complete check on server
+ if (!data.gameComplete) {
+ self.updateCards(data);
+ self.increaseScore();
+ } else {
+ self.gameWon();
+ }
+ },
+ error: function() {
+ console.log(arguments);
+ }
+ });
+
+ this.clearSelections();
+ },
+
+ clearCards: function(ids) {
+ // remove submitted cards game's card array and clear the board
+ var self = this;
+ this.selected = [];
+ this.$board.empty();
+ var cardIds = $.map(self.cards, function(card) { return card.id; });
+ $.each(ids, function(idx, id) {
+ var location = cardIds.indexOf(id);
+ if (location > -1) {
+ cardIds.splice(location, 1);
+ self.cards.splice(location, 1);
+ }
+ });
+ },
+
+ updateCards: function(newCards) {
+ this.cards = this.cards.concat(newCards);
+ this.displayCards();
+ },
+
+ increaseScore: function() {
+ this.$score.html(++this.score);
+ },
+
+ startRound: function() {
+ // todo
+ // reset timer to 30 seconds
+ },
+
+ gameWon: function() {
+ alert("you won!");
+ },
+
+ gameLost: function() {
+ alert("you lost :(");
+ }
+
+};
+
+$(document).ready(Game.deal());
\ No newline at end of file
diff --git a/HyperSet/set.php b/HyperSet/set.php
new file mode 100644
index 0000000..592d3c0
--- /dev/null
+++ b/HyperSet/set.php
@@ -0,0 +1,18 @@
+start());
+} else if (isset($_GET['action']) && $_GET['action'] == 'submit'){
+ $deck = $_SESSION['deck'];
+ echo json_encode($deck->threeMore());
+}
\ No newline at end of file