Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions 2.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@
],
"active_suit": "♣",
"attacker": [

[
"♣",
"7"
"10"
],
[
"♦",
Expand Down Expand Up @@ -155,7 +156,7 @@
[
[
"♣",
"7"
"10"
],
[
"♦",
Expand Down
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
26 changes: 24 additions & 2 deletions cardStyles.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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);
};
}


Expand Down
17 changes: 15 additions & 2 deletions view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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);
};
Expand Down Expand Up @@ -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}`;

}
};

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -189,4 +193,13 @@ export default (state) => (path, value) => {
break;
}
}
}
}