66 lines
1.9 KiB
Markdown
66 lines
1.9 KiB
Markdown
# poker.js — poker_handler() (satır 546)
|
||
|
||
[← poker.js](index.md) · [← Master](../../wiki.md)
|
||
|
||
Parça 4/6 · [önceki](poker_handler-3.md) · [sonraki](poker_handler-5.md)
|
||
|
||
```javascript
|
||
openPokerUI(c, player, tableId);
|
||
return;
|
||
}
|
||
|
||
// MASADAN AYRIL / LOBİYE DÖN
|
||
if (lastAction === "btn_leave") {
|
||
var pIndex = getPlayerIndex(table, playerName);
|
||
if (pIndex !== -1) {
|
||
table.players.splice(pIndex, 1); // Oyuncuyu listeden çıkar
|
||
|
||
// Eğer ayrılan kişi host ise, yeni host masadaki ilk oyuncu olur
|
||
if (table.host === playerName) {
|
||
if (table.players.length > 0) {
|
||
table.host = table.players[0].name;
|
||
} else {
|
||
table.host = "";
|
||
}
|
||
}
|
||
|
||
// Eğer masada hiç oyuncu kalmadıysa masayı tamamen sil
|
||
if (table.players.length === 0) {
|
||
for (var i = 0; i < lobby.tables.length; i++) {
|
||
if (lobby.tables[i].id === tableId) {
|
||
lobby.tables.splice(i, 1);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
c.send("§c" + playerName + " poker masasından ayrıldı!");
|
||
saveLobbyData(c, lobby);
|
||
refreshTablePlayers(c, tableId);
|
||
}
|
||
openLobbyUI(c, player);
|
||
return;
|
||
}
|
||
|
||
// MASAYI KAPAT (Masadan tetiklenen)
|
||
if (lastAction === "btn_close") {
|
||
if (table.host === playerName || isPlayerOP(player)) {
|
||
for (var i = 0; i < lobby.tables.length; i++) {
|
||
if (lobby.tables[i].id === tableId) {
|
||
lobby.tables.splice(i, 1);
|
||
break;
|
||
}
|
||
}
|
||
c.send("§c" + table.name + " poker masası kapatıldı!");
|
||
saveLobbyData(c, lobby);
|
||
openLobbyUI(c, player);
|
||
}
|
||
return;
|
||
}
|
||
|
||
// OYUNU BAŞLAT
|
||
if (lastAction === "btn_start") {
|
||
if (table.host === playerName && table.players.length >= 1) {
|
||
table.state = "playing";
|
||
```
|