Commit 96f8c8bb authored by quentin.vrel's avatar quentin.vrel

testing chow

parent d6504fda
...@@ -21,12 +21,13 @@ export default { ...@@ -21,12 +21,13 @@ export default {
} }
}, },
mounted(){ mounted(){
let startingHand = [8,11,11,14,16,7,4,5,20,21,22,6,0]; let startingHand = [0,1,2,3,4,5,6,7,8,9,10,25,26,27,28,29,30,31,32,8,11,11,14,16,7,4,5,20,21,22,6,0];
this.Hand= new Hand(); this.Hand= new Hand();
startingHand.forEach(tile => { startingHand.forEach(tile => {
this.Hand.draw(new TileModel(tile)); this.Hand.draw(new TileModel(tile));
}); });
this.Hand.sort(); this.Hand.sort();
console.log(this.Hand.checkChow());
}, },
updated(){ updated(){
}, },
...@@ -34,6 +35,7 @@ export default { ...@@ -34,6 +35,7 @@ export default {
tileClickedListener: function(event){ tileClickedListener: function(event){
let dicarded = this.Hand.discard(event.id_tuile); let dicarded = this.Hand.discard(event.id_tuile);
console.log(dicarded); console.log(dicarded);
console.log(this.Hand.checkChow());
} }
} }
} }
......
...@@ -34,14 +34,17 @@ export default class Hand{ ...@@ -34,14 +34,17 @@ export default class Hand{
// //
checkChow(){ checkChow(){
this.sort(); this.sort();
let chowArray = [];
const tile_ids = this.tiles_left.map(tile => tile.id_tuile); const tile_ids = this.tiles_left.map(tile => tile.id_tuile);
let current_tile = -1; tile_ids.forEach( unique_tile => {
tile_ids.forEach(tile_id => { if (unique_tile<7 || (8<unique_tile && unique_tile<16) || (17<unique_tile && unique_tile<25)) { //bamboo <8 || char <8 || dot <8
if(tile_id>current_tile){ if ((tile_ids.indexOf(unique_tile+1) && tile_ids.indexOf(unique_tile+2)) != -1) {
current_tile=tile_id; chowArray.push(unique_tile)
}
} }
//WIP
}); });
return chowArray;
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment