// Token used by statusbar.
class NinjaToken : Inventory
{
	Default
	{
		Inventory.MaxAmount 10;
	}
}

// Lump reading stuff provided by Keks for any weird bulletpuffs that don't
// actually inherit from bulletpuff.
class Gc_NinjaData {
	private Array <class <Actor> >	inflictors;
	
	void UseAllNinjaLumps () {
		int lump_num = -1;
		
		do {
			lump_num		= wads.FindLump("gcninja", startlump: lump_num + 1);
			
			if(0 <= lump_num ) {
				let lump_data	= wads.ReadLump(lump_num);
				AppendInflictorsFromText(lump_data);
			}
		} while(0 <= lump_num);
	}
	
	bool IsInflictor (class <Actor> mo_class) const {
		let size = inflictors.size();
		return
			0 < size &&
			size != inflictors.find(mo_class);
	}
	
	private void AppendInflictorsFromText (String data) {
		
		// kd: The data is just a list of actors. We allow whitespaces or
		// returns. This here should work fine.
		Array <String> split_data;
		data.replace("\r\n", " ");
		data.replace("\n", " ");
		data.replace("\r", " ");
		data.split(split_data, " ");
		
		for(int i = split_data.size(); 0 <= --i; ) {
			
			// kd: Just making sure (trailing names without newline would
			// not be counted for some reason):
			let check_data = split_data [i];
			check_data.replace(" ", "");
			
			// Check if this is actually some actor.
			let class_type = (class <Actor>)(check_data);
			
			if(
			class_type != NULL &&
			inflictors.size() == inflictors.find(class_type)) {
				inflictors.push((class <Actor>)(class_type));
			}
		}
	}
}

/* 
// Keks' original attempt at the Ninjamode stuff. It shall rest here.
class PowerNinja : Inventory
{
	Default
	{
		//Powerup.Duration 0x7FFFFFFF;
		PowerNinja.ResistDamageType 'None';
		PowerNinja.GracePeriod 15;
		PowerNinja.DecayPeriod 5;
		PowerNinja.AbsorbLevels 10;
		PowerNinja.ElevationVelocity 19.0;
		//+INVENTORY.PERSISTENTPOWER
	}

	Name resist;
	int graceperiod;
	int decayperiod;
	int absorblevels;
	float elevatevel;

	property ResistDamageType: resist;
	property GracePeriod: graceperiod;
	property DecayPeriod: decayperiod;
	property AbsorbLevels: absorblevels;
	property ElevationVelocity: elevatevel;

	int elevate;
	int decay;
	int gracetics;
	int level;

	override void AbsorbDamage(int damage, Name damageType, out int newdamage)
	{
		// We have 0 <= level < absorblevels and all these numbers are whole.
		// So the line below is equivalent to what we previously had (damage
		// factor decrements of 0.1 per level).

		// owner.player.mo.A_Log(damageType);

		if(damageType == resist)
			newdamage =
				(int)(damage * (1.0 * (absorblevels - level)) / absorblevels);
	}

	// This was written by zhs2 in ACS. But oh wait -- ACS got superseded. Now
	// instead of being a looping script that gives and takes powerups as needed
	// it just calculates your "absorption level" as it used to. Then it does
	// some maths as seen above only when you receive damage. Huh!
	override void DoEffect()
	{
		Actor user;

		if(Owner.player != NULL)
		{
			user = Owner.player.mo;

			// Dragons prefer the taxi-cab norm.
			float totalvel = user.vel.length();
			if(elevatevel <= totalvel)
			{
				gracetics = 0;
				decay = 0;
				if(level < absorblevels - 1 && absorblevels <= elevate)
				{
					level++;
					elevate = 0;
				}

				else
					elevate++;
			}

			else if(graceperiod <= gracetics)
			{
				if(1 <= level && decayperiod <= decay)
				{
					level--;
					decay = 0;
				}

				else
					decay++;
			}

			else
				gracetics++;
		}
	}
}

class PowerCygnisIsAnActualRYUHayabusa : PowerNinja
{
	Default
	{
		PowerNinja.ResistDamageType 'Bueller';
	}

	override void DoEffect()
	{
		Actor user = owner.player.mo;
		super.DoEffect();
		user.A_TakeInventory("NinjaToken", 10);
		if(0 < level)
			user.A_GiveInventory("NinjaToken", level);
		// user.A_LogInt(user.CountInv("NinjaToken"));
	}
}
*/