// -*- c++ -*-
#ifndef _MYTYPES_H
#define _MYTYPES_H

class MsgQ;

typedef unsigned long ulong;
typedef unsigned short ushort;
typedef unsigned char uchar;
typedef char *charp;

typedef void (*HandlerFunc)(int, void *);
typedef void (*readNotifyFunc)(MsgQ *, int, int);
typedef void (*MessageHandlerFunc)(void *);
typedef void (*ChoiceHandlerFunc)(char *, void *);

struct ReadHandler
{
  readNotifyFunc func;
  int fd, q;
  int info;
};

typedef ReadHandler *ReadHandlerP;

// if the key isn't one of these, its an ordinary key
typedef enum { KEY_UPLEFT = 0x100, KEY_UP, KEY_UPRIGHT, KEY_LEFT, KEY_RIGHT,
       KEY_DOWNLEFT, KEY_DOWN, KEY_DOWNRIGHT, NO_KEY } MoveKey;

typedef enum { MOUSE_LEFT, MOUSE_RIGHT, KEYBOARD} EventType;

// from move.h
typedef enum { PIECE_DIE, PIECE_MOVE, PIECE_CREATE, UNIT_UPDATE,
	       CITY_CREATE, CITY_DIE, CITY_SIZE, CITY_WALL, CITY_WORK_MAP,
	       DISCOVERY, BUILDWONDER, DESTROY_WONDER, CAPTURE_WONDER,
	       DECLARE_WAR, OFFER_TREATY, ACCEPT_TREATY, REFUSE_TREATY,
	       TERRAIN_CHANGE, SDI_DEFENSE}
MoveType;

typedef enum {NEUTRAL, AT_WAR, TREATY} TreatyStatus;
typedef enum { NORMAL, IN_SELECT } StateType;

// from net.h
enum { RestoreSaveFile, StartNewGame };

// from player.h
// MarkM added ANARCHY to govt types enumeration:
typedef enum { ANARCHY, DESPOT, MONARCH, REPUBLIC, DEMOCRATIC} Govts;

typedef enum { UNIT, BUILDING, WONDER} Class;

typedef enum { NOOBJECT = 0,
  ARMOR, ARTILLERY, BATTLESHIP, BOMBER, CANNON, CARAVAN,
  CARRIER, CATAPULT, CAVALRY, CHARIOT, CRUISER, DIPLOMAT, FIGHTER,
  FRIGATE, IRONCLAD, KNIGHTS, LEGION, MECH_INF, MILITIA, MUSKETEERS,
  NUCLEAR, PHALANX, RIFLEMEN, SAIL, SETTLER, SUBMARINE, TRANSPORT,
  TRIREME,
  AQUADUCT, BANK, BARRACKS, CATHEDRAL, CITYWALLS, COLOSSEUM, COURTHOUSE, 
  FACTORY, FUSIONPLANT, GRANARY, HYDROPLANT, LIBRARY, MARKETPLACE,
  MASSTRANSIT, MFGPLANT, NUCLEARPLANT, PALACE, POWERPLANT,
  RECYCLINGCTR, SDIDEFENSE, TEMPLE, UNIVERSITY,
  COLOSSUS, COPERNICUS, CUREFORCANCER, DARWIN, GREATLIBRARY, GREATWALL,
  HANGINGGARDENS, HOOVERDAM, ISAACNEWTON, JSBACH, LIGHTHOUSE, MAGELLAN,
  MANHATTAN, MICHELANGELO, ORACLE, PYRAMIDS, SETIPROGRAM, SHAKESPEARE,
  UNITEDNATIONS, WOMENSSUFFRAGE,
  MAXOBJECTS
} BuildObject;

#define FIRSTUNIT     ARMOR
#define LASTUNIT      TRIREME
#define FIRSTBUILDING AQUADUCT
#define LASTBUILDING  UNIVERSITY
#define FIRSTWONDER   COLOSSUS
#define LASTWONDER    WOMENSSUFFRAGE

#define FOR_ALL_BUILDOBJS(i) for (i = FIRSTUNIT; i <= LASTWONDER; i = BuildObject(i+1))
#define FOR_ALL_UNITS(i) for (i = FIRSTUNIT; i <= LASTUNIT; i = BuildObject(i+1))
#define FOR_ALL_BUILDINGS(i) for (i = FIRSTBUILDING; i <= LASTBUILDING; i = BuildObject(i+1))
#define FOR_ALL_WONDERS(i) for (i = FIRSTWONDER; i <= LASTWONDER; i = BuildObject(i+1))

typedef enum { NOSCIENCE = 0,
  ADVANCEDFLIGHT, ALPHABET, ASTRONOMY, ATOMICTHEORY, AUTOMOBILE, BANKING,
  BRIDGEBUILDING, BRONZEWORKING, CEREMONIALBURIAL, CHEMISTRY, CHIVALRY,
  CODEOFLAWS, COMBUSTION, COMMUNISM, COMPUTERS, CONSCRIPTION, CONSTRUCTION,
  CURRENCY, DEMOCRACY, ELECTRICITY, ELECTRONICS, ENGINEERING, EXPLOSIVES,
  FEUDALISM, FLIGHT, FUSIONPOWER, GENETICENGINEERING, GUNPOWDER,
  HORSEBACKRIDING, INDUSTRIALIZATION, INVENTION, IRONWORKING, LABORUNION,
  LITERACY, MAGNETISM, MAPMAKING, MASONRY, MASSPRODUCTION, MATHEMATICS,
  MEDICINE, METALLURGY, MONARCHY, MYSTICISM, NAVIGATION, NUCLEARFISSION,
  NUCLEARPOWER, PHILOSOPHY, PHYSICS, PLASTICS, POTTERY, RAILROAD, RECYCLING,
  REFINING, RELIGION, ROBOTICS, ROCKETRY, STEAMENGINE, STEEL, SUPERCONDUCTOR,
  SURVIVAL, THECORPORATION, THEREPUBLIC, THEWHEEL, THEORYOFGRAVITY, TRADE,
  UNIVERSITIES, WRITING,
  FUTURETECH
} Science;

#define FIRSTSCIENCE ADVANCEDFLIGHT
#define FOR_ALL_SCIENCES(i) for (i = FIRSTSCIENCE; i < FUTURETECH; i = Science(i+1))

struct ObjectData {
  char *name;
  BuildObject type;
  Class isunit;

  int prodCost;
  int maint;

  Science NeededScience;
  int built; // if it's a wonder and it's been built
  int isObsolete;
  char *line;

  int IsBuilding() {return (isunit == BUILDING);} 
  int IsWonder() {return (isunit == WONDER);} 
  int IsUnit() {return (isunit == UNIT);} 
  int SellValue() {return IsBuilding() ? prodCost : 0;}
  int DisbandValue() {return IsUnit() ? prodCost/2 : 0;}
};

struct ScienceData {
  char *name;
  Science type;
  
  Science NeededScience[2];
};

struct UnitData {
  BuildObject type;
  int attack;
  int defend;
  int move;
  class CPixmap *picture;
};

#include "boolList.h"

typedef BOOLList<FUTURETECH-FIRSTSCIENCE,FIRSTSCIENCE> ScienceList;
typedef BOOLList<LASTBUILDING-FIRSTBUILDING+1,FIRSTBUILDING> BuildingList;
typedef BOOLList<LASTWONDER-FIRSTWONDER+1,FIRSTWONDER> WonderList;

#endif // _MYTYPES_H
