diff --git a/index.html b/index.html index f3069e8..3f29523 100644 --- a/index.html +++ b/index.html @@ -7622,13 +7622,59 @@ Gamestate.restart = function () { barEl.style.marginTop = '12px'; // Double space } + // --- NEW: PLAYER COLOR IDENTIFIER & ALLIANCE STATUS --- + let colorBar = infoBox.querySelector('.player-color-bar'); + if (!colorBar) { + colorBar = document.createElement('div'); + // Give it the exact same CSS class as the standard buttons! + colorBar.className = 'btn-diplomacy player-color-bar'; + infoBox.appendChild(colorBar); + } + + if (player.name === this.player.name) { + colorBar.style.display = "block"; + colorBar.style.backgroundColor = player.color; + colorBar.style.color = "#000"; + colorBar.style.border = "1px solid var(--pip-color)"; + colorBar.style.pointerEvents = "none"; // Make it non-clickable + + // Keep text to one line safely + colorBar.style.whiteSpace = "nowrap"; + colorBar.style.overflow = "hidden"; + colorBar.style.textOverflow = "ellipsis"; + + let statusText = "NO ALLIANCES"; + if (this.isAllianceMode) { + let ally = this.players.find(p => p.team === this.player.team && p.name !== this.player.name && !p.isNeutral); + if (ally && ally.alive) { + statusText = `ALLIED: ${ally.name}`; + } else { + statusText = `ALLIANCE SEVERED`; + } + } else { + let myTruce = this.diplomacy.truces.find(t => t.f1 === this.player.name || t.f2 === this.player.name); + if (myTruce) { + let allyName = myTruce.f1 === this.player.name ? myTruce.f2 : myTruce.f1; + statusText = `TRUCE: ${allyName} (${myTruce.turns}T)`; + } + } + + colorBar.textContent = statusText; + } else { + colorBar.style.display = "none"; + } + + // --- FINAL BUTTON LOGIC FOR DIPLOMACY & ALLIANCE --- - let dipBtn = infoBox.querySelector('.btn-diplomacy'); + // FIX: Specify 'button' so it doesn't accidentally grab our new color bar! + let dipBtn = infoBox.querySelector('button.btn-diplomacy'); // First, a universal rule: no buttons for the player, dead/neutral factions. if ((player.name === this.player.name) || player.isNeutral || player.areas.length === 0) { if (dipBtn) dipBtn.style.display = "none"; } + + // If we are in Alliance Mode... else if (this.isAllianceMode) { // And this player is our ally...