1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-04-10 17:00:08 -09:00

Changed history handling for user a bit. Added history to table waiting dialog and user avatar tooltip.

This commit is contained in:
LevelX2 2016-01-23 13:37:34 +01:00
parent 24dddd3e06
commit 151e678e84
9 changed files with 102 additions and 79 deletions
Mage.Client/src/main/java/mage/client
Mage.Common/src/mage/view
Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human
Mage.Server/src/main/java/mage/server
Mage/src/main/java/mage

View file

@ -26,7 +26,7 @@
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
/* /*
* TableWaitingDialog.java * TableWaitingDialog.java
* *
* Created on Dec 16, 2009, 10:27:44 AM * Created on Dec 16, 2009, 10:27:44 AM
@ -68,7 +68,7 @@ public class TableWaitingDialog extends MageDialog {
private Session session; private Session session;
private final TableWaitModel tableWaitModel; private final TableWaitModel tableWaitModel;
private UpdateSeatsTask updateTask; private UpdateSeatsTask updateTask;
private static final int[] defaultColumnsWidth = {20, 50, 100, 100}; private static final int[] defaultColumnsWidth = {20, 50, 100, 100, 100};
/** /**
* Creates new form TableWaitingDialog * Creates new form TableWaitingDialog
@ -268,10 +268,8 @@ public class TableWaitingDialog extends MageDialog {
if (session.startMatch(roomId, tableId)) { if (session.startMatch(roomId, tableId)) {
closeDialog(); closeDialog();
} }
} else { } else if (session.startTournament(roomId, tableId)) {
if (session.startTournament(roomId, tableId)) { closeDialog();
closeDialog();
}
} }
}//GEN-LAST:event_btnStartActionPerformed }//GEN-LAST:event_btnStartActionPerformed
@ -319,7 +317,7 @@ public class TableWaitingDialog extends MageDialog {
class TableWaitModel extends AbstractTableModel { class TableWaitModel extends AbstractTableModel {
private final String[] columnNames = new String[]{"Seat", "Loc", "Player Name", "Player Type"}; private final String[] columnNames = new String[]{"Seat", "Loc", "Player Name", "Player Type", "History"};
private SeatView[] seats = new SeatView[0]; private SeatView[] seats = new SeatView[0];
public void loadData(TableView table) { public void loadData(TableView table) {
@ -353,6 +351,8 @@ class TableWaitModel extends AbstractTableModel {
return seats[arg0].getPlayerName(); return seats[arg0].getPlayerName();
case 3: case 3:
return seats[arg0].getPlayerType(); return seats[arg0].getPlayerType();
case 4:
return seats[arg0].getHistory();
} }
} }
return ""; return "";

View file

@ -26,7 +26,7 @@
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
/* /*
* PlayerPanel.java * PlayerPanel.java
* *
* Created on Nov 18, 2009, 3:01:31 PM * Created on Nov 18, 2009, 3:01:31 PM
@ -288,7 +288,8 @@ public class PlayerPanelExt extends javax.swing.JPanel {
basicTooltipText = "<HTML>Name: " + player.getName() basicTooltipText = "<HTML>Name: " + player.getName()
+ "<br/>Country: " + countryname + "<br/>Country: " + countryname
+ "<br/>Deck hash code: " + player.getDeckHashCode() + "<br/>Deck hash code: " + player.getDeckHashCode()
+ "<br/>Wins: " + player.getWins() + " of " + player.getWinsNeeded() + " (to win the match)"; + "<br/>This match wins: " + player.getWins() + " of " + player.getWinsNeeded() + " (to win the match)"
+ (player.getUserData() == null ? "" : "<br/>History: " + player.getUserData().getHistory());
} }
// Extend tooltip // Extend tooltip
StringBuilder tooltipText = new StringBuilder(basicTooltipText); StringBuilder tooltipText = new StringBuilder(basicTooltipText);

View file

@ -44,6 +44,7 @@ public class SeatView implements Serializable {
private UUID playerId; private UUID playerId;
private final String playerName; private final String playerName;
private final String playerType; private final String playerType;
private final String history;
public SeatView(Seat seat) { public SeatView(Seat seat) {
if (seat.getPlayer() != null) { if (seat.getPlayer() != null) {
@ -51,13 +52,16 @@ public class SeatView implements Serializable {
this.playerName = seat.getPlayer().getName(); this.playerName = seat.getPlayer().getName();
if (seat.getPlayer().getUserData() == null) { if (seat.getPlayer().getUserData() == null) {
this.flagName = UserData.getDefaultFlagName(); this.flagName = UserData.getDefaultFlagName();
this.history = "";
} else { } else {
this.flagName = seat.getPlayer().getUserData().getFlagName(); this.flagName = seat.getPlayer().getUserData().getFlagName();
this.history = seat.getPlayer().getUserData().getHistory();
} }
} else { } else {
// Empty seat // Empty seat
this.playerName = ""; this.playerName = "";
this.flagName = ""; this.flagName = "";
this.history = "";
} }
this.playerType = seat.getPlayerType(); this.playerType = seat.getPlayerType();
} }
@ -78,4 +82,8 @@ public class SeatView implements Serializable {
return flagName; return flagName;
} }
public String getHistory() {
return history;
}
} }

View file

@ -358,15 +358,13 @@ public class HumanPlayer extends PlayerImpl {
} }
} }
} }
} else { } else if (target.canTarget(response.getUUID(), game)) {
if (target.canTarget(response.getUUID(), game)) { if (target.getTargets().contains(response.getUUID())) { // if already included remove it with
if (target.getTargets().contains(response.getUUID())) { // if already included remove it with target.remove(response.getUUID());
target.remove(response.getUUID()); } else {
} else { target.addTarget(response.getUUID(), null, game);
target.addTarget(response.getUUID(), null, game); if (target.doneChosing()) {
if (target.doneChosing()) { return true;
return true;
}
} }
} }
} }
@ -530,12 +528,10 @@ public class HumanPlayer extends PlayerImpl {
if (response.getUUID() != null) { if (response.getUUID() != null) {
if (target.getTargets().contains(response.getUUID())) { // if already included remove it if (target.getTargets().contains(response.getUUID())) { // if already included remove it
target.remove(response.getUUID()); target.remove(response.getUUID());
} else { } else if (target.canTarget(response.getUUID(), cards, game)) {
if (target.canTarget(response.getUUID(), cards, game)) { target.addTarget(response.getUUID(), source, game);
target.addTarget(response.getUUID(), source, game); if (target.doneChosing()) {
if (target.doneChosing()) { return true;
return true;
}
} }
} }
} else { } else {
@ -1065,10 +1061,8 @@ public class HumanPlayer extends PlayerImpl {
// does not block yet and can block or can block more attackers // does not block yet and can block or can block more attackers
if (filter.match(blocker, null, playerId, game)) { if (filter.match(blocker, null, playerId, game)) {
selectCombatGroup(defendingPlayerId, blocker.getId(), game); selectCombatGroup(defendingPlayerId, blocker.getId(), game);
} else { } else if (filterBlock.match(blocker, null, playerId, game) && game.getStack().isEmpty()) {
if (filterBlock.match(blocker, null, playerId, game) && game.getStack().isEmpty()) { removeBlocker = true;
removeBlocker = true;
}
} }
if (removeBlocker) { if (removeBlocker) {
@ -1546,4 +1540,9 @@ public class HumanPlayer extends PlayerImpl {
pass(game); pass(game);
return true; return true;
} }
@Override
public String getHistory() {
return "no available";
}
} }

View file

@ -88,7 +88,6 @@ public class User {
private UserState userState; private UserState userState;
private UserData userData; private UserData userData;
private UserStats userStats; private UserStats userStats;
private String history;
public User(String userName, String host) { public User(String userName, String host) {
this.userId = UUID.randomUUID(); this.userId = UUID.randomUUID();
@ -108,12 +107,7 @@ public class User {
this.watchedGames = new ArrayList<>(); this.watchedGames = new ArrayList<>();
this.tablesToDelete = new ArrayList<>(); this.tablesToDelete = new ArrayList<>();
this.sessionId = ""; this.sessionId = "";
this.userStats = UserStatsRepository.instance.getUser(this.userName); this.userStats = null;
if (userStats != null) {
this.history = userStatsToString(userStats.getProto());
} else {
this.history = "<No Games yet>";
}
} }
public String getName() { public String getName() {
@ -406,6 +400,12 @@ public class User {
this.userData.update(userData); this.userData.update(userData);
} else { } else {
this.userData = userData; this.userData = userData;
this.userStats = UserStatsRepository.instance.getUser(this.userName);
if (userStats != null) {
this.userData.setHistory(userStatsToString(userStats.getProto()));
} else {
this.userData.setHistory("<new player>");
}
} }
} }
@ -549,11 +549,16 @@ public class User {
// resetUserStats loads UserStats from DB. // resetUserStats loads UserStats from DB.
public void resetUserStats() { public void resetUserStats() {
this.userStats = UserStatsRepository.instance.getUser(this.userName); this.userStats = UserStatsRepository.instance.getUser(this.userName);
this.history = userStatsToString(userStats.getProto()); if (userData != null) {
userData.setHistory(userStatsToString(userStats.getProto()));
}
} }
public String getHistory() { public String getHistory() {
return history; if (userData != null) {
return userData.getHistory();
}
return "<not available>";
} }
private static String userStatsToString(ResultProtos.UserStatsProto proto) { private static String userStatsToString(ResultProtos.UserStatsProto proto) {

View file

@ -24,8 +24,7 @@
* The views and conclusions contained in the software and documentation are those of the * The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.game; package mage.game;
import java.io.Serializable; import java.io.Serializable;
@ -38,7 +37,6 @@ import mage.players.Player;
public class Seat implements Serializable { public class Seat implements Serializable {
// private static final Logger logger = Logger.getLogger(Seat.class); // private static final Logger logger = Logger.getLogger(Seat.class);
private String playerType; private String playerType;
private Player player; private Player player;

View file

@ -824,4 +824,6 @@ public interface Player extends MageItem, Copyable<Player> {
* @return * @return
*/ */
boolean addTargets(Ability ability, Game game); boolean addTargets(Ability ability, Game game);
String getHistory();
} }

View file

@ -524,31 +524,29 @@ public abstract class PlayerImpl implements Player, Serializable {
inRange.add(player.getId()); inRange.add(player.getId());
} }
} }
} else if ((range.getRange() * 2) + 1 >= game.getPlayers().size()) {
for (Player player : game.getPlayers().values()) {
if (!player.hasLeft()) {
inRange.add(player.getId());
}
}
} else { } else {
if ((range.getRange() * 2) + 1 >= game.getPlayers().size()) { inRange.add(playerId);
for (Player player : game.getPlayers().values()) { PlayerList players = game.getState().getPlayerList(playerId);
if (!player.hasLeft()) { for (int i = 0; i < range.getRange(); i++) {
inRange.add(player.getId()); Player player = players.getNext(game);
} while (player.hasLeft()) {
player = players.getNext(game);
} }
} else { inRange.add(player.getId());
inRange.add(playerId); }
PlayerList players = game.getState().getPlayerList(playerId); players = game.getState().getPlayerList(playerId);
for (int i = 0; i < range.getRange(); i++) { for (int i = 0; i < range.getRange(); i++) {
Player player = players.getNext(game); Player player = players.getPrevious(game);
while (player.hasLeft()) { while (player.hasLeft()) {
player = players.getNext(game); player = players.getPrevious(game);
}
inRange.add(player.getId());
}
players = game.getState().getPlayerList(playerId);
for (int i = 0; i < range.getRange(); i++) {
Player player = players.getPrevious(game);
while (player.hasLeft()) {
player = players.getPrevious(game);
}
inRange.add(player.getId());
} }
inRange.add(player.getId());
} }
} }
} }
@ -2098,7 +2096,8 @@ public abstract class PlayerImpl implements Player, Serializable {
break; break;
} }
} }
if (!opponentInGame || // if no more opponent is in game the wins event may no longer be replaced if (!opponentInGame
|| // if no more opponent is in game the wins event may no longer be replaced
!game.replaceEvent(new GameEvent(GameEvent.EventType.WINS, null, null, playerId))) { !game.replaceEvent(new GameEvent(GameEvent.EventType.WINS, null, null, playerId))) {
logger.debug("player won -> start: " + this.getName()); logger.debug("player won -> start: " + this.getName());
if (!this.loses) { if (!this.loses) {
@ -2178,10 +2177,8 @@ public abstract class PlayerImpl implements Player, Serializable {
if (blocker != null && group != null && group.canBlock(blocker, game)) { if (blocker != null && group != null && group.canBlock(blocker, game)) {
group.addBlocker(blockerId, playerId, game); group.addBlocker(blockerId, playerId, game);
game.getCombat().addBlockingGroup(blockerId, attackerId, playerId, game); game.getCombat().addBlockingGroup(blockerId, attackerId, playerId, game);
} else { } else if (this.isHuman() && !game.isSimulation()) {
if (this.isHuman() && !game.isSimulation()) { game.informPlayer(this, "You can't block this creature.");
game.informPlayer(this, "You can't block this creature.");
}
} }
} }
@ -2802,14 +2799,12 @@ public abstract class PlayerImpl implements Player, Serializable {
} }
if (targetNum < option.getTargets().size() - 2) { if (targetNum < option.getTargets().size() - 2) {
addTargetOptions(options, newOption, targetNum + 1, game); addTargetOptions(options, newOption, targetNum + 1, game);
} else if (option.getChoices().size() > 0) {
addChoiceOptions(options, newOption, 0, game);
} else if (option.getCosts().getTargets().size() > 0) {
addCostTargetOptions(options, newOption, 0, game);
} else { } else {
if (option.getChoices().size() > 0) { options.add(newOption);
addChoiceOptions(options, newOption, 0, game);
} else if (option.getCosts().getTargets().size() > 0) {
addCostTargetOptions(options, newOption, 0, game);
} else {
options.add(newOption);
}
} }
} }
} }
@ -2820,12 +2815,10 @@ public abstract class PlayerImpl implements Player, Serializable {
newOption.getChoices().get(choiceNum).setChoice(choice); newOption.getChoices().get(choiceNum).setChoice(choice);
if (choiceNum < option.getChoices().size() - 1) { if (choiceNum < option.getChoices().size() - 1) {
addChoiceOptions(options, newOption, choiceNum + 1, game); addChoiceOptions(options, newOption, choiceNum + 1, game);
} else if (option.getCosts().getTargets().size() > 0) {
addCostTargetOptions(options, newOption, 0, game);
} else { } else {
if (option.getCosts().getTargets().size() > 0) { options.add(newOption);
addCostTargetOptions(options, newOption, 0, game);
} else {
options.add(newOption);
}
} }
} }
} }
@ -3512,4 +3505,9 @@ public abstract class PlayerImpl implements Player, Serializable {
return true; return true;
} }
@Override
public String getHistory() {
return "no available";
}
} }

View file

@ -23,6 +23,8 @@ public class UserData implements Serializable {
protected boolean passPriorityActivation; protected boolean passPriorityActivation;
protected boolean autoOrderTrigger; protected boolean autoOrderTrigger;
protected String history;
public UserData(UserGroup userGroup, int avatarId, boolean showAbilityPickerForced, public UserData(UserGroup userGroup, int avatarId, boolean showAbilityPickerForced,
boolean allowRequestShowHandCards, boolean confirmEmptyManaPool, UserSkipPrioritySteps userSkipPrioritySteps, boolean allowRequestShowHandCards, boolean confirmEmptyManaPool, UserSkipPrioritySteps userSkipPrioritySteps,
String flagName, boolean askMoveToGraveOrder, boolean manaPoolAutomatic, boolean manaPoolAutomaticRestricted, String flagName, boolean askMoveToGraveOrder, boolean manaPoolAutomatic, boolean manaPoolAutomaticRestricted,
@ -40,6 +42,7 @@ public class UserData implements Serializable {
this.passPriorityCast = passPriorityCast; this.passPriorityCast = passPriorityCast;
this.passPriorityActivation = passPriorityActivation; this.passPriorityActivation = passPriorityActivation;
this.autoOrderTrigger = autoOrderTrigger; this.autoOrderTrigger = autoOrderTrigger;
this.history = "";
} }
public void update(UserData userData) { public void update(UserData userData) {
@ -166,7 +169,16 @@ public class UserData implements Serializable {
this.autoOrderTrigger = autoOrderTrigger; this.autoOrderTrigger = autoOrderTrigger;
} }
public void setHistory(String history) {
this.history = history;
}
public String getHistory() {
return history;
}
public static String getDefaultFlagName() { public static String getDefaultFlagName() {
return "world.png"; return "world.png";
} }
} }