im trying to figure out how can i make my deck deal 6 cards to each player.
I manage to do it with splice method, and i have now my deck and 2 players getting 6 cards in player1Hand and player2Hand.
Right know im getting stucked with how to display vissualy all 6 cards, im stucked with displaying only first card from array. here is the code, and i would be thankfull if someone can help out.
import Deck from './deck.js'
const CARD_VALUE_MAP = {
"2" : 2,
"3" : 3,
"4" : 4,
"5" : 5,
"6" : 6,
"7" : 7,
"8" : 8,
"9" : 9,
"10" : 10,
"J" : 11,
"Q" : 12,
"K" : 13,
"A" : 14
}
let player1Hand = [];
let player2Hand = [];
// Selectors
const player1deck = document.querySelector('.player1Hand');
const player2deck = document.querySelector('.player2Hand');
const fulldeck = document.querySelector('.fulldeck');
let deck;
gameStart();
function gameStart() {
deck = new Deck();
deck.shuffle();
console.log(deck.cards)
player1Hand = deck.cards.splice(0,6);
player2Hand = deck.cards.splice(0,6);
console.log(player1Hand, player2Hand, deck.cards)
const i = 2;
player1Hand.forEach(card => {
player1deck.appendChild(player1Hand[0].getHTML())
});
player2Hand.forEach(card => {
player2deck.appendChild(player2Hand[0].getHTML())
})
}
fulldeck.innerText = deck.cards.length;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…