ftp.nice.ch/pub/next/games/card/NeXTmille.2.0.s.tar.gz#/NeXTmille-2.0a/types.c

This is types.c in view mode; [Download] [Up]

/*
 * Copyright (c) 1982 Regents of the University of California.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms are permitted
 * provided that the above copyright notice and this paragraph are
 * duplicated in all such forms and that any documentation,
 * advertising materials, and other materials related to such
 * distribution and use acknowledge that the software was developed
 * by the University of California, Berkeley.  The name of the
 * University may not be used to endorse or promote products derived
 * from this software without specific prior written permission.
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 */

#ifndef lint
static char sccsid[] = "@(#)types.c	5.3 (Berkeley) 6/18/88";
#endif /* not lint */

#import	"CardView.h"
#import	"mille.h"
#import	"prototypes.h"
#import	<assert.h>


/*
 * @(#)types.c	1.1 (Berkeley) 4/1/82
 */

BOOL	isDistance( CardView *aCard )
{

	BOOL	retVal = NO;
	
	
	switch([ aCard tag ]) {
		case C_200:
		case C_100:
		case C_75:
		case C_50:
		case C_25:
			retVal = YES;
	}
	
	return retVal;
}


BOOL	isSafety( CardView *aCard )
{

	BOOL	retVal = NO;
	
	
	switch([ aCard tag ]) {
		case C_EXTRA_TANK_SAFETY:
		case C_PUNCTURE_PROOF_SAFETY:
		case C_DRIVING_ACE_SAFETY:
		case C_RIGHT_OF_WAY_SAFETY:
			retVal = YES;
	}
	
	return retVal;
}


BOOL	isRemedy( CardView *aCard )
{

	BOOL	retVal = NO;


	switch([ aCard tag ]) {
		case C_GASOLINE_REMEDY:	
		case C_SPARE_TIRE_REMEDY:		
		case C_REPAIRS_REMEDY:		
		case C_ROLL_REMEDY:		
		case C_END_OF_LIMIT_REMEDY:
			retVal = YES;
	}
	
	return retVal;
}


BOOL	isHazard( CardView *aCard )
{

	BOOL	retVal = NO;
	
	
	switch([ aCard tag ]) {
		case C_OUT_OF_GAS_HAZARD:		
		case C_FLAT_TIRE_HAZARD:			
		case C_ACCIDENT_HAZARD:		
		case C_STOP_HAZARD:		
		case C_SPEED_LIMIT_HAZARD:
			retVal = YES;
	}
	
	return retVal;
}


BOOL	isRemedyForHazard( CardView *hazard, CardView *remedy ) 
{

	
	if(([ hazard tag ] == C_OUT_OF_GAS_HAZARD ) && (([ remedy tag ] == C_GASOLINE_REMEDY ) || ([ remedy tag ] == C_EXTRA_TANK_SAFETY )))
		return YES;
	
	if(([ hazard tag ] == C_FLAT_TIRE_HAZARD ) && (([ remedy tag ] == C_SPARE_TIRE_REMEDY ) || ([ remedy tag ] == C_PUNCTURE_PROOF_SAFETY )))
		return YES;
	
	if(([ hazard tag ] == C_ACCIDENT_HAZARD ) && (([ remedy tag ] == C_REPAIRS_REMEDY ) || ([ remedy tag ] == C_DRIVING_ACE_SAFETY )))
		return YES;
	
	if(([ hazard tag ] == C_STOP_HAZARD ) && (([ remedy tag ] == C_ROLL_REMEDY ) || ([ remedy tag ] == C_RIGHT_OF_WAY_SAFETY )))
		return YES;
	
	if(([ hazard tag ] == C_SPEED_LIMIT_HAZARD ) && (([ remedy tag ] == C_END_OF_LIMIT_REMEDY ) || ([ remedy tag ] == C_RIGHT_OF_WAY_SAFETY )))
		return YES;
	
	return NO;
}


int	distanceCardValue( CardView *aCard )
{

	int	value = 0;
	
	
	switch([ aCard tag ]) {
		case C_200:
			value = 200;
			break;
		case C_100:
			value = 100;
			break;
		case C_75:
			value = 75;
			break;
		case C_50:
			value = 50;
			break;
		case C_25:
			value = 25;
			break;
		default:
			perror( "unknown card value" );
	}
	
	return value;
}


int	safetyForHazard( int aCardTag )
{


	switch( aCardTag ) {
		case C_STOP_HAZARD:
		case C_SPEED_LIMIT_HAZARD:
			return C_RIGHT_OF_WAY_SAFETY;
		case C_ACCIDENT_HAZARD:
			return C_DRIVING_ACE_SAFETY;
		case C_FLAT_TIRE_HAZARD:
			return C_PUNCTURE_PROOF_SAFETY;
		case C_OUT_OF_GAS_HAZARD:
			return C_EXTRA_TANK_SAFETY;
		default:
			assert( 0 /* unknown hazard card passed */ );
	}
	
}


int	hazardForRemedy( int aCardTag )
{

	
	switch( aCardTag ) {
		case C_GASOLINE_REMEDY:		
			return	C_OUT_OF_GAS_HAZARD;
		case C_SPARE_TIRE_REMEDY:		
			return C_FLAT_TIRE_HAZARD;
		case C_REPAIRS_REMEDY:		
			return C_ACCIDENT_HAZARD;
		case C_ROLL_REMEDY:		
			return C_STOP_HAZARD;	
		case C_END_OF_LIMIT_REMEDY:	
			return C_SPEED_LIMIT_HAZARD;
		default:
			assert( 0 /* bad remedy card */ );
	}
	
}


int	remedyForHazard( int aCardTag )
{


	switch( aCardTag ) {
		case C_OUT_OF_GAS_HAZARD:
			return C_GASOLINE_REMEDY;	
		case C_FLAT_TIRE_HAZARD:
			return C_SPARE_TIRE_REMEDY;			
		case C_ACCIDENT_HAZARD:
			return C_REPAIRS_REMEDY;		
		case C_STOP_HAZARD:
			return C_ROLL_REMEDY;			
		case C_SPEED_LIMIT_HAZARD:
			return C_END_OF_LIMIT_REMEDY;	
		default:
			assert( 0 /* bad hazard card */ );
	}

}


int	safetyForRemedy( int aCardTag )
{


	switch( aCardTag ) {
		case C_GASOLINE_REMEDY:		
			return	C_EXTRA_TANK_SAFETY;
		case C_SPARE_TIRE_REMEDY:		
			return C_PUNCTURE_PROOF_SAFETY;
		case C_REPAIRS_REMEDY:		
			return C_DRIVING_ACE_SAFETY;
		case C_ROLL_REMEDY:		
		case C_END_OF_LIMIT_REMEDY:	
			return C_RIGHT_OF_WAY_SAFETY;	
		default:
			assert( 0 /* bad remedy card */ );
	}
	
}



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