ImmortalityAffect.java

codebase/src/net/sourceforge/pain/logic/affect/ImmortalityAffect.java · 1.2 KB

From the archive pain_0_44.tgz

Download the archive   « Back to the archive contents

package net.sourceforge.pain.logic.affect;

import net.sourceforge.pain.*;
import net.sourceforge.pain.data.*;
import net.sourceforge.pain.data.type.*;
import net.sourceforge.pain.logic.*;
import net.sourceforge.pain.logic.fn.*;

/**
 * User: fmike  Date: Mar 22, 2004  Time: 3:51:36 AM
 */
public final class ImmortalityAffect extends Affect {

    public ImmortalityAffect(AffectData ad) {
        super(ad);
    }

    public static void makeImmortal(Creature c) throws Exception {
        if (c == null) {
            throw new NullPointerException("creature == null!!!");
        }
        new AffectData(Core.getDB(), c, ImmobilityAffect.class, AffectType.AFFECT_IMMORTAL);
        MessageOutFn.outln(c, "Immortality ON");//just an example
    }

    public static void makeMortal(Creature c) throws Exception {
        AffectData ad = c.getAffectImage(AffectType.AFFECT_IMMORTAL);
        if (ad == null) {
            return;
        }
        ad.delete();
        MessageOutFn.outln(c, "Immortality OFF!");//just an example
    }

    /**
     * required by codebase (performance)
     */
    public Affect newInstance(AffectData ad) {
        return new ImmortalityAffect(ad);
    }
}

Site Stats

Snippets: 1791
Codebases: 571