mirror of
https://github.com/correl/mage.git
synced 2024-11-14 19:19:32 +00:00
Changed history handling for user a bit. Added history to table waiting dialog and user avatar tooltip.
This commit is contained in:
parent
24dddd3e06
commit
151e678e84
9 changed files with 102 additions and 79 deletions
|
@ -26,7 +26,7 @@
|
|||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
* TableWaitingDialog.java
|
||||
*
|
||||
* Created on Dec 16, 2009, 10:27:44 AM
|
||||
|
@ -68,7 +68,7 @@ public class TableWaitingDialog extends MageDialog {
|
|||
private Session session;
|
||||
private final TableWaitModel tableWaitModel;
|
||||
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
|
||||
|
@ -268,10 +268,8 @@ public class TableWaitingDialog extends MageDialog {
|
|||
if (session.startMatch(roomId, tableId)) {
|
||||
closeDialog();
|
||||
}
|
||||
} else {
|
||||
if (session.startTournament(roomId, tableId)) {
|
||||
closeDialog();
|
||||
}
|
||||
} else if (session.startTournament(roomId, tableId)) {
|
||||
closeDialog();
|
||||
}
|
||||
}//GEN-LAST:event_btnStartActionPerformed
|
||||
|
||||
|
@ -319,7 +317,7 @@ public class TableWaitingDialog extends MageDialog {
|
|||
|
||||
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];
|
||||
|
||||
public void loadData(TableView table) {
|
||||
|
@ -353,6 +351,8 @@ class TableWaitModel extends AbstractTableModel {
|
|||
return seats[arg0].getPlayerName();
|
||||
case 3:
|
||||
return seats[arg0].getPlayerType();
|
||||
case 4:
|
||||
return seats[arg0].getHistory();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
* PlayerPanel.java
|
||||
*
|
||||
* 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()
|
||||
+ "<br/>Country: " + countryname
|
||||
+ "<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
|
||||
StringBuilder tooltipText = new StringBuilder(basicTooltipText);
|
||||
|
|
|
@ -44,6 +44,7 @@ public class SeatView implements Serializable {
|
|||
private UUID playerId;
|
||||
private final String playerName;
|
||||
private final String playerType;
|
||||
private final String history;
|
||||
|
||||
public SeatView(Seat seat) {
|
||||
if (seat.getPlayer() != null) {
|
||||
|
@ -51,13 +52,16 @@ public class SeatView implements Serializable {
|
|||
this.playerName = seat.getPlayer().getName();
|
||||
if (seat.getPlayer().getUserData() == null) {
|
||||
this.flagName = UserData.getDefaultFlagName();
|
||||
this.history = "";
|
||||
} else {
|
||||
this.flagName = seat.getPlayer().getUserData().getFlagName();
|
||||
this.history = seat.getPlayer().getUserData().getHistory();
|
||||
}
|
||||
} else {
|
||||
// Empty seat
|
||||
this.playerName = "";
|
||||
this.flagName = "";
|
||||
this.history = "";
|
||||
}
|
||||
this.playerType = seat.getPlayerType();
|
||||
}
|
||||
|
@ -78,4 +82,8 @@ public class SeatView implements Serializable {
|
|||
return flagName;
|
||||
}
|
||||
|
||||
public String getHistory() {
|
||||
return history;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -358,15 +358,13 @@ public class HumanPlayer extends PlayerImpl {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (target.canTarget(response.getUUID(), game)) {
|
||||
if (target.getTargets().contains(response.getUUID())) { // if already included remove it with
|
||||
target.remove(response.getUUID());
|
||||
} else {
|
||||
target.addTarget(response.getUUID(), null, game);
|
||||
if (target.doneChosing()) {
|
||||
return true;
|
||||
}
|
||||
} else if (target.canTarget(response.getUUID(), game)) {
|
||||
if (target.getTargets().contains(response.getUUID())) { // if already included remove it with
|
||||
target.remove(response.getUUID());
|
||||
} else {
|
||||
target.addTarget(response.getUUID(), null, game);
|
||||
if (target.doneChosing()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -530,12 +528,10 @@ public class HumanPlayer extends PlayerImpl {
|
|||
if (response.getUUID() != null) {
|
||||
if (target.getTargets().contains(response.getUUID())) { // if already included remove it
|
||||
target.remove(response.getUUID());
|
||||
} else {
|
||||
if (target.canTarget(response.getUUID(), cards, game)) {
|
||||
target.addTarget(response.getUUID(), source, game);
|
||||
if (target.doneChosing()) {
|
||||
return true;
|
||||
}
|
||||
} else if (target.canTarget(response.getUUID(), cards, game)) {
|
||||
target.addTarget(response.getUUID(), source, game);
|
||||
if (target.doneChosing()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -1065,10 +1061,8 @@ public class HumanPlayer extends PlayerImpl {
|
|||
// does not block yet and can block or can block more attackers
|
||||
if (filter.match(blocker, null, playerId, game)) {
|
||||
selectCombatGroup(defendingPlayerId, blocker.getId(), game);
|
||||
} else {
|
||||
if (filterBlock.match(blocker, null, playerId, game) && game.getStack().isEmpty()) {
|
||||
removeBlocker = true;
|
||||
}
|
||||
} else if (filterBlock.match(blocker, null, playerId, game) && game.getStack().isEmpty()) {
|
||||
removeBlocker = true;
|
||||
}
|
||||
|
||||
if (removeBlocker) {
|
||||
|
@ -1546,4 +1540,9 @@ public class HumanPlayer extends PlayerImpl {
|
|||
pass(game);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHistory() {
|
||||
return "no available";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,7 +88,6 @@ public class User {
|
|||
private UserState userState;
|
||||
private UserData userData;
|
||||
private UserStats userStats;
|
||||
private String history;
|
||||
|
||||
public User(String userName, String host) {
|
||||
this.userId = UUID.randomUUID();
|
||||
|
@ -108,12 +107,7 @@ public class User {
|
|||
this.watchedGames = new ArrayList<>();
|
||||
this.tablesToDelete = new ArrayList<>();
|
||||
this.sessionId = "";
|
||||
this.userStats = UserStatsRepository.instance.getUser(this.userName);
|
||||
if (userStats != null) {
|
||||
this.history = userStatsToString(userStats.getProto());
|
||||
} else {
|
||||
this.history = "<No Games yet>";
|
||||
}
|
||||
this.userStats = null;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
@ -406,6 +400,12 @@ public class User {
|
|||
this.userData.update(userData);
|
||||
} else {
|
||||
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.
|
||||
public void resetUserStats() {
|
||||
this.userStats = UserStatsRepository.instance.getUser(this.userName);
|
||||
this.history = userStatsToString(userStats.getProto());
|
||||
if (userData != null) {
|
||||
userData.setHistory(userStatsToString(userStats.getProto()));
|
||||
}
|
||||
}
|
||||
|
||||
public String getHistory() {
|
||||
return history;
|
||||
if (userData != null) {
|
||||
return userData.getHistory();
|
||||
}
|
||||
return "<not available>";
|
||||
}
|
||||
|
||||
private static String userStatsToString(ResultProtos.UserStatsProto proto) {
|
||||
|
|
|
@ -24,8 +24,7 @@
|
|||
* 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
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
*/
|
||||
package mage.game;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -38,7 +37,6 @@ import mage.players.Player;
|
|||
public class Seat implements Serializable {
|
||||
|
||||
// private static final Logger logger = Logger.getLogger(Seat.class);
|
||||
|
||||
private String playerType;
|
||||
private Player player;
|
||||
|
||||
|
|
|
@ -824,4 +824,6 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
* @return
|
||||
*/
|
||||
boolean addTargets(Ability ability, Game game);
|
||||
|
||||
String getHistory();
|
||||
}
|
||||
|
|
|
@ -524,31 +524,29 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
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 {
|
||||
if ((range.getRange() * 2) + 1 >= game.getPlayers().size()) {
|
||||
for (Player player : game.getPlayers().values()) {
|
||||
if (!player.hasLeft()) {
|
||||
inRange.add(player.getId());
|
||||
}
|
||||
inRange.add(playerId);
|
||||
PlayerList players = game.getState().getPlayerList(playerId);
|
||||
for (int i = 0; i < range.getRange(); i++) {
|
||||
Player player = players.getNext(game);
|
||||
while (player.hasLeft()) {
|
||||
player = players.getNext(game);
|
||||
}
|
||||
} else {
|
||||
inRange.add(playerId);
|
||||
PlayerList players = game.getState().getPlayerList(playerId);
|
||||
for (int i = 0; i < range.getRange(); i++) {
|
||||
Player player = players.getNext(game);
|
||||
while (player.hasLeft()) {
|
||||
player = players.getNext(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());
|
||||
}
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2098,7 +2096,8 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
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))) {
|
||||
logger.debug("player won -> start: " + this.getName());
|
||||
if (!this.loses) {
|
||||
|
@ -2178,10 +2177,8 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
if (blocker != null && group != null && group.canBlock(blocker, game)) {
|
||||
group.addBlocker(blockerId, playerId, game);
|
||||
game.getCombat().addBlockingGroup(blockerId, attackerId, playerId, game);
|
||||
} else {
|
||||
if (this.isHuman() && !game.isSimulation()) {
|
||||
game.informPlayer(this, "You can't block this creature.");
|
||||
}
|
||||
} else if (this.isHuman() && !game.isSimulation()) {
|
||||
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) {
|
||||
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 {
|
||||
if (option.getChoices().size() > 0) {
|
||||
addChoiceOptions(options, newOption, 0, game);
|
||||
} else if (option.getCosts().getTargets().size() > 0) {
|
||||
addCostTargetOptions(options, newOption, 0, game);
|
||||
} else {
|
||||
options.add(newOption);
|
||||
}
|
||||
options.add(newOption);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2820,12 +2815,10 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
newOption.getChoices().get(choiceNum).setChoice(choice);
|
||||
if (choiceNum < option.getChoices().size() - 1) {
|
||||
addChoiceOptions(options, newOption, choiceNum + 1, game);
|
||||
} else if (option.getCosts().getTargets().size() > 0) {
|
||||
addCostTargetOptions(options, newOption, 0, game);
|
||||
} else {
|
||||
if (option.getCosts().getTargets().size() > 0) {
|
||||
addCostTargetOptions(options, newOption, 0, game);
|
||||
} else {
|
||||
options.add(newOption);
|
||||
}
|
||||
options.add(newOption);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3512,4 +3505,9 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHistory() {
|
||||
return "no available";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@ public class UserData implements Serializable {
|
|||
protected boolean passPriorityActivation;
|
||||
protected boolean autoOrderTrigger;
|
||||
|
||||
protected String history;
|
||||
|
||||
public UserData(UserGroup userGroup, int avatarId, boolean showAbilityPickerForced,
|
||||
boolean allowRequestShowHandCards, boolean confirmEmptyManaPool, UserSkipPrioritySteps userSkipPrioritySteps,
|
||||
String flagName, boolean askMoveToGraveOrder, boolean manaPoolAutomatic, boolean manaPoolAutomaticRestricted,
|
||||
|
@ -40,6 +42,7 @@ public class UserData implements Serializable {
|
|||
this.passPriorityCast = passPriorityCast;
|
||||
this.passPriorityActivation = passPriorityActivation;
|
||||
this.autoOrderTrigger = autoOrderTrigger;
|
||||
this.history = "";
|
||||
}
|
||||
|
||||
public void update(UserData userData) {
|
||||
|
@ -166,7 +169,16 @@ public class UserData implements Serializable {
|
|||
this.autoOrderTrigger = autoOrderTrigger;
|
||||
}
|
||||
|
||||
public void setHistory(String history) {
|
||||
this.history = history;
|
||||
}
|
||||
|
||||
public String getHistory() {
|
||||
return history;
|
||||
}
|
||||
|
||||
public static String getDefaultFlagName() {
|
||||
return "world.png";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue