Search in sources :

Example 1 with GameDescription

use of games.strategy.engine.lobby.server.GameDescription in project triplea by triplea-game.

the class LobbyGameTableModelTest method updateGameWithNullGuidIsIgnored.

@Test
public void updateGameWithNullGuidIsIgnored() {
    testObj.getLobbyGameBroadcaster().gameUpdated(null, new GameDescription());
    TestUtil.waitForSwingThreads();
    assertThat("expect row count to remain 1, null guid is bogus data", testObj.getRowCount(), is(1));
}
Also used : GameDescription(games.strategy.engine.lobby.server.GameDescription) Test(org.junit.jupiter.api.Test)

Example 2 with GameDescription

use of games.strategy.engine.lobby.server.GameDescription in project triplea by triplea-game.

the class LobbyGameTableModelTest method updateGame.

@Test
public void updateGame() {
    final int commentColumnIndex = testObj.getColumnIndex(LobbyGameTableModel.Column.Comments);
    assertThat(testObj.getValueAt(0, commentColumnIndex), nullValue());
    final String newComment = "comment";
    final GameDescription newDescription = new GameDescription();
    newDescription.setComment(newComment);
    testObj.getLobbyGameBroadcaster().gameUpdated(fakeGame.getFirst(), newDescription);
    TestUtil.waitForSwingThreads();
    assertThat(testObj.getRowCount(), is(1));
    assertThat(testObj.getValueAt(0, commentColumnIndex), is(newComment));
}
Also used : GameDescription(games.strategy.engine.lobby.server.GameDescription) Test(org.junit.jupiter.api.Test)

Example 3 with GameDescription

use of games.strategy.engine.lobby.server.GameDescription in project triplea by triplea-game.

the class LobbyGamePanel method getLobbyWatcherNodeForTableRow.

private INode getLobbyWatcherNodeForTableRow(final int selectedIndex) {
    final GameDescription description = gameTableModel.get(gameTable.convertRowIndexToModel(selectedIndex));
    final String hostedByName = description.getHostedBy().getName();
    return new Node((hostedByName.endsWith("_" + InGameLobbyWatcher.LOBBY_WATCHER_NAME) ? hostedByName : hostedByName + "_" + InGameLobbyWatcher.LOBBY_WATCHER_NAME), description.getHostedBy().getAddress(), description.getHostedBy().getPort());
}
Also used : INode(games.strategy.net.INode) Node(games.strategy.net.Node) GameDescription(games.strategy.engine.lobby.server.GameDescription)

Example 4 with GameDescription

use of games.strategy.engine.lobby.server.GameDescription in project triplea by triplea-game.

the class LobbyGameTable method prepareRenderer.

@Override
public Component prepareRenderer(final TableCellRenderer renderer, final int rowIndex, final int colIndex) {
    final Component component = super.prepareRenderer(renderer, rowIndex, colIndex);
    final LobbyGameTableModel lobbyGameTableModel = (LobbyGameTableModel) getModel();
    final GameDescription gameDescription = lobbyGameTableModel.get(convertRowIndexToModel(rowIndex));
    component.setFont(gameDescription.isBot() ? ITALIC_FONT : DEFAULT_FONT);
    return component;
}
Also used : GameDescription(games.strategy.engine.lobby.server.GameDescription) Component(java.awt.Component)

Example 5 with GameDescription

use of games.strategy.engine.lobby.server.GameDescription in project triplea by triplea-game.

the class LobbyGameTableModel method getValueAt.

@Override
public Object getValueAt(final int rowIndex, final int columnIndex) {
    final Column column = Column.values()[columnIndex];
    final GameDescription description = gameList.get(rowIndex).getSecond();
    switch(column) {
        case Host:
            return description.getHostName();
        case Round:
            return description.getRound();
        case Name:
            return description.getGameName();
        case Players:
            return description.getPlayerCount();
        case P:
            return (description.getPassworded() ? "*" : "");
        case B:
            return description.isBot() ? "-" : "";
        case GV:
            return description.getGameVersion();
        case EV:
            return description.getEngineVersion();
        case Status:
            return description.getStatus();
        case Comments:
            return description.getComment();
        case Started:
            return formatBotStartTime(description.getStartDateTime());
        case GUID:
            return gameList.get(rowIndex).getFirst();
        default:
            throw new IllegalStateException("Unknown column:" + column);
    }
}
Also used : GameDescription(games.strategy.engine.lobby.server.GameDescription)

Aggregations

GameDescription (games.strategy.engine.lobby.server.GameDescription)9 Test (org.junit.jupiter.api.Test)3 GameEngineVersion (games.strategy.engine.GameEngineVersion)1 GUID (games.strategy.net.GUID)1 INode (games.strategy.net.INode)1 Node (games.strategy.net.Node)1 SwingAction (games.strategy.ui.SwingAction)1 Version (games.strategy.util.Version)1 Component (java.awt.Component)1 Action (javax.swing.Action)1 JPopupMenu (javax.swing.JPopupMenu)1