Projects >> mage >>d9f1d71d9877f9a719b631254b8778432b761a70

Chunk
Conflicting content
import org.mage.card.arcane.CardPanel;
import org.mage.plugins.card.images.ImageCache;

<<<<<<< HEAD
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.awt.image.BufferedImage;
import java.util.*;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import org.mage.network.Client;

=======
>>>>>>> e6b76a0704dd10b0a83a681043d1627c3d6b5629
/**
 * Class that handles the callbacks from the card panels to mage to display big
 * card images from the cards the mouse hovers on. Also handles tooltip text
Solution content
import org.mage.card.arcane.CardPanel;
import org.mage.plugins.card.images.ImageCache;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.awt.image.BufferedImage;
import java.util.*;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import org.mage.network.Client;

/**
 * Class that handles the callbacks from the card panels to mage to display big
 * card images from the cards the mouse hovers on. Also handles tooltip text
File
MageActionCallback.java
Developer's decision
Version 1
Kind of conflict
Import
Chunk
Conflicting content
                        break;
                    case "Remove":
                        if (JOptionPane.showConfirmDialog(null, "Are you sure you want to remove table?", "Removing table", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
<<<<<<< HEAD
                            client.removeTable(roomId, tableId);
                        }  
=======
                            session.removeTable(roomId, tableId);
                        }
>>>>>>> e6b76a0704dd10b0a83a681043d1627c3d6b5629
                        break;
                    case "Show":
                        if (isTournament) {
Solution content
                        break;
                    case "Remove":
                        if (JOptionPane.showConfirmDialog(null, "Are you sure you want to remove table?", "Removing table", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
                            client.removeTable(roomId, tableId);
                        }
                        break;
                    case "Show":
                        if (isTournament) {
File
TablesPanel.java
Developer's decision
Version 1
Kind of conflict
Method invocation
Chunk
Conflicting content
                    case "Show":
                        if (isTournament) {
                            logger.info("Showing tournament table " + tableId);
<<<<<<< HEAD
                            client.watchTable(roomId, tableId);
                        }  
=======
                            session.watchTable(roomId, tableId);
                        }
>>>>>>> e6b76a0704dd10b0a83a681043d1627c3d6b5629
                        break;
                    case "Watch":
                        if (!isTournament) {
Solution content
                    case "Show":
                        if (isTournament) {
                            logger.info("Showing tournament table " + tableId);
                            client.watchTable(roomId, tableId);
                        }
                        break;
                    case "Watch":
                        if (!isTournament) {
File
TablesPanel.java
Developer's decision
Version 1
Kind of conflict
Method invocation
Chunk
Conflicting content
                    case "Watch":
                        if (!isTournament) {
                            logger.info("Watching table " + tableId);
<<<<<<< HEAD
                            client.watchTable(roomId, tableId);
                        }  
=======
                            session.watchTable(roomId, tableId);
                        }
>>>>>>> e6b76a0704dd10b0a83a681043d1627c3d6b5629
                        break;
                    case "Replay":
                        logger.info("Replaying game " + gameId);
Solution content
                    case "Watch":
                        if (!isTournament) {
                            logger.info("Watching table " + tableId);
                            client.watchTable(roomId, tableId);
                        }
                        break;
                    case "Replay":
                        logger.info("Replaying game " + gameId);
File
TablesPanel.java
Developer's decision
Version 1
Kind of conflict
Method invocation
Chunk
Conflicting content
                        List gameList = matchesModel.getListofGames(modelRow);
                        if (gameList != null && gameList.size() > 0) {
                            if (gameList.size() == 1) {
<<<<<<< HEAD
                                client.replayGame(gameList.get(0));
                            }
                            else {
=======
                                session.replayGame(gameList.get(0));
                            } else {
>>>>>>> e6b76a0704dd10b0a83a681043d1627c3d6b5629
                                gameChooser.show(gameList, MageFrame.getDesktop().getMousePosition());
                            }
                        }
Solution content
                        List gameList = matchesModel.getListofGames(modelRow);
                        if (gameList != null && gameList.size() > 0) {
                            if (gameList.size() == 1) {
                                client.replayGame(gameList.get(0));
                            } else {
                                gameChooser.show(gameList, MageFrame.getDesktop().getMousePosition());
                            }
                        }
File
TablesPanel.java
Developer's decision
Version 1
Kind of conflict
Method invocation
Chunk
Conflicting content
                    case "Show":;
                        if (matchesModel.isTournament(modelRow)) {
                            logger.info("Showing tournament table " + matchesModel.getTableId(modelRow));
<<<<<<< HEAD
                            client.watchTable(roomId, matchesModel.getTableId(modelRow));
                        }                         
=======
                            session.watchTable(roomId, matchesModel.getTableId(modelRow));
                        }
>>>>>>> e6b76a0704dd10b0a83a681043d1627c3d6b5629
                        break;
                }
            }
Solution content
                    case "Show":;
                        if (matchesModel.isTournament(modelRow)) {
                            logger.info("Showing tournament table " + matchesModel.getTableId(modelRow));
                            client.watchTable(roomId, matchesModel.getTableId(modelRow));
                        }
                        break;
                }
            }
File
TablesPanel.java
Developer's decision
Version 1
Kind of conflict
Method invocation
Chunk
Conflicting content
    }

    public void startTasks() {
<<<<<<< HEAD
        if (client != null) {
            if (updateRoomTask == null || updateRoomTask.isDone()) {
                updateRoomTask = new UpdateRoomTask(client, roomId, this, this.chatPanel);
                updateRoomTask.execute();
=======
        if (session != null) {
            if (updateTablesTask == null || updateTablesTask.isDone()) {
                updateTablesTask = new UpdateTablesTask(session, roomId, this);
                updateTablesTask.execute();
            }
            if (updatePlayersTask == null || updatePlayersTask.isDone()) {
                updatePlayersTask = new UpdatePlayersTask(session, roomId, this.chatPanel);
                updatePlayersTask.execute();
            }
            if (this.btnStateFinished.isSelected()) {
                if (updateMatchesTask == null || updateMatchesTask.isDone()) {
                    updateMatchesTask = new UpdateMatchesTask(session, roomId, this);
                    updateMatchesTask.execute();
                }
            } else {
                if (updateMatchesTask != null) {
                    updateMatchesTask.cancel(true);
                }
>>>>>>> e6b76a0704dd10b0a83a681043d1627c3d6b5629
            }
//            if (updatePlayersTask == null || updatePlayersTask.isDone()) {
//                updatePlayersTask = new UpdatePlayersTask(client, roomId, this.chatPanel);
Solution content
    }

    public void startTasks() {
        if (client != null) {
            if (updateRoomTask == null || updateRoomTask.isDone()) {
                updateRoomTask = new UpdateRoomTask(client, roomId, this, this.chatPanel);
                updateRoomTask.execute();
            }
//            if (updatePlayersTask == null || updatePlayersTask.isDone()) {
//                updatePlayersTask = new UpdatePlayersTask(client, roomId, this.chatPanel);
File
TablesPanel.java
Developer's decision
Version 1
Kind of conflict
Attribute
If statement
Method invocation
Chunk
Conflicting content
}//GEN-LAST:event_btnNewTournamentActionPerformed

        private void btnQuickStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuickStartActionPerformed
<<<<<<< HEAD
            TableView table;
            try {
                File f = new File("test.dck");
                if (!f.exists()) {
                    JOptionPane.showMessageDialog(null, "Couldn't find test.dck file for quick game start", "Error", JOptionPane.ERROR_MESSAGE);
                    return;
                }

                MatchOptions options = new MatchOptions("1", "Two Player Duel");
                options.getPlayerTypes().add("Human");
                options.getPlayerTypes().add("Computer - mad");
                options.setDeckType("Limited");
                options.setAttackOption(MultiplayerAttackOption.LEFT);
                options.setRange(RangeOfInfluence.ALL);
                options.setWinsNeeded(1);
                options.setMatchTimeLimit(MatchTimeLimit.NONE);
                options.setFreeMulligans(2);
                options.setSkillLevel(SkillLevel.CASUAL);
                options.setRollbackTurnsAllowed(true);
                table = client.createTable(roomId, options);

                client.joinTable(roomId, table.getTableId(), "Human", "Human", 1, DeckImporterUtil.importDeck("test.dck"),"");
                client.joinTable(roomId, table.getTableId(), "Computer", "Computer - mad", 5, DeckImporterUtil.importDeck("test.dck"),"");
                client.startMatch(roomId, table.getTableId());
            } catch (HeadlessException ex) {
                handleError(ex);
=======
        TableView table;
        try {
            File f = new File("test.dck");
            if (!f.exists()) {
                JOptionPane.showMessageDialog(null, "Couldn't find test.dck file for quick game start", "Error", JOptionPane.ERROR_MESSAGE);
                return;
>>>>>>> e6b76a0704dd10b0a83a681043d1627c3d6b5629
            }

            MatchOptions options = new MatchOptions("1", "Two Player Duel");
Solution content
}//GEN-LAST:event_btnNewTournamentActionPerformed

        private void btnQuickStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuickStartActionPerformed
        TableView table;
        try {
            File f = new File("test.dck");
            if (!f.exists()) {
                JOptionPane.showMessageDialog(null, "Couldn't find test.dck file for quick game start", "Error", JOptionPane.ERROR_MESSAGE);
                return;
            }

                MatchOptions options = new MatchOptions("1", "Two Player Duel");
                options.getPlayerTypes().add("Human");
                options.getPlayerTypes().add("Computer - mad");
                options.setDeckType("Limited");
                options.setAttackOption(MultiplayerAttackOption.LEFT);
                options.setRange(RangeOfInfluence.ALL);
                options.setWinsNeeded(1);
                options.setMatchTimeLimit(MatchTimeLimit.NONE);
                options.setFreeMulligans(2);
                options.setSkillLevel(SkillLevel.CASUAL);
                options.setRollbackTurnsAllowed(true);
                table = client.createTable(roomId, options);

                client.joinTable(roomId, table.getTableId(), "Human", "Human", 1, DeckImporterUtil.importDeck("test.dck"),"");
                client.joinTable(roomId, table.getTableId(), "Computer", "Computer - mad", 5, DeckImporterUtil.importDeck("test.dck"),"");
                client.startMatch(roomId, table.getTableId());
            } catch (HeadlessException ex) {
                handleError(ex);
            }
File
TablesPanel.java
Developer's decision
Version 1
Kind of conflict
Catch clause
If statement
Method invocation
Return statement
Try statement
Variable
Chunk
Conflicting content
    private static final DateFormat timeFormatter = new SimpleDateFormat("HH:mm:ss");
    ;

<<<<<<< HEAD
    private Client client;
    
=======
    private Session session;

>>>>>>> e6b76a0704dd10b0a83a681043d1627c3d6b5629
    public void loadData(Collection tables) throws MageRemoteException {
        this.tables = tables.toArray(new TableView[0]);
        this.fireTableDataChanged();
Solution content
    private static final DateFormat timeFormatter = new SimpleDateFormat("HH:mm:ss");
    ;

    private Client client;

    public void loadData(Collection tables) throws MageRemoteException {
        this.tables = tables.toArray(new TableView[0]);
        this.fireTableDataChanged();
File
TablesPanel.java
Developer's decision
Version 1
Kind of conflict
Attribute
Chunk
Conflicting content
                            return "Show";
                        } else {
                            owner = tables[arg0].getControllerName();
<<<<<<< HEAD
                            if (client != null && owner.equals(client.getUserName())) {
                                  return "";
=======
                            if (session != null && owner.equals(session.getUserName())) {
                                return "";
>>>>>>> e6b76a0704dd10b0a83a681043d1627c3d6b5629
                            }
                            return "Watch";
                        }
Solution content
                            return "Show";
                        } else {
                            owner = tables[arg0].getControllerName();
                            if (client != null && owner.equals(client.getUserName())) {
                                return "";
                            }
                            return "Watch";
                        }
File
TablesPanel.java
Developer's decision
Version 1
Kind of conflict
If statement
Return statement
Chunk
Conflicting content
    @Override
            get();
//
    protected void done() {

}

<<<<<<< HEAD
//class UpdatePlayersTask extends SwingWorker> {
//
//    private final Client client;
//    private final UUID roomId;
//    private final ChatPanel chat;
//
//    private static final Logger logger = Logger.getLogger(UpdatePlayersTask.class);
        try {
//    UpdatePlayersTask(Client client, UUID roomId, ChatPanel chat) {
//        this.client = client;
//        this.roomId = roomId;
//        this.chat = chat;
//    }
//
//    @Override
//    protected Void doInBackground() throws Exception {
//        while (!isCancelled()) {
//            this.publish(client.getRoomUsers(roomId));
//            Thread.sleep(3000);
//        }
//        return null;
//    }
//
//    @Override
//    protected void process(List> roomUserInfo) {
//        chat.setRoomUserInfo(roomUserInfo);
//    }
//
//    @Override
//    protected void done() {
//        try {
//            get();
//        } catch (InterruptedException | ExecutionException ex) {
//            logger.fatal("Update Players Task error", ex);
//        } catch (CancellationException ex) {}
//    }
//
//}
=======
class UpdatePlayersTask extends SwingWorker> {

    private final Session session;
    private final UUID roomId;
    private final ChatPanel chat;

    private static final Logger logger = Logger.getLogger(UpdatePlayersTask.class);

    UpdatePlayersTask(Session session, UUID roomId, ChatPanel chat) {
        this.session = session;
        this.roomId = roomId;
        this.chat = chat;
    }

    @Override
    protected Void doInBackground() throws Exception {
        while (!isCancelled()) {
            this.publish(session.getRoomUsers(roomId));
            Thread.sleep(3000);
        }
        return null;
    }

    @Override
    protected void process(List> roomUserInfo) {
        chat.setRoomUserInfo(roomUserInfo);
    }

        } catch (InterruptedException | ExecutionException ex) {
            logger.fatal("Update Players Task error", ex);
        } catch (CancellationException ex) {
        }
    }

}
>>>>>>> e6b76a0704dd10b0a83a681043d1627c3d6b5629

class MatchesTableModel extends AbstractTableModel {
Solution content
}

//class UpdatePlayersTask extends SwingWorker> {
//
//    private final Client client;
//    private final UUID roomId;
//    private final ChatPanel chat;
//
//    private static final Logger logger = Logger.getLogger(UpdatePlayersTask.class);
//
//    UpdatePlayersTask(Client client, UUID roomId, ChatPanel chat) {
//        this.client = client;
//        this.roomId = roomId;
//        this.chat = chat;
//    }
//
//    @Override
//    protected Void doInBackground() throws Exception {
//        while (!isCancelled()) {
//            this.publish(client.getRoomUsers(roomId));
//            Thread.sleep(3000);
//        }
//        return null;
//    }
//
//    @Override
//    protected void process(List> roomUserInfo) {
//        chat.setRoomUserInfo(roomUserInfo);
//    }
//
//    @Override
//    protected void done() {
//        try {
//            get();
//        } catch (InterruptedException | ExecutionException ex) {
//            logger.fatal("Update Players Task error", ex);
//        } catch (CancellationException ex) {}
//    }
//
//}

class MatchesTableModel extends AbstractTableModel {
File
TablesPanel.java
Developer's decision
Version 1
Kind of conflict
Class declaration
Comment
Chunk
Conflicting content
}

<<<<<<< HEAD
//class UpdateMatchesTask extends SwingWorker> {
//
//    private final Client client;
//    private final UUID roomId;
//    private final TablesPanel panel;
//
//    private static final Logger logger = Logger.getLogger(UpdateTablesTask.class);
//
//    UpdateMatchesTask(Client client, UUID roomId, TablesPanel panel) {
//        this.client = client;
//        this.roomId = roomId;
//        this.panel = panel;
//    }
//
//    @Override
//    protected Void doInBackground() throws Exception {
//        while (!isCancelled()) {
//            Collection matches = client.getFinishedMatches(roomId);
//            if (matches != null) {
//                this.publish(matches);
//            }
//            Thread.sleep(10000);
//        }
//        return null;
//    }
//
//    @Override
//    protected void process(List> view) {
//        panel.updateMatches(view.get(0));
//    }
//
//    @Override
//    protected void done() {
//        try {
//            get();
//        } catch (InterruptedException | ExecutionException ex) {
//            logger.fatal("Update Matches Task error", ex);
//        } catch (CancellationException ex) {}
//    }
//
//}
=======
class UpdateMatchesTask extends SwingWorker> {

    private final Session session;
    private final UUID roomId;
    private final TablesPanel panel;

    private static final Logger logger = Logger.getLogger(UpdateTablesTask.class);

    UpdateMatchesTask(Session session, UUID roomId, TablesPanel panel) {
        this.session = session;
        this.roomId = roomId;
        this.panel = panel;
    }

    @Override
    protected Void doInBackground() throws Exception {
        while (!isCancelled()) {
            Collection matches = session.getFinishedMatches(roomId);
            if (matches != null) {
                this.publish(matches);
            }
            Thread.sleep(10000);
        }
        return null;
    }

    @Override
    protected void process(List> view) {
        panel.updateMatches(view.get(0));
    }

    @Override
    protected void done() {
        try {
            get();
        } catch (InterruptedException | ExecutionException ex) {
            logger.fatal("Update Matches Task error", ex);
        } catch (CancellationException ex) {
        }
    }

}
>>>>>>> e6b76a0704dd10b0a83a681043d1627c3d6b5629

class GameChooser extends JPopupMenu {
Solution content
//        this.roomId = roomId;

}

//class UpdateMatchesTask extends SwingWorker> {
//
//    private final Client client;
//    private final UUID roomId;
//    private final TablesPanel panel;
//
//    private static final Logger logger = Logger.getLogger(UpdateTablesTask.class);
//
//    UpdateMatchesTask(Client client, UUID roomId, TablesPanel panel) {
//        this.client = client;
//        this.panel = panel;
//    }
//
//    @Override
//    protected Void doInBackground() throws Exception {
//        while (!isCancelled()) {
//            Collection matches = client.getFinishedMatches(roomId);
//            if (matches != null) {
//                this.publish(matches);
//            }
//            Thread.sleep(10000);
//        }
//        return null;
//    }
//
//    @Override
//    protected void process(List> view) {
//        panel.updateMatches(view.get(0));
//    }
//
//    @Override
//    protected void done() {
//        try {
//            get();
//        } catch (InterruptedException | ExecutionException ex) {
//            logger.fatal("Update Matches Task error", ex);
//        } catch (CancellationException ex) {}
//    }
//
//}

class GameChooser extends JPopupMenu {
File
TablesPanel.java
Developer's decision
Version 1
Kind of conflict
Class declaration
Comment
Chunk
Conflicting content
                controlledByOwner = false;
            }
            if (game != null && permanent.getCounters() != null && !permanent.getCounters().isEmpty()) {
<<<<<<< HEAD
                counters.clear();
                for (Counter counter: permanent.getCounters().values()) {
=======
                counters = new ArrayList<>();
                for (Counter counter : permanent.getCounters().values()) {
>>>>>>> e6b76a0704dd10b0a83a681043d1627c3d6b5629
                    counters.add(new CounterView(counter));
                }
            }
Solution content
                controlledByOwner = false;
            }
            if (game != null && permanent.getCounters() != null && !permanent.getCounters().isEmpty()) {
                counters.clear();
                for (Counter counter : permanent.getCounters().values()) {
                    counters.add(new CounterView(counter));
                }
            }
File
CardView.java
Developer's decision
Version 1
Kind of conflict
For statement
Method invocation
Chunk
Conflicting content
            }
            this.loyalty = "";
            if (game != null && card.getCounters(game) != null && !card.getCounters(game).isEmpty()) {
<<<<<<< HEAD
                counters.clear();
                for (Counter counter: card.getCounters(game).values()) {
=======
                counters = new ArrayList<>();
                for (Counter counter : card.getCounters(game).values()) {
>>>>>>> e6b76a0704dd10b0a83a681043d1627c3d6b5629
                    counters.add(new CounterView(counter));
                }
            }
Solution content
            }
            this.loyalty = "";
            if (game != null && card.getCounters(game) != null && !card.getCounters(game).isEmpty()) {
                counters.clear();
                for (Counter counter : card.getCounters(game).values()) {
                    counters.add(new CounterView(counter));
                }
            }
File
CardView.java
Developer's decision
Version 1
Kind of conflict
For statement
Method invocation
Chunk
Conflicting content
            }
            //
            // set code und card number for token copies to get the image
<<<<<<< HEAD
            this.rules.clear();
            this.rules.addAll(((PermanentToken) card).getRules(game));
            this.type = ((PermanentToken)card).getToken().getTokenType();
=======
            this.rules = ((PermanentToken) card).getRules(game);
            this.type = ((PermanentToken) card).getToken().getTokenType();
>>>>>>> e6b76a0704dd10b0a83a681043d1627c3d6b5629
        } else {
            this.rarity = card.getRarity();
            this.isToken = false;
Solution content
            //
            }
            // set code und card number for token copies to get the image
            this.rules.clear();
            this.rules.addAll(((PermanentToken) card).getRules(game));
            this.type = ((PermanentToken) card).getToken().getTokenType();
        } else {
            this.rarity = card.getRarity();
            this.isToken = false;
File
CardView.java
Developer's decision
Version 1
Kind of conflict
Attribute
Method invocation