LifeFormFactory.java

src/net/sourceforge/pain/logic/fn/factory/LifeFormFactory.java · 1.0 KB

From the archive pain_0_41.zip

Download the archive   « Back to the archive contents

package net.sourceforge.pain.logic.fn.factory;

import net.sourceforge.pain.data.prototype.*;
import net.sourceforge.pain.data.type.*;
import net.sourceforge.pain.util.*;

/**
 * User: fmike  Date: Sep 13, 2003   Time: 8:38:14 PM
 */
public class LifeFormFactory {

	public static void init(LifeFormPrototype proto, LifeForm obj) {
		int lifePoints = proto.getLifePointsDice().roll();
		obj.setLifePoints(lifePoints);
		obj.setMaxLifePoints(lifePoints);
		int sex = proto.getSex();
		switch (sex) {
			case LifeFormPrototype.SEX_FEMALE:
				sex = LifeForm.SEX_FEMALE;
				break;
			case LifeFormPrototype.SEX_MALE:
				sex = LifeForm.SEX_MALE;
				break;
			case LifeFormPrototype.SEX_UNDEFINED:
				sex = LifeForm.SEX_UNDEFINED;
				break;
			case LifeFormPrototype.SEX_EITHER:
				sex = (System.currentTimeMillis() & 0x1) == 0 ? LifeForm.SEX_FEMALE : LifeForm.SEX_MALE;
				break;
			default:
				throw new RuntimeException("BUG!, life form prototype sex:" + sex);
		}
		Log.debug("set sex to:" + sex);
		obj.setSex(sex);
		obj.setRace(proto.getRace());
	}

}

Site Stats

Snippets: 1791
Codebases: 571