Search in sources :

Example 1 with ListeningPerson

use of com.codingchili.realm.instance.model.npc.ListeningPerson in project chili-core by codingchili.

the class GameContext method main.

public static void main(String[] args) throws InterruptedException {
    RealmSettings settings = new RealmSettings().setName("testing");
    RealmContext.create(new SystemContext(), settings).setHandler(create -> {
        RealmContext realm = create.result();
        InstanceContext ins = new InstanceContext(realm, new InstanceSettings());
        GameContext game = new GameContext(ins);
        /*        game.ticker(ticker -> {
            System.out.println("DING");
        }, 50);*/
        Creature cl = new ListeningPerson();
        game.add(cl);
        // cast the poison spell on himself.
        cl.getSpells().getLearned().add("poisoner");
        for (int i = 0; i < 2; i++) {
            boolean casted = game.spells.cast(cl, new SpellTarget().setCreature(cl), "poisoner");
            System.out.println("casted = " + casted);
        }
    });
// todo: add more hooks to SpellEngine afflictions. onDamage etc.
// todo: test cases
// todo: script npcs: onDeath, onAI etc.
// - afflict, duration, cancel etc.
// - cast spell: cooldown, charges etc.
/*for (int i = 0; i < 200; i++) {
            game.add(new TalkingPerson());
            game.add(new TalkingPerson());
            game.add(new ListeningPerson());
        }*/
/*game.ticker(ticker -> {
            System.out.println(ListeningPerson.called);
        }, TICK_INTERVAL_MS);*/
// game.ticker((ticker) -> System.out.println(ticker.delta()), 1);
// System.exit(0);
/*        game.addCreature(new TalkingPerson(game));
        game.addCreature(new TalkingPerson(game));
        game.addCreature(new ListeningPerson(game));*/
}
Also used : RealmSettings(com.codingchili.realm.configuration.RealmSettings) SpellTarget(com.codingchili.realm.instance.model.spells.SpellTarget) RealmContext(com.codingchili.realm.configuration.RealmContext) SystemContext(com.codingchili.core.context.SystemContext) ListeningPerson(com.codingchili.realm.instance.model.npc.ListeningPerson)

Example 2 with ListeningPerson

use of com.codingchili.realm.instance.model.npc.ListeningPerson in project chili-core by codingchili.

the class SpellEngine method main.

public static void main(String[] args) {
    RealmSettings settings = new RealmSettings().setName("testing");
    RealmContext.create(new SystemContext(), settings).setHandler(create -> {
        RealmContext rc = create.result();
        InstanceContext ins = new InstanceContext(rc, new InstanceSettings());
        GameContext game = new GameContext(ins);
        SpellEngine engine = new SpellEngine(game);
        JsonObject affConfig = ConfigurationFactory.readObject("/afflictiontest.yaml");
        Affliction affliction = Serializer.unpack(affConfig, Affliction.class);
        Creature target = new ListeningPerson();
        Creature source = new ListeningPerson();
        game.add(target);
        game.add(source);
        for (int i = 0; i < 500; i++) {
            engine.afflict(source, target, affliction.getName());
        }
    });
}
Also used : RealmSettings(com.codingchili.realm.configuration.RealmSettings) RealmContext(com.codingchili.realm.configuration.RealmContext) SystemContext(com.codingchili.core.context.SystemContext) JsonObject(io.vertx.core.json.JsonObject) ListeningPerson(com.codingchili.realm.instance.model.npc.ListeningPerson)

Aggregations

SystemContext (com.codingchili.core.context.SystemContext)2 RealmContext (com.codingchili.realm.configuration.RealmContext)2 RealmSettings (com.codingchili.realm.configuration.RealmSettings)2 ListeningPerson (com.codingchili.realm.instance.model.npc.ListeningPerson)2 SpellTarget (com.codingchili.realm.instance.model.spells.SpellTarget)1 JsonObject (io.vertx.core.json.JsonObject)1