2025-03-05 11:39:47 +01:00
|
|
|
package de.towerdefence.server.match;
|
|
|
|
|
|
|
|
import de.towerdefence.server.player.Player;
|
2025-03-10 13:39:14 +01:00
|
|
|
import de.towerdefence.server.server.channels.match.placing.Tower;
|
2025-03-05 11:39:47 +01:00
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
@Service
|
|
|
|
public class MatchService {
|
|
|
|
private final Map<Player, Match> playerMatches = new HashMap<>();
|
|
|
|
|
|
|
|
public void createMatch(String matchId, Player player1, Player player2) {
|
|
|
|
Match match = new Match(matchId, player1, player2);
|
|
|
|
playerMatches.put(player1, match);
|
|
|
|
playerMatches.put(player2, match);
|
|
|
|
}
|
|
|
|
|
|
|
|
public Match get(Player player) {
|
|
|
|
return playerMatches.get(player);
|
|
|
|
}
|
2025-03-10 13:39:14 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return opponent
|
|
|
|
*/
|
|
|
|
public Player placeTower(Player player, int x, int y) throws InvalidPlacementException {
|
|
|
|
return playerMatches.get(player).addTower(player, new Tower(), x, y);
|
|
|
|
|
|
|
|
}
|
2025-03-05 11:39:47 +01:00
|
|
|
}
|