#import <appkit/appkit.h>
#import "RagnarokListener.h"
#import <mach.h>
#import <sys/message.h>
#import <servers/netname.h>
extern port_t name_server_port;
extern id NXResponsibleDelegate();
@implementation  RagnarokListener :Listener
{}
static NXRemoteMethod *remoteMethods = NULL;
#define REMOTEMETHODS 13
+ (void)initialize 
/* */
{
    if (!remoteMethods) {
	remoteMethods =
	(NXRemoteMethod *) malloc((REMOTEMETHODS+1)*sizeof(NXRemoteMethod));
	remoteMethods[0].key = 
	@selector(submitMoveFrom:To:);
	remoteMethods[0].types = "ii";
	remoteMethods[1].key = 
	@selector(submitTentativeMoveFrom:To:);
	remoteMethods[1].types = "ii";
	remoteMethods[2].key = 
	@selector(submitNoTentativeMove);
	remoteMethods[2].types = "";
	remoteMethods[3].key = 
	@selector(submitUndos:);
	remoteMethods[3].types = "i";
	remoteMethods[4].key = 
	@selector(submitResetGame);
	remoteMethods[4].types = "";
	remoteMethods[5].key = 
	@selector(submitMessage:);
	remoteMethods[5].types = "c";
	remoteMethods[6].key = 
	@selector(goodbye);
	remoteMethods[6].types = "";
	remoteMethods[7].key = 
	@selector(pleaseAllow:Undo:);
	remoteMethods[7].types = "ii";
	remoteMethods[8].key = 
	@selector(pleaseAllow:StartOver:);
	remoteMethods[8].types = "ii";
	remoteMethods[9].key = 
	@selector(pleaseHurryUp:);
	remoteMethods[9].types = "i";
	remoteMethods[10].key = 
	@selector(allow:);
	remoteMethods[10].types = "i";
	remoteMethods[11].key = 
	@selector(refuse:);
	remoteMethods[11].types = "i";
	remoteMethods[12].key = 
	@selector(ok:);
	remoteMethods[12].types = "i";
	remoteMethods[REMOTEMETHODS].key = NULL;
    }
}
-(int)submitMoveFrom : (int) from
	To : (int) to
/* */
{
    id _NXd;
    if (_NXd = NXResponsibleDelegate(self,
	@selector(submitMoveFrom:To:)))
	return [_NXd submitMoveFrom : from
		To : to];
    return -1;
}

-(int)submitTentativeMoveFrom : (int) from
	To : (int) to
/* */
{
    id _NXd;
    if (_NXd = NXResponsibleDelegate(self,
	@selector(submitTentativeMoveFrom:To:)))
	return [_NXd submitTentativeMoveFrom : from
		To : to];
    return -1;
}

-(int)submitNoTentativeMove
/* */
{
    id _NXd;
    if (_NXd = NXResponsibleDelegate(self,
	@selector(submitNoTentativeMove)))
	return [_NXd submitNoTentativeMove];
    return -1;
}

-(int)submitUndos : (int) howMany
/* */
{
    id _NXd;
    if (_NXd = NXResponsibleDelegate(self,
	@selector(submitUndos:)))
	return [_NXd submitUndos : howMany];
    return -1;
}

-(int)submitResetGame
/* */
{
    id _NXd;
    if (_NXd = NXResponsibleDelegate(self,
	@selector(submitResetGame)))
	return [_NXd submitResetGame];
    return -1;
}

-(int)submitMessage : (char *) aString
/* */
{
    id _NXd;
    if (_NXd = NXResponsibleDelegate(self,
	@selector(submitMessage:)))
	return [_NXd submitMessage : aString];
    return -1;
}

-(int)goodbye
/* */
{
    id _NXd;
    if (_NXd = NXResponsibleDelegate(self,
	@selector(goodbye)))
	return [_NXd goodbye];
    return -1;
}

-(int)pleaseAllow : (int) tag
	Undo : (int) howMany
/* */
{
    id _NXd;
    if (_NXd = NXResponsibleDelegate(self,
	@selector(pleaseAllow:Undo:)))
	return [_NXd pleaseAllow : tag
		Undo : howMany];
    return -1;
}

-(int)pleaseAllow : (int) tag
	StartOver : (int) ignored
/* */
{
    id _NXd;
    if (_NXd = NXResponsibleDelegate(self,
	@selector(pleaseAllow:StartOver:)))
	return [_NXd pleaseAllow : tag
		StartOver : ignored];
    return -1;
}

-(int)pleaseHurryUp : (int) tag
/* */
{
    id _NXd;
    if (_NXd = NXResponsibleDelegate(self,
	@selector(pleaseHurryUp:)))
	return [_NXd pleaseHurryUp : tag];
    return -1;
}

-(int)allow : (int) tag
/* */
{
    id _NXd;
    if (_NXd = NXResponsibleDelegate(self,
	@selector(allow:)))
	return [_NXd allow : tag];
    return -1;
}

-(int)refuse : (int) tag
/* */
{
    id _NXd;
    if (_NXd = NXResponsibleDelegate(self,
	@selector(refuse:)))
	return [_NXd refuse : tag];
    return -1;
}

-(int)ok : (int) tag
/* */
{
    id _NXd;
    if (_NXd = NXResponsibleDelegate(self,
	@selector(ok:)))
	return [_NXd ok : tag];
    return -1;
}

- (int) performRemoteMethod : (NXRemoteMethod *) method
                  paramList : (NXParamValue *) paramList {
/* */
    switch (method - remoteMethods) {
    case 0:
	return [self submitMoveFrom : paramList[0].ival
		To : paramList[1].ival];
    case 1:
	return [self submitTentativeMoveFrom : paramList[0].ival
		To : paramList[1].ival];
    case 2:
	return [self submitNoTentativeMove];
    case 3:
	return [self submitUndos : paramList[0].ival];
    case 4:
	return [self submitResetGame];
    case 5:
	return [self submitMessage : paramList[0].bval.p];
    case 6:
	return [self goodbye];
    case 7:
	return [self pleaseAllow : paramList[0].ival
		Undo : paramList[1].ival];
    case 8:
	return [self pleaseAllow : paramList[0].ival
		StartOver : paramList[1].ival];
    case 9:
	return [self pleaseHurryUp : paramList[0].ival];
    case 10:
	return [self allow : paramList[0].ival];
    case 11:
	return [self refuse : paramList[0].ival];
    case 12:
	return [self ok : paramList[0].ival];
    default:
	return [super performRemoteMethod : method paramList : paramList];
    }
}
- (NXRemoteMethod *) remoteMethodFor: (SEL) aSel {
/* */
    NXRemoteMethod *rm;
    if (rm = NXRemoteMethodFromSel(aSel,remoteMethods))
        return rm;
    return [super remoteMethodFor : aSel];
}
@end
