diff --git a/2.json b/2.json index b690fb3..f30ca63 100644 --- a/2.json +++ b/2.json @@ -100,9 +100,10 @@ ], "active_suit": "♣", "attacker": [ + [ "♣", - "7" + "10" ], [ "♦", @@ -155,7 +156,7 @@ [ [ "♣", - "7" + "10" ], [ "♦", diff --git a/app.js b/app.js index 6ca3b75..8e102d2 100644 --- a/app.js +++ b/app.js @@ -57,7 +57,7 @@ const app = () => { }; function connect() { - var ws = new WebSocket('ws://localhost:8765'); + var ws = new WebSocket('wss://durak.vit.ooo/ws/'); ws.onopen = function() { // subscribe to some channels ws.send(JSON.stringify({ diff --git a/cardStyles.js b/cardStyles.js index e96e9c0..188b97e 100644 --- a/cardStyles.js +++ b/cardStyles.js @@ -7,6 +7,7 @@ export default function handleCard (image, passes, index) { function sound(sound){ var snd = new Audio(`./sounds/${sound}.mp3`) snd.play() + } const passesMapping = { @@ -36,8 +37,29 @@ export default function handleCard (image, passes, index) { image.style.top = `-${screenHeight / 2 - 100}px`; image.classList.remove(`cards_number-hover`); image.style.transform = 'none'; - image. - players.slice(index, 1); + + let userId=document.querySelector(`.player${index}_container`); + userId.id=String(index); + let fullcardname= image.getAttribute('src').replace('.png', '').replace('/img/',''); + if(fullcardname.includes('10')){ + let suit= fullcardname.slice(0, -2); + let nominal= fullcardname.slice(-2); + let Obj={ + id: userId.id, + nominal, + suit, + }; + console.log(Obj); + }else{ + let nominal= fullcardname.slice(0, -1); + let suit= fullcardname.slice(-1); + let Obj={ + id: userId.id, + nominal, + suit + }; + console.log(Obj); + }; } diff --git a/view.js b/view.js index d1e6058..ec9d254 100644 --- a/view.js +++ b/view.js @@ -52,6 +52,7 @@ const dealingCards = (players_count, players, attacker, defender, deck) => { const renderCard = (card, container, cardsNumber, passes, index, players) => { + const [symbol, rank] = card; const suit = suitsMapping[symbol]; const image = document.createElement('img'); @@ -65,7 +66,7 @@ const renderCard = (card, container, cardsNumber, passes, index, players) => { // что pass это те карты которые сейчас в игре??? - image.addEventListener('click', () => handleCard(image, passes, index), {once: true}); + image.addEventListener('click', () => handleCard(image, passes, index), {once: true}); div.appendChild(image); container.appendChild(div); }; @@ -110,8 +111,10 @@ const renderPlayerRoles = (players, attacker, defender) => { const renderPlayersNames = (players_count) => { for (let i = 0; i < players_count; i += 1) { + const playerNameTextEl = document.querySelector(`.player${i}-name`); playerNameTextEl.textContent = `player${i}`; + } }; @@ -145,6 +148,7 @@ const renderDeck = (deck) => { const renderPlayerCards = (players, currentPlayer, passes) => { let i = 0; players.forEach((player) => { + const playerCardsDiv = document.querySelector(`.player${i}CardsContainer`); player === currentPlayer ? renderCards(players, player, playerCardsDiv, true, passes, i) : renderCards(players, player, playerCardsDiv, false, passes, i); @@ -189,4 +193,13 @@ export default (state) => (path, value) => { break; } } -} \ No newline at end of file +} + + + + + + + + +