Add exploding bunny rabbit

This commit is contained in:
Isaac Shoebottom 2022-11-04 17:53:17 -03:00
parent 5c03647a4a
commit 38135762f6

View File

@ -44,6 +44,10 @@ actionTypes.reproduce = function(critter, vector, action) {
return true; return true;
}; };
actionTypes.die = function(critter, action) {
}
class LifelikeWorld extends life.World { class LifelikeWorld extends life.World {
constructor(map,legend){ constructor(map,legend){
super(map,legend); super(map,legend);
@ -95,8 +99,24 @@ class PlantEater{
}; };
} }
class ExplodingBunnyRabbit extends PlantEater {
constructor () {
super()
}
act(view) {
super.act(view);
if(this.energy > 55) {
if (Math.random() < 0.25) {
return {type: "die"}
}
}
}
}
exports.LifelikeWorld=LifelikeWorld; exports.LifelikeWorld=LifelikeWorld;
exports.BouncingCritter=life.BouncingCritter; exports.BouncingCritter=life.BouncingCritter;
exports.Wall=life.Wall; exports.Wall=life.Wall;
exports.PlantEater = PlantEater; exports.PlantEater = PlantEater;
exports.Plant = Plant; exports.Plant = Plant;
exports.actionTypes = actionTypes;