generated from Arquisoft/wiq_0
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into code-smells
- Loading branch information
Showing
27 changed files
with
1,075 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.uniovi.entities; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
@Getter // getters para todas las propiedades | ||
@Setter // setters para todas las propiedades | ||
@Entity | ||
public class MultiplayerSession { | ||
@Id | ||
@GeneratedValue | ||
private Long id; | ||
@Column | ||
private String multiplayerCode; | ||
|
||
@ElementCollection | ||
@Column | ||
private Map<Player, Integer> playerScores = new HashMap<>(); | ||
|
||
public MultiplayerSession() {} | ||
|
||
public MultiplayerSession(String code, Player p) { | ||
this.multiplayerCode=code; | ||
playerScores.put(p,-1); | ||
|
||
} | ||
|
||
public void addPlayer(Player p){ | ||
playerScores.put(p,-1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/main/java/com/uniovi/repositories/MultiplayerSessionRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.uniovi.repositories; | ||
|
||
import com.uniovi.entities.GameSession; | ||
import com.uniovi.entities.MultiplayerSession; | ||
import com.uniovi.entities.Player; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.CrudRepository; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
import java.util.List; | ||
|
||
public interface MultiplayerSessionRepository extends CrudRepository<MultiplayerSession, Long> { | ||
MultiplayerSession findByMultiplayerCode(String code); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
package com.uniovi.repositories; | ||
|
||
import com.uniovi.entities.Player; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.repository.CrudRepository; | ||
|
||
public interface PlayerRepository extends CrudRepository<Player, Long> { | ||
Player findByEmail(String email); | ||
Player findByUsername(String nickname); | ||
@Query("SELECT player FROM Player player WHERE player.multiplayerCode=:multiplayerCode") | ||
Iterable<Player> findAllByMultiplayerCode(int multiplayerCode); | ||
|
||
Page<Player> findAll(Pageable pageable); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/com/uniovi/services/MultiplayerSessionService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.uniovi.services; | ||
|
||
import com.uniovi.entities.GameSession; | ||
import com.uniovi.entities.MultiplayerSession; | ||
import com.uniovi.entities.Player; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@Service | ||
public interface MultiplayerSessionService { | ||
|
||
Map<Player, Integer> getPlayersWithScores(int multiplayerCode); | ||
void multiCreate(String code, Long id); | ||
|
||
void addToLobby(String code, Long id); | ||
|
||
void changeScore(String code,Long id,int score); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.