ftp.nice.ch/pub/next/games/board/Risk.0.97.s.tar.gz#/RiskSource0.97/Risk/Card.m

This is Card.m in view mode; [Download] [Up]

// Card.m
// Part of Risk by Mike Ferris

#import "Card.h"
#import <appkit/NXImage.h>
#import <appkit/Panel.h>

@implementation Card

+ initialize
{
	if (self == [Card class])  {
		[self setVersion:1];
	}
	return self;
}

- init
{
	[self initCountry:-1 type:NIL_TYPE imageFile:NULL];
	return self;
}

- initCountry:(int)c type:(int)t imageFile:(const char *)imageName
{
	[super init];
	countryNum=c;
	type=t;
	if (imageName!=NULL)  {
		image=[[NXImage allocFromZone:[self zone]] initFromSection:imageName];
		if (image==nil)  {
			NXRunAlertPanel("Debug", "Didn't get bmap", "OK", NULL, NULL);
		}
	}  else  {
		image=nil;
	}
	return self;
}

- free
{
	[image free];
	return [super free];
}

- (int)countryNum
{
	return countryNum;
}

- (int)type
{
	return type;
}

- image
{
	return image;
}

- setCountryNum:(int)c
{
	countryNum=c;
	return self;
}

- setType:(int)t
{
	type=t;
	return self;
}

- setImageName:(const char *)imageName
{
	if (imageName!=NULL)  {
		image=[[NXImage allocFromZone:[self zone]] initFromFile:imageName];
	}  else  {
		image=nil;
	}
	return self;
}

- write:(NXTypedStream *)typedStream
{
	[super write:typedStream];
	NXWriteType(typedStream, "i", &countryNum);
	NXWriteType(typedStream, "i", &type);
	NXWriteObject(typedStream, image);
	
	return self;
}

- read:(NXTypedStream *)typedStream
{
	[super read:typedStream];
	NXReadType(typedStream, "i", &countryNum);
	NXReadType(typedStream, "i", &type);
	image=NXReadObject(typedStream);

	return self;
}

@end

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