mirror of
https://github.com/AlecM33/Werewolf.git
synced 2025-12-28 16:57:51 +01:00
display current moderator, fix assignment of spectator
This commit is contained in:
@@ -88,6 +88,10 @@ export const HTMLFragments = {
|
||||
<p>(Double-click here again to hide)</p>
|
||||
</div>
|
||||
<div id='game-people-container'>
|
||||
<div id="current-moderator" class="moderator">
|
||||
<div id="current-moderator-name"></div>
|
||||
<div id="current-moderator-type"></div>
|
||||
</div>
|
||||
<label id='players-alive-label'></label>
|
||||
<div id="spectator-count" tabindex="0"></div>
|
||||
<div id='game-player-list'></div>
|
||||
@@ -118,6 +122,10 @@ export const HTMLFragments = {
|
||||
</div>
|
||||
</div>
|
||||
<div id='game-people-container'>
|
||||
<div id="current-moderator" class="moderator">
|
||||
<div id="current-moderator-name"></div>
|
||||
<div id="current-moderator-type"></div>
|
||||
</div>
|
||||
<label id='players-alive-label'></label>
|
||||
<div id="spectator-count" tabindex="0"></div>
|
||||
<div id='game-player-list'></div>
|
||||
@@ -294,6 +302,10 @@ export const HTMLFragments = {
|
||||
</div>
|
||||
</div>
|
||||
<div id='game-people-container'>
|
||||
<div id="current-moderator" class="moderator">
|
||||
<div id="current-moderator-name"></div>
|
||||
<div id="current-moderator-type"></div>
|
||||
</div>
|
||||
<label id='players-alive-label'></label>
|
||||
<div id='game-player-list'></div>
|
||||
</div>`,
|
||||
|
||||
@@ -88,6 +88,9 @@ export class InProgress {
|
||||
}
|
||||
}
|
||||
renderPlayerRole(this.stateBucket.currentGameState);
|
||||
displayCurrentModerator(this.stateBucket.currentGameState.people
|
||||
.find((person) => person.userType === globals.USER_TYPES.MODERATOR
|
||||
|| person.userType === globals.USER_TYPES.TEMPORARY_MODERATOR));
|
||||
this.renderPlayersWithNoRoleInformationUnlessRevealed(false);
|
||||
}
|
||||
|
||||
@@ -162,38 +165,40 @@ export class InProgress {
|
||||
}
|
||||
|
||||
renderSpectatorView () {
|
||||
displayCurrentModerator(this.stateBucket.currentGameState.people
|
||||
.find((person) => person.userType === globals.USER_TYPES.MODERATOR
|
||||
|| person.userType === globals.USER_TYPES.TEMPORARY_MODERATOR));
|
||||
this.renderPlayersWithNoRoleInformationUnlessRevealed();
|
||||
}
|
||||
|
||||
setSocketHandlers () {
|
||||
this.socket.on(globals.EVENT_IDS.KILL_PLAYER, (id) => {
|
||||
const killedPerson = this.stateBucket.currentGameState.people.find((person) => person.id === id);
|
||||
if (killedPerson) {
|
||||
killedPerson.out = true;
|
||||
killedPerson.killed = true;
|
||||
killedPerson.userType = killedPerson.userType === globals.USER_TYPES.BOT
|
||||
? globals.USER_TYPES.KILLED_BOT
|
||||
: globals.USER_TYPES.KILLED_PLAYER;
|
||||
if (this.stateBucket.currentGameState.client.userType === globals.USER_TYPES.MODERATOR) {
|
||||
toast(killedPerson.name + ' killed.', 'success', true, true, 'medium');
|
||||
this.renderPlayersWithRoleAndAlignmentInfo(this.stateBucket.currentGameState.status === globals.STATUS.ENDED);
|
||||
this.socket.on(globals.EVENT_IDS.KILL_PLAYER, (killedPlayer) => {
|
||||
this.stateBucket.currentGameState.people = this.stateBucket.currentGameState.people
|
||||
.map(person => person.id === killedPlayer.id ? killedPlayer : person);
|
||||
console.log(this.stateBucket.currentGameState.people);
|
||||
if (this.stateBucket.currentGameState.client.userType === globals.USER_TYPES.MODERATOR) {
|
||||
toast(killedPlayer.name + ' killed.', 'success', true, true, 'medium');
|
||||
this.renderPlayersWithRoleAndAlignmentInfo(this.stateBucket.currentGameState.status === globals.STATUS.ENDED);
|
||||
} else {
|
||||
console.log(killedPlayer);
|
||||
if (killedPlayer.id === this.stateBucket.currentGameState.client.id) {
|
||||
const clientUserType = document.getElementById('client-user-type');
|
||||
if (clientUserType) {
|
||||
clientUserType.innerText = globals.USER_TYPES.KILLED_PLAYER + ' \uD83D\uDC80';
|
||||
}
|
||||
this.updatePlayerCardToKilledState();
|
||||
toast('You have been killed!', 'warning', true, true, 'medium');
|
||||
} else {
|
||||
if (killedPerson.id === this.stateBucket.currentGameState.client.id) {
|
||||
const clientUserType = document.getElementById('client-user-type');
|
||||
if (clientUserType) {
|
||||
clientUserType.innerText = globals.USER_TYPES.KILLED_PLAYER + ' \uD83D\uDC80';
|
||||
}
|
||||
this.updatePlayerCardToKilledState();
|
||||
toast('You have been killed!', 'warning', true, true, 'medium');
|
||||
} else {
|
||||
toast(killedPerson.name + ' was killed!', 'warning', true, true, 'medium');
|
||||
}
|
||||
if (this.stateBucket.currentGameState.client.userType === globals.USER_TYPES.TEMPORARY_MODERATOR) {
|
||||
this.removePlayerListEventListeners(false);
|
||||
} else {
|
||||
this.renderPlayersWithNoRoleInformationUnlessRevealed(false);
|
||||
toast(killedPlayer.name + ' was killed!', 'warning', true, true, 'medium');
|
||||
if (killedPlayer.userType === globals.USER_TYPES.MODERATOR) {
|
||||
displayCurrentModerator(killedPlayer);
|
||||
}
|
||||
}
|
||||
if (this.stateBucket.currentGameState.client.userType === globals.USER_TYPES.TEMPORARY_MODERATOR) {
|
||||
this.removePlayerListEventListeners(false);
|
||||
} else {
|
||||
this.renderPlayersWithNoRoleInformationUnlessRevealed(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -301,6 +306,7 @@ export class InProgress {
|
||||
socket = null
|
||||
) {
|
||||
for (const player of people) {
|
||||
console.log(player);
|
||||
const playerEl = document.createElement('div');
|
||||
playerEl.classList.add('game-player');
|
||||
|
||||
@@ -478,6 +484,11 @@ function removeExistingPlayerElements (killPlayerHandlers, revealRoleHandlers) {
|
||||
});
|
||||
}
|
||||
|
||||
function displayCurrentModerator(moderator) {
|
||||
document.getElementById("current-moderator-name").innerText = moderator.name;
|
||||
document.getElementById("current-moderator-type").innerText = moderator.userType + globals.USER_TYPE_ICONS[moderator.userType];
|
||||
}
|
||||
|
||||
function createEndGamePromptComponent (socket, stateBucket) {
|
||||
if (document.querySelector('#game-control-prompt') === null) {
|
||||
const div = document.createElement('div');
|
||||
|
||||
Reference in New Issue
Block a user