Skip to content

Commit e0939c2

Browse files
committed
continued working on a lot of stuff and player level overview mainly
1 parent 42a84dc commit e0939c2

File tree

13 files changed

+885
-197
lines changed

13 files changed

+885
-197
lines changed

src/script/public/App/GameSetUp.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -330,13 +330,11 @@ function Click_single_NxN(e) {
330330
function UserCreateRoom(readOnlyLevel, Data1, Data2, UserName, thirdplayerRequired, PointsToWinGame, patterns) {
331331
let Check = SetGameData_CheckConfirm();
332332

333-
// console.log(NewCreativeLevel.Settings["playertimer"][NewCreativeLevel.selectedLevel[3]]);
334-
335333
// if Player1 Namefield and Player2 Namefield isn't empty etc., initialize Game
336334
if (Player1_NameInput.value != "" &&
337335
Player1_IconInput.value != "" &&
338336
Check[0] == true && Check[1] == true && !PlayingInCreatedLevel || PlayingInCreatedLevel &&
339-
Player1_NameInput.value != "" && Player1_IconInput.value != "" && Check[1] == true && NewCreativeLevel.Settings["playertimer"][NewCreativeLevel.selectedLevel[3]]) {
337+
Player1_NameInput.value != "" && Player1_IconInput.value != "" && Check[1] == true && creative_level_instance.Settings["playertimer"][creative_level_instance.selectedLevel[3]]) {
340338
// server
341339
let fieldIndex = curr_field_ele.getAttribute('index');
342340
let fieldTitle = curr_field_ele.getAttribute('title');
@@ -387,32 +385,32 @@ function UserCreateRoom(readOnlyLevel, Data1, Data2, UserName, thirdplayerRequir
387385
if (patterns) allowedPatternsFromUser = patterns;
388386

389387
if (PlayingInCreatedLevel) {
390-
Check[2] = NewCreativeLevel.Settings["playertimer"][NewCreativeLevel.selectedLevel[3]];
388+
Check[2] = creative_level_instance.Settings["playertimer"][creative_level_instance.selectedLevel[3]];
391389

392390
// set up x and y coordinates. case: default field is choosen
393-
if (NewCreativeLevel.selectedLevel[16] == {}) {
394-
costumX = NewCreativeLevel.Settings.cellgrid[NewCreativeLevel.selectedLevel[7]];
395-
costumY = NewCreativeLevel.Settings.cellgrid[NewCreativeLevel.selectedLevel[7]];
391+
if (creative_level_instance.selectedLevel[16] == {}) {
392+
costumX = creative_level_instance.Settings.cellgrid[creative_level_instance.selectedLevel[7]];
393+
costumY = creative_level_instance.Settings.cellgrid[creative_level_instance.selectedLevel[7]];
396394

397395
} else {
398-
costumX = NewCreativeLevel.selectedLevel[16]["x"];
399-
costumY = NewCreativeLevel.selectedLevel[16]["y"];
396+
costumX = creative_level_instance.selectedLevel[16]["x"];
397+
costumY = creative_level_instance.selectedLevel[16]["y"];
400398
};
401399

402400
if (costumX == undefined || costumY == undefined) {
403401
costumX = xyCell_Amount;
404402
costumY = xyCell_Amount;
405403
};
406404

407-
costumPatterns = NewCreativeLevel.selectedLevel[15];
405+
costumPatterns = creative_level_instance.selectedLevel[15];
408406

409-
allowedPatternsFromUser = NewCreativeLevel.selectedLevel[6];
407+
allowedPatternsFromUser = creative_level_instance.selectedLevel[6];
410408

411-
costumIcon = NewCreativeLevel.Settings.levelicon[NewCreativeLevel.selectedLevel[4]];
409+
costumIcon = creative_level_instance.Settings.levelicon[creative_level_instance.selectedLevel[4]];
412410

413-
fieldTitle = NewCreativeLevel.selectedLevel[8];
411+
fieldTitle = creative_level_instance.selectedLevel[8];
414412

415-
UserSetPointsToWinGameInput.value = NewCreativeLevel.selectedLevel[2];
413+
UserSetPointsToWinGameInput.value = creative_level_instance.selectedLevel[2];
416414
};
417415

418416
console.log(UserSetPointsToWinGameInput.value, PointsToWinGame, costumX, costumY, costumIcon);
@@ -601,18 +599,18 @@ function SetPlayerData_ConfirmEvent() {
601599
// check if this is user created level
602600
if (PlayingInCreatedLevel) {
603601
Check[0] = true;
604-
Check[2] = NewCreativeLevel.Settings.playertimer[NewCreativeLevel.selectedLevel[3]];
605-
UserSetPointsToWinGameInput.value = NewCreativeLevel.selectedLevel[2];
606-
allowedPatternsFromUser = NewCreativeLevel.selectedLevel[6];
602+
Check[2] = creative_level_instance.Settings.playertimer[creative_level_instance.selectedLevel[3]];
603+
UserSetPointsToWinGameInput.value = creative_level_instance.selectedLevel[2];
604+
allowedPatternsFromUser = creative_level_instance.selectedLevel[6];
607605

608606
// set up x and y coordinates. case: default field is choosen
609-
if (NewCreativeLevel.selectedLevel[16] == {}) {
610-
costumX = NewCreativeLevel.Settings.cellgrid[NewCreativeLevel.selectedLevel[7]];
611-
costumY = NewCreativeLevel.Settings.cellgrid[NewCreativeLevel.selectedLevel[7]];
607+
if (creative_level_instance.selectedLevel[16] == {}) {
608+
costumX = creative_level_instance.Settings.cellgrid[creative_level_instance.selectedLevel[7]];
609+
costumY = creative_level_instance.Settings.cellgrid[creative_level_instance.selectedLevel[7]];
612610

613611
} else {
614-
costumX = NewCreativeLevel.selectedLevel[16]["x"];
615-
costumY = NewCreativeLevel.selectedLevel[16]["y"];
612+
costumX = creative_level_instance.selectedLevel[16]["x"];
613+
costumY = creative_level_instance.selectedLevel[16]["y"];
616614
};
617615
};
618616

@@ -634,13 +632,15 @@ function SetPlayerData_ConfirmEvent() {
634632
curr_selected_PlayerClock = Check[2]; // Player Clock
635633

636634
DarkLayer.style.display = 'none';
635+
online_level_scene.style.display = 'none';
636+
637637
initializeGame(curr_field_ele, undefined, undefined, allowedPatternsFromUser, undefined, UserSetPointsToWinGameInput.value, undefined, undefined, [costumX, costumY]);
638638

639639
// play theme music
640640
PauseMusic();
641641
if (PlayingInCreatedLevel) {
642-
if (NewCreativeLevel.selectedLevel[5] != 0) {
643-
CreateMusicBars(document.querySelector(`[src="${NewCreativeLevel.Settings["bgmusic"][NewCreativeLevel.selectedLevel[5]]}"]`));
642+
if (creative_level_instance.selectedLevel[5] != 0) {
643+
CreateMusicBars(document.querySelector(`[src="${creative_level_instance.Settings["bgmusic"][creative_level_instance.selectedLevel[5]]}"]`));
644644
};
645645

646646
} else {

src/script/public/App/MaxTextLength.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ SearchBar_placeholderText.addEventListener('keydown', event => {
123123
};
124124
});
125125

126-
SearchLevelInput.addEventListener("keydown", () => {
126+
SearchLevelInput.addEventListener("keydown", (e) => {
127127
let len = event.target.value.trim().length;
128128
let hasSelection = false;
129129
let selection = window.getSelection();

src/script/public/App/documents.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ let AllowedPatternsContainer_ScrollBtn = document.querySelectorAll(".AllowedPatt
458458
let Credits = document.querySelector(".Credits");
459459
let Credits_closeBtn = document.querySelector(".Credits_closeBtn");
460460
let AddLevelBtn = document.querySelector(".AddLevelBtn");
461-
let ReplaceText_Levellist = document.querySelector(".ReplaceText_Levellist");
461+
let ReplaceText_Levellist = document.querySelectorAll(".ReplaceText_Levellist");
462462
let CurrentSelectedLevel_Display = document.querySelector(".CurrentSelectedLevel_Display");
463463
let closeSaveLevelWarning = document.querySelector(".closeSaveLevelWarning");
464464
let saveLevelWarnText = document.querySelector(".saveLevel_mainInnerWrapper");
@@ -618,6 +618,22 @@ let clan_playground_leave_text = document.querySelector(".clan_playground_leave_
618618
let clan_chat_chat = document.querySelector(".clan_chat_chat");
619619
let clan_chat_header = document.querySelector(".clan_chat_header");
620620
let clan_logo_el = document.querySelector(".clan_logo");
621+
let multiple_use_scene_content_wrapper = multiple_use_scene.querySelector(`[use_for]`);
622+
let multiple_use_scene_title = document.querySelector(".multiple_use_scene_title");
623+
let player_levels_results_list = document.querySelector(".player_levels_results_list");
624+
let player_level_search_btn = document.querySelector(".player_level_search_btn");
625+
let level_scene_back_btn = document.querySelector(".level_scene_back_btn");
626+
let online_level_scene = document.querySelector(".online_level_scene");
627+
let online_level_scene_title = document.querySelector(".online_level_scene_title");
628+
let level_scene_grid = document.querySelector(".level_scene_grid");
629+
let level_scene_patterns_btn = document.querySelector(".level_scene_patterns_btn");
630+
let level_scene_comments_btn = document.querySelector(".level_scene_comments_btn");
631+
let level_scene_likes_btn = document.querySelector(".level_scene_likes_btn");
632+
let level_scene_progress_text = document.querySelector(".level_scene_progress_text");
633+
let level_scene_progress_bar = document.querySelector(".level_scene_progress_bar");
634+
let level_scene_start_btn = document.querySelector(".level_scene_start_btn");
635+
let level_scene_common_pattern_btn = document.querySelector(".level_scene_common_pattern_btn");
636+
let level_scene_player_conquered_btn = document.querySelector(".level_scene_player_conquered_btn");
621637

622638
// Search Player elements
623639
let SearchPlayerPopUp = document.querySelector('.SearchPlayerPopUp');

src/script/public/App/features/AdvantureMap_scripts/stars.js

Lines changed: 44 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -474,54 +474,61 @@ class stars_handler {
474474
};
475475

476476
async check() {
477-
let starsUser = JSON.parse(localStorage.getItem("starsUser"));
478-
let filled_stars = [];
477+
if (inAdvantureMode) {
478+
endgame_level_stars.forEach(star => star.style.display = "block");
479479

480-
// fill stars that were already filled
481-
for (const [i, val] of Object.entries(starsUser[current_selected_level])) {
482-
if (val) {
483-
endgame_level_stars[i - 1].className = "endgame_level_stars fa-solid fa-star";
480+
let starsUser = JSON.parse(localStorage.getItem("starsUser"));
481+
let filled_stars = [];
482+
483+
// fill stars that were already filled
484+
for (const [i, val] of Object.entries(starsUser[current_selected_level])) {
485+
if (val) {
486+
endgame_level_stars[i - 1].className = "endgame_level_stars fa-solid fa-star";
487+
};
484488
};
485-
};
486489

487-
// check for new stars to be filled
488-
for (let [i, val] of Object.entries(this.liveData)) {
489-
i = Number(i);
490-
let condition = this.starsData[current_selected_level][i + 1]["requirementCondition"];
491-
let userValue = this.liveData[i];
490+
// check for new stars to be filled
491+
for (let [i, val] of Object.entries(this.liveData)) {
492+
i = Number(i);
493+
let condition = this.starsData[current_selected_level][i + 1]["requirementCondition"];
494+
let userValue = this.liveData[i];
492495

493-
if (this.starsUser[current_selected_level][i + 1] == true) continue;
496+
if (this.starsUser[current_selected_level][i + 1] == true) continue;
494497

495-
switch (i + 1) {
496-
case 2:
497-
if (MaxAmountOfMovesCount >= condition) {
498-
console.log(`Good! ${max_amount_of_moves - userValue} ${condition}`);
498+
switch (i + 1) {
499+
case 2:
500+
if (MaxAmountOfMovesCount >= condition) {
501+
console.log(`Good! ${max_amount_of_moves - userValue} ${condition}`);
499502

500-
starsUser[current_selected_level][i + 1] = true;
501-
filled_stars.push(endgame_level_stars[i]);
502-
};
503-
break;
503+
starsUser[current_selected_level][i + 1] = true;
504+
filled_stars.push(endgame_level_stars[i]);
505+
};
506+
break;
504507

505-
default:
506-
if (userValue <= condition) {
507-
console.log(`Good! ${userValue} ${condition}`)
508+
default:
509+
if (userValue <= condition) {
510+
console.log(`Good! ${userValue} ${condition}`)
508511

509-
starsUser[current_selected_level][i + 1] = true;
510-
filled_stars.push(endgame_level_stars[i]);
511-
};
512-
break;
512+
starsUser[current_selected_level][i + 1] = true;
513+
filled_stars.push(endgame_level_stars[i]);
514+
};
515+
break;
516+
};
513517
};
514-
};
515518

516-
// fill
517-
for (const i of filled_stars) {
518-
await sleep(750);
519-
this.fill_star_animation(i);
520-
};
519+
// fill
520+
for (const i of filled_stars) {
521+
await sleep(750);
522+
this.fill_star_animation(i);
523+
};
521524

522-
// save in storage
523-
localStorage.setItem("starsUser", JSON.stringify(starsUser));
524-
this.starsUser = starsUser;
525+
// save in storage
526+
localStorage.setItem("starsUser", JSON.stringify(starsUser));
527+
this.starsUser = starsUser;
528+
529+
} else {
530+
endgame_level_stars.forEach(star => star.style.display = "none");
531+
};
525532
};
526533

527534
fill_star_animation(star) {

src/script/public/App/music.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,15 @@ async function CreateMusicBars(Audio) {
7979
const barWidth = firstDiv.offsetWidth / numBars;
8080

8181
bars.forEach((bar, index) => {
82-
const barHeight = (dataArray[index] / 195) * firstDiv.offsetHeight;
82+
const barHeight = (dataArray[index] / 100) * firstDiv.offsetHeight;
8383

8484
bar.style.width = barWidth + "px";
8585
bar.style.height = barHeight + "px";
8686
});
8787

8888
bars2.forEach((bar, index) => {
8989
const reversedIndex = numBars - 1 - index; // Umkehren der Indexreihenfolge
90-
const barHeight = (dataArray[reversedIndex] / 195) * secondDiv.offsetHeight;
90+
const barHeight = (dataArray[reversedIndex] / 100) * secondDiv.offsetHeight;
9191

9292
bar.style.width = barWidth + "px";
9393
bar.style.height = barHeight + "px";

src/script/public/App/script.js

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ let GameMode = {
1616
"opponent": "CreateLevel",
1717
"icon": "",
1818
"description": "Arena",
19+
},
20+
4: {
21+
"opponent": "CreateLevel",
22+
"icon": "",
23+
"description": "Create Level",
1924
}
2025
};
2126

@@ -472,6 +477,11 @@ let socket;
472477
// check if admin created a lobby based on a self created game from the game cards or on a costum level which a user can create and publish to the server
473478
let PlayingInCreatedLevel = false;
474479

480+
let NewCreativeLevel;
481+
let player_levels_handler;
482+
let creative_level_instance;
483+
let inPlayerLevelsScene = false;
484+
475485
// Request friends from database and take action
476486
const RequestFriendsListFromDatabase = async() => {
477487
await socket.emit("RequestFriends", localStorage.getItem("PlayerID"), cb => {
@@ -1020,7 +1030,7 @@ fieldsArea_back_btn.addEventListener('click', () => {
10201030
DailyChallenge.check();
10211031
});
10221032

1023-
let NewCreativeLevel;
1033+
10241034
// Game Mode buttons
10251035
gameMode_KI_card.addEventListener('click', () => {
10261036
// if (localStorage.getItem("UserName")) {
@@ -1973,16 +1983,33 @@ class multiple_use_scenery {
19731983
this.events();
19741984
};
19751985

1976-
open(use_for) {
1986+
open(pop_up, use_for, close_el) {
19771987
this.use = use_for;
1978-
DisplayPopUp_PopAnimation(multiple_use_scene, "flex", false);
1988+
1989+
DarkLayerAnimation(multiple_use_scene, close_el);
1990+
this.alter_scene_use(pop_up, use_for);
19791991
};
19801992

19811993
events() {
19821994
use_scene_back_btn.addEventListener("click", () => {
1983-
multiple_use_scene.style.display = "none";
1995+
switch (multiple_use_scene.getAttribute("open_scene_x")) {
1996+
case "lobby":
1997+
DarkLayerAnimation(gameModeCards_Div, multiple_use_scene);
1998+
break;
1999+
2000+
case "social_scene":
2001+
DarkLayerAnimation(online_stuff_scene, multiple_use_scene);
2002+
break;
2003+
};
19842004
});
19852005
};
2006+
2007+
alter_scene_use(use, specific_content) {
2008+
multiple_use_scene.setAttribute("open_scene_x", use);
2009+
multiple_use_scene_content_wrapper.setAttribute("use_for", specific_content);
2010+
2011+
multiple_use_scene_title.textContent = this.use;
2012+
};
19862013
};
19872014

19882015
let use_scene = new multiple_use_scenery();
@@ -2004,4 +2031,11 @@ class scene_mode {
20042031
};
20052032

20062033
let sceneMode = new scene_mode();
2007-
sceneMode.default();
2034+
sceneMode.default();
2035+
2036+
SearchLevelInput.addEventListener("keyup", (e) => {
2037+
if (e.key == "Enter") {
2038+
e.preventDefault();
2039+
player_levels_handler.RequestLevelSearchResults(SearchLevelInput.value);
2040+
};
2041+
});

0 commit comments

Comments
 (0)