remove red outline when 3 card selected
continuous-integration/drone/push Build is passing Details

master
Bastien JACQUELIN 2 years ago
parent 2fe9c94bdd
commit 1ff4e91de4

@ -70,7 +70,7 @@ class Deck {
* @author Bastien Jacquelin * @author Bastien Jacquelin
*/ */
checkSet(selectedCards) {//toTest⌛ checkSet(selectedCards) {//toTest⌛
if (true) {//isSet(selectedCards)){// is a set if (isSet(selectedCards)){// is a set
if (this.outputCards.length == 0) { if (this.outputCards.length == 0) {
console.log("C'est win") console.log("C'est win")
return 2; return 2;

@ -11,6 +11,7 @@ export default{
id:0, id:0,
deck : new Deck([0,1,2,3],3), 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',
@ -18,39 +19,40 @@ export default{
}, },
methods:{ methods:{
selected(id){ selected(id){
console.log(id);
if(this.nbCardsSelected>=this.deck.nbCards){ if(this.nbCardsSelected>=this.deck.nbCards){
this.set(); this.set();
console.log("deb")
} }
else{ else{
if(this.selectedCards[id]!=null){ if(this.selectedCards[id]!=null){
console.log("deselec")
document.querySelector(`#id${id}`).setAttribute("style","border: none;cursor: pointer;"); document.querySelector(`#id${id}`).setAttribute("style","border: none;cursor: pointer;");
this.nbCardsSelected-=1 this.nbCardsSelected-=1
this.selectedCards[id]=null this.selectedCards[id]=null
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; cursor: pointer;"); 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") let checkSet=this.deck.checkSet(this.selectedCards);
let checkSet=true; if(checkSet){//is set
if(checkSet){
console.log("this.selectedCards.length",this.selectedCards.length) }
this.deck.checkSet(this.selectedCards); // remove red outline
this.selectedCardsindex.forEach((e) => {
document.querySelector(`#id${e}`).setAttribute("style","cursor: pointer;");
})
// flush array
this.nbCardsSelected=0; this.nbCardsSelected=0;
this.selectedCards.splice(0,this.selectedCards.length+1) this.selectedCards.splice(0,this.selectedCards.length+1)
} this.selectedCardsindex.splice(0,this.selectedCardsindex.length+1)
}, },
}, },
template:` template:`

Loading…
Cancel
Save