You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
2.6 KiB
69 lines
2.6 KiB
export default{
|
|
emits:[],
|
|
props:{
|
|
deckR:Deck,
|
|
idRoom:String,
|
|
mode:String//true for chrono
|
|
},
|
|
data: function(){
|
|
return{
|
|
card:new Card({"filling":"empty"}),
|
|
id:0,
|
|
deck : new Deck([0,1,2,3],3),
|
|
selectedCards:[],
|
|
nbCardsSelected:0,
|
|
connected:'7/8',
|
|
timer:'10.51',
|
|
}
|
|
},
|
|
methods:{
|
|
selected(id){
|
|
if(this.nbCardsSelected>=this.deck.nbCards){
|
|
this.set();
|
|
console.log("deb")
|
|
}
|
|
else{
|
|
if(this.selectedCards[id]!=null){
|
|
console.log("deselec")
|
|
document.querySelector(`#id${id}`).setAttribute("style","border: 2px solid black; color: red; fontSize: 20px; cursor: pointer; width:100%; height:100%");
|
|
this.nbCardsSelected-=1
|
|
this.selectedCards[id]=null
|
|
}
|
|
else{
|
|
console.log("Selec")
|
|
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%");
|
|
this.nbCardsSelected+=1
|
|
if(this.nbCardsSelected==this.deck.nbCards){
|
|
console.log("this.selectedCards.length",this.selectedCards.length)
|
|
this.set();
|
|
}
|
|
}
|
|
}
|
|
},
|
|
set(){
|
|
console.log("Check Set")
|
|
let checkSet=true;
|
|
if(checkSet){
|
|
console.log("this.selectedCards.length",this.selectedCards.length)
|
|
this.deck.checkSet(this.selectedCards);
|
|
this.nbCardsSelected=0;
|
|
this.selectedCards.splice(0,this.selectedCards.length+1)
|
|
}
|
|
},
|
|
},
|
|
template:`
|
|
<div class="description">
|
|
<h2>Room: {{idRoom}}</h2>
|
|
<h2 v-if="mode">{{timer}}</h2>
|
|
<h2 v-else="!mode"> Remaining cards: {{deck.remainingCards.length}}/{{deck.allCards.length}}</h2>
|
|
<h2>Players: {{connected}}</h2>
|
|
</div>
|
|
|
|
<div v-bind:style="{border: '3px solid black', fontSize: '20px', display:'flex', 'flex-wrap':'wrap',margin:'1rem 25rem 20px 20px'}">
|
|
<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]></card-module>
|
|
</div>
|
|
</div>
|
|
`
|
|
} |