Xiangqi 1.0
===========

Description  : A Chinese chess (Xiang Qi) component for Delphi (version 3 and above)
Release date : 10/09/1998
Author       : Axel Fontaine
E-Mail       : axel-fontaine@usa.net
CopyRight    : Axel Fontaine 1998
Cost         : free, or maybe an e-mail to tell me what you think about TXiangqi/NetXiangqi
Version      : 1.0 (initial release)
Recommended config:
  Delphi 3 or higher
  800x600 or higher
  16, 24 or 32 bit color


Legal Issues
============

This component is my creation and the demos are distributed under the GNU GPL.
If you make changes to NetXiangqi, please send them back to me.
The cartoon cliparts are from Corel Mega Gallery (http://www.corel.com).
The TCP/IP component is part of ICS from Franois PIETTE (http://www.rtfm.be/fpiette/indexuk.htm).
The GoToWeb component is from Sylvain CRESTO (http://www.mygale.org/~cresto).
This component and the examples are provided "as-is" with no warranty of any kind.
I may not be held liable for any damage caused by this component or the examples.
You are not allowed to modify or remove the copyright notices in any of the source files.
You cannot claim you wrote these files.
ICS and GoToWeb files distributed for compiling purposes only. 
I stronly recommend you get the full packages at the indicated URLs.


And now the cool stuff
======================

Once you've got the component installed in the palette, simply drop it on a form. 
Make sure the playing property is set to true. Run the program. 
To move pieces, simply drag and drop them.

Here is a quick overview of the public methods and the properies:

Note: StartPos and EndPos are always in board coordinates. The board is 9x10 . 
The coordinates are zero-based, not one-based. Example: TopLeft (0,0)   BottomRight (8,9);


TPlayerColor = (pcRed,pcGreen);

The 2 possible colors for the players.



TPlayerSet = Set of TPlayerColor;

Speaks for itself.


TPieceType = (ptPawn,ptCannon,ptElephant,ptKnight,ptRook,ptGuard,ptKing);

The different types of pieces on the board. Each of these has a specific behavior.


TPieceInfo = record        //Info about a piece
  Color: TPlayerColor;     //Color of the piece
  PieceType: TPieceType;   //Type of the piece
  ImageIndex: Integer;     //Index of the image representing the piece in the internal imagelist
end;


PPieceInfo = ^TPieceInfo;

A pointer for the above structure.


TMove = record               //Info about a move for the move history
  StartPos: TPoint;          //From here
  EndPos: TPoint;            //to there
  Piece: PPieceInfo;         //does this piece move
  CapturedPiece: PPieceInfo; //to capture this one (Nil=empty square)
End;


PMove = ^TMove;

A pointer for the above structure.


TPieceSet = (psCartoon,psChinese);

The 2 available piecesets. Each contains 14 bitmaps with the different pieces on it. 
(7 red / 7 green)


TGameBoard = array[0..Pred(MaxXPieces),0..Pred(MaxYPieces)] of PPieceInfo;

The memory structure of the playing surface.


TMateType = (mtCheckMate,mtStaleMate);

Did he win by Checkmate or Stalemate ?


function DoMove(StartPos, EndPos: TPoint):Boolean;
  
Programmaticaly move a piece from StartPos to EndPos.


procedure PreviousMove;

An undo of the last move: goes one move back in the move history.


procedure NextMove;

An redo of the last move: goes one move forward in the move history.


procedure GoToMove(MoveNumber: Cardinal);

Goes to a specified move in the move history.


procedure DrawPiece(ACanvas: TCanvas; TopLeft: TPoint; Piece: PPieceInfo);

Draws a piece (the one specified in Piece) on a specified canvas at TopLeft.


procedure NewGame;

Starts a new game. Resets the board to its initial setup.


class function OtherColor(Color: TPlayerColor):TPlayerColor;

Simple function that returns Green for Red or Red for Green.


property PieceBitmap[PieceIndex: Cardinal]:TBitmap read GetPieceBitmap;

The bitmap associated with a partical index (index contained in TPieceInfo).


property Board[XPos, YPos: Cardinal]:PPieceInfo read GetBoard write SetBoard; default;

Get the info about a certain piece on the board. In board coordinates. Nil = empty square.
default => Xiangqi1[X,Y] works too


property CurrentMove: Cardinal read FMove write GoToMove default 0;

The current move number. Zero-based index.


property LastMove: Cardinal read GetLastMove;

The index of the last move in the move history. Is equal to CurrentMove unless you called PreviousMove. Then CurrentMove < LastMove.


property PieceSet: TPieceSet read FPieceSet write SetPieceSet default psCartoon;

To choose between the different piece sets.


property Playing: Boolean read FPlaying write FPlaying default False;

Set to false to prevent user input. Programmatically playing is still allowed.


property ShowHint;

Show Piece names or not.


property Turn: TPlayerColor read FTurn write FTurn default pcRed;

Whose Turn is it? Red or Green?


property Version: String read GetVersion;

What is the version of the component?


property OnCheck: TOnCheckEvent read FOnCheck write FOnCheck default Nil;

Called when somebody is in check after a move.


property OnMate: TOnMateEvent read FOnMate write FOnMate default Nil;

Called when a move results in a checkmate or a stalemate of the opponent.


property OnCapture: TOnCaptureEvent read FOnCapture write FOnCapture default Nil;

Called when a piece is captured.


property OnMove: TOnMoveEvent read FOnMove write FOnMove default Nil;

Called when a piece is moved.


property OnPreviousMove: TNotifyEvent read FOnPreviousMove write FOnPreviousMove default Nil;

Called after PreviousMove is called.


property OnNextMove: TNotifyEvent read FOnNextMove write FOnNextMove default Nil;

Called after NextMove is called.


property OnResurrect: TVoodooEvent read FOnResurrect write FOnResurrect default Nil;

Called after PreviousMove is called and resulted in the "resurrection" of a piece.


property OnReKill: TVoodooEvent read FOnReKill write FOnReKill default Nil;

Called after NextMove is called and resulted in a piece to be "rekilled".


property OnPieceSetChange: TOnPieceSetChangeEvent 
  read FOnPieceSetChange write FOnPieceSetChange default Nil;

Called when you switch between the sets of pieces



Files
=====
\                            Xiangqi Component and resource files
\resource                    Files needed in order to build bitmaps.res
\demos\simple                Simple demo program
\demos\NetXiangqi            NetXiangqi 1.0
\demos\NetXiangqi\GameRules  A copy of the game rules 
  (for the most recent version: 
     http://freezone.exmachina.net/Axel and look for the Chinese chess section)
\netcomps         
Additionnal files required in order to compile NetXiangqi. These are part of different packages. 
To get the full packages (which I truly recommend because they are great, 
go to the URL's I put in the legal section.


Game rules
==========

See \demos\NetXiangqi\GameRules\GameRules.html


How to use NetXiangqi?
======================

You need to have a running copy of mIRC32 or ICQ. Then get your friend's IP address. 
Type your name in the area provided on the Bottom Right. 
You agree on who's gonna be server and who's gonna be client. 
The server simply has to wait. 
The client has to type the domain name or the IP address in the box on the BottomLeft of the window. 
And then click on connect. You can chat in the little window in the Center in the right. 
The server decides on the colors. By default server=red/client=green. 
But the server can change that in the options menu before connecting.
You're all set! Enjoy!


You like it and/or you have suggestions. What do you have to do?
================================================================

Send me a little something by e-mail or what I really appreciate is a postcard from where you live. 
Try to avoid envelopes, I like the cards better with the stamp on. ;-)
Money donnations are always welcome too!

Axel Fontaine
Rue de Malaise 2
1331 Rosieres
Belgium

axel-fontaine@usa.net


Still have some questions?
==========================

E-mail me, or write me. I'd love to help you out!


I've finished reading all the docs what should I do now?
========================================================

Play NetXiangqi with all your friends around the globe of course!


Enjoy.

Axel