CharString NounShip::status() const { CharString sTargetInfo; // team & ship type.. sTargetInfo += CharString().format("%s - %s\n", teamName(), nounContext()->name() ); // hull % sTargetInfo += CharString().format("Hull: %d%%\n", int( damageRatioInv() * 100) ); int armor = 0, maxArmor = 0; int shield = 0, maxShield = 0; for(int i=0;i<childCount();i++) { BaseNode * pChild = child(i); if ( WidgetCast<GadgetShield>( pChild ) ) { shield += ((GadgetShield *)pChild)->charge(); maxShield += ((GadgetShield *)pChild)->maxCharge(); } else if ( WidgetCast<GadgetArmor>( pChild ) ) { armor += ((GadgetArmor *)pChild)->armor(); maxArmor += ((GadgetArmor *)pChild)->maxArmor(); } } if ( maxShield > 0 ) sTargetInfo += CharString().format("Shield: %d%%\n", (shield * 100) / maxShield); if ( maxArmor > 0 ) sTargetInfo += CharString().format("Armor: %d%%\n", (armor * 100) / maxArmor ); return sTargetInfo; }
void Command::seg(std::string cmd, GameEngine *game) { std::string teamName(cmd.begin() + 4, cmd.end()); game->endGame(teamName); }