Compare commits

..

46 Commits

Author SHA1 Message Date
remrem 792122ffaa fix bug when shape have empty filling and an outline
continuous-integration/drone/push Build is passing Details
2 years ago
remrem d59ce13b7b conflicts
continuous-integration/drone/push Build is passing Details
2 years ago
remrem d3823183d9 trop de choses
2 years ago
Bastien JACQUELIN 17d0fb6c97 Merge branch 'master' of https://codefirst.iut.uca.fr/git/HyperSet/HyperSet
continuous-integration/drone/push Build is passing Details
2 years ago
Bastien JACQUELIN bd9c12f63c deck define in the rooom page
2 years ago
Aurian JAULT 28cd162516 Merge pull request 'card-class' (#88) from card-class into master
continuous-integration/drone/push Build is passing Details
2 years ago
Aurian JAULT 9e4e206b59 opti checkattributes
continuous-integration/drone/push Build is passing Details
2 years ago
Bastien JACQUELIN ba3be75ddb add favicon on pages
continuous-integration/drone/push Build is passing Details
2 years ago
Bastien JACQUELIN ec42198642 fix end of game bug
continuous-integration/drone/push Build is passing Details
2 years ago
Aurian JAULT 869d0d6f89 Merge branch 'master' of https://codefirst.iut.uca.fr/git/HyperSet/HyperSet into card-class
continuous-integration/drone/push Build is passing Details
2 years ago
Aurian JAULT 070a72162c update Checkqttriutes
continuous-integration/drone/push Build is passing Details
2 years ago
Bastien JACQUELIN e54a8e652f add {
continuous-integration/drone/push Build is passing Details
2 years ago
Bastien JACQUELIN bef330d194 Merge branch 'master' of https://codefirst.iut.uca.fr/git/HyperSet/HyperSet
continuous-integration/drone/push Build is passing Details
2 years ago
Bastien JACQUELIN 4cd4a11383 fix bug end of game
2 years ago
remrem c7ddd44f54 just add an emoji
continuous-integration/drone/push Build is passing Details
2 years ago
remrem cc4eebe0ab zoomed form in cards and center game div
continuous-integration/drone/push Build is passing Details
2 years ago
remrem 397a9de18c Merge branch 'master' of https://codefirst.iut.uca.fr/git/HyperSet/hyper-set
2 years ago
Bastien JACQUELIN 11fcaadbef fix end of game
continuous-integration/drone/push Build is passing Details
2 years ago
remrem 0e45e5e73d Merge branch 'master' of https://codefirst.iut.uca.fr/git/HyperSet/hyper-set
2 years ago
Bastien JACQUELIN 12416b979a fix
continuous-integration/drone/push Build is passing Details
2 years ago
remrem 3815ab4fb2 Merge branch 'master' of https://codefirst.iut.uca.fr/git/HyperSet/hyper-set
2 years ago
Bastien JACQUELIN 71eb7e0d42 fix
continuous-integration/drone/push Build is passing Details
2 years ago
remrem 8c082aaef9 Merge branch 'master' of https://codefirst.iut.uca.fr/git/HyperSet/hyper-set
2 years ago
Bastien JACQUELIN a2b05084de Merge branch 'master' of https://codefirst.iut.uca.fr/git/HyperSet/hyper-set
continuous-integration/drone/push Build is passing Details
2 years ago
Bastien JACQUELIN 1868a12a4e fix
2 years ago
remrem 26dfe10ece Merge branch 'master' of https://codefirst.iut.uca.fr/git/HyperSet/hyper-set
2 years ago
remrem 2293e6f304 tw
2 years ago
Aurian JAULT 54d319ef6c Mise à jour de 'src/algo.js'
continuous-integration/drone/push Build is passing Details
2 years ago
remrem 7fe0e5f7f7 card horizontal -> vertical
continuous-integration/drone/push Build is passing Details
2 years ago
remrem 430632932b css to be responsive (a moitié)
continuous-integration/drone/push Build is passing Details
2 years ago
remrem 8f1f6cf7dd Merge branch 'master' of https://codefirst.iut.uca.fr/git/HyperSet/hyper-set
continuous-integration/drone/push Build is passing Details
2 years ago
Bastien JACQUELIN 83bf3ef838 add win message
continuous-integration/drone/push Build is passing Details
2 years ago
remrem 44cce9f48b Merge branch 'master' of https://codefirst.iut.uca.fr/git/HyperSet/hyper-set
2 years ago
remrem 128d641657 tweaks + bug
2 years ago
Bastien JACQUELIN 76d2378146 fix bug, now remove the element key + value in the selectedCard array
continuous-integration/drone/push Build is passing Details
2 years ago
Bastien JACQUELIN 1ff4e91de4 remove red outline when 3 card selected
continuous-integration/drone/push Build is passing Details
2 years ago
Bastien JACQUELIN 2fe9c94bdd navigation between pages
continuous-integration/drone/push Build is passing Details
2 years ago
remrem 02f974126e Merge pull request 'roomPage' (#84) from roomPage into master
continuous-integration/drone/push Build is passing Details
2 years ago
remrem bf237efc15 pull master + resolve conflicts
continuous-integration/drone/push Build is passing Details
2 years ago
remrem 4a0aed7345 add card-to-html to game.html + lots of things
continuous-integration/drone/push Build is passing Details
2 years ago
remrem 8c99f9408b conflict index.html ok
continuous-integration/drone/push Build is passing Details
2 years ago
remrem c73b7b6859 i want to pull master
continuous-integration/drone/push Build is passing Details
2 years ago
remrem 0e5f32f673 roomPage.html css + idk
continuous-integration/drone/push Build is passing Details
2 years ago
remrem 5a68199adb rewrite all tests cards with new constructor
continuous-integration/drone/push Build is passing Details
2 years ago
remrem 1177bb3889 a lot of things: repair code, room.css ...
continuous-integration/drone/push Build is passing Details
2 years ago
remrem d51368dc3e create room.html + room.css
continuous-integration/drone/push Build is passing Details
2 years ago

2
.gitignore vendored

@ -0,0 +1,2 @@
# because you don't need to know what's in here
note.txt

@ -7,6 +7,7 @@
<!-- <base href="https://codefirst.iut.uca.fr/containers/HyperSet-hyperset/"> --> <!-- <base href="https://codefirst.iut.uca.fr/containers/HyperSet-hyperset/"> -->
<link rel="stylesheet" type="text/css" href="./styles/style.css"> <link rel="stylesheet" type="text/css" href="./styles/style.css">
<link rel="stylesheet" type="text/css" href="./styles/index.css"> <link rel="stylesheet" type="text/css" href="./styles/index.css">
<link rel="icon" type="image/x-icon" href="/resources/favicon.ico">
</head> </head>
<body> <body>
@ -37,9 +38,15 @@
</div> </div>
<div id="right" class="column"> <div id="right" class="column">
<button class="action-button">Create solo game</button> <button id="soloGame" class="action-button">Create solo game</button>
<button class="action-button">Join game</button> <button class="action-button">Join game</button>
<button class="action-button">New Game</button> <button id="newGame" class="action-button">New Game</button>
<script>
let button=document.querySelector("#soloGame")
button.addEventListener('click', event => {
window.location.href = "/views/game.html";
});
</script>
</div> </div>
</div> </div>

@ -1,11 +1,13 @@
class Card{ class Card {
/** /**
* *
* @param {*} attributes : dictionnary of attributes : key : name of the attributes and value : value of the attributes * @param {*} attributes : dictionnary of attributes : key : name of the attributes and value : value of the attributes
*/ */
// attributes : shape, color, number, outline, filling
constructor(attributes){ constructor(attributes){
this.attributes=attributes; this.attributes=attributes;
} }
/** /**
* *
* @returns all attributes of a card * @returns all attributes of a card
@ -17,6 +19,7 @@ class Card{
}); });
return att; return att;
} }
/** /**
* *
* @param {*} card card to be compared with the current obj * @param {*} card card to be compared with the current obj

@ -1,6 +1,6 @@
const TAB_COLOR = ['red', 'purple', 'green', 'blue', 'orange']; const TAB_COLOR = ['red', 'purple', 'green', 'blue', 'orange'];
const TAB_NUMBER = [1, 2, 3, 4, 5]; const TAB_NUMBER = [1, 2, 3, 4, 5];
const TAB_SHAPE = ['diamond', 'oval', 'squiggle', 'star', 'triangle']; const TAB_SHAPE = ['diamond', 'oval', 'squiggle', 'triangle', 'star'];
const TAB_FILLING = ['empty', 'stripped', 'full', 'pointed', 'squared']; const TAB_FILLING = ['empty', 'stripped', 'full', 'pointed', 'squared'];
const TAB_OUTLINE = ['continuous', 'dot', 'rect', 'spade', 'sharp']; const TAB_OUTLINE = ['continuous', 'dot', 'rect', 'spade', 'sharp'];
const ATTRIBUTES = [TAB_COLOR, TAB_NUMBER, TAB_SHAPE, TAB_FILLING, TAB_OUTLINE]; const ATTRIBUTES = [TAB_COLOR, TAB_NUMBER, TAB_SHAPE, TAB_FILLING, TAB_OUTLINE];
@ -15,9 +15,9 @@ const SHAPE_PATH = {
}; };
const OUTLINE_SPEC = { const OUTLINE_SPEC = {
full: {}, continuous: {},
dot: { "stroke-dasharray": "1 20", "stroke-linecap": "round" }, dot: { "stroke-dasharray": "1 25", "stroke-linecap": "round" },
rect: { "stroke-dasharray": 70 }, rect: { "stroke-dasharray": 70 },
spade: { "stroke-dasharray": "10 15", "stroke-width": 40 }, spade: { "stroke-dasharray": "10 15", "stroke-width": 40 },
sharp: {} sharp: { "stroke-dasharray": "30 30", "stroke-width": 25 }
}; };

@ -29,8 +29,12 @@ class Deck {
*/ */
createDeck(nbCards) {//toTest⌛when more than 12c to d't add other cards createDeck(nbCards) {//toTest⌛when more than 12c to d't add other cards
if (this.remainingCards.length < this.nbCards) {// no more cards if (this.remainingCards.length < this.nbCards) {// no more cards
console.log("PLUS DE CARTES"); if(setsCounter(this.outputCards, this.nbCards)==0){
return; return 2;
}
else{
return 1;
}
} }
else { else {
let nbSets = setsCounter(this.outputCards, this.nbCards); let nbSets = setsCounter(this.outputCards, this.nbCards);
@ -45,8 +49,6 @@ class Deck {
} }
nbSets = setsCounter(this.outputCards, this.nbCards); nbSets = setsCounter(this.outputCards, this.nbCards);
console.log("nbSets", nbSets); console.log("nbSets", nbSets);
// console.log("outputCards.length", this.outputCards.length);
// console.log("remainingCards.length", this.remainingCards.length);
if (nbSets == 0) { if (nbSets == 0) {
this.createDeck(this.nbCards) this.createDeck(this.nbCards)
} }
@ -70,21 +72,31 @@ class Deck {
* @author Bastien Jacquelin * @author Bastien Jacquelin
*/ */
checkSet(selectedCards) {//toTest⌛ checkSet(selectedCards) {//toTest⌛
if (true) {//isSet(selectedCards)){// is a set console.log("nb set",setsCounter(this.outputCards, this.nbCards))
if (this.outputCards.length == 0) { if (isSet(selectedCards)){// is a set
if (this.outputCards.length == 0) {//plus de deck
console.log("C'est win") console.log("C'est win")
return 2; return 2;
} }
else { else {//encore des cartes sur le deck
this.removeFromoutputCards(selectedCards); if(this.remainingCards.length < this.nbCards){// plus de pile
return 1; if(setsCounter(this.outputCards, this.nbCards) == 0){//plus de set mais encore des cartes dans le deck
return 2;
}
else{//encore des set
console.log("plus la pile")
return this.removeFromoutputCards(selectedCards);
}
}
else{// encore de la pile
console.log("encore de la pile")
return this.removeFromoutputCards(selectedCards);
}
} }
} }
else if (this.remainingCards.length < this.nbCards) { else{// pas un set
console.log("C'est win") return -1;
return 2;
} }
return 0;
} }
/** /**
@ -93,6 +105,7 @@ class Deck {
* @author Bastien Jacquelin * @author Bastien Jacquelin
*/ */
removeFromoutputCards(selectedCards) {//working✅ removeFromoutputCards(selectedCards) {//working✅
console.log(JSON.parse(JSON.stringify(selectedCards)))
let set = []; let set = [];
selectedCards.forEach(element => { selectedCards.forEach(element => {
for (let i = 0; i < this.outputCards.length; i++) { for (let i = 0; i < this.outputCards.length; i++) {
@ -108,7 +121,7 @@ class Deck {
} }
else { else {
this.setMade.push(set); this.setMade.push(set);
this.createDeck(this.nbCards) return this.createDeck(this.nbCards)
} }
} }
} }

@ -81,9 +81,10 @@ class Factory{
let attributes=this.attributesName(dicoAttributes); let attributes=this.attributesName(dicoAttributes);
let nbAttributes=this.nbAttr; let nbAttributes=this.nbAttr;
if(attributes.length==3){ if(attributes.length==3){
for (let c=0; c<nbAttributes; c++){ for (let a=0; a<nbAttributes; a++){
for (let n=0; n<nbAttributes; n++){ for (let b=0; b<nbAttributes; b++){
for (let s=0; s<nbAttributes; s++){ for (let c=0; c<nbAttributes; c++){
let attribDic = {};
attribDic[attributes[0]]=dicoAttributes[attributes[0]][a] attribDic[attributes[0]]=dicoAttributes[attributes[0]][a]
attribDic[attributes[1]]=dicoAttributes[attributes[1]][b] attribDic[attributes[1]]=dicoAttributes[attributes[1]][b]
attribDic[attributes[2]]=dicoAttributes[attributes[2]][c] attribDic[attributes[2]]=dicoAttributes[attributes[2]][c]
@ -114,6 +115,7 @@ class Factory{
for (let c=0; c<nbAttributes; c++){ for (let c=0; c<nbAttributes; c++){
for (let d=0; d<nbAttributes; d++){ for (let d=0; d<nbAttributes; d++){
for (let e=0; e<nbAttributes; e++){ for (let e=0; e<nbAttributes; e++){
let attribDic = {};
attribDic[attributes[0]]=dicoAttributes[attributes[0]][a] attribDic[attributes[0]]=dicoAttributes[attributes[0]][a]
attribDic[attributes[1]]=dicoAttributes[attributes[1]][b] attribDic[attributes[1]]=dicoAttributes[attributes[1]][b]
attribDic[attributes[2]]=dicoAttributes[attributes[2]][c] attribDic[attributes[2]]=dicoAttributes[attributes[2]][c]

@ -1,7 +1,7 @@
class CardToHtml { class CardToHtml {
static create(card) { static create(card) {
const gameWindow = document.querySelector('#main'); // const gamewindow = document.querySelector('#main');
const div = document.createElement('div'); const div = document.createElement('div');
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
@ -10,47 +10,53 @@ class CardToHtml {
svg.setAttribute('height','160'); svg.setAttribute('height','160');
svg.setAttribute('width','80'); svg.setAttribute('width','80');
svg.setAttribute('viewBox','0 0 200 400'); svg.setAttribute('viewBox','0 0 200 400');
if(card.attributes['number'] == undefined){
card.attributes['number'] = 1;
}
// Create paths + add to svg // Create paths + add to svg
for(let j = 0; j < 2; j++) { for(let j = 0; j < 2; j++) {
const path = this.createPath(card.shape,card.color,card.filling,card.outline,j); // Faut pas oublier le j à la fin hein, c'est pas une typo
const path = this.createPath(card.attributes['shape'], card.attributes['color'], card.attributes['filling'], card.attributes['outline'], j);
svg.appendChild(path); svg.appendChild(path);
} }
// Loop to add svg card.number times // Loop to add svg card.number times
for(let i = 0; i < card.number; i++) { for(let i = 0; i < card.attributes['number']; i++) {
div.appendChild(svg.cloneNode(true)) div.appendChild(svg.cloneNode(true))
} }
gameWindow.appendChild(div); // gamewindow.appendChild(div);
return div;
} }
static createPath(shape,color,filling,outline,step) { static createPath(shape,color,filling,outline,step) {
// The way to create svg element (differs from html element) // The way to create svg element (differs from html element)
const path = document.createElementNS("http://www.w3.org/2000/svg", "path"); const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
if(shape === null) shape = 'oval'; if(shape === undefined) shape = 'oval';
if(color === null) color = '000000'; if(color === undefined) color = 'black';
if(filling === null) filling = 'fill'; if(filling === undefined) filling = 'empty';
// Add lots of attributes // Add lots of attributes
path.setAttribute("d",SHAPE_PATH[shape]); path.setAttribute("d",SHAPE_PATH[shape]);
path.setAttribute('stroke',`#${color}`); path.setAttribute('stroke',`${color}`);
path.setAttribute('fill',`#${color}`); path.setAttribute('fill',`${color}`);
path.setAttribute('stroke-width','18'); path.setAttribute('stroke-width','18');
// Case shape do not have color // Case shape do not have color
if(filling === 'none') { if(filling === 'none' || filling === 'empty') {
path.setAttribute('fill','none'); path.setAttribute('fill','none');
} }
// Add svg attributes for shape outline // Add svg attributes for shape outline
if(outline !== null){ if(outline !== null && outline!==undefined) {
Object.keys(OUTLINE_SPEC[outline]).forEach(function(k){ Object.keys(OUTLINE_SPEC[outline]).forEach(function(k) {
path.setAttribute(k,OUTLINE_SPEC[outline][k]); path.setAttribute(k,OUTLINE_SPEC[outline][k]);
}); });
if(filling == 'empty') path.setAttribute('stroke',color);
path.setAttribute('stroke','#000000'); else path.setAttribute('stroke','black');
} }
// Diff between two paths in svg // Diff between two paths in svg

@ -14,14 +14,28 @@ function isSet(cards)
for(let j = 0; j < attributesMatrix.length; j++) { for(let j = 0; j < attributesMatrix.length; j++) {
listAttributes.push(attributesMatrix[j][i]); listAttributes.push(attributesMatrix[j][i]);
} }
if(!checkAttributes(listAttributes)){ console.log("JE SUIS LES ATTRIBUTS")
console.log(listAttributes)
if(!checkAttributes2(listAttributes,attributesMatrix.length)){
return false; return false;
} }
} }
console.log(cards)
return true; return true;
} }
function checkAttributes2(params,length) {
var tab = []
params.forEach(element => {
if (!tab.includes(element)) {
tab.push(element)
}
});
console.log(tab.length === 1 || tab.length === length)
return tab.length === 1 || tab.length === length;
}
function checkAttributes(attributes){ function checkAttributes(attributes){
let orderingMethod = "null"; // Can only take ["null", "same", "different"] let orderingMethod = "null"; // Can only take ["null", "same", "different"]
let boolLoop = true; let boolLoop = true;
@ -82,7 +96,7 @@ function numberOfSets4(deck){
for(j = i+1 ; j < deck.length - 2; j++){ for(j = i+1 ; j < deck.length - 2; j++){
for(k = j+1 ; k < deck.length - 1 ; k++){ for(k = j+1 ; k < deck.length - 1 ; k++){
for(l = k + 1 ; l < deck.length;l++){ for(l = k + 1 ; l < deck.length;l++){
if(isSet([deck[i],deck[j],deck[k]])){ if(isSet([deck[i],deck[j],deck[k],deck[l]])){
//console.log(deck[i],deck[j],deck[k],deck[l]) //console.log(deck[i],deck[j],deck[k],deck[l])
res += 1 res += 1
} }
@ -100,7 +114,7 @@ function numberOfSets5(deck){
for(k = j+1 ; k < deck.length - 2 ; k++){ for(k = j+1 ; k < deck.length - 2 ; k++){
for(l = k + 1 ; l < deck.length - 1;l++){ for(l = k + 1 ; l < deck.length - 1;l++){
for(m = l + 1; m <deck.length;m++){ for(m = l + 1; m <deck.length;m++){
if(isSet([deck[i],deck[j],deck[k]])){ if(isSet([deck[i],deck[j],deck[k],deck[l],deck[m]])){
//console.log(deck[i],deck[j],deck[k],deck[l],deck[m]) //console.log(deck[i],deck[j],deck[k],deck[l],deck[m])
res += 1 res += 1
} }

@ -1,19 +1,28 @@
.card { .card {
display: flex; display: flex;
flex-direction: row; flex-direction: column;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
height: 10rem; width: 6vw;
min-width: 20rem; min-height: 30vh;
padding: 3em; padding: 0.5em 1em 0.5em 1em;
margin: 1.7rem; /* for better display */ margin: 1.2rem; /* for better display */
border: 0.3em solid black; border: 0.3em solid black;
border-radius: 2em; border-radius: 2em;
background-color: white; background-color: white;
} }
.card:hover {
cursor: pointer;
}
svg {
rotate: 90deg;
height: 10vh;
width: 5vw;
}
.item { .item {
margin: 1rem;
} }
#main { #main {

@ -62,27 +62,6 @@
background-color: white; background-color: white;
} }
.action-button {
display: flex;
justify-content: center;
align-items: center;
width: 50%;
padding: 1.2em;
padding-top: 2.1rem;
background-color: white;
border: 0.2rem solid black;
border-radius: 0.5em;
font-family: var(--font);
font-size: 1.5em;
transition: 0.3s;
}
.action-button:hover {
background-color: black;
color: white;
transform: scale(1.2);
cursor: pointer;
}
h1 { h1 {
color: black; color: black;

@ -0,0 +1,72 @@
section {
display: flex;
padding: 3em;
flex-direction: column;
height: calc(100vh - 6em);
}
.title2 {
font-size: 4em;
margin-bottom: 1em;
}
.title3 {
font-size: 2em;
}
#left-section {
background-color: white;
width: 70vw;
}
#right-section {
display: flex;
justify-content: space-between;
background-color: white;
width: 30vw;
}
.button {
display: flex;
width: 30vw;
color: black;
justify-content: center;
align-items: center;
padding: 1.2em;
margin-bottom: 1em;
background-color: white;
border: 0.2rem solid black;
border-radius: 0.5em;
font-family: var(--font);
font-size: 1.5em;
transition: 0.3s;
}
.button:hover {
background-color: black;
color: white;
scale: 1.1;
}
.subtitle {
font-family: var(--font);
font-size: 1.6em;
font-weight: bold;
}
input[type="checkbox"] {
margin-left: 1rem;
}
.group {
margin-bottom: 5em;
}
.param {
margin-top: 1em;
}
#start {
bottom: 3vh;
right: 3vw;
}

@ -7,4 +7,27 @@
margin: 0; margin: 0;
border: 0; border: 0;
font-family: var(--font); font-family: var(--font);
}
.action-button {
display: flex;
justify-content: center;
align-items: center;
width: 50%;
padding: 1.2em;
padding-top: 2.1rem;
background-color: white;
border: 0.2rem solid black;
border-radius: 0.5em;
font-family: var(--font);
font-size: 1.5em;
transition: 0.3s;
}
.action-button:hover {
background-color: black;
color: white;
transform: scale(1.2);
cursor: pointer;
} }

@ -5,16 +5,30 @@ export default{
return{ return{
idUsed:"id"+this.id, idUsed:"id"+this.id,
isClicked:false, isClicked:false,
svgCard: CardToHtml.create(this.card)
} }
}, },
methods:{ methods:{
clicked() { clicked() {
this.$emit('selected',this.id); this.$emit('selected',this.id);
} },
},
// display svg card on component apparition
mounted() {
const cardDiv = document.querySelector(`#${this.idUsed}`);
cardDiv.appendChild(this.svgCard);
},
// change svg card when card object is updated
beforeUpdate() {
this.svgCard = CardToHtml.create(this.card)
const cardDiv = document.querySelector(`#${this.idUsed}`);
cardDiv.querySelector('.card').remove();
cardDiv.appendChild(this.svgCard);
}, },
template:` template:`
<div v-bind:id="idUsed" v-bind:style="{border: '2px solid black', color: 'red', fontSize: '20px', cursor: 'pointer',width:'100%',height:'100%' }" v-on:click="clicked"> <div v-bind:id="idUsed" v-on:click="clicked">
{{card.attributes}}
</div> </div>
` `
} }

@ -79,11 +79,11 @@
</svg> </svg>
<div id="main"> <div id="main">
<div class="card"> <!-- <div class="card">
<svg class="item" height="160" width="80" viewBox="0 0 200 400"> <svg class="item" height="160" width="80" viewBox="0 0 200 400">
<path <path
d="m98.544521,10.311863l-87.830189,189.330815l88.201143,189.644391l88.942329,-190.362741l-89.313283,-188.612465z" d="m67.892902,12.746785c43.231313,-6.717223 107.352741,6.609823 121.028973,58.746408c13.676233,52.136585 -44.848649,161.467192 -45.07116,204.650732c4.566246,56.959708 83.805481,87.929227 22.329944,105.806022c-61.475536,17.876795 -126.122496,-1.855045 -143.73294,-41.933823c-17.610444,-40.07878 49.274638,-120.109409 46.14822,-188.091997c-3.126418,-67.982588 -21.873669,-70.257464 -49.613153,-80.177084c-27.739485,-9.919618 5.678801,-52.283035 48.910115,-59.000258z"
stroke-dasharray="1 20" stroke-dasharray="1 20"
stroke-linecap="round" stroke-linecap="round"
stroke-width="18" stroke-width="18"
@ -93,7 +93,7 @@
/> />
<path <path
d="m98.544521,10.311863l-87.830189,189.330815l88.201143,189.644391l88.942329,-190.362741l-89.313283,-188.612465z" d="m67.892902,12.746785c43.231313,-6.717223 107.352741,6.609823 121.028973,58.746408c13.676233,52.136585 -44.848649,161.467192 -45.07116,204.650732c4.566246,56.959708 83.805481,87.929227 22.329944,105.806022c-61.475536,17.876795 -126.122496,-1.855045 -143.73294,-41.933823c-17.610444,-40.07878 49.274638,-120.109409 46.14822,-188.091997c-3.126418,-67.982588 -21.873669,-70.257464 -49.613153,-80.177084c-27.739485,-9.919618 5.678801,-52.283035 48.910115,-59.000258z"
stroke-dasharray="1 20" stroke-dasharray="1 20"
stroke-linecap="round" stroke-linecap="round"
stroke-width="18" stroke-width="18"
@ -103,25 +103,35 @@
/> />
</svg> </svg>
</div> </div> -->
</div> </div>
<script src="../src/Model/Card.js"></script> <script src="../src/Model/Card.js"></script>
<script src="../src/Model/Card5.js"></script>
<script src="../src/Model/Const.js"></script> <script src="../src/Model/Const.js"></script>
<script src="../src/Model/card-to-html.js"></script> <script src="../src/Model/card-to-html.js"></script>
<script> <script>
const testCard1 = new Card5('ed5467',3,'diamond','grid','rect'); // const testCard1 = new Card({shape: 'diamond', color: 'ed5467', number: 2, filling: 'grid', outline: 'rect'})
const testCard2 = new Card5('78ef56',3,'star','dot','dot'); // const testCard2 = new Card({shape: 'star', color: '78ef56', number: 3, filling: 'dot', outline: 'dot'});
const testCard3 = new Card5('79ec36',3,'squiggle','stripe','spade'); // const testCard3 = new Card({shape: 'squiggle', color: '79ec36', number: 2, filling: 'stripe', outline: 'spade'});
const testCard4 = new Card5('79ec36',3,'oval','full','full'); // const testCard4 = new Card({shape: 'oval', color: '79ec36', number: 3, filling: 'full', outline: 'full'});
const testCard5 = new Card5('79ec36',3,'triangle','none','spade'); // const testCard5 = new Card({shape: 'triangle', color: '79ec36', number: 3, filling: 'none', outline: 'spade'});
// const testCard6 = new Card({shape: 'squiggle', color: '008000', number: 1, filling: 'dot', outline: 'dot'});
// const testCard7 = new Card({shape: 'diamond', color: 'ff0000', number: 5, filling: 'stripe', outline: null});
CardToHtml.create(testCard1); // const c1 = new Card({shape: 'oval', color: 'FF0000', number: 1, filling: 'full', outline: null})
CardToHtml.create(testCard2); // const c2 = new Card({shape: 'oval', color: '008000', number: 2, filling: 'full', outline: null})
CardToHtml.create(testCard3); // const c3 = new Card({shape: 'oval', color: '800080', number: 3, filling: 'full', outline: null})
CardToHtml.create(testCard4);
CardToHtml.create(testCard5); // const c1 = new Card({shape: 'diamond', color: 'green', number: 3, filling: 'empty', outline: null})
// const c2 = new Card({shape: 'squiggle', color: 'blue', number: 1, filling: 'stripe', outline: null})
// const c3 = new Card({shape: 'squiggle', color: 'blue', number: 2, filling: 'stripe', outline: null})
// const c4 = new Card({shape: 'diamond', color: 'green', number: 2, filling: 'empty', outline: null})
// const c5 = new Card({shape: 'oval', color: 'red', number: 2, filling: 'full', outline: null})
// const c6 = new Card({shape: 'oval', color: 'red', number: 1, filling: 'dot', outline: null})
const c1 = new Card({shape: 'diamond',color: 'orange' ,filling: 'grid', outline: 'dot'})
CardToHtml.create(c1);
</script> </script>
</body> </body>
</html> </html>

@ -115,105 +115,6 @@
</svg> </svg>
<div id="main"> <div id="main">
<!-- <div class="card">
<svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#squiggle" fill="#008002" mask="url(#mask-dot)"></use>
<use href="#squiggle" stroke="#008002" fill="none" stroke-width="18"></use>
</svg>
<svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#squiggle" fill="#008002" mask="url(#mask-stripe)"></use>
<use href="#squiggle" stroke="#008002" fill="none" stroke-width="18"></use>
</svg>
<svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#squiggle" fill="#008002" mask="url(#mask-grid)"></use>
<use href="#squiggle" stroke="#008002" fill="none" stroke-width="18"></use>
</svg>
</div>
<div class="card">
<svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#triangle" fill="#0000FF" mask="url(#mask-stripe)"></use>
<use href="#triangle" stroke="#0000FF" fill="none" stroke-width="18"></use>
</svg>
<svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#triangle" fill="#0000FF" mask="url(#mask-stripe)"></use>
<use href="#triangle" stroke="#0000FF" fill="none" stroke-width="18" "></use>
</svg>
<svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#triangle" fill="#0000FF" mask="url(#mask-stripe)"></use>
<use href="#triangle" stroke="#0000FF" fill="none" stroke-width="18"></use>
</svg>
</div>
<div class="card">
<svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#star" fill="#FFA500" mask="url(#mask-stripe)"></use>
<use href="#star" stroke="#FFA500" fill="none" stroke-width="18"></use>
</svg>
<svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#star" fill="#FFA500" mask="url(#mask-dot)"></use>
<use href="#star" stroke="#FFA500" fill="none" stroke-width="18"></use>
</svg>
<svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#star" fill="#FFA500" mask="url(#mask-grid)"></use>
<use href="#star" stroke="#FFA500" fill="none" stroke-width="18"></use>
</svg>
</div>
<div class="card">
<svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#diamond" fill="#ff0000" mask="url(#mask-stripe)"></use>
<use href="#diamond" stroke="#ff0000" fill="none" stroke-width="18"></use>
</svg>
<svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#diamond" fill="#ff0000" mask="url(#mask-stripe)"></use>
<use href="#diamond" stroke="#ff0000" fill="none" stroke-width="18"></use>
</svg>
<svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#diamond" fill="#ff0000" mask="url(#mask-stripe)"></use>
<use href="#diamond" stroke="#ff0000" fill="none" stroke-width="18"></use>
</svg>
</div>
<div class="card">
<svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#oval" fill="#800080" mask="url(#mask-stripe)"></use>
<use href="#oval" stroke="#800080" fill="none" stroke-width="18"></use>
</svg>
<svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#oval" fill="#800080" mask="url(#mask-stripe)"></use>
<use href="#oval" stroke="#800080" fill="none" stroke-width="18"></use>
</svg>
<svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#oval" fill="#800080" mask="url(#mask-stripe)"></use>
<use href="#oval" stroke="#800080" fill="none" stroke-width="18"></use>
</svg>
</div>
<div class="card">
<svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#oval" stroke="#800080" fill="#800080" stroke-width="18"></use>
</svg>
<svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#oval" stroke="#800080" fill="#800080" stroke-width="18"></use>
</svg>
<svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#oval" stroke="#800080" fill="#800080" stroke-width="18"></use>
</svg>
</div> -->
<div class="card"> <div class="card">
<svg class="item" height="160" width="80" viewBox="0 0 200 400"> <svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#oval" stroke="#800080" fill="#800080" stroke-width="40"></use> <use href="#oval" stroke="#800080" fill="#800080" stroke-width="40"></use>
@ -241,101 +142,101 @@
<div class="card"> <div class="card">
<svg class="item" height="160" width="80" viewBox="0 0 200 400"> <svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#squiggle" stroke="#800080" fill="#800080" stroke-width="18"></use> <use href="#squiggle" stroke="#FF0000" fill="#FF0000" stroke-width="18"></use>
</svg> </svg>
<svg class="item" height="160" width="80" viewBox="0 0 200 400"> <svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#squiggle" fill="#800080" mask="url(#mask-grid)"></use> <use href="#squiggle" fill="#FF0000" mask="url(#mask-grid)"></use>
<use href="#squiggle" stroke="#800080" fill="none" stroke-width="18"></use> <use href="#squiggle" stroke="#FF0000" fill="none" stroke-width="18"></use>
</svg> </svg>
<svg class="item" height="160" width="80" viewBox="0 0 200 400"> <svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#squiggle" fill="#800080" mask="url(#mask-stripe)"></use> <use href="#squiggle" fill="#FF0000" mask="url(#mask-stripe)"></use>
<use href="#squiggle" stroke="#800080" fill="none" stroke-width="18"></use> <use href="#squiggle" stroke="#FF0000" fill="none" stroke-width="18"></use>
</svg> </svg>
<svg class="item" height="160" width="80" viewBox="0 0 200 400"> <svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#squiggle" fill="#800080" mask="url(#mask-dot)"></use> <use href="#squiggle" fill="#FF0000" mask="url(#mask-dot)"></use>
<use href="#squiggle" stroke="#800080" fill="none" stroke-width="18"></use> <use href="#squiggle" stroke="#FF0000" fill="none" stroke-width="18"></use>
</svg> </svg>
<svg class="item" height="160" width="80" viewBox="0 0 200 400"> <svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#squiggle" stroke="#800080" fill="none" stroke-width="18"></use> <use href="#squiggle" stroke="#FF0000" fill="none" stroke-width="18"></use>
</svg> </svg>
</div> </div>
<div class="card"> <div class="card">
<svg class="item" height="160" width="80" viewBox="0 0 200 400"> <svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#diamond" stroke="#800080" fill="#800080" stroke-width="18"></use> <use href="#diamond" stroke="#008000" fill="#008000" stroke-width="18"></use>
</svg> </svg>
<svg class="item" height="160" width="80" viewBox="0 0 200 400"> <svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#diamond" fill="#800080" mask="url(#mask-grid)"></use> <use href="#diamond" fill="#008000" mask="url(#mask-grid)"></use>
<use href="#diamond" stroke="#800080" fill="none" stroke-width="18"></use> <use href="#diamond" stroke="#008000" fill="none" stroke-width="18"></use>
</svg> </svg>
<svg class="item" height="160" width="80" viewBox="0 0 200 400"> <svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#diamond" fill="#800080" mask="url(#mask-stripe)"></use> <use href="#diamond" fill="#008000" mask="url(#mask-stripe)"></use>
<use href="#diamond" stroke="#800080" fill="none" stroke-width="18"></use> <use href="#diamond" stroke="#008000" fill="none" stroke-width="18"></use>
</svg> </svg>
<svg class="item" height="160" width="80" viewBox="0 0 200 400"> <svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#diamond" fill="#800080" mask="url(#mask-dot)"></use> <use href="#diamond" fill="#008000" mask="url(#mask-dot)"></use>
<use href="#diamond" stroke="#800080" fill="none" stroke-width="18"></use> <use href="#diamond" stroke="#008000" fill="none" stroke-width="18"></use>
</svg> </svg>
<svg class="item" height="160" width="80" viewBox="0 0 200 400"> <svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#diamond" stroke="#800080" fill="none" stroke-width="18"></use> <use href="#diamond" stroke="#008000" fill="none" stroke-width="18"></use>
</svg> </svg>
</div> </div>
<div class="card"> <div class="card">
<svg class="item" height="160" width="80" viewBox="0 0 200 400"> <svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#star" stroke="#800080" fill="#800080" stroke-width="18"></use> <use href="#star" stroke="#0000FF" fill="#0000FF" stroke-width="18"></use>
</svg> </svg>
<svg class="item" height="160" width="80" viewBox="0 0 200 400"> <svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#star" fill="#800080" mask="url(#mask-grid)"></use> <use href="#star" fill="#0000FF" mask="url(#mask-grid)"></use>
<use href="#star" stroke="#800080" fill="none" stroke-width="18"></use> <use href="#star" stroke="#0000FF" fill="none" stroke-width="18"></use>
</svg> </svg>
<svg class="item" height="160" width="80" viewBox="0 0 200 400"> <svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#star" fill="#800080" mask="url(#mask-stripe)"></use> <use href="#star" fill="#0000FF" mask="url(#mask-stripe)"></use>
<use href="#star" stroke="#800080" fill="none" stroke-width="18"></use> <use href="#star" stroke="#0000FF" fill="none" stroke-width="18"></use>
</svg> </svg>
<svg class="item" height="160" width="80" viewBox="0 0 200 400"> <svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#star" fill="#800080" mask="url(#mask-dot)"></use> <use href="#star" fill="#0000FF" mask="url(#mask-dot)"></use>
<use href="#star" stroke="#800080" fill="none" stroke-width="18"></use> <use href="#star" stroke="#0000FF" fill="none" stroke-width="18"></use>
</svg> </svg>
<svg class="item" height="160" width="80" viewBox="0 0 200 400"> <svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#star" stroke="#800080" fill="none" stroke-width="18"></use> <use href="#star" stroke="#0000FF" fill="none" stroke-width="18"></use>
</svg> </svg>
</div> </div>
<div class="card"> <div class="card">
<svg class="item" height="160" width="80" viewBox="0 0 200 400"> <svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#triangle" stroke="#800080" fill="#800080" stroke-width="18"></use> <use href="#triangle" stroke="#FFA500" fill="#FFA500" stroke-width="18"></use>
</svg> </svg>
<svg class="item" height="160" width="80" viewBox="0 0 200 400"> <svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#triangle" fill="#800080" mask="url(#mask-grid)"></use> <use href="#triangle" fill="#FFA500" mask="url(#mask-grid)"></use>
<use href="#triangle" stroke="#800080" fill="none" stroke-width="18"></use> <use href="#triangle" stroke="#FFA500" fill="none" stroke-width="18"></use>
</svg> </svg>
<svg class="item" height="160" width="80" viewBox="0 0 200 400"> <svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#triangle" fill="#800080" mask="url(#mask-stripe)"></use> <use href="#triangle" fill="#FFA500" mask="url(#mask-stripe)"></use>
<use href="#triangle" stroke="#800080" fill="none" stroke-width="18"></use> <use href="#triangle" stroke="#FFA500" fill="none" stroke-width="18"></use>
</svg> </svg>
<svg class="item" height="160" width="80" viewBox="0 0 200 400"> <svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#triangle" fill="#800080" mask="url(#mask-dot)"></use> <use href="#triangle" fill="#FFA500" mask="url(#mask-dot)"></use>
<use href="#triangle" stroke="#800080" fill="none" stroke-width="18"></use> <use href="#triangle" stroke="#FFA500" fill="none" stroke-width="18"></use>
</svg> </svg>
<svg class="item" height="160" width="80" viewBox="0 0 200 400"> <svg class="item" height="160" width="80" viewBox="0 0 200 400">
<use href="#triangle" stroke="#800080" fill="none" stroke-width="18"></use> <use href="#triangle" stroke="#FFA500" fill="none" stroke-width="18"></use>
</svg> </svg>
</div> </div>
</div> </div>

@ -1,55 +1,60 @@
export default{ export default{
emits:[], emits:[],
props:{ props:{
deckR:Deck, deck:Deck,
idRoom:String, idRoom:String,
mode:Boolean//true for chrono mode:Boolean,//true for chrono
hyperSet:Boolean,
}, },
data: function(){ data: function(){
return{ return{
card:new Card({"filling":"empty"}), card:new Card({"filling":"empty"}),
id:0, id:0,
deck : new Deck([0,1,2,3],3),
selectedCards:[], selectedCards:[],
selectedCardsindex:[],
nbCardsSelected:0, nbCardsSelected:0,
connected:'7/8', connected:'7/8',
timer:'10.51', timer:'10.51',
win:false,
} }
}, },
methods:{ methods:{
selected(id){ selected(id){
if(this.nbCardsSelected>=this.deck.nbCards){ if(this.nbCardsSelected>=this.deck.nbCards){
this.set(); this.set();
console.log("deb")
} }
else{ else{// pas suffisament de cartes pour un set
if(this.selectedCards[id]!=null){ if(this.selectedCards[id]!=null){// carte déja selectionnée
console.log("deselec") document.querySelector(`#id${id}`).setAttribute("style","border: none;cursor: pointer;");
document.querySelector(`#id${id}`).setAttribute("style","border: 2px solid black; color: red; fontSize: 20px; cursor: pointer; width:100%; height:100%");
this.nbCardsSelected-=1 this.nbCardsSelected-=1
this.selectedCards[id]=null delete this.selectedCards[id]//pb
this.selectedCardsindex.splice(this.selectedCardsindex.indexOf(id),1)
} }
else{ else{
console.log("Selec")
this.selectedCards[id]=this.deck.outputCards[id-1] this.selectedCards[id]=this.deck.outputCards[id-1]
document.querySelector(`#id${id}`).setAttribute("style","border: 2px solid red; color: red; fontSize: 20px; cursor: pointer; width:100%; height:100%"); document.querySelector(`#id${id}`).setAttribute("style","border: 2px solid red; cursor: pointer;");
this.nbCardsSelected+=1 this.nbCardsSelected+=1
this.selectedCardsindex.push(id)
if(this.nbCardsSelected==this.deck.nbCards){ if(this.nbCardsSelected==this.deck.nbCards){
console.log("this.selectedCards.length",this.selectedCards.length)
this.set(); this.set();
} }
} }
} }
}, },
set(){ set(){
console.log("Check Set") console.log("this.selectedCards",this.selectedCards)
let checkSet=true; let checkSet=this.deck.checkSet(this.selectedCards);
if(checkSet){ if(checkSet==2){//is set
console.log("this.selectedCards.length",this.selectedCards.length) this.win=true;
this.deck.checkSet(this.selectedCards);
this.nbCardsSelected=0;
this.selectedCards.splice(0,this.selectedCards.length+1)
} }
// remove red outline
this.selectedCardsindex.forEach((e) => {
document.querySelector(`#id${e}`).setAttribute("style","cursor: pointer;");
})
// flush array
this.nbCardsSelected=0;
this.selectedCards=[]
this.selectedCardsindex=[]
}, },
}, },
template:` template:`
@ -60,10 +65,11 @@ export default{
<h2>Players: {{connected}}</h2> <h2>Players: {{connected}}</h2>
</div> </div>
<div v-bind:style="{border: '3px solid black', fontSize: '20px', display:'flex', 'flex-wrap':'wrap',margin:'1rem 25rem 20px 20px'}"> <div v-if="!win" v-bind:style="{border: '3px solid black', fontSize: '20px', display:'flex', 'flex-wrap':'wrap',margin:'1rem 17vw 20px 17vw'}">
<div class="Cardframe" v-bind:style="{ width:'12%', height:'15rem', margin:'2% 2% 2% 2%'}" v-for="n in deck.outputCards.length"> <card-module @selected='selected' :id=n :card=this.deck.outputCards[n-1] v-for="n in deck.outputCards.length"/>
<card-module @selected='selected' :id=n :card=this.deck.outputCards[n-1]></card-module> </div>
</div> <div v-if="win">
<h2>Félicitations, vous venez de gagner la partie ! 🎉</h2>
</div> </div>
` `
} }

@ -9,10 +9,11 @@
<link rel="stylesheet" type="text/css" href="/styles/style.css"> <link rel="stylesheet" type="text/css" href="/styles/style.css">
<link rel="stylesheet" type="text/css" href="/styles/index.css"> <link rel="stylesheet" type="text/css" href="/styles/index.css">
<link rel="stylesheet" type="text/css" href="/styles/game.css"> <link rel="stylesheet" type="text/css" href="/styles/game.css">
<link rel="stylesheet" type="text/css" href="/styles/card.css">
<link rel="stylesheet" type="text/css" href="/styles/room.css">
<link rel="icon" type="image/x-icon" href="/resources/favicon.ico"> <link rel="icon" type="image/x-icon" href="/resources/favicon.ico">
</head> </head>
<header> <header>
<ul id="nav-bar"> <ul id="nav-bar">
<li><a href="/index.html">Home</a></li> <!-- maybe put a logo --> <li><a href="/index.html">Home</a></li> <!-- maybe put a logo -->
@ -23,11 +24,75 @@
</ul> </ul>
</header> </header>
<body> <body>
<svg width="200" height="400" style="position: fixed; z-index: -1">
<defs>
<pattern
id="pattern-stripe"
width="2"
height="20"
patternUnits="userSpaceOnUse"
>
<rect width="2" height="8" fill="#fff" />
</pattern>
<pattern
id="pattern-grid"
width="30"
height="30"
patternUnits="userSpaceOnUse"
>
<rect width="7.5" height="30" fill="#fff" />
<rect width="30" height="7.5" fill="#fff" />
</pattern>
<pattern
id="pattern-dot"
width="40"
height="40"
patternUnits="userSpaceOnUse"
>
<circle cx="18" cy="18" r="12" fill="#fff" />
</pattern>
<mask id="mask-stripped">
<rect
x="0"
y="0"
width="200"
height="400"
fill="url(#pattern-stripe)"
/>
</mask>
<mask id="mask-pointed">
<rect
x="0"
y="0"
width="200"
height="400"
fill="url(#pattern-dot)"
/>
</mask>
<mask id="mask-squared">
<rect
x="0"
y="0"
width="200"
height="400"
fill="url(#pattern-grid)"
/>
</mask>
</defs>
</svg>
<div id="app"> <div id="app">
<deck-module id-room="00000" :mode=false></deck-module> <room-component id='Room' @send-deck="sendDeck"></room-component>
<deck-module :id-room="00000" :deck=this.deck :mode=false v-if="this.deck != null"></deck-module>
</div> </div>
<section> <section>
</section> </section>
<script src="/src/Model/card-to-html.js"></script>
<script src="/src/Model/Exceptions.js"></script> <script src="/src/Model/Exceptions.js"></script>
<script src="/src/Model/Card.js"></script> <script src="/src/Model/Card.js"></script>
<script src="/src/algo.js"></script> <script src="/src/algo.js"></script>
@ -39,17 +104,32 @@
import { createApp } from 'https://unpkg.com/vue@3/dist/vue.esm-browser.js'; import { createApp } from 'https://unpkg.com/vue@3/dist/vue.esm-browser.js';
import CardModule from '/views/card-module.js'; import CardModule from '/views/card-module.js';
import DeckModule from '/views/deck-module.js'; import DeckModule from '/views/deck-module.js';
import RoomComponent from '/views/room-component.js';
const app = createApp({ const app = createApp({
created(){}, created()
{
},
mounted()
{},
data(){ data(){
return{} return{
deck: null
}
}, },
methods:{ methods:{
myFun:function(){} sendDeck:function(deck) {
this.deck = deck
document.querySelector('#Room').setAttribute("style","display: none")
document.querySelector('#Game').setAttribute("style","display: flex");
console.log('send deck')
}
} }
}); });
app.component('CardModule', CardModule); app.component('CardModule', CardModule)
app.component('DeckModule', DeckModule); .component('DeckModule', DeckModule)
.component('RoomComponent', RoomComponent);
app.mount('#app'); app.mount('#app');
</script> </script>
</body> </body>

@ -0,0 +1,104 @@
export default {
data: function() {
return {
chronoTime: 0,
isHyperset: false,
nbCards: 3,
attr: [0,1,2,3],
errorMessage: "",
// red: "red"
}
},
methods: {
updateNbCard(nb) {
console.log(nb);
this.nbCards = nb
const card3 = document.querySelector("#card3");
const card4 = document.querySelector("#card4");
const card5 = document.querySelector("#card5");
if(nb == 3) {
card4.checked = false
card5.checked = false
} else if (nb == 4){
card3.checked = false
card5.checked = false
}else {
card3.checked = false
card4.checked = false
}
},
updateAttributes(attrNb) {
console.log(attrNb)
console.log(this.attr)
const att1 = document.querySelector("#attr1");
const att2 = document.querySelector("#attr2");
const att3 = document.querySelector("#attr3");
const att4 = document.querySelector("#attr4");
const att5 = document.querySelector("#attr5");
if(this.attr.includes(attrNb)) {
this.attr.splice(this.attr.indexOf(attrNb), 1)
console.log(this.attr)
//`att${attrNb}`.checked = false
} else {
this.attr.push(attrNb);
}
},
startGame: function() {
console.log('startGame')
if( this.nbCards <= this.attr.length) {
try {
const deck = new Deck(this.attr, this.nbCards)
this.$emit('send-deck',deck);
} catch (EmptyParamterException) {
this.errorMessage = "Number of attributes must be superior to number of cards"
}
}
else this.errorMessage = "Number of attributes must be superior to number of cards"
}
},
template:`
<section>
<h2 class="title2">Room Creation</h2>
<div class="group">
<h3 class="title3">Game parameters</h3>
<div id="game-param">
<label id="player-slider-label">Chrono: {{ chronoTime }}min</label><br>
<input type="range" min="0" max="20" value="0" class="slider" id="player-slider" v-model=chronoTime ><br>
<span>HyperSet</span> <input type='checkbox' v-model=isHyperset /><br>
</div>
</div>
<div class="group">
<h3 class="title3">Card number to make a set</h3>
<div id='card-param' class="param">
<input id="card3" type='checkbox' v-on:click="updateNbCard(3)" checked=true /> <span>3</span>
<input id="card4" type='checkbox' v-on:click="updateNbCard(4)" /> <span>4</span>
<input id="card5" type='checkbox' v-on:click="updateNbCard(5)" /> <span>5</span>
</div>
</div>
<div class="group">
<h3 class="title3">Attributes to play with</h3>
<div id='attributes-param' class="param">
<input id="attr1" type='checkbox' checked=true @click="updateAttributes(1)" /> <span>number</span>
<input id="attr2" type='checkbox' checked=true @click="updateAttributes(0)" /> <span>color</span>
<input id="attr3" type='checkbox' checked=true @click="updateAttributes(2)" /> <span>shape</span>
<input id="attr4" type='checkbox' checked=true @click="updateAttributes(3)" /> <span>filling</span>
<input id="attr5" type='checkbox' @click="updateAttributes(4)" /> <span>outline</span>
</div>
<span v-bind:style="{color: 'red'}">{{ errorMessage }}</span>
</div>
<input class='button' type="submit" value="Start Game" @click="startGame()" />
</section>
`
}

@ -0,0 +1,77 @@
<!DOCTYPE html>
<html>
<head>
<title>Room - HyperSet</title>
<link rel='stylesheet' type='text/css' href='/styles/style.css' />
<link rel='stylesheet' type='text/css' href='/styles/room.css' />
<link rel="icon" type="image/x-icon" href="/resources/favicon.ico">
</head>
<body>
<section id="left-section">
<button>Orignal Set Game</button>
<div>
<label>Private</label>
<input type='checkbox' />
</div>
<span id="or">OR</span>
<div class="group">
<span class="subtitle">Game parameters</span>
<div id="game-param">
<label id="chrono-slider-label">js</label><br>
<input type="range" min="1" max="8" value="1" class="slider" id="chrono-slider"><br>
<label id="player-slider-label">js</label><br>
<input type="range" min="0" max="20" value="0" class="slider" id="player-slider"><br>
<span>HyperSet</span> <input type='checkbox' /><br>
</div>
</div>
<div class="group">
<span class="subtitle">Card number to make a set</span>
<div id='card-param' class="param">
<input type='checkbox' /> <span>3</span>
<input type='checkbox' /> <span>4</span>
<input type='checkbox' /> <span>5</span>
</div>
</div>
<div class="group">
<span class="subtitle">Attributes to play with</span>
<div id='attributes-param' class="param">
<input type='checkbox' /> <span>number</span>
<input type='checkbox' /> <span>color</span>
<input type='checkbox' /> <span>shape</span>
<input type='checkbox' /> <span>filling</span>
<input type='checkbox' /> <span>outline (honnêtement c'est nul)</span>
</div>
</div>
</section>
<section id="right-section">
<div>
<span class="subtitle">List of players waiting in the room:</span>
<div id="players">
<span>Aurianus</span>
<span>Basuw</span>
<span>Raph</span>
<span>Remrem</span>
</div>
</div>
<button id="start" class="action-button">Start</button>
<script>
let button=document.querySelector("#start")
button.addEventListener('click', event => {
window.location.href = "/views/game.html";
});
</script>
</section>
</body>
</html>

@ -0,0 +1,45 @@
<!DOCTYPE html>
<html>
<head>
<title>Room - HyperSet</title>
<link rel='stylesheet' type='text/css' href='/styles/style.css' />
<link rel='stylesheet' type='text/css' href='/styles/room.css' />
</head>
<body>
<section id="left-section">
<button>Orignal Set Game</button>
<div>
<label>Private</label>
<input type='checkbox' />
</div>
<span id="or">OR</span>
<div class="group">
<section id="right-section">
<div>
<span class="subtitle">List of players waiting in the room:</span>
<div id="players">
<span>Aurianus</span>
<span>Basuw</span>
<span>Raph</span>
<span>Remrem</span>
</div>
</div>
<button id="start" class="action-button">Start</button>
<script>
let button=document.querySelector("#start")
button.addEventListener('click', event => {
window.location.href = "/views/game.html";
});
</script>
</section>
</body>
</html>
Loading…
Cancel
Save