mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
* Used some default code to get opponents for Game classes.
This commit is contained in:
parent
f249a819e9
commit
58d618e8d7
8 changed files with 30 additions and 142 deletions
|
|
@ -139,21 +139,37 @@ public interface Game extends MageItem, Serializable {
|
|||
PlayerList getPlayerList();
|
||||
|
||||
/**
|
||||
* Returns a Set of opponents in range for the given playerId
|
||||
* Returns a Set of opponents in range for the given playerId This return
|
||||
* also a player, that has dies this turn.
|
||||
*
|
||||
* @param playerId
|
||||
* @return
|
||||
*/
|
||||
Set<UUID> getOpponents(UUID playerId);
|
||||
default public Set<UUID> getOpponents(UUID playerId) {
|
||||
Set<UUID> opponents = new HashSet<>();
|
||||
Player player = getPlayer(playerId);
|
||||
for (UUID opponentId : player.getInRange()) {
|
||||
if (!opponentId.equals(playerId)) {
|
||||
opponents.add(opponentId);
|
||||
}
|
||||
}
|
||||
return opponents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given playerToCheckId is an opponent of player
|
||||
* Checks if the given playerToCheckId is an opponent of player As long as
|
||||
* no team formats are implemented, this method returns always true for each
|
||||
* playerId not equal to the player it is checked for. Also if this player
|
||||
* is out of range. This method can't handle that only players in range are
|
||||
* processed because it can only return TRUE or FALSE.
|
||||
*
|
||||
* @param player
|
||||
* @param playerToCheckId
|
||||
* @return
|
||||
*/
|
||||
boolean isOpponent(Player player, UUID playerToCheckId);
|
||||
default public boolean isOpponent(Player player, UUID playerToCheckId) {
|
||||
return !player.getId().equals(playerToCheckId);
|
||||
}
|
||||
|
||||
Turn getTurn();
|
||||
|
||||
|
|
|
|||
|
|
@ -27,14 +27,13 @@
|
|||
*/
|
||||
package mage.game;
|
||||
|
||||
import java.util.*;
|
||||
import mage.constants.MultiplayerAttackOption;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.RangeOfInfluence;
|
||||
import mage.game.turn.TurnMod;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public abstract class GameCanadianHighlanderImpl extends GameImpl {
|
||||
|
||||
protected boolean startingPlayerSkipsDraw = true;
|
||||
|
|
@ -160,19 +159,4 @@ public abstract class GameCanadianHighlanderImpl extends GameImpl {
|
|||
super.endMulligan(playerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<UUID> getOpponents(UUID playerId) {
|
||||
Set<UUID> opponents = new HashSet<>();
|
||||
for (UUID opponentId : getState().getPlayersInRange(playerId, this)) {
|
||||
if (!opponentId.equals(playerId)) {
|
||||
opponents.add(opponentId);
|
||||
}
|
||||
}
|
||||
return opponents;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpponent(Player player, UUID playerToCheck) {
|
||||
return !player.getId().equals(playerToCheck);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,9 +27,7 @@
|
|||
*/
|
||||
package mage.game;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
|
|
@ -200,22 +198,6 @@ public abstract class GameCommanderImpl extends GameImpl {
|
|||
return super.checkStateBasedActions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<UUID> getOpponents(UUID playerId) {
|
||||
Set<UUID> opponents = new HashSet<>();
|
||||
for (UUID opponentId : getState().getPlayersInRange(playerId, this)) {
|
||||
if (!opponentId.equals(playerId)) {
|
||||
opponents.add(opponentId);
|
||||
}
|
||||
}
|
||||
return opponents;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpponent(Player player, UUID playerToCheck) {
|
||||
return !player.getId().equals(playerToCheck);
|
||||
}
|
||||
|
||||
public void setAlsoHand(boolean alsoHand) {
|
||||
this.alsoHand = alsoHand;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,22 +132,6 @@ public abstract class GameTinyLeadersImpl extends GameImpl {
|
|||
return commander;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<UUID> getOpponents(UUID playerId) {
|
||||
Set<UUID> opponents = new HashSet<>();
|
||||
for (UUID opponentId : getState().getPlayersInRange(playerId, this)) {
|
||||
if (!opponentId.equals(playerId)) {
|
||||
opponents.add(opponentId);
|
||||
}
|
||||
}
|
||||
return opponents;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpponent(Player player, UUID playerToCheck) {
|
||||
return !player.getId().equals(playerToCheck);
|
||||
}
|
||||
|
||||
public void setAlsoHand(boolean alsoHand) {
|
||||
this.alsoHand = alsoHand;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue