feat: dev-web - frontend login, register, dashboard

This commit is contained in:
kmitresse
2024-03-20 13:41:23 +01:00
parent 19ba5514b4
commit 6229718c4f
14 changed files with 280 additions and 93 deletions
@@ -9,16 +9,16 @@ import java.util.Set;
public class Deck {
private Set<Card> cards;
public Deck(){
public Deck(int nbColors, int nbValues){
cards = new HashSet<>();
initializeDeck();
initializeDeck(nbColors, nbValues);
shuffleDeck();
}
private void initializeDeck() {
for (Card.Color color : Card.Color.values()){
for (Card.Value value : Card.Value.values()) {
cards.add(new Card(color, value));
private void initializeDeck(int nbColors, int nbValues){
for (int i = 0; i < nbColors; i++) {
for (int j = 0; j < nbValues; j++) {
cards.add(new Card(Card.Color.values()[i], Card.Value.values()[j]));
}
}
}
@@ -3,6 +3,8 @@ package uppa.project.pojo;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
@@ -31,12 +33,28 @@ public class Game implements Serializable {
@Column(name="created_at")
private Date createdAt;
@Column(name = "difficulty")
@Enumerated(EnumType.STRING)
private User.Gender difficulty;
@OneToMany(mappedBy = "game", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private Set<Player> players;
public Game() {
}
public Game(User.Gender difficulty) {
this.difficulty = difficulty;
}
public Game(BigDecimal id, Date createdAt, User.Gender difficulty, Set<Player> players) {
this.id = id;
this.createdAt = createdAt;
this.difficulty = difficulty;
this.players = players;
}
@Override
public int hashCode() {
return Objects.hash(id, createdAt, players);
@@ -49,6 +67,14 @@ public class Game implements Serializable {
return createdAt;
}
public User.Gender getDifficulty() {
return difficulty;
}
public void setDifficulty(User.Gender difficulty) {
this.difficulty = difficulty;
}
public Set<Player> getPlayers() {
return players;
}
@@ -67,4 +93,7 @@ public class Game implements Serializable {
public String toString() {
return String.format("Game{id=%s, createdAt=%s, players=%s}", id.toString(), createdAt, players);
}
public static enum difficulty {EASY, HARD}
}
@@ -32,35 +32,46 @@ public class User implements Serializable {
@Column(name = "username")
private String username;
@Column(name = "email")
private String email;
@Column(name = "password")
private String password;
@Temporal(TemporalType.DATE)
@Column(name = "birth")
private Date birth;
@Column(name = "gender")
@Enumerated(EnumType.STRING)
private Gender gender;
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private Set<Player> playedGame;
public User() {
}
public User(String username, String password, Date birth, Gender gender) {
public User(String username, String email, String password, Date birth, Gender gender) {
this.username = username;
this.email = email;
this.password = hashPassword(password);
this.birth = birth;
this.gender = gender;
}
public User(BigDecimal id, String username, String password) {
public User(BigDecimal id, String username, String email, String password, Date birth, Gender gender) {
this.id = id;
this.username = username;
this.email = email;
this.password = password;
this.birth = birth;
this.gender = gender;
}
@Override
public int hashCode() {
return Objects.hash(id, username, password, birth, gender);
return Objects.hash(id, username, email, password, birth, gender);
}
public BigDecimal getId() {
@@ -75,6 +86,14 @@ public class User implements Serializable {
this.username = username;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPassword() {
return password;
}
@@ -135,5 +154,5 @@ public class User implements Serializable {
return String.format("User{id=%s, username='%s', birth=%s, gender=%s}", id.toString(), username, birth.toString(), gender.toString());
}
public enum Gender {MALE, FEMALE, OTHER}
public static enum Gender {MALE, FEMALE, OTHER}
}