diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..d365e34 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,40 @@ +kind: pipeline +type: docker +name: HyperSet + +trigger: + event: + - push + +steps: + + - name: hyperset-build + image: plugins/docker + settings: + dockerfile: Dockerfile + context: . + registry: hub.codefirst.iut.uca.fr + repo: hub.codefirst.iut.uca.fr/remi.arnal/hyper-set + username: + from_secret: registry_username + password: + from_secret: registry_password + + - name: hyperset-deployment + image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest + environment: + IMAGENAME: hub.codefirst.iut.uca.fr/remi.arnal/hyper-set:latest + CONTAINERNAME: hyperset + COMMAND: create + OVERWRITE: true + ADMINS: aurianjault,raphaellacote,bastienjacquelin,remiarnal + depends_on : [hyperset-build] + + - name: code-analysis + image: sonarsource/sonar-scanner-cli + environment: + SONAR_TOKEN: + from_secret: SONAR_TOKEN + commands: + - sonar-scanner -Dsonar.projectKey=hyperset -Dsonar.sources=. -Dsonar.host.url=https://codefirst.iut.uca.fr/sonar -Dsonar.login=$${SONAR_TOKEN} + depends_on: [ hyperset-build ] \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a0f4c14 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,2 @@ +FROM httpd +COPY ./ /usr/local/apache2/htdocs/ \ No newline at end of file diff --git a/README.md b/README.md index 5624f99..6c760b3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # HyperSet ## Notes - +- [Website link](https://codefirst.iut.uca.fr/containers/HyperSet-hyperset) - [Project subject](https://codefirst.iut.uca.fr/git/cedric.bouhours/Projets_SAE_S4/src/branch/master/Projets/Projet_11.md) - [Original project website](https://sancy.iut.uca.fr/~lafourcade/hyper-set-reda/HyperSet/) diff --git a/index.html b/index.html new file mode 100644 index 0000000..842313c --- /dev/null +++ b/index.html @@ -0,0 +1,47 @@ + + + + + + HyperSet + + + + + + +
+ +
+ +
+
+

HyperSet

+ Find all the Sets ! + +
+ +
+ +
+ Connected players: 1345 + Total Played Games: 1,455,876 +
+ +
+ +
+ + + + \ No newline at end of file diff --git a/src/Console/main.js b/src/Console/main.js index a349a7b..0d00811 100644 --- a/src/Console/main.js +++ b/src/Console/main.js @@ -3,12 +3,14 @@ //import {Card} from '../Model/Card'; console.log("~#Test#~"); -let card4 = new Card('red','2','losange','full'); +let card4 = new Card4WithoutOutline('red','2','losange','full'); console.group('Carte 4 attributes'); console.log(`carte de 4 elements : ${card4.color}`); console.groupEnd(); + let card5 = new Card5('blue','2','losange','full','pointillet'); console.group('Carte 5 attributes'); +console.log(`carte de 5 elements : ${card5.color}`); console.log(`carte de 5 elements : ${card5.outline}`); console.log(`carte de 5 éléments instance de 5: ${card5 instanceof Card5}`); console.log(`carte de 5 éléments accès par méthode idx 0: ${card5.getAttributes()[0]}`); @@ -26,45 +28,68 @@ try { } } console.groupEnd(); -console.group('Deck'); -let deck = new Deck(4); -console.log(`All cards with 4 attributes size ${deck.allCards.length}`); -console.log(`size ${deck.outputCards.length}`); +// CREATE DECK + +console.group('Deck'); +let deck = new Deck([0,1,2,3],3); +console.log(`All cards : ${deck.allCards.length}`); +//Display all cards +console.log(`All cards display`); // deck.allCards.forEach(e => { -// console.log(e.color,e.number,e.shape,e.filling); +// console.log(e.color,e.number,e.shape,e.filling);//no outline +// //console.log(e.color,e.number,e.filling,e.outline);//no shape +// //console.log(e.color,e.number,e.shape,e.outline);//no filling // }); -console.log(`Output cards`); +console.log(`remaining cards : ${deck.remainingCards.length}`) +// deck.remainingCards.forEach(e => { +// console.log(e.getAttributes()); +// }); +console.log(`size output ${deck.outputCards.length}`); +console.group('Output cards'); deck.outputCards.forEach(e => { - console.log(e.color,e.number,e.shape,e.filling); + console.log(e.getAttributes()); }); +console.groupEnd(); console.log(`set already made ${deck.setMade}`); - -deck.allCards.forEach(e => { +deck.setMade.forEach(e => { console.log(e.color,e.number,e.shape,e.filling); }); -let customCard=[new Card('red',1,'diamond','stripped')]; + + +// CHECK SET +console.log("CHECKING SET") + +console.log("Card to remove: ") +console.log(deck.outputCards[0].getAttributes(),deck.outputCards[1].getAttributes(),deck.outputCards[2].getAttributes()) +let customCard=[deck.outputCards[0],deck.outputCards[1],deck.outputCards[2]]; deck.checkSet(customCard); -console.log(`deck size :${deck.allCards.length}`); -deck.allCards.forEach(e => { - console.log(e.color,e.number,e.shape,e.filling); +console.log(`remaining cards : ${deck.remainingCards.length}`) +console.log(`All cards : ${deck.allCards.length}`) +// deck.remainingCards.forEach(e => { +// console.log(e.getAttributes()); +// }); +console.log(`size output ${deck.outputCards.length}`); +console.group('Output cards'); +deck.outputCards.forEach(e => { + console.log(e.getAttributes()); }); -console.log(`remaining cars:`); +console.groupEnd(); + +console.group('set made'); +console.log(`set already made : ${deck.setMade.length}`); deck.setMade.forEach(e => { console.log(e.color,e.number,e.shape,e.filling); }); + console.groupEnd(); -let deck5 = new Deck(5) -console.log(`All cards with 5 attributes size ${deck5.allCards.length}`); +//let deck5 = new Deck([0,1,2,3,4]); +//console.log(`All cards with 5 attributes size ${deck5.allCards.length}`); // deck5.allCards.forEach(e => { // console.log(e.color,e.number,e.shape,e.filling,e.outline); // }); //console.log(`Remaining cards ${deck.remainingCards}`); //console.log(`random : ${deck.getRandCard()}`); - - - - console.groupEnd(); diff --git a/src/Model/Card.js b/src/Model/Card.js index 0b8997b..45c5972 100644 --- a/src/Model/Card.js +++ b/src/Model/Card.js @@ -1,36 +1,15 @@ class Card{ - constructor(color, number, shape, filling){ - if(!color){ - throw new EmptyParamaterException('Color'); - } - if(!number){ - throw new EmptyParamaterException('Number'); - } - if(!shape){ - throw new EmptyParamaterException('Shape'); - } - if(!filling){ - throw new EmptyParamaterException('Filling'); - } - this.color=color; - this.number=number; - this.shape=shape; - this.filling=filling; - } + constructor(){} /** - * @returns array of all attributes : - idx 1 : color - idx 2 : number - idx 3 : shape - idx 4 : filling - idx 5 : null - * @author Bastien Jacquelin + * + * @returns all attributes of a card */ - getAttributes(){ - return [this.color,this.number,this.shape,this.filling]; - } - equals(card){ - return this.color===card.color && this.number===card.number && this.shape===card.shape && this.filling===card.filling; - } + getAttributes(){} + /** + * + * @param {*} card card to be compared with the current obj + * @returns boolean + */ + equals(card){} }//export {Card} \ No newline at end of file diff --git a/src/Model/Card4WithoutColor.js b/src/Model/Card4WithoutColor.js new file mode 100644 index 0000000..cbad689 --- /dev/null +++ b/src/Model/Card4WithoutColor.js @@ -0,0 +1,27 @@ +class Card4WithoutColor extends Card{ + constructor(number, shape, filling, outline){ + super(); + if(number==''){ + throw new EmptyParamaterException('Number'); + } + if(shape==''){ + throw new EmptyParamaterException('Shape'); + } + if(filling==''){ + throw new EmptyParamaterException('Filling'); + } + if(outline==''){ + throw new EmptyParamaterException('Outline'); + } + this.number=number; + this.shape=shape; + this.filling=filling; + this.outline=outline; + } + getAttributes(){ + return [this.number,this.shape,this.filling,this.outline]; + } + equals(card){ + return this.number===card.number && this.shape===card.shape && this.filling===card.filling && this.outline===card.outline ; + } +} \ No newline at end of file diff --git a/src/Model/Card4WithoutFilling.js b/src/Model/Card4WithoutFilling.js new file mode 100644 index 0000000..b895c07 --- /dev/null +++ b/src/Model/Card4WithoutFilling.js @@ -0,0 +1,27 @@ +class Card4WithoutFilling extends Card{ + constructor(color,number, shape, outline){ + super(); + if(number==''){ + throw new EmptyParamaterException('Number'); + } + if(shape==''){ + throw new EmptyParamaterException('Shape'); + } + if(color==''){ + throw new EmptyParamaterException('Color'); + } + if(outline==''){ + throw new EmptyParamaterException('Outline'); + } + this.number=number; + this.shape=shape; + this.color=color; + this.outline=outline; + } + getAttributes(){ + return [this.number,this.shape,this.color,this.outline]; + } + equals(card){ + return this.number===card.number && this.shape===card.shape && this.color===card.color && this.outline===card.outline ; + } +} \ No newline at end of file diff --git a/src/Model/Card4WithoutNumber.js b/src/Model/Card4WithoutNumber.js new file mode 100644 index 0000000..95abc61 --- /dev/null +++ b/src/Model/Card4WithoutNumber.js @@ -0,0 +1,27 @@ +class Card4WithoutNumber extends Card{ + constructor(color, shape, filling, outline){ + super(); + if(color==''){ + throw new EmptyParamaterException('Color'); + } + if(shape==''){ + throw new EmptyParamaterException('Shape'); + } + if(filling==''){ + throw new EmptyParamaterException('Filling'); + } + if(outline==''){ + throw new EmptyParamaterException('Outline'); + } + this.color=color; + this.shape=shape; + this.filling=filling; + this.outline=outline; + } + getAttributes(){ + return [this.color,this.shape,this.filling,this.outline]; + } + equals(card){ + return this.color===card.color && this.shape===card.shape && this.filling===card.filling && this.outline===card.outline ; + } +} \ No newline at end of file diff --git a/src/Model/Card4WithoutOutline.js b/src/Model/Card4WithoutOutline.js new file mode 100644 index 0000000..b1db83c --- /dev/null +++ b/src/Model/Card4WithoutOutline.js @@ -0,0 +1,27 @@ +class Card4WithoutOutline extends Card{ + constructor(color, number, shape, filling){ + super(); + if(color==''){ + throw new EmptyParamaterException('Color'); + } + if(number==''){ + throw new EmptyParamaterException('Number'); + } + if(shape==''){ + throw new EmptyParamaterException('Shape'); + } + if(filling==''){ + throw new EmptyParamaterException('Filling'); + } + this.color=color; + this.number=number; + this.shape=shape; + this.filling=filling; + } + getAttributes(){ + return [this.color,this.number,this.shape,this.filling]; + } + equals(card){ + return this.number===card.number && this.shape===card.shape && this.filling===card.filling && this.color===card.color; + } +} \ No newline at end of file diff --git a/src/Model/Card4WithoutShape.js b/src/Model/Card4WithoutShape.js new file mode 100644 index 0000000..bf0d36c --- /dev/null +++ b/src/Model/Card4WithoutShape.js @@ -0,0 +1,27 @@ +class Card4WithoutShape extends Card{ + constructor(color,number, filling, outline){ + super(); + if(color==''){ + throw new EmptyParamaterException('Color'); + } + if(number==''){ + throw new EmptyParamaterException('Number'); + } + if(filling==''){ + throw new EmptyParamaterException('Filling'); + } + if(outline==''){ + throw new EmptyParamaterException('Outline'); + } + this.color=color; + this.number=number; + this.filling=filling; + this.outline=outline; + } + getAttributes(){ + return [this.number,this.color,this.filling,this.outline]; + } + equals(card){ + return this.number===card.number && this.color===card.color && this.filling===card.filling && this.outline===card.outline ; + } +} \ No newline at end of file diff --git a/src/Model/Card5.js b/src/Model/Card5.js index bead780..a22e47a 100644 --- a/src/Model/Card5.js +++ b/src/Model/Card5.js @@ -2,10 +2,26 @@ class Card5 extends Card { constructor(color, number, shape, filling, outline){ - super(color,number,shape,filling); - if(!outline){ + super(); + if(color==''){ + throw new EmptyParamaterException('Color'); + } + if(number==''){ + throw new EmptyParamaterException('Number'); + } + if(shape==''){ + throw new EmptyParamaterException('Shape'); + } + if(filling==''){ + throw new EmptyParamaterException('Filling'); + } + if(outline==''){ throw new EmptyParamaterException('Outline'); } + this.color=color; + this.number=number; + this.shape=shape; + this.filling=filling; this.outline=outline; } /** @@ -18,8 +34,7 @@ class Card5 extends Card { * @author Bastien Jacquelin */ getAttributes(){ - // return [this.color,this.number,this.shape,this.filling,this.outline]; - return super.getAttributes().concat(this.outline); + return [this.color,this.number,this.shape,this.filling,this.outline]; } equals(card){ return this.color===card.color && this.number===card.number && this.shape===card.shape && this.filling===card.filling && this.outline===card.outline ; diff --git a/src/Model/Const.js b/src/Model/Const.js new file mode 100644 index 0000000..201e43e --- /dev/null +++ b/src/Model/Const.js @@ -0,0 +1,6 @@ +const tabColor = ['red','purple','green','blue','orange']; +const tabNumber = [1,2,3,4,5]; +const tabShape = ['diamond','oval','wave','star','triangle']; +const tabFilling = ['empty','stripped','full','pointed','squared']; +const tabOutline = ['full','dotted ','hyphen','cloudy','sharpy']; +const ATTRIBUTES=[tabColor,tabNumber,tabShape,tabFilling,tabOutline] \ No newline at end of file diff --git a/src/Model/Deck.js b/src/Model/Deck.js index 5be6949..03fe67f 100644 --- a/src/Model/Deck.js +++ b/src/Model/Deck.js @@ -1,74 +1,82 @@ class Deck{ - constructor(nbAttributes=4){ - this.allCards=this.createCards(nbAttributes);// All the cards in the game - this.remainingCards=this.allCards;// cards in the stack + /** + * + * @param {*} attributes : array with the attributes index for the cards + * @author Bastien Jacquelin + */ + constructor(attributes,nbCards){ + //console.log(attributes); + this.allCards=this.createCards(attributes);// All the cards in the game + this.remainingCards=[] + this.nbCards=nbCards; + this.remainingCards=this.remainingCards.concat(this.allCards);// cards in the stack this.outputCards=[];// 12 cards lay on the table this.setMade=[];// array with all the set already mades (array of set) - //this.createDeck(); + this.createDeck(12); } - createDeck(){ - for (let i=0; i<12; i++){ + /** + * @brief creation of the deck : 12 cards lay in front of the player + * @author Bastien Jacquelin + */ + createDeck(nbCards){ + for (let i=0; i { - this.removeFromRemainingCards(e); - }); + this.removeFromoutputCards(selectedCards); } } - removeFromRemainingCards(selectedCards){//better check of card type more opti + /** + * @brief when a set is made, need to remove the card from the array remainingCards + * @param {*} selectedCards cards which need to be removed from the outputcards + * @author Bastien Jacquelin + */ + removeFromoutputCards(selectedCards){//better check of card type more opti let set=[]; - for(let i=0; i { + for(let i=0; i + + + + + HyperSet + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + \ No newline at end of file