import java.awt.Image;
import java.io.IOException;
import javax.imageio.ImageIO;
import java.util.Random;

public class BreedingPool extends Platform implements java.io.Serializable {
	static final long serialVersionUID = 1L;

	public static final int type = 0;
	public static final int size = 128;
	private static final int images_num = 1; //このクラスの総使用画像数
	private static final int anime_pattern = 1; //このクラスのアニメーション数
	private static int AnimeImagesNum[] = {1};//アニメごとに何枚使うか
	private static Image[] images = new Image[images_num];
	protected Random rnd = new Random();
	
	public static void loadImages (ClassLoader loader) throws IOException {
		final String path = "images/";
		images[0] = ImageIO.read(loader.getResourceAsStream(path+"breedingpool.png"));		
		images[0] = images[0].getScaledInstance(size*9/8, size*3/4, Image.SCALE_AREA_AVERAGING);
	}

	public Image getImage(){
		return images[0];
	}

	public int getSize() {
		return size;
	}
	
	public int run( Obj o ) {
		if ( (int)age % 10 == 0 && o.objType == Obj.Type.YUKKURI ) {
			Body p = (Body)o;
			int babyType;
			babyType = p.getType();
			if ((babyType == Reimu.type) && rnd.nextBoolean()) {
				babyType = WasaReimu.type;
			}
			else if ((babyType == WasaReimu.type) && rnd.nextBoolean()) {
				babyType = Reimu.type;
			}
			if ((p.isSick() || p.isSick()) || p.isDamaged() || p.isDamaged()) {
				babyType = Tarinai.type;
			}
			p.babyTypes.add(babyType);
			p.hasBaby = true;
		}
		return 0;
	}

	public BreedingPool(int initX, int initY, Direction initDir) {
		super(initX, initY, Platform.Direction.BACK);
	}
}