/*
	
	IRC-Bot "Kvasir"
    Copyright (C) 2016	Fenris Wolf (fenris@folksprak.org)
	
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
	
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
	
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
       
*/


/**
 * @author fenris
 */
abstract class klaso_kromajxo
{
	
	/**
	 * @author fenris
	 */
	protected identigilo : string;
	
	
	/**
	 * @author fenris
	 */
	protected nomo : string;
	
	
	/**
	 * @author fenris
	 */
	protected priskribo : string;
	
	
	/**
	 * @author fenris
	 */
	protected uzo : string;
	
	
	/**
	 * @author fenris
	 */
	protected auxtoro : string;
	
	
	/**
	 * @author fenris
	 */
	public constructor
	(
		identigilo : string = null,
		nomo : string = null,
		priskribo : string = null,
		uzo : string = null,
		auxtoro : string = null
	)
	{
		if (identigilo == null)
		{
			identigilo = cxeno_generi("kromajxo_");
			console.warn("nenia identigilo donita; la jena estis generita: " + identigilo);
		}
		this.identigilo = identigilo;
		this.nomo = nomo;
		this.priskribo = priskribo;
		this.uzo = uzo;
		this.auxtoro = auxtoro;
	}
	
	
	/**
	 * @author fenris
	 */
	public identigilo_legi() : string
	{
		return this.identigilo;
	}
	
	
	/**
	 * @author fenris
	 */
	public nomo_legi() : string
	{
		return this.nomo;
	}
	
	
	/**
	 * @author fenris
	 */
	public priskribo_legi() : string
	{
		return this.priskribo;
	}
	
	
	/**
	 * @author fenris
	 */
	public uzo_legi() : string
	{
		return this.uzo;
	}
	
	
	/**
	 * @author fenris
	 */
	public auxtoro_legi() : string
	{
		return this.auxtoro;
	}
	
	
	/**
	 * @author fenris
	 */
	public enigi(enigo : klaso_evento_eniga, eligi : (eligo : klaso_evento_eliga)=>void) : void
	{
		let that : klaso_kromajxo = this;
		this.reagi
		(
			enigo.kruda_al(),
			eligo_kruda => eligi(klaso_evento_eliga_mesagxo.kruda_de(eligo_kruda))
		)
	}
		
	
	/**
	 * @author fenris
	 */
	public starigi(finado : (eraro ?: Error)=>void) : void
	{
		finado(null);
	}
	
	
	/**
	 * @author fenris
	 */
	protected abstract reagi(enigo_kruda : Object, eligi : (eligo_kruda : Object)=>void) : void;
	
}