ftp.nice.ch/Attic/openStep/games/Empire.0.6.m.NIS.bs.tgz#/Empire.0.6/src/DistributedGameManager.h

This is DistributedGameManager.h in view mode; [Download] [Up]

//
// $Id: DistributedGameManager.h,v 1.6 1997/10/31 05:44:19 nygard Exp $
//

//
//  This file is a part of Empire, a game of exploration and conquest.
//  Copyright (C) 1996  Steve Nygard
//
//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation; either version 2 of the License, or
//  (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
//  You may contact the author by:
//     e-mail:  nygard@telusplanet.net
//

#import <AppKit/AppKit.h>
#import <Foundation/NSConnection.h>
#import "GameManager.h"

//======================================================================

@interface DistributedGameManager : GameManager <EmpireGameManagerProtocol>
{
    // Client:
    DistributedGameManager *master;
    NSConnection *masterConnection;
    Player clientPlayer;

    // Server
    DistributedGameManager *playerManagers[4];
    NSConnection *clientConnections[4];
    int unreadyRemotePlayers; // Accessed by different threads?

    // Both, but the server has a bit different semantics
    Map *cachedMaps[4]; // Just a reference to part of a player.
}

+ (void) initialize;

- init;
- (void) dealloc;

//======================================================================
// Empire Game Manager Protocol
//======================================================================

- (void) ping;
- (void) aboutToDisconnect:sender;
- (void) peer:clientGameManager forPlayer:(Player)number;
- (Map *) remoteFetchMapForPlayer:(Player)number;
- (void) otherMaps:(Map *)map1:(Map *)map2 forPlayer:(Player)number;

- (void) remoteUpdateMapAroundCitiesForPlayer:(Player)number;

- (void) remoteTurn:(int)turn withCookie:(NSNumber *)aCookie forPlayer:(Player)number;
- (void) remoteTurnDone:(NSNumber *)aCookie forPlayer:(Player)number updatedMap:(Map *)newMap;

//======================================================================
// Establish Game
//======================================================================

- (void) startGameWithMapNamed:(NSString *)mapName;
- (void) tryToStart;
- (void) stopGame;
- (void) startGameWithMap:(Map *)worldMap master:masterGameManager;
- (void) addRemotePlayer:(Player)number forClient:remoteClient;
- (void) notifyMasterForPlayer:(Player)number;
- (void) distributeMaps;

//======================================================================
// Turn Handling
//======================================================================

- (void) turnDone:(NSNumber *)aCookie;

// Here???
- (void) distributeMapsToRemotePlayer:(Player)p;

//======================================================================
// Empire Game Manager Protocol:
//======================================================================

//----------------------------------------------------------------------
// Game Initialization / Termination
//----------------------------------------------------------------------

- (City *) remoteRandomNeutralCity;
- (void) remoteGameHasStopped:(Player)number activePlayers:(int)activePlayers;

//----------------------------------------------------------------------
// Combat Support
//----------------------------------------------------------------------

- (void) remoteSet3x3Tokens:(struct NineTokens)tokens aroundLocation:(EMMapLocation)target forPlayer:(Player)number;
- (void) remoteSetToken:(MapToken)token atLocation:(EMMapLocation)target forPlayer:(Player)number;

- (MoveResult) remoteUnitWithCombatProfile:(CombatProfile)attackerProfile
                             attacksPlayer:(Player)cityPlayer
                            cityAtLocation:(EMMapLocation)target
                 playersAdjacentToDefender:(int)adjacentPlayers;

- (MoveResult) remoteUnitWithCombatProfile:(CombatProfile)attackerProfile
                             attacksPlayer:(Player)defender
                            unitAtLocation:(EMMapLocation)target
                           withBombardment:(BOOL)bombarding
                 playersAdjacentToDefender:(int)adjacentPlayers;

- (CombatProfile) remoteReadyDefendingCityAtLocation:(EMMapLocation)target forPlayer:(Player)number;
- (CombatProfile) remoteReadyDefendingUnitAtLocation:(EMMapLocation)target
                                           forPlayer:(Player)number
                                  againstBombardment:(BOOL)bombarding;
- (void) remoteShowExplosions:(int)count forPlayer:(Player)number atLocation:(EMMapLocation)target;
- (void) remoteHitDefendingUnit:(Player)number withDamage:(int)damage;
- (City *) remoteLostDefendingCityOfPlayer:(Player)number;
- (void) remoteHitAttacker:(Player)number withDamage:(int)damage;
- (void) remotePlayer:(Player)number hasCapturedCity:(City *)capturedCity;
- (void) remoteFinishedCombatForPlayer:(Player)number;

- (BOOL) remoteCheckForEndOfPlayer:(Player)number;
- (BOOL) remoteHasPlayerLost:(Player)number;
- (void) remotePlayerHasLost:(Player)number activePlayers:(int)activePlayers;
- (BOOL) remotePlayerHasWon:(Player)number activePlayers:(int)activePlayers;

//----------------------------------------------------------------------
// Methods that may communicate with remote game managers:
//----------------------------------------------------------------------

- (void) gameHasStopped:(Player)number activePlayers:(int)activePlayers;
- (void) set3x3Tokens:(MapToken *)tokens aroundLocation:(EMMapLocation)target forPlayer:(Player)number;

- (City *) randomNeutralCity;

- (MoveResult) unitWithCombatProfile:(CombatProfile)attackerProfile
                       attacksPlayer:(Player)cityPlayer
                      cityAtLocation:(EMMapLocation)target
           playersAdjacentToDefender:(int)adjacentPlayers;

- (MoveResult) unitWithCombatProfile:(CombatProfile)attackerProfile
                       attacksPlayer:(Player)defender
                      unitAtLocation:(EMMapLocation)target
                     withBombardment:(BOOL)bombarding
           playersAdjacentToDefender:(int)adjacentPlayers;

- (CombatProfile) readyDefendingCityAtLocation:(EMMapLocation)target forPlayer:(Player)number;
- (CombatProfile) readyDefendingUnitAtLocation:(EMMapLocation)target forPlayer:(Player)number againstBombardment:(BOOL)bombarding;
- (void) showExplosions:(int)count forPlayer:(Player)number atLocation:(EMMapLocation)target;
- (void) hitDefendingUnit:(Player)number withDamage:(int)damage;
- (City *) lostDefendingCityOfPlayer:(Player)number;
- (void) hitAttacker:(Player)number withDamage:(int)damage;
- (void) player:(Player)number hasCapturedCity:(City *)capturedCity;
- (void) finishedCombatForPlayer:(Player)number;

- (BOOL) checkForEndOfPlayer:(Player)number;
- (BOOL) hasPlayerLost:(Player)number;
- (void) playerHasLost:(Player)number activePlayers:(int)activePlayers;
- (BOOL) playerHasWon:(Player)number activePlayers:(int)activePlayers;

//======================================================================

- (Map *) mapForPlayer:(Player)number;
- (Map *) fetchMapForPlayer:(Player)number;
- (void) set3x3Tokens:(MapToken *)tokens aroundLocation:(EMMapLocation)target forPlayer:(Player)number;
- (void) setToken:(MapToken)token atLocation:(EMMapLocation)target forPlayer:(Player)number;

- (void) remove:(Icon)icon atLocation:(EMMapLocation)target forPlayer:(Player)number;
- (void) put:(Icon)icon atLocation:(EMMapLocation)target forPlayer:(Player)number;
- (void) setCityAtLocation:(EMMapLocation)target toPlayer:(Player)newCityPlayer forPlayer:(Player)number;



- (void) remoteUpdateMapAroundCitiesForPlayer:(Player)number;
- (void) updateMapAroundCitiesForPlayer:(Player)number;

- (void) connectionDidDie:(NSNotification *)notification;


- (void) remoteResignPlayerFromGame:(Player)number;
- (void) resignPlayerFromGame:(Player)number;

- (NSArray *) remoteRemainingCitiesForPlayer:(Player)number;
- (NSArray *) remainingCitiesForPlayer:(Player)number;


- (void) deactivatePlayer:(Player)number;

- (void) remotePlayerHasResigned:(Player)number activePlayers:(int)activePlayers;
- (void) playerHasResigned:(Player)number activePlayers:(int)activePlayers;

- (Map *) remoteFinalMapForPlayer:(Player)number;
- (Map *) finalMapForPlayer:(Player)number;

- (void) remoteNotifyPlayer:(Player)number aPlayerHasResigned:(Player)resignedPlayer;
- (void) notifyPlayer:(Player)number aPlayerHasResigned:(Player)resignedPlayer;

- (void) logStatus;

@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.