nerf jouer deux fois
This commit is contained in:
parent
57c1c71e63
commit
c4f8b21373
2 changed files with 21 additions and 9 deletions
|
|
@ -105,7 +105,7 @@
|
||||||
|
|
||||||
socket.on('room:update', (data)=>{
|
socket.on('room:update', (data)=>{
|
||||||
console.log('room:update', data);
|
console.log('room:update', data);
|
||||||
statusEl.textContent = data.status || '-';
|
if(statusEl) statusEl.textContent = data.status || '-';
|
||||||
const count = (data.players||[]).length;
|
const count = (data.players||[]).length;
|
||||||
playerCountEl.textContent = `${count}/2`;
|
playerCountEl.textContent = `${count}/2`;
|
||||||
// remember hostId from server updates; if missing, fall back to first player
|
// remember hostId from server updates; if missing, fall back to first player
|
||||||
|
|
|
||||||
26
server.js
26
server.js
|
|
@ -292,7 +292,7 @@ function buildDefaultDeck(){
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'Jouer deux fois',
|
'Jouer deux fois',
|
||||||
'Le joueur peut déplacer deux pièces',
|
'Le joueur peut déplacer deux pièces. Ne peut pas capturer pendant son deuxième tour',
|
||||||
'double'
|
'double'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
|
@ -361,7 +361,7 @@ function buildDefaultDeck(){
|
||||||
'sniper'
|
'sniper'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'Inversion',
|
'Échange',
|
||||||
"Échange la position d'une pièce avec une pièce adverse.\n\nCompte comme un mouvement",
|
"Échange la position d'une pièce avec une pièce adverse.\n\nCompte comme un mouvement",
|
||||||
'inversion'
|
'inversion'
|
||||||
],
|
],
|
||||||
|
|
@ -995,6 +995,18 @@ io.on('connection', (socket) => {
|
||||||
}
|
}
|
||||||
}catch(_){ }
|
}catch(_){ }
|
||||||
|
|
||||||
|
// Second move of "double"
|
||||||
|
try{
|
||||||
|
const effects = room.activeCardEffects || [];
|
||||||
|
const dbl = effects.find(e => e && (e.type === 'double') && e.playerId === senderId);
|
||||||
|
if(dbl && typeof dbl.remainingMoves === 'number' && dbl.remainingMoves === 1){
|
||||||
|
const occupant = (pieces || []).find(p => p.square === to);
|
||||||
|
if(occupant){
|
||||||
|
return cb && cb({ error: 'capture_forbidden_double', message: "Vous ne pouvez pas capturer lors du deuxième mouvement de 'Jouer deux fois'." });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch(_){ }
|
||||||
|
|
||||||
const targetIndex = pieces.findIndex(p => p.square === to);
|
const targetIndex = pieces.findIndex(p => p.square === to);
|
||||||
let sniperTriggered = false;
|
let sniperTriggered = false;
|
||||||
let capturedPieceForReactions = null;
|
let capturedPieceForReactions = null;
|
||||||
|
|
@ -1163,7 +1175,7 @@ io.on('connection', (socket) => {
|
||||||
room.activeCardEffects = room.activeCardEffects || [];
|
room.activeCardEffects = room.activeCardEffects || [];
|
||||||
for(let i = room.activeCardEffects.length - 1; i >= 0; i--){
|
for(let i = room.activeCardEffects.length - 1; i >= 0; i--){
|
||||||
const e = room.activeCardEffects[i];
|
const e = room.activeCardEffects[i];
|
||||||
if(e.type === 'double' && e.playerId === senderId){
|
if((e.type === 'double') && e.playerId === senderId){
|
||||||
const newRemaining = (typeof e.remainingMoves === 'number') ? (e.remainingMoves - 1) : ((e.remainingMoves || 2) - 1);
|
const newRemaining = (typeof e.remainingMoves === 'number') ? (e.remainingMoves - 1) : ((e.remainingMoves || 2) - 1);
|
||||||
if(newRemaining > 0){
|
if(newRemaining > 0){
|
||||||
e.remainingMoves = newRemaining;
|
e.remainingMoves = newRemaining;
|
||||||
|
|
@ -1178,7 +1190,7 @@ io.on('connection', (socket) => {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch(err){ console.error('double_move consume error', err); }
|
}catch(err){ console.error('double move consume error', err); }
|
||||||
|
|
||||||
if(!consumedDoubleMove){
|
if(!consumedDoubleMove){
|
||||||
board.turn = (board.turn === 'w') ? 'b' : 'w';
|
board.turn = (board.turn === 'w') ? 'b' : 'w';
|
||||||
|
|
@ -2203,11 +2215,11 @@ io.on('connection', (socket) => {
|
||||||
else if(cardId === 'double'){
|
else if(cardId === 'double'){
|
||||||
try{
|
try{
|
||||||
room.activeCardEffects = room.activeCardEffects || [];
|
room.activeCardEffects = room.activeCardEffects || [];
|
||||||
const effect = { id: played.id, type: 'double_move', playerId: senderId, ts: Date.now(), remainingMoves: (payload && payload.moves) || 2 };
|
const effect = { id: played.id, type: 'double', playerId: senderId, ts: Date.now(), remainingMoves: (payload && payload.moves) || 2 };
|
||||||
room.activeCardEffects.push(effect);
|
room.activeCardEffects.push(effect);
|
||||||
try{ io.to(room.id).emit('card:effect:applied', { roomId: room.id, effect }); }catch(_){ }
|
try{ io.to(room.id).emit('card:effect:applied', { roomId: room.id, effect }); }catch(_){ }
|
||||||
played.payload = Object.assign({}, payload, { applied: 'double_move', moves: effect.remainingMoves });
|
played.payload = Object.assign({}, payload, { applied: 'double', moves: effect.remainingMoves });
|
||||||
}catch(e){ console.error('double_move effect error', e); }
|
}catch(e){ console.error('double effect error', e); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// tous les même
|
// tous les même
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue