Merge branch 'master' of https://codefirst.iut.uca.fr/git/HyperSet/HyperSet into algo
commit
6dd579ae16
@ -1,14 +1,19 @@
|
|||||||
# HyperSet
|
# HyperSet
|
||||||
|
|
||||||
## Description of the project
|
## Notes
|
||||||
|
|
||||||
2nd Year Project of IT BUT in Aubière
|
|
||||||
|
|
||||||
## Subject
|
- [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/)
|
||||||
|
|
||||||
|
## Description of the project
|
||||||
|
|
||||||
[link of the initial project](https://codefirst.iut.uca.fr/git/cedric.bouhours/Projets_SAE_S4/src/branch/master/Projets/Projet_11.md)
|
null
|
||||||
|
|
||||||
## Created by :
|
## Project Convention
|
||||||
|
|
||||||
LACOTE Raphaël JAULT Aurian ARNAL Rémi JACQUELIN Bastien
|
- Functions names must be explicit, complete and follow **camelCase** naming
|
||||||
|
- Variable follow **camelCase** naming convention
|
||||||
|
- Opening brace must be at end of line
|
||||||
|
- Directories names my_directory
|
||||||
|
- Files names -> my_file.js
|
||||||
|
- No useless comments
|
@ -1,19 +1,74 @@
|
|||||||
class Deck{
|
class Deck{
|
||||||
constructor(){
|
constructor(nbAttributes=4){
|
||||||
this.outputCards=this.createDeck();
|
this.allCards=this.createCards(nbAttributes);// All the cards in the game
|
||||||
this.setMade=[];
|
this.remainingCards=this.allCards;// cards in the stack
|
||||||
this.allCards=this.createCards();
|
this.outputCards=[];// 12 cards lay on the table
|
||||||
this.remainingCards=this.allCards;
|
this.setMade=[];// array with all the set already mades (array of set)
|
||||||
|
//this.createDeck();
|
||||||
}
|
}
|
||||||
createDeck(){
|
createDeck(){
|
||||||
for (let i=0; i<12; i++){
|
for (let i=0; i<12; i++){
|
||||||
|
const rand = this.getRandCard();
|
||||||
|
this.outputCards.push(this.remainingCards[rand]);
|
||||||
|
this.remainingCards.splice(rand,1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getRandCard(){
|
getRandCard(){
|
||||||
Math.floor(Math.random() * remainingCards.length);
|
const random = Math.floor(Math.random() * this.remainingCards.length);
|
||||||
|
return random;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {*} nbAttributes : attributes of the card, by default = 4
|
||||||
|
* @returns all cards: 81 in case of 4 attributes and 1224
|
||||||
|
*/
|
||||||
|
createCards(nbAttributes){
|
||||||
|
const tabColor = ['red','purple','green','blue','orange'];
|
||||||
|
const tabNumber = [1,2,3,4,5];
|
||||||
|
const tabShape = ['diamond','oval','wave','star','circle'];
|
||||||
|
const tabFilling = ['empty','stripped','full','pointed','squared'];
|
||||||
|
const tabOutline = ['full','dotted ','aa','bb','cc'];
|
||||||
|
let tabOfAllCards=[];
|
||||||
|
for (let c=0; c<nbAttributes-1; c++){
|
||||||
|
for (let n=0; n<nbAttributes-1; n++){
|
||||||
|
for (let s=0; s<nbAttributes-1; s++){
|
||||||
|
for (let f=0; f<nbAttributes-1; f++){
|
||||||
|
if(nbAttributes==4){
|
||||||
|
tabOfAllCards.push(new Card(tabColor[c],tabNumber[n],tabShape[s],tabFilling[f]));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
for(let o=0;o<nbAttributes-1;o++){
|
||||||
|
tabOfAllCards.push(new Card5(tabColor[c],tabNumber[n],tabShape[s],tabFilling[f],tabOutline[o]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tabOfAllCards;
|
||||||
|
}
|
||||||
|
checkSet(selectedCards){
|
||||||
|
if(true){//isSet(selectedCards)){
|
||||||
|
selectedCards.forEach(e => {
|
||||||
|
this.removeFromRemainingCards(e);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
removeFromRemainingCards(selectedCards){//better check of card type more opti
|
||||||
|
let set=[];
|
||||||
|
for(let i=0; i<this.allCards.length;i++){
|
||||||
|
let e = this.allCards[i]
|
||||||
|
if(e.equals(selectedCards)){
|
||||||
|
set.push(e);
|
||||||
|
this.allCards.splice(i,1);
|
||||||
|
console.log("card remove : "+e.color,e.number,e.filling,e.shape);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(set.length!=1){
|
||||||
|
throw new UnFoundCardException(selectedCards);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
this.setMade.push(set);
|
||||||
}
|
}
|
||||||
createCards(){
|
|
||||||
return 456;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
class UnFoundCardException extends Error{
|
||||||
|
constructor(card){
|
||||||
|
super(`Card ${card.color +" "+ card.shape+ " " + card.number +" "+ card.filling} is missing`);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue