From 941c64546ca22b87a9153d36e9e3fe59c18abafe Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 7 Dec 2014 18:40:54 +0000 Subject: Improved Entity::print(). --- src/core/entity.cc | 56 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 13 deletions(-) (limited to 'src/core') diff --git a/src/core/entity.cc b/src/core/entity.cc index 0c49a3e..610db6b 100644 --- a/src/core/entity.cc +++ b/src/core/entity.cc @@ -269,23 +269,23 @@ void Entity::print() const con_print << " ^Ntype ^B"; switch (type()) { case Default: - con_print << "entity"; + con_print << "^Bentity"; break; case Dynamic: - con_print << "dynamic"; + con_print << "^Bdynamic"; break; case Controlable: - con_print << "controlable"; + con_print << "^Bcontrolable"; break; case Globe: - con_print << "globe"; + con_print << "^Bglobe"; break; case Projectile: - con_print << "projectile"; + con_print << "^Bprojectile"; } con_print << std::endl; con_print << " ^Nmodule type ^B" << moduletype() << std::endl; @@ -293,26 +293,56 @@ void Entity::print() const // print entity flags con_print << " ^Nflags ^B"; if (has_flag(NonSolid)) { - con_print << " nonsolid"; + con_print << " ^Bnonsolid"; } if (has_flag(Bright)) { - con_print << " bright"; + con_print << " ^Bbright"; } if (has_flag(Dockable)) { - con_print << " dockable"; + con_print << " ^Bdockable"; } if (has_flag(ShowOnMap)) { - con_print << " shownmap"; + con_print << " ^Bshownmap"; } if (has_flag(KeepAlive)) { - con_print << " keepalive"; + con_print << " ^Bkeepalive"; } con_print << std::endl; if (inventory()) { - con_print << " ^Ninventory ^Byes" << std::endl; + con_print << " ^Ninventory capacity ^B" << inventory()->capacity_used() << "/" << inventory()->capacity() << " ^Nitems^B " << inventory()->items().size() << std::endl; } - if (slots()) { - con_print << " ^Nslots ^Byes" << std::endl; + if (slots() && slots()->size()) { + int nbcannons = 0; + int nbturrets = 0; + int nbdocks = 0; + + for (Slots::iterator slit = slots()->begin(); slit != slots()->end(); ++slit) { + switch ((*slit)->type()) { + case model::Slot::Cannon: + ++nbcannons; + break; + case model::Slot::Turret: + ++nbturrets; + break; + case model::Slot::Dock: + ++nbdocks; + break; + case model::Slot::None: + break; + } + } + + con_print << " ^Nslots "; + if (nbcannons > 0) { + con_print << " ^Ncannons^B " << nbcannons; + } + if (nbturrets > 0) { + con_print << " ^Nturrets^B " << nbturrets; + } + if (nbdocks > 0) { + con_print << " ^Ndocks^B " << nbdocks; + } + con_print << std::endl; } if (faction()) { con_print << " ^Nfaction ^B" << faction()->label() << std::endl; -- cgit v1.2.3