home *** CD-ROM | disk | FTP | other *** search
- //
- // $Id: Unit.h,v 1.5 1997/10/27 08:28:27 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 "Empire.h"
-
- @class City;
- @class EmPlayer;
- @class Order;
-
- //======================================================================
-
- @interface Unit : NSObject
- {
- UnitType unitType;
- EmPlayer *owner;
-
- NSString *unitName;
- EMMapLocation unitLocation;
-
- int currentHitPoints;
- int currentRange;
- int fuel;
-
- Order *order;
-
- BOOL isDestroyed;
- BOOL isDoneTurn;
-
- NSMutableArray *cargo;
-
- Unit *onBoard; // The ship we are on board, if any.
- City *withinCity;
- }
-
- + (void) initialize;
-
- - initWithUnitType:(UnitType)aUnitType inCity:(City *)producingCity;
- - (void) dealloc;
-
- - (NSString *) description;
-
- //======================================================================
- // General static values
- //======================================================================
-
- - (UnitType) unitType;
- - (EmPlayer *) owner;
- - (Player) playerNumber;
- - (NSString *) unitName;
- - (BOOL) isAShip;
-
- //======================================================================
- // Combat information
- //======================================================================
-
- - (int) currentHitPoints;
-
- // Intrinsic values
- - (int) maxHitPoints;
- - (int) damagePerHit;
-
- // These values have NOT been adjusted by player efficiencies.
- - (float) attackFactor;
- - (float) defenseFactor:(BOOL)bombardment;
-
- - (BOOL) canBombard;
-
- //======================================================================
- // Movement information
- //======================================================================
-
- - (int) currentRange;
- - (int) remainingFuel;
-
- - (BOOL) canMoveOnTerrain:(Terrain)terrain;
- - (MovementType) movementType;
-
- - (EMMapLocation) unitLocation;
- - (void) setLocation:(EMMapLocation)newLocation;
- - (void) takeLocationFromTransport;
-
- //======================================================================
- // Display
- //======================================================================
-
- - (Icon) icon;
- - (NSImage *) iconImage;
-
- //======================================================================
- // Order support
- //======================================================================
-
- - (void) setOrder:(Order *)newOrder;
- - (Order *) currentOrder;
- - (BOOL) isSentried;
- - (int) remainingCargoCapacity;
- - (BOOL) isFull;
-
- //======================================================================
- // Turn handling
- //======================================================================
-
- - (void) repairDamage;
- - (void) refuel;
- - (void) resetRange;
-
- - (void) skipMove;
- - (void) useSkippedFuel;
- - (void) moved;
-
- - (BOOL) isFinishedMoving;
- - (void) setUnitFinishedMoving:(BOOL)flag;
-
- - (BOOL) tryToMove; // Maybe under order support?
-
- //======================================================================
- // Human UI support
- //======================================================================
-
- - (NSString *) statusLine;
-
- //======================================================================
- // Commands
- //======================================================================
-
- - (void) unloadShip;
- - (void) destroyUnit:(BOOL)disbanded;
- - (BOOL) loadUnit:(Unit *)aUnit;
-
- //======================================================================
- // Combat Support
- //======================================================================
-
- - (BOOL) hitForDamage:(int)damage;
- - (CombatProfile) combatProfileAgainstBombardment:(BOOL)bombarding;
-
- //======================================================================
- // Other
- //======================================================================
-
- - (BOOL) isOnBoardShip;
- - (BOOL) isInCity;
- - (BOOL) hasBeenDestroyed;
-
- - (City *) city;
- - (void) setCity:(City *)aCity;
-
- // If this unit is aboard a ship, this method returns the containing ship.
- - (Unit *) shipOnBoard;
- - (void) setOnBoardShip:(Unit *)ship;
-
- // Shared with City..
- - (void) unitDidExit:(Unit *)aUnit;
- - (void) unitDidEnter:(Unit *)aUnit;
-
- @end
-