-
Notifications
You must be signed in to change notification settings - Fork 0
/
kata.js
74 lines (49 loc) · 1.63 KB
/
kata.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// let deck = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"];
// let types = ["♠︎","♣︎","♡","♢"];
/*function createDeck (arr1, arr2) {
let newArr = [];
for (a in deck) {
for (b in types){
while (a < deck.length && b < types.length) {
newArr = (deck[a] + types[b]);
}
return newArr;
}
}
} Nop...*/
let carte = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"];
let types = ["♠︎", "♣︎", "♡", "♢"];
function createDeck(arr1, arr2) {
let newArr = [];
for (let a = 0; a < arr1.length; a++) {
for (let b = 0; b < arr2.length; b++) {
newArr.push(arr1[a] + arr2[b]);
}
}
return newArr;
}
let deck = createDeck(carte, types);
console.log(deck);
function shuffleDeck (array) {
let actuelIndex = deck.length;
while (actuelIndex !== 0) { // Tant qu'on peut mélanger
let randomIndex = Math.floor(Math.random() * actuelIndex);
actuelIndex --;
[array[actuelIndex], array[randomIndex]] = [array[randomIndex], array[actuelIndex]]; // Swap de l'élement mélangé et celui en "place"
}
}
shuffleDeck(deck);
console.log(deck); //
function deal (cartes) {
let distrib = deck.splice(2,2);
return distrib;
}
player1 = deal(2);
player2 = deal(2);
console.log(player1);
console.log(player2);
function flop (deal) {
let cards = [];
cards.push(deal(1,1),deal(1,1), deal(1,0))
} // 16:42 j'arrête, je pense qu'il faut push dans [] 3 cartes avec deal() et appeler deal()
// pour bruler la carte avant chaque tour