Search in sources :

Example 21 with SOCGame

use of soc.game.SOCGame in project JSettlers2 by jdmonin.

the class SOCGameList method deleteGame.

/**
 * Remove the game from the list
 * and call {@link SOCGame#destroyGame()}.
 * Set its mutex's {@link GameInfo#gameDestroyed} flag.
 *
 * @param gaName  the name of the game; should not be marked with any prefix.
 */
public synchronized void deleteGame(final String gaName) {
    D.ebugPrintln("SOCGameList : deleteGame(" + gaName + ")");
    SOCGame game = gameData.get(gaName);
    if (game != null) {
        game.destroyGame();
        gameData.remove(gaName);
    }
    GameInfo info = gameInfo.get(gaName);
    info.gameDestroyed = true;
    gameInfo.remove(gaName);
    synchronized (info.mutex) {
        info.mutex.notifyAll();
    }
    info.dispose();
}
Also used : SOCGame(soc.game.SOCGame)

Example 22 with SOCGame

use of soc.game.SOCGame in project JSettlers2 by jdmonin.

the class SOCDisplaylessPlayerClient method handleRESOURCECOUNT.

/**
 * handle "resource count" message
 * @param mes  the message
 */
protected void handleRESOURCECOUNT(SOCResourceCount mes) {
    final SOCGame ga = games.get(mes.getGame());
    if (ga == null)
        return;
    handlePLAYERELEMENT_simple(ga, null, mes.getPlayerNumber(), SOCPlayerElement.SET, SOCPlayerElement.RESOURCE_COUNT, mes.getCount(), nickname);
}
Also used : SOCGame(soc.game.SOCGame)

Example 23 with SOCGame

use of soc.game.SOCGame in project JSettlers2 by jdmonin.

the class SOCDisplaylessPlayerClient method handlePIECEVALUE.

/**
 * Update a village piece's value on the board (cloth remaining) in _SC_CLVI,
 * or a pirate fortress's strength in _SC_PIRI.
 * @since 2.0.00
 */
protected void handlePIECEVALUE(final SOCPieceValue mes) {
    final String gaName = mes.getGame();
    SOCGame ga = games.get(gaName);
    if (ga == null)
        // Not one of our games
        return;
    if (!ga.hasSeaBoard)
        // should not happen
        return;
    final int coord = mes.getParam1();
    final int pv = mes.getParam2();
    if (ga.isGameOptionSet(SOCGameOption.K_SC_CLVI)) {
        SOCVillage vi = ((SOCBoardLarge) (ga.getBoard())).getVillageAtNode(coord);
        if (vi != null)
            vi.setCloth(pv);
    } else if (ga.isGameOptionSet(SOCGameOption.K_SC_PIRI)) {
        SOCFortress fort = ga.getFortress(coord);
        if (fort != null)
            fort.setStrength(pv);
    }
}
Also used : SOCVillage(soc.game.SOCVillage) SOCBoardLarge(soc.game.SOCBoardLarge) SOCFortress(soc.game.SOCFortress) SOCGame(soc.game.SOCGame)

Example 24 with SOCGame

use of soc.game.SOCGame in project JSettlers2 by jdmonin.

the class SOCDisplaylessPlayerClient method handleREVEALFOGHEX.

/**
 * Reveal a hidden hex on the board.
 * @since 2.0.00
 */
protected void handleREVEALFOGHEX(final SOCRevealFogHex mes) {
    final String gaName = mes.getGame();
    SOCGame ga = games.get(gaName);
    if (ga == null)
        // Not one of our games
        return;
    if (!ga.hasSeaBoard)
        // should not happen
        return;
    ga.revealFogHiddenHex(mes.getParam1(), mes.getParam2(), mes.getParam3());
}
Also used : SOCGame(soc.game.SOCGame)

Example 25 with SOCGame

use of soc.game.SOCGame in project JSettlers2 by jdmonin.

the class SOCDisplaylessPlayerClient method handleDICERESULTRESOURCES.

/**
 * Handle all players' dice roll result resources.  Looks up the game and calls
 * {@link #handleDICERESULTRESOURCES(SOCDiceResultResources, SOCGame)}
 * so the players gain resources.
 * @since 2.0.00
 */
protected void handleDICERESULTRESOURCES(final SOCDiceResultResources mes) {
    SOCGame ga = games.get(mes.getGame());
    if (ga == null)
        return;
    handleDICERESULTRESOURCES(mes, ga, nickname, false);
}
Also used : SOCGame(soc.game.SOCGame)

Aggregations

SOCGame (soc.game.SOCGame)60 SOCPlayer (soc.game.SOCPlayer)17 Connection (soc.server.genericServer.Connection)7 SOCBoardLarge (soc.game.SOCBoardLarge)5 MissingResourceException (java.util.MissingResourceException)3 Vector (java.util.Vector)3 SOCBoard (soc.game.SOCBoard)3 StringConnection (soc.server.genericServer.StringConnection)3 SQLException (java.sql.SQLException)2 HashMap (java.util.HashMap)2 SOCResourceSet (soc.game.SOCResourceSet)2 SOCShip (soc.game.SOCShip)2 SOCTradeOffer (soc.game.SOCTradeOffer)2 SOCVillage (soc.game.SOCVillage)2 SOCGameBoardReset (soc.util.SOCGameBoardReset)2 Color (java.awt.Color)1 IOException (java.io.IOException)1 InterruptedIOException (java.io.InterruptedIOException)1 ArrayList (java.util.ArrayList)1 EnumMap (java.util.EnumMap)1