import { Registry } from "../../core/registry.ts";
import {
BURNTWOOD,
BUSHES,
DARKOLIVEGREEN,
FOREST,
GRASS,
SADDLEBROWN,
} from "../../core/color.ts";
import { ORGANIC, PENETRABLE } from "../../core/flags.ts";
import { Sym } from "../../core/sym.ts";
import { TypeOnlySerializer } from "../../core/serializer.ts";
import { ImmobileAgent, Tree } from "./creatures.ts";
// exported to test the conversion of trees into stumps when exposed to fire
export class Alder extends Tree {
constructor() {
super("Alder Tree", Sym.of("ϒ", FOREST));
}
static SERIALIZER = new (class extends TypeOnlySerializer {
constructor() {
super("Alder");
}
create() {
return new Alder();
}
tag() {
return "Trees";
}
})();
}
class Cactus extends Tree {
constructor() {
super("Cactus", Sym.of("ψ", DARKOLIVEGREEN));
}
static SERIALIZER = new (class extends TypeOnlySerializer {
constructor() {
super("Cactus");
}
create() {
return new Cactus();
}
tag() {
return "Trees";
}
})();
}
class Cypress extends Tree {
constructor() {
super("Cypress Tree", Sym.of("ϒ", GRASS));
}
static SERIALIZER = new (class extends TypeOnlySerializer {
constructor() {
super("Cypress");
}
create() {
return new Cypress();
}
tag() {
return "Trees";
}
})();
}
class Elm extends Tree {
constructor() {
super("Elm Tree", Sym.of("♣", BUSHES));
}
static SERIALIZER = new (class extends TypeOnlySerializer {
constructor() {
super("Elm");
}
create() {
return new Elm();
}
tag() {
return "Trees";
}
})();
}
class Fir extends Tree {
constructor() {
super("Fir Tree", Sym.of("♠", FOREST));
}
static SERIALIZER = new (class extends TypeOnlySerializer {
constructor() {
super("Fir");
}
create() {
return new Fir();
}
tag() {
return "Trees";
}
})();
}
class Hemlock extends Tree {
constructor() {
super("Hemlock Tree", Sym.of("♠", BUSHES));
}
static SERIALIZER = new (class extends TypeOnlySerializer {
constructor() {
super("Hemlock");
}
create() {
return new Hemlock();
}
tag() {
return "Trees";
}
})();
}
class Maple extends Tree {
constructor() {
super("Maple Tree", Sym.of("♣", GRASS));
}
static SERIALIZER = new (class extends TypeOnlySerializer {
constructor() {
super("Maple");
}
create() {
return new Maple();
}
tag() {
return "Trees";
}
})();
}
class Oak extends Tree {
constructor() {
super("Oak Tree", Sym.of("♣", FOREST));
}
static SERIALIZER = new (class extends TypeOnlySerializer {
constructor() {
super("Oak");
}
create() {
return new Oak();
}
tag() {
return "Trees";
}
})();
}
class Spruce extends Tree {
constructor() {
super("Spruce Tree", Sym.of("♠", GRASS));
}
static SERIALIZER = new (class extends TypeOnlySerializer {
constructor() {
super("Spruce");
}
create() {
return new Spruce();
}
tag() {
return "Trees";
}
})();
}
class Willow extends Tree {
constructor() {
super("Willow Tree", Sym.of("ϒ", BUSHES));
}
static SERIALIZER = new (class extends TypeOnlySerializer {
constructor() {
super("Willow");
}
create() {
return new Willow();
}
tag() {
return "Trees";
}
})();
}
/**
* When trees get set on fire they turn into stumps. Stumps still block
* movement but are no longer considered to be trees (mirrors Java: Stump
* extends ImmobileAgent directly, not Tree, and is ORGANIC | PENETRABLE).
*/
class Stump extends ImmobileAgent {
constructor() {
super(
"Stump",
ORGANIC | PENETRABLE,
Sym.of("╨", SADDLEBROWN, null, BURNTWOOD, null),
);
}
static SERIALIZER = new (class extends TypeOnlySerializer {
constructor() {
super("Stump");
}
create() {
return new Stump();
}
tag() {
return "Trees";
}
})();
}
export function registerTrees() {
Registry.register("Alder", Alder.SERIALIZER);
Registry.register("Cactus", Cactus.SERIALIZER);
Registry.register("Cypress", Cypress.SERIALIZER);
Registry.register("Elm", Elm.SERIALIZER);
Registry.register("Fir", Fir.SERIALIZER);
Registry.register("Hemlock", Hemlock.SERIALIZER);
Registry.register("Maple", Maple.SERIALIZER);
Registry.register("Oak", Oak.SERIALIZER);
Registry.register("Spruce", Spruce.SERIALIZER);
Registry.register("Willow", Willow.SERIALIZER);
Registry.register("Stump", Stump.SERIALIZER);
}