diff --git a/HyperSet/.idea/vcs.xml b/HyperSet/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/HyperSet/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/HyperSet/.idea/workspace.xml b/HyperSet/.idea/workspace.xml index fee62e4..6a45058 100644 --- a/HyperSet/.idea/workspace.xml +++ b/HyperSet/.idea/workspace.xml @@ -1,7 +1,13 @@ - + + + + + + + + + + @@ -95,5 +107,9 @@ + + + + \ No newline at end of file diff --git a/HyperSet/card.php b/HyperSet/card.php deleted file mode 100644 index f048680..0000000 --- a/HyperSet/card.php +++ /dev/null @@ -1,18 +0,0 @@ - $value) { - $this->{$attribute} = $value; - } - - $deck->cards[] = $this; - } -} \ No newline at end of file diff --git a/HyperSet/cardAttributes.php b/HyperSet/cardAttributes.php deleted file mode 100644 index 6b2679c..0000000 --- a/HyperSet/cardAttributes.php +++ /dev/null @@ -1,17 +0,0 @@ -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 deleted file mode 100644 index 3da4320..0000000 --- a/HyperSet/css/style.css +++ /dev/null @@ -1,79 +0,0 @@ -* { - 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 deleted file mode 100644 index 2662a56..0000000 --- a/HyperSet/deck.php +++ /dev/null @@ -1,62 +0,0 @@ -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 deleted file mode 100644 index e32db6d..0000000 --- a/HyperSet/functions.php +++ /dev/null @@ -1,7 +0,0 @@ -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 deleted file mode 100644 index 3805d19..0000000 Binary files a/HyperSet/images/diamond.png and /dev/null differ diff --git a/HyperSet/images/oval.png b/HyperSet/images/oval.png deleted file mode 100644 index 7d9a873..0000000 Binary files a/HyperSet/images/oval.png and /dev/null differ diff --git a/HyperSet/images/wave.png b/HyperSet/images/wave.png deleted file mode 100644 index 1cb0cb0..0000000 Binary files a/HyperSet/images/wave.png and /dev/null differ diff --git a/HyperSet/index.html b/HyperSet/index.html deleted file mode 100644 index a39cced..0000000 --- a/HyperSet/index.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - Set - - - - -
-

(TEST) Set

-

Find sets.

-

Sets found: 0

-
-
- - - - - diff --git a/HyperSet/player.php b/HyperSet/player.php deleted file mode 100644 index a785c06..0000000 --- a/HyperSet/player.php +++ /dev/null @@ -1,14 +0,0 @@ -score += $points; -} -} \ No newline at end of file diff --git a/HyperSet/set.js b/HyperSet/set.js deleted file mode 100644 index 010c81e..0000000 --- a/HyperSet/set.js +++ /dev/null @@ -1,202 +0,0 @@ -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 deleted file mode 100644 index 592d3c0..0000000 --- a/HyperSet/set.php +++ /dev/null @@ -1,18 +0,0 @@ -start()); -} else if (isset($_GET['action']) && $_GET['action'] == 'submit'){ - $deck = $_SESSION['deck']; - echo json_encode($deck->threeMore()); -} \ No newline at end of file