mirror of
https://github.com/magefree/mage.git
synced 2025-12-26 05:22:02 -08:00
* UI: improved hand request dialog (users can ask your hand once per game, reset it by re-activate button);
This commit is contained in:
parent
a18c3e1d88
commit
9a9b304fd5
8 changed files with 82 additions and 59 deletions
|
|
@ -855,7 +855,9 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
|
||||
void revokePermissionToSeeHandCards();
|
||||
|
||||
boolean isRequestToShowHandCardsAllowed();
|
||||
boolean isPlayerAllowedToRequestHand(UUID gameId, UUID requesterPlayerId);
|
||||
|
||||
void addPlayerToRequestedHandList(UUID gameId, UUID requesterPlayerId);
|
||||
|
||||
Set<UUID> getUsersAllowedToSeeHandCards();
|
||||
|
||||
|
|
|
|||
|
|
@ -2284,6 +2284,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
break;
|
||||
case PERMISSION_REQUESTS_ALLOWED_ON:
|
||||
userData.setAllowRequestShowHandCards(true);
|
||||
userData.resetRequestedHandPlayersList(game.getId()); // users can send request again
|
||||
break;
|
||||
}
|
||||
logger.trace("PASS Priority: " + playerAction.toString());
|
||||
|
|
@ -3969,8 +3970,13 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isRequestToShowHandCardsAllowed() {
|
||||
return userData.isAllowRequestShowHandCards();
|
||||
public boolean isPlayerAllowedToRequestHand(UUID gameId, UUID requesterPlayerId) {
|
||||
return userData.isAllowRequestHandToPlayer(gameId, requesterPlayerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPlayerToRequestedHandList(UUID gameId, UUID requesterPlayerId) {
|
||||
userData.addPlayerToRequestedHandList(gameId, requesterPlayerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package mage.players.net;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* User data that is passed during connection to the server.
|
||||
|
|
@ -24,6 +25,7 @@ public class UserData implements Serializable {
|
|||
protected boolean autoOrderTrigger;
|
||||
protected boolean useFirstManaAbility = false;
|
||||
private String userIdStr;
|
||||
protected Map<UUID, Set<UUID>> requestedHandPlayersList; // game -> players list
|
||||
|
||||
protected String matchHistory;
|
||||
protected int matchQuitRatio;
|
||||
|
|
@ -35,9 +37,9 @@ public class UserData implements Serializable {
|
|||
private int limitedRating;
|
||||
|
||||
public UserData(UserGroup userGroup, int avatarId, boolean showAbilityPickerForced,
|
||||
boolean allowRequestShowHandCards, boolean confirmEmptyManaPool, UserSkipPrioritySteps userSkipPrioritySteps,
|
||||
String flagName, boolean askMoveToGraveOrder, boolean manaPoolAutomatic, boolean manaPoolAutomaticRestricted,
|
||||
boolean passPriorityCast, boolean passPriorityActivation, boolean autoOrderTrigger, boolean useFirstManaAbility, String userIdStr) {
|
||||
boolean allowRequestShowHandCards, boolean confirmEmptyManaPool, UserSkipPrioritySteps userSkipPrioritySteps,
|
||||
String flagName, boolean askMoveToGraveOrder, boolean manaPoolAutomatic, boolean manaPoolAutomaticRestricted,
|
||||
boolean passPriorityCast, boolean passPriorityActivation, boolean autoOrderTrigger, boolean useFirstManaAbility, String userIdStr) {
|
||||
this.groupId = userGroup.getGroupId();
|
||||
this.avatarId = avatarId;
|
||||
this.showAbilityPickerForced = showAbilityPickerForced;
|
||||
|
|
@ -57,6 +59,7 @@ public class UserData implements Serializable {
|
|||
this.tourneyHistory = "";
|
||||
this.tourneyQuitRatio = 0;
|
||||
this.userIdStr = userIdStr;
|
||||
this.requestedHandPlayersList = new HashMap<>();
|
||||
}
|
||||
|
||||
public void update(UserData userData) {
|
||||
|
|
@ -106,14 +109,35 @@ public class UserData implements Serializable {
|
|||
this.showAbilityPickerForced = showAbilityPickerForced;
|
||||
}
|
||||
|
||||
public boolean isAllowRequestShowHandCards() {
|
||||
public boolean isAllowRequestHandToAll() {
|
||||
return allowRequestShowHandCards;
|
||||
}
|
||||
|
||||
public boolean isAllowRequestHandToPlayer(UUID gameId, UUID requesterPlayerId) {
|
||||
// once per game
|
||||
boolean allowToPlayer = true;
|
||||
if (requestedHandPlayersList.containsKey(gameId) && requestedHandPlayersList.get(gameId).contains(requesterPlayerId)) {
|
||||
allowToPlayer = false;
|
||||
}
|
||||
return isAllowRequestHandToAll() && allowToPlayer;
|
||||
}
|
||||
|
||||
public void addPlayerToRequestedHandList(UUID gameId, UUID requesterPlayerId) {
|
||||
if (!requestedHandPlayersList.containsKey(gameId)) {
|
||||
requestedHandPlayersList.put(gameId, new HashSet<>());
|
||||
}
|
||||
Set<UUID> requestedPlayers = requestedHandPlayersList.get(gameId);
|
||||
requestedPlayers.add(requesterPlayerId);
|
||||
}
|
||||
|
||||
public void setAllowRequestShowHandCards(boolean allowRequestShowHandCards) {
|
||||
this.allowRequestShowHandCards = allowRequestShowHandCards;
|
||||
}
|
||||
|
||||
public void resetRequestedHandPlayersList(UUID gameId) {
|
||||
this.requestedHandPlayersList.remove(gameId);
|
||||
}
|
||||
|
||||
public UserSkipPrioritySteps getUserSkipPrioritySteps() {
|
||||
return userSkipPrioritySteps;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue