Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added profile button functionality #15

Closed
wants to merge 10 commits into from
51 changes: 50 additions & 1 deletion html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<a class="nav-link" href="#leaderboard">LEADERBOARD</a>
</li>
<li>
<a class="nav-link" href="#">PROFILE</a>
<a class="nav-link" href="#profile" onclick="showProfile()">PROFILE</a>
</li>
<li>
<a class="nav-link" href="#contact">SUPPORT</a>
Expand Down Expand Up @@ -154,6 +154,17 @@ <h1>LOBBY</h1>
</div>
</div>

<div data-aos="fade-up" class="container-fluid custom-body d-none" id="profile">
<div id="home" class="container-fluid text-center flex-column d-flex justify-content-center align-items-center"
style="height: 100vh;">
<h1 style="font-size: 5vw;">PROFILE</h1>
<h3 >GAMES WON: </h3>
<h3 >GAMES LOST: </h3>
<a class="btn btn-primary justify-content-center btn-lg active" onclick=goBackToGame()
role="button" aria-pressed="true">GO BACK TO GAME</a>
</div>
</div>

<!-- DO A FOR EACH LOOP TO DISPLAY THE PLAYERS IN THE LEADERBOARD -->
<div data-aos="fade-up" class="d-flex justify-content-center flex-column text-center h-auto pb-5" id="leaderboard">
<h1>LEADERBOARD</h1>
Expand Down Expand Up @@ -309,6 +320,9 @@ <h1>LEADERBOARD</h1>
// Hide matchmaking form
document.getElementById("lobby").classList.add("d-none");

// Hide profile elements
document.getElementById("profile").classList.add("d-none");

// Show game elements
document.getElementById("game").classList.remove("d-none");

Expand All @@ -319,6 +333,41 @@ <h1>LEADERBOARD</h1>
// Start matchmaking process or any other game initialization logic
}

function showProfile() {
// Hide matchmaking form
document.getElementById("lobby").classList.add("d-none");

// Hide game elements
document.getElementById("game").classList.add("d-none");


// Show profile elements
document.getElementById("profile").classList.remove("d-none");

// Update player names
// document.getElementById("playerOneName").innerText = "@" + UserId.toUpperCase();
document.getElementById("playerTwoName").innerText = "@opponent"; // Replace "opponent" with actual opponent's name

// Start matchmaking process or any other game initialization logic
}

function goBackToGame() {
// Hide matchmaking form
document.getElementById("lobby").classList.add("d-none");

// Hide profile elements
document.getElementById("profile").classList.add("d-none");

// Show game elements
document.getElementById("game").classList.remove("d-none");

// Update player names
// document.getElementById("playerOneName").innerText = "@" + UserId.toUpperCase();
document.getElementById("playerTwoName").innerText = "@opponent"; // Replace "opponent" with actual opponent's name

// Start matchmaking process or any other game initialization logic
}

</script>


Expand Down
25 changes: 25 additions & 0 deletions src/test/java/com/cse3310/GameTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.cse3310;
import java.util.ArrayList;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

public class GameTest {
Game game = new Game();
User user = new User("user");
ArrayList<User> users = new ArrayList<>();
/**
* if a player's score equals 4 their wins should equal 4
*/
@Test
public void addFourToScoreAndWins()
{
users.add(user);
user.gameWon+=4;
game.checkWin(user);
//assertTrue(users.contains(user));
assertEquals(4, user.gameWon);

}
}
31 changes: 31 additions & 0 deletions src/test/java/com/cse3310/UserTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.cse3310;
import java.util.ArrayList;

import org.junit.Test;
import static org.junit.Assert.assertTrue;

public class UserTest {
User user1 = new User("");
User user2 = new User("");
//Game game = new Game();
ArrayList<User> users = new ArrayList<>();
/**
* no duplicate usernames
*/
public boolean usernamesAreNotEqual(ArrayList<User> users, String username1, String username2)
{
user1.setName(username1);
user2.setName(username2);
if(user1.getName().equals(user2.getName()))
{
return false;
}
return true;
}

@Test
public void testForDuplicateUsernames()
{
assertTrue(usernamesAreNotEqual(users, "user", "user1"));
}
}