From a5aef07b4a2b85933f3a2f358a4d1b6fe27948b7 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 16 Dec 2014 23:13:17 +0000 Subject: Improved list_entity engine function. --- src/core/entity.cc | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) (limited to 'src/core') diff --git a/src/core/entity.cc b/src/core/entity.cc index 610db6b..f4a29dd 100644 --- a/src/core/entity.cc +++ b/src/core/entity.cc @@ -265,7 +265,12 @@ void Entity::print() const // print header print_header(); - // type + // faction + if (faction()) { + con_print << " ^Nfaction ^B" << faction()->label() << std::endl; + } + + // entity type id con_print << " ^Ntype ^B"; switch (type()) { case Default: @@ -288,6 +293,8 @@ void Entity::print() const con_print << "^Bprojectile"; } con_print << std::endl; + + // game module type id con_print << " ^Nmodule type ^B" << moduletype() << std::endl; // print entity flags @@ -308,9 +315,13 @@ void Entity::print() const con_print << " ^Bkeepalive"; } con_print << std::endl; - if (inventory()) { - con_print << " ^Ninventory capacity ^B" << inventory()->capacity_used() << "/" << inventory()->capacity() << " ^Nitems^B " << inventory()->items().size() << std::endl; - } + + // info record + if (info()) { + con_print << " ^Ninfo id ^B" << info()->id() << std::endl; + } + + // slots if (slots() && slots()->size()) { int nbcannons = 0; int nbturrets = 0; @@ -334,18 +345,20 @@ void Entity::print() const con_print << " ^Nslots "; if (nbcannons > 0) { - con_print << " ^Ncannons^B " << nbcannons; + con_print << " ^B" << nbcannons << " ^Ncannons"; } if (nbturrets > 0) { - con_print << " ^Nturrets^B " << nbturrets; + con_print << " ^B" << nbturrets << " ^Nturrets"; } if (nbdocks > 0) { - con_print << " ^Ndocks^B " << nbdocks; + con_print << " ^B" << nbdocks << " ^Ndocks"; } con_print << std::endl; - } - if (faction()) { - con_print << " ^Nfaction ^B" << faction()->label() << std::endl; + } + + // invenotry + if (inventory()) { + print_inventory(); } } @@ -364,8 +377,8 @@ void Entity::print_inventory() const con_print << "no inventory availble" << std::endl; return; } - - con_print << " ^Nitem infotype info amount flags" << std::endl; + con_print << " ^Ninventory capacity ^B" << inventory()->capacity_used() << "/" << inventory()->capacity() << " ^Nused by^B " << inventory()->items().size() << " ^Nitems" << std::endl; + con_print << " ^Nitem infotype info amount price flags" << std::endl; for (Inventory::Items::const_iterator it = entity_inventory->items().begin(); it != entity_inventory->items().end(); it++) { Item *item = (*it); // TODO item flags @@ -373,7 +386,8 @@ void Entity::print_inventory() const << " ^B" << std::setw(4) << item->id() << " ^N" << aux::pad_right((item->info()->type() ? item->info()->type()->label() : "NULL"), 8) << " ^N" << aux::pad_right(item->info()->label(), 24) - << std::setw(5) << item->amount(); + << std::setw(5) << item->amount() << " " + << std::setw(9) << item->price(); if (item->has_flag(core::Item::Tradeable)) { con_print << " tradeable"; } @@ -388,7 +402,6 @@ void Entity::print_inventory() const } con_print<< std::endl; } - con_print << "^B " << entity_inventory->items().size() << " inventory items" << std::endl; } void Entity::die() -- cgit v1.2.3