${actionButton({
onClick: (e: MouseEvent) => this.openModeration(e, other),
icon: shieldIcon,
iconAlt: "Moderation",
title: moderationTitle,
label: moderationTitle,
type: "red",
})}
`;
}
private renderRelationPillIfNation(other: PlayerView, my: PlayerView) {
if (other.type() !== PlayerType.Nation) return html``;
if (other.isTraitor()) return html``;
if (my?.isAlliedWith && my.isAlliedWith(other)) return html``;
if (!this.otherProfile || !my) return html``;
const relation =
this.otherProfile.relations?.[my.smallID()] ?? Relation.Neutral;
const cls = this.getRelationClass(relation);
const name = this.getRelationName(relation);
return html`
`;
}
private renderStats(other: PlayerView, my: PlayerView) {
return html`
${translateText("player_panel.alliance_time_remaining")}
${this.allianceExpiryText}
`;
}
private renderActions(my: PlayerView, other: PlayerView) {
const myPlayer = this.g.myPlayer();
const canDonateGold = this.actions?.interaction?.canDonateGold;
const canDonateTroops = this.actions?.interaction?.canDonateTroops;
const canSendAllianceRequest =
this.actions?.interaction?.canSendAllianceRequest;
const canSendEmoji =
other === myPlayer
? this.actions?.canSendEmojiAllPlayers
: this.actions?.interaction?.canSendEmoji;
const canBreakAlliance = this.actions?.interaction?.canBreakAlliance;
const canTarget = this.actions?.interaction?.canTarget;
const canEmbargo = this.actions?.interaction?.canEmbargo;
return html`
${actionButton({
onClick: (e: MouseEvent) => this.handleChat(e, my, other),
icon: chatIcon,
iconAlt: "Chat",
title: translateText("player_panel.chat"),
label: translateText("player_panel.chat"),
})}
${canSendEmoji
? actionButton({
onClick: (e: MouseEvent) => this.handleEmojiClick(e, my, other),
icon: emojiIcon,
iconAlt: "Emoji",
title: translateText("player_panel.emotes"),
label: translateText("player_panel.emotes"),
type: "normal",
})
: ""}
${canTarget
? actionButton({
onClick: (e: MouseEvent) => this.handleTargetClick(e, other),
icon: targetIcon,
iconAlt: "Target",
title: translateText("player_panel.target"),
label: translateText("player_panel.target"),
type: "normal",
})
: ""}
${canDonateTroops
? actionButton({
onClick: (e: MouseEvent) =>
this.handleDonateTroopClick(e, my, other),
icon: donateTroopIcon,
iconAlt: "Troops",
title: translateText("player_panel.send_troops"),
label: translateText("player_panel.troops"),
type: "normal",
})
: ""}
${canDonateGold
? actionButton({
onClick: (e: MouseEvent) =>
this.handleDonateGoldClick(e, my, other),
icon: donateGoldIcon,
iconAlt: "Gold",
title: translateText("player_panel.send_gold"),
label: translateText("player_panel.gold"),
type: "normal",
})
: ""}
${other === my
? html``
: html`
${canEmbargo
? actionButton({
onClick: (e: MouseEvent) =>
this.handleEmbargoClick(e, my, other),
icon: stopTradingIcon,
iconAlt: "Stop Trading",
title: translateText("player_panel.stop_trade"),
label: translateText("player_panel.stop_trade"),
type: "yellow",
})
: actionButton({
onClick: (e: MouseEvent) =>
this.handleStopEmbargoClick(e, my, other),
icon: startTradingIcon,
iconAlt: "Start Trading",
title: translateText("player_panel.start_trade"),
label: translateText("player_panel.start_trade"),
type: "green",
})}
${canBreakAlliance
? actionButton({
onClick: (e: MouseEvent) =>
this.handleBreakAllianceClick(e, my, other),
icon: breakAllianceIcon,
iconAlt: "Break Alliance",
title: translateText("player_panel.break_alliance"),
label: translateText("player_panel.break_alliance"),
type: "red",
})
: ""}
${canSendAllianceRequest
? actionButton({
onClick: (e: MouseEvent) =>
this.handleAllianceClick(e, my, other),
icon: allianceIcon,
iconAlt: "Alliance",
title: translateText("player_panel.send_alliance"),
label: translateText("player_panel.send_alliance"),
type: "indigo",
})
: ""}
`}
${other === my
? html`
${actionButton({
onClick: (e: MouseEvent) => this.onStopTradingAllClick(e),
icon: stopTradingIcon,
iconAlt: "Stop Trading With All",
title: !this.actions?.canEmbargoAll
? `${translateText("player_panel.stop_trade_all")} - ${translateText("cooldown")}`
: translateText("player_panel.stop_trade_all"),
label: !this.actions?.canEmbargoAll
? `${translateText("player_panel.stop_trade_all")} ⏳`
: translateText("player_panel.stop_trade_all"),
type: "yellow",
disabled: !this.actions?.canEmbargoAll,
})}
${actionButton({
onClick: (e: MouseEvent) => this.onStartTradingAllClick(e),
icon: startTradingIcon,
iconAlt: "Start Trading With All",
title: !this.actions?.canEmbargoAll
? `${translateText("player_panel.start_trade_all")} - ${translateText("cooldown")}`
: translateText("player_panel.start_trade_all"),
label: !this.actions?.canEmbargoAll
? `${translateText("player_panel.start_trade_all")} ⏳`
: translateText("player_panel.start_trade_all"),
type: "green",
disabled: !this.actions?.canEmbargoAll,
})}
`
: ""}
${this.renderModeration(my, other)}
`;
}
render() {
if (!this.isVisible) return html``;
const my = this.g.myPlayer();
if (!my) return html``;
if (!this.tile) return html``;
const owner = this.g.owner(this.tile);
if (!owner || !owner.isPlayer()) {
this.hide();
console.warn("Tile is not owned by a player");
return html``;
}
const other = owner as PlayerView;
const myGoldNum = my.gold();
const myTroopsNum = Number(my.troops());
return html`