Skip to content

Commit

Permalink
optimizations, bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
josef-stips committed Mar 26, 2024
1 parent 15cc986 commit f2df425
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/script/public/App/features/bosses/BossClass.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Boss {
};

attack = () => {
removeAccessToAnything();
gameCounter && removeAccessToAnything();

// start animation
if (this.attack_animation != null) {
Expand Down
4 changes: 2 additions & 2 deletions src/script/public/Game/PlayerClocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ function removeAccessToAnything() {
globalChooseWinnerBtn.style.color = '#56565659';
restartBtn.removeEventListener('click', restartGame);
restartBtn.style.color = '#56565659';

CloseOnlinePopUps(true);
console.log("lol")
// CloseOnlinePopUps(true);
GiveUpPopUp.style.display = "none";

// remove access to set
Expand Down
36 changes: 30 additions & 6 deletions src/script/public/Game/processWinner.js
Original file line number Diff line number Diff line change
Expand Up @@ -792,16 +792,19 @@ const continueGame = () => {

// not advanture mode
if (!inAdvantureMode) {

// in online mode
if (curr_mode == GameMode[2].opponent) {

if (PlayingInCreatedLevel) { // Player played user created level

if (NewCreativeLevel.selectedLevel[9] == 0) {
// admin leaves game and this info all player get
if (personal_GameData.role == "admin") {
UserleavesGame();
NewCreativeLevel.verified(); // User beat his own created level and can publish it now
};

} else if (NewCreativeLevel.selectedLevel[9] == 1) {
// admin leaves game and this info all player get
if (personal_GameData.role == "admin") {
Expand All @@ -810,15 +813,29 @@ const continueGame = () => {
};

} else { // user played standard card level from game

// admin leaves game and this info all player get
if (personal_GameData.role == "admin") {
UserleavesGame();
};

};
DarkLayer.style.display = "block";

// when user wants to leave from the game on game finished he must wait for the admin to leave the game
// But if user clicked "continue", a text aappears to wait for the admin
if (personal_GameData.role == "user") {

let bigText = document.createElement("h1");
bigText.classList.add("bigScreenText");
bigText.textContent = "Wait for the admin to continue.";

document.body.appendChild(bigText);
};

// in offline mode
} else if (curr_mode != GameMode[2].opponent) {

if (PlayingInCreatedLevel) { // Player played user created level
if (NewCreativeLevel.selectedLevel[9] == 0) {
NewCreativeLevel.verified(); // User beat his own created level and can publish it now
Expand All @@ -835,6 +852,7 @@ const continueGame = () => {

// in advanture mode
} else {

if (endGame_player1Won) { // user won and conquered the level
UserleavesGame(true, current_selected_level);
} else {
Expand Down Expand Up @@ -935,6 +953,10 @@ function UltimateGameWin(player1_won, player2_won, WinCombination, UserGivesUp)

} else {
setTimeout(() => {

console.log(current_level_boss);
current_level_boss && current_level_boss.stop_attack_interval();

// basic stuff
stopStatusTextInterval = false;
cellGrid.style.opacity = "0";
Expand Down Expand Up @@ -1017,8 +1039,6 @@ function PlayerWon_UpdateHisData(Player1_won, player2_won, WinCombination) {
wins_storage = wins_storage + 1;
localStorage.setItem('onlineMatches-won', wins_storage);

console.log("lelelellelelellele", WinCombination);

// all previous 100 patterns the player used
WinCombination && recentUsedPattern_add(WinCombination); // add used pattern to recently used pattern list

Expand All @@ -1027,10 +1047,6 @@ function PlayerWon_UpdateHisData(Player1_won, player2_won, WinCombination) {
lastOnlineWins = lastOnlineWins + 1;
localStorage.setItem("Last24Hours_Won_OnlineGames", lastOnlineWins);

console.log("lelelellelelellele", lastOnlineWins);

console.log(GameData.InnerGameMode, InnerGameModes[1]);

// online win in specific mode
switch (GameData.InnerGameMode) {
case InnerGameModes[1]: // win in boneyard mode
Expand All @@ -1054,6 +1070,14 @@ function PlayerWon_UpdateHisData(Player1_won, player2_won, WinCombination) {
// this message recieve all clients
socket.on('global_UltimateWin', (player1_won, player2_won, WinCombination, player1_score, player2_score) => {
setTimeout(() => {

// to prevent bugs
if (current_level_boss) {
console.log(current_level_boss)
current_level_boss.died = true
current_level_boss.stop_attack_interval();
};

// basic stuff
stopStatusTextInterval = false;
cellGrid.style.opacity = "0";
Expand Down
12 changes: 12 additions & 0 deletions src/script/public/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -1876,6 +1876,18 @@ label h3 {
color: var(--font-color);
}

.bigScreenText {
z-index: 500;
font-size: 75px;
position: absolute;
top: 40%;
bottom: 0;
left: 0;
right: 0;
margin: auto auto auto auto;
color: white;
}


/* Game Info Pop Up */

Expand Down
42 changes: 31 additions & 11 deletions src/script/public/serverHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -844,17 +844,22 @@ const SetClickOnProfileListeners = (fromAdmin) => {

// This message goes to all users in a room and gets callen when the admin of the room leaves it
socket.on('killed_room', () => {
// server
personal_GameData.role = 'user';
personal_GameData.currGameID = null;
personal_GameData.EnterOnlineGame = false;

// some things
OnlineGame_Lobby.style.display = 'none';
SetPlayerNamesPopUp.style.display = 'none';
OnlineGameLobby_alertText.style.display = 'none';

CloseOnlinePopUps(true);

if (personal_GameData.role != "admin") {
AlertText.textContent = "Admin killed the lobby.";
DisplayPopUp_PopAnimation(alertPopUp, "flex", true);
};

// server
personal_GameData.role = 'user';
personal_GameData.currGameID = null;
personal_GameData.EnterOnlineGame = false;
});

// if they were in a game in the admin left the game
Expand All @@ -874,11 +879,20 @@ socket.on('killed_game', () => {
// clear timer and stuff to prevent bugs
clearTimer();

DarkLayer.style.display = "block";

// remove big screen text if there was one
if (document.querySelector(".bigScreenText")) {
document.querySelector(".bigScreenText").remove();
};

// lobby footer remove background
lobbyFooter.style.background = "";
lobbyFooterText.style.display = 'flex';

// play music
PauseMusic();
if (!PlayingInCreatedLevel) CreateMusicBars(audio);

DarkLayer.style.display = "block";
});

// Admin created the game and now waits for the second player
Expand Down Expand Up @@ -1012,11 +1026,14 @@ socket.on('INFORM_user_left_game', () => {
// so user can select game code with mouse
Lobby_GameCode_display.style.userSelect = 'text';

DarkLayer.style.display = 'block';

lobbyFooter.style.background = "";
lobbyFooterText.style.display = 'flex';

// play music
PauseMusic();
if (!PlayingInCreatedLevel) CreateMusicBars(audio);

DarkLayer.style.display = 'block';
};
});

Expand All @@ -1041,11 +1058,14 @@ socket.on('INFORM_blocker_left_game', () => {
friendLeft_text.textContent = 'The blocker left the game';
Lobby_GameCode_display.style.userSelect = 'text';

DarkLayer.style.display = 'block';

lobbyFooter.style.background = "";
lobbyFooterText.style.display = 'flex';

// play music
PauseMusic();
if (!PlayingInCreatedLevel) CreateMusicBars(audio);

DarkLayer.style.display = 'block';
};
});

Expand Down

0 comments on commit f2df425

Please sign in to comment.