All pastes #905573 Raw Edit

Monster

public java v1 · immutable
·published 2008-02-15 21:42 UTC
rendered paste body
//base class from which all monsters are built//so im saying every monster has these attributes, hp, str, resistances to 12 things//im going to have a seperate file that contains all the monster stats//but then when you get in a fight, you can just call monster = new Monster("goblin", 10,10,10...)// this way i wouldnt need a seperate file for each monsterpublic enum ResistanceType {	FIRE,	WATER,	PHLEGM}public class ElementalResistance {	ResistanceType type;	int Amount = 1;	// Methods to add, subtract, get, etc., go here}public enum MonsterAttributeType {	HITPOINTS,	MAGICPOINTS,	STRENGTH,	ENDURANCE,	INTELLIGENCE,	WILL,	SPEED,	WEAPON,	ARMOR}public class MonsterAttribute {	MonsterAttributeType type;	int Amount = 1;	// Methods to add, subtract, get, etc., go here}public class Monster{	String name = "undefined";	MonsterAttribute HitPoints    = new MonsterAttribute( MonsterAttributeType.HITPOINTS,    1 );	MonsterAttribute MagicPoints  = new MonsterAttribute( MonsterAttributeType.MAGICPOINTS,  1 );	MonsterAttribute Strength     = new MonsterAttribute( MonsterAttributeType.STRENGTH,     1 );	MonsterAttribute Endurance    = new MonsterAttribute( MonsterAttributeType.ENDURANCE,    1 );	MonsterAttribute Intelligence = new MonsterAttribute( MonsterAttributeType.INTELLIGENCE, 1 );	MonsterAttribute Will         = new MonsterAttribute( MonsterAttributeType.WILL,         1 );	MonsterAttribute Speed        = new MonsterAttribute( MonsterAttributeType.SPEED,        1 );	MonsterAttribute Weapon       = new MonsterAttribute( MonsterAttributeType.WEAPON,       1 );	MonsterAttribute Armor        = new MonsterAttribute( MonsterAttributeType.ARMOR,        1 );	ElementalResistance Fire   = new ElementalResistance( ResistanceType.FIRE,   0 );	ElementalResistance Water  = new ElementalResistance( ResistanceType.WATER,  0 );	ElementalResistance Phlegm = new ElementalResistance( ResistanceType.PHLEGM, 0 );        // Should really have an array of Item[s] which can be        // accumulated and maintain their own attributes.	int gold = 0, exp = 0; //gold and exp worth	//items dropped	//default monster constructor, should never be used, but just in case :P	public Monster(){}	//real monster constructor, define all starting stats, and sets resists to zero	public Monster(String nameIn,int hp,int mp,int str,int end,int intel,int wil,int spd,int wep,int arm,int goldIn,int expIn)	{		name = nameIn;		HP=hp;		MP=mp;		STR=str;		END=end;		INT=intel;		WIL=wil;		SPD=spd;		WEP=wep;		ARM=arm;		gold = goldIn;		exp = expIn;		setResistsZero();	}	//sets all resistance stats to zero	//get methods        MonsterAttribute getAttribute( MonsterAttributeType type ){		MonsterAttribute returnAttribute;		switch( type ){			case STRENGTH:				returnAttribute = Strength;				break;			case HITPOINTS:				returnAddtribute = HitPoints;				break;			/* etc. */			default: break;		}		return( returnAttribute );	}	MonsterAttribute getStrength(){ return this.getAttribute( MonsterAttributeType.STRENGTH ) ); }	/* etc. */	ElementalResistance getResistance( ResistanceType type ){		ElementalResistance returnResistance;		switch( type ){			case Fire:				returnResistance = Fire;				break;			case Water:				returnResistance = Water;				break;			case Phlegm:				returnResistance = Phlegm;				break;			default: break;		}		return( returnResistance );	}	ElementalResistance getFireResistance(){ return( this.getResistance( ResistanceType.FIRE ) ); }}public class Goblin extens Monster {	String name = "Goblin";	MonsterAttribute HitPoints = new MonsterAttribute( MonsterAttributeType.HITPOINTS, 1 );	}