mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
Some changes to manual mana pool handling.
This commit is contained in:
parent
5481841b9f
commit
d9e4e99a0f
13 changed files with 33 additions and 24 deletions
|
@ -414,7 +414,6 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
zonesPanel.setSize(100, 20);
|
||||
zonesPanel.setLayout(null);
|
||||
|
||||
//
|
||||
image = ImageHelper.getImageFromResources("/info/command_zone.png");
|
||||
r = new Rectangle(21, 21);
|
||||
resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
|
||||
|
@ -735,7 +734,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
private void btnManaActionPerformed(ManaType manaType) {
|
||||
session.sendPlayerManaType(gameId, manaType);
|
||||
session.sendPlayerManaType(gameId, player.getPlayerId(), manaType);
|
||||
}
|
||||
|
||||
private void btnGraveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGraveActionPerformed
|
||||
|
@ -764,10 +763,6 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
private ImagePanel life;
|
||||
private ImagePanel poison;
|
||||
private ImagePanel hand;
|
||||
|
||||
// private HoverButton btnWhiteMana;
|
||||
// private HoverButton btnBlueMana;
|
||||
|
||||
private HoverButton grave;
|
||||
private ImagePanel library;
|
||||
private CardView topCard;
|
||||
|
|
|
@ -114,7 +114,7 @@ public interface MageServer {
|
|||
void sendPlayerString(UUID gameId, String sessionId, String data) throws MageException;
|
||||
void sendPlayerBoolean(UUID gameId, String sessionId, Boolean data) throws MageException;
|
||||
void sendPlayerInteger(UUID gameId, String sessionId, Integer data) throws MageException;
|
||||
void sendPlayerManaType(UUID gameId, String sessionId, ManaType data) throws MageException;
|
||||
void sendPlayerManaType(UUID gameId, UUID playerId, String sessionId, ManaType data) throws MageException;
|
||||
void concedeGame(UUID gameId, String sessionId) throws MageException;
|
||||
void quitMatch(UUID gameId, String sessionId) throws MageException;
|
||||
void undo(UUID gameId, String sessionId) throws MageException;
|
||||
|
|
|
@ -625,10 +625,10 @@ public class SessionImpl implements Session {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean sendPlayerManaType(UUID gameId, ManaType data) {
|
||||
public boolean sendPlayerManaType(UUID gameId, UUID playerId, ManaType data) {
|
||||
try {
|
||||
if (isConnected()) {
|
||||
server.sendPlayerManaType(gameId, sessionId, data);
|
||||
server.sendPlayerManaType(gameId, playerId, sessionId, data);
|
||||
return true;
|
||||
}
|
||||
} catch (MageException ex) {
|
||||
|
|
|
@ -51,7 +51,7 @@ public interface GamePlay {
|
|||
|
||||
boolean sendPlayerString(UUID gameId, String data);
|
||||
|
||||
boolean sendPlayerManaType(UUID gameId, ManaType data);
|
||||
boolean sendPlayerManaType(UUID gameId, UUID playerId, ManaType data);
|
||||
|
||||
boolean concedeGame(UUID gameId);
|
||||
|
||||
|
|
|
@ -520,8 +520,11 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
|||
}
|
||||
} else if (response.getManaType() != null) {
|
||||
// this mana type can be paid once from pool
|
||||
if (response.getResponseManaTypePlayerId().equals(this.getId())) {
|
||||
this.getManaPool().unlockManaType(response.getManaType());
|
||||
}
|
||||
// TODO: Handle if mana pool
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -965,9 +968,10 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setResponseManaType(ManaType manaType) {
|
||||
public void setResponseManaType(UUID playerId, ManaType manaType) {
|
||||
synchronized(response) {
|
||||
response.setManaType(manaType);
|
||||
response.setResponseManaTypePlayerId(playerId);
|
||||
response.notify();
|
||||
log.debug("Got response mana type from player: " + getId());
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ public class PlayerResponse implements Serializable {
|
|||
private Boolean responseBoolean;
|
||||
private Integer responseInteger;
|
||||
private ManaType responseManaType;
|
||||
private UUID responseManaTypePlayerId;
|
||||
|
||||
public void clear() {
|
||||
responseString = null;
|
||||
|
@ -50,6 +51,7 @@ public class PlayerResponse implements Serializable {
|
|||
responseBoolean = null;
|
||||
responseInteger = null;
|
||||
responseManaType = null;
|
||||
responseManaTypePlayerId = null;
|
||||
}
|
||||
|
||||
public String getString() {
|
||||
|
@ -92,4 +94,12 @@ public class PlayerResponse implements Serializable {
|
|||
this.responseManaType = responseManaType;
|
||||
}
|
||||
|
||||
public UUID getResponseManaTypePlayerId() {
|
||||
return responseManaTypePlayerId;
|
||||
}
|
||||
|
||||
public void setResponseManaTypePlayerId(UUID responseManaTypePlayerId) {
|
||||
this.responseManaTypePlayerId = responseManaTypePlayerId;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -570,13 +570,13 @@ public class MageServerImpl implements MageServer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sendPlayerManaType(final UUID gameId, final String sessionId, final ManaType data) throws MageException {
|
||||
public void sendPlayerManaType(final UUID gameId, final UUID playerId, final String sessionId, final ManaType data) throws MageException {
|
||||
execute("sendPlayerManaType", sessionId, new Action() {
|
||||
@Override
|
||||
public void execute() {
|
||||
User user = SessionManager.getInstance().getUser(sessionId);
|
||||
if (user != null) {
|
||||
user.sendPlayerManaType(gameId, data);
|
||||
user.sendPlayerManaType(gameId, playerId, data);
|
||||
} else {
|
||||
logger.warn("Your session expired: gameId=" + gameId + ", sessionId=" + sessionId);
|
||||
}
|
||||
|
|
|
@ -223,9 +223,9 @@ public class User {
|
|||
GameManager.getInstance().sendPlayerString(gameId, userId, data);
|
||||
}
|
||||
|
||||
public void sendPlayerManaType(final UUID gameId, final ManaType data) {
|
||||
public void sendPlayerManaType(final UUID gameId, final UUID playerId, final ManaType data) {
|
||||
lastActivity = new Date();
|
||||
GameManager.getInstance().sendPlayerManaType(gameId, userId, data);
|
||||
GameManager.getInstance().sendPlayerManaType(gameId, playerId, userId, data);
|
||||
}
|
||||
|
||||
public void sendPlayerBoolean(final UUID gameId, final Boolean data) {
|
||||
|
|
|
@ -475,11 +475,11 @@ public class GameController implements GameCallback {
|
|||
});
|
||||
}
|
||||
|
||||
public void sendPlayerManaType(UUID userId, final ManaType data) {
|
||||
public void sendPlayerManaType(UUID userId, UUID playerId, final ManaType data) {
|
||||
sendMessage(userId, new Command() {
|
||||
@Override
|
||||
public void execute(UUID playerId) {
|
||||
getGameSession(playerId).sendPlayerManaType(data);
|
||||
getGameSession(playerId).sendPlayerManaType(data, playerId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -85,9 +85,9 @@ public class GameManager {
|
|||
}
|
||||
}
|
||||
|
||||
public void sendPlayerManaType(UUID gameId, UUID userId, ManaType data) {
|
||||
public void sendPlayerManaType(UUID gameId, UUID playerId, UUID userId, ManaType data) {
|
||||
if (gameControllers.containsKey(gameId)) {
|
||||
gameControllers.get(gameId).sendPlayerManaType(userId, data);
|
||||
gameControllers.get(gameId).sendPlayerManaType(userId, playerId, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -221,9 +221,9 @@ public class GameSession extends GameWatcher {
|
|||
game.getPlayer(playerId).setResponseString(data);
|
||||
}
|
||||
|
||||
public void sendPlayerManaType(ManaType manaType) {
|
||||
public void sendPlayerManaType(ManaType manaType, UUID playerId) {
|
||||
cancelTimeout();
|
||||
game.getPlayer(playerId).setResponseManaType(manaType);
|
||||
game.getPlayer(playerId).setResponseManaType(playerId, manaType);
|
||||
}
|
||||
|
||||
public void sendPlayerBoolean(Boolean data) {
|
||||
|
|
|
@ -278,7 +278,7 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
void setResponseUUID(UUID responseUUID);
|
||||
void setResponseBoolean(Boolean responseBoolean);
|
||||
void setResponseInteger(Integer data);
|
||||
void setResponseManaType(ManaType responseManaType);
|
||||
void setResponseManaType(UUID playerId, ManaType responseManaType);
|
||||
|
||||
boolean priority(Game game);
|
||||
boolean choose(Outcome outcome, Target target, UUID sourceId, Game game);
|
||||
|
|
|
@ -1473,7 +1473,7 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
|||
public void setResponseString(String responseString) {}
|
||||
|
||||
@Override
|
||||
public void setResponseManaType(ManaType responseManaType) {}
|
||||
public void setResponseManaType(UUID playerId, ManaType responseManaType) {}
|
||||
|
||||
@Override
|
||||
public void setResponseUUID(UUID responseUUID) {}
|
||||
|
|
Loading…
Reference in a new issue