72 lines
1.9 KiB
Markdown
72 lines
1.9 KiB
Markdown
# poker.js — poker_handler() (satır 546)
|
||
|
||
[← poker.js](index.md) · [← Master](../../wiki.md)
|
||
|
||
Parça 1/6 · [sonraki](poker_handler-2.md)
|
||
|
||
```javascript
|
||
function poker_handler(c) {
|
||
var player = c.getSubject();
|
||
var playerName = player.getName();
|
||
var uiContext = player.getUIContext();
|
||
if (uiContext === null) {
|
||
return;
|
||
}
|
||
|
||
var lobby = getLobbyData(c);
|
||
|
||
// EKRAN KAPATILDI/ESC YAPILDI (Temizlik)
|
||
if (uiContext.isClosed()) {
|
||
var pStates = player.getStates();
|
||
if (pStates.has("programmatic_open")) {
|
||
pStates.reset("programmatic_open");
|
||
return;
|
||
}
|
||
|
||
var tableId = getPlayerTableId(lobby, playerName);
|
||
if (tableId) {
|
||
var table = getTableData(lobby, tableId);
|
||
if (table) {
|
||
var pIndex = getPlayerIndex(table, playerName);
|
||
if (pIndex !== -1) {
|
||
table.players.splice(pIndex, 1);
|
||
|
||
if (table.host === playerName) {
|
||
if (table.players.length > 0) {
|
||
table.host = table.players[0].name;
|
||
} else {
|
||
table.host = "";
|
||
}
|
||
}
|
||
|
||
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);
|
||
}
|
||
}
|
||
}
|
||
pStates.reset("refresh_active");
|
||
return;
|
||
}
|
||
|
||
var lastAction = uiContext.getLast();
|
||
var uiData = uiContext.getData();
|
||
|
||
// --- LOBİ YÖNETİMİ AKSİYONLARI ---
|
||
|
||
// LOBİ YENİLE
|
||
if (lastAction === "lobby_refresh") {
|
||
openLobbyUI(c, player);
|
||
return;
|
||
}
|
||
```
|