示例#1
0
std::string InitialStealthEvent::CombatLogDescription(int viewing_empire_id) const {
    std::string desc = "";

    //Viewing empire stealth first
    for (const StealthInvisbleMap::value_type& attack_empire : target_empire_id_to_invisble_obj_id) {
        if (attack_empire.first == viewing_empire_id)
            continue;

        std::map<int, std::set<std::pair<int, Visibility> > >::const_iterator target_empire
            = attack_empire.second.find(viewing_empire_id);
        if (target_empire != attack_empire.second.end()
            && !target_empire->second.empty()) {

            std::vector<std::string> cloaked_attackers;
            for (const std::set<std::pair<int, Visibility>>::value_type& attacker : target_empire->second) {
                 std::string attacker_link = FighterOrPublicNameLink(viewing_empire_id, attacker.first, viewing_empire_id);
                // It doesn't matter if targets of viewing empire have no_visibility or basic_visibility
                 cloaked_attackers.push_back(attacker_link);
            }

            if (!cloaked_attackers.empty()) {
                desc += "\n"; //< Add \n at start of the report and between each empire
                std::vector<std::string> attacker_empire_link(1, EmpireLink(attack_empire.first));
                desc += FlexibleFormatList(attacker_empire_link, cloaked_attackers
                                           , UserString("ENC_COMBAT_INITIAL_STEALTH_LIST")).str();
            }
        }
    }

    //Viewing empire defending
    StealthInvisbleMap::const_iterator attack_empire
        = target_empire_id_to_invisble_obj_id.find(viewing_empire_id);
    if (attack_empire != target_empire_id_to_invisble_obj_id.end()
        && !attack_empire->second.empty()) {
        for (const std::map<int, std::set<std::pair<int, Visibility>>>::value_type& target_empire : attack_empire->second) {
            if (target_empire.first == viewing_empire_id)
                continue;

            std::vector<std::string> cloaked_attackers;
            for (const std::pair<int, Visibility>& attacker : target_empire.second) {
                 std::string attacker_link = FighterOrPublicNameLink(viewing_empire_id, attacker.first, viewing_empire_id);
                // Don't even report on targets with no_visibility it is supposed to be a surprise
                if (attacker.second >= VIS_BASIC_VISIBILITY ) {
                    cloaked_attackers.push_back(attacker_link);
                }
            }

            if (!cloaked_attackers.empty()) {
                if (!desc.empty())
                    desc += "\n";
                std::vector<std::string> attacker_empire_link(1, EmpireLink(attack_empire->first));
                desc += FlexibleFormatList(attacker_empire_link, cloaked_attackers
                                           , UserString("ENC_COMBAT_INITIAL_STEALTH_LIST")).str();
            }
        }
    }

    return desc;
}
示例#2
0
std::string StealthChangeEvent::StealthChangeEventDetail::CombatLogDescription(int viewing_empire_id) const {

    std::string attacker_link = FighterOrPublicNameLink(viewing_empire_id, attacker_id, attacker_empire_id);
    std::string target_link = FighterOrPublicNameLink(viewing_empire_id, target_id, target_empire_id);
    std::string empire_link = EmpireLink(target_empire_id);
    const std::string& template_str = UserString("ENC_COMBAT_STEALTH_DECLOAK_ATTACK");

    return str(FlexibleFormat(template_str)
               % attacker_link
               % target_link
               % empire_link);
}
示例#3
0
std::string WeaponFireEvent::CombatLogDescription(int viewing_empire_id) const {
    std::string attacker_link = FighterOrPublicNameLink(viewing_empire_id, attacker_id, attacker_owner_id);
    std::string target_link = FighterOrPublicNameLink(viewing_empire_id, target_id, target_owner_id);

    const std::string& template_str = UserString("ENC_COMBAT_ATTACK_STR");

    return str(FlexibleFormat(template_str)
               % attacker_link
               % target_link
               % damage
               % bout
               % round);
}
示例#4
0
std::string WeaponsPlatformEvent::CombatLogDescription(int viewing_empire_id) const {
    if (events.empty())
        return "";

    std::vector<std::string> damaged_target_links;
    std::vector<std::string> undamaged_target_links;

    for (const auto& target : events) {
        if (target.second.empty())
            continue;

        const auto& fire_event(*target.second.begin());
        std::string target_public_name(
            FighterOrPublicNameLink(viewing_empire_id, target.first,
                                    fire_event->target_owner_id));

        double damage = 0.0f;
        for (auto attack_it : target.second) {
            damage += attack_it->damage;
        }

        if (damage <= 0.0f) {
            undamaged_target_links.push_back(target_public_name);

        } else {
            damaged_target_links.push_back(
                str(FlexibleFormat(UserString("ENC_COMBAT_PLATFORM_TARGET_AND_DAMAGE"))
                    % target_public_name % damage));
        }
    }

    std::string desc = "";

    const std::vector<std::string> attacker_link(
        1, FighterOrPublicNameLink(viewing_empire_id, attacker_id, attacker_owner_id));

    if (!damaged_target_links.empty() ) {
        desc += FlexibleFormatList(attacker_link, damaged_target_links,
                                   UserString("ENC_COMBAT_PLATFORM_DAMAGE_MANY_EVENTS"),
                                   UserString("ENC_COMBAT_PLATFORM_DAMAGE_1_EVENTS")).str();

        if (!undamaged_target_links.empty())
            desc += "\n";
    }
    if (!undamaged_target_links.empty()) {
        desc += FlexibleFormatList(attacker_link, undamaged_target_links,
                                   UserString("ENC_COMBAT_PLATFORM_NO_DAMAGE_MANY_EVENTS"),
                                   UserString("ENC_COMBAT_PLATFORM_NO_DAMAGE_1_EVENTS")).str();
    }
    return desc;
}
示例#5
0
std::string IncapacitationEvent::CombatLogDescription(int viewing_empire_id) const {
    std::shared_ptr<const UniverseObject> object = GetUniverseObject(object_id);
    std::string template_str, object_str;
    int owner_id = object_owner_id;

    if (!object && object_id < 0) {
        template_str = UserString("ENC_COMBAT_FIGHTER_INCAPACITATED_STR");
        object_str = UserString("OBJ_FIGHTER");

    } else if (!object) {
        template_str = UserString("ENC_COMBAT_UNKNOWN_DESTROYED_STR");
        object_str = UserString("ENC_COMBAT_UNKNOWN_OBJECT");

    } else if (object->ObjectType() == OBJ_PLANET) {
        template_str = UserString("ENC_COMBAT_PLANET_INCAPACITATED_STR");
        object_str = PublicNameLink(viewing_empire_id, object_id);

    } else {    // ships or other to-be-determined objects...
        template_str = UserString("ENC_COMBAT_DESTROYED_STR");
        object_str = PublicNameLink(viewing_empire_id, object_id);
    }

    std::string owner_string = " ";
    if (const Empire* owner = GetEmpire(owner_id))
        owner_string += owner->Name() + " ";

    std::string object_link = FighterOrPublicNameLink(viewing_empire_id, object_id, object_owner_id);

    return str(FlexibleFormat(template_str) % owner_string % object_link);
}
示例#6
0
std::string StealthChangeEvent::StealthChangeEventDetail::DebugString() const {
    std::stringstream ss;
    ss << "StealthChangeDetailEvent"
       <<  FighterOrPublicNameLink(ALL_EMPIRES, attacker_id, attacker_empire_id)
       << "->" << visibility << " ";
    return ss.str();
}
示例#7
0
std::string InitialStealthEvent::DebugString() const {
    std::stringstream ss;
    ss << "InitialStealthEvent: ";
    if (target_empire_id_to_invisble_obj_id.size() > 4) {
        ss << target_empire_id_to_invisble_obj_id.size() << " events.";
    } else {
        for (const StealthInvisbleMap::value_type& attack_empire : target_empire_id_to_invisble_obj_id) {
            ss << " Attacking Empire: " << EmpireLink(attack_empire.first) << "\n";
            for (const std::map<int, std::set<std::pair<int, Visibility>>>::value_type& target_empire : attack_empire.second) {
                ss << " Target Empire: " << EmpireLink(target_empire.first) << " Targets: ";

                if (target_empire.second.size() > 4) {
                    ss << target_empire.second.size() << " attackers.";
                } else {
                    for (const std::pair<int, Visibility>& attacker : target_empire.second) {
                        ss << FighterOrPublicNameLink(ALL_EMPIRES, attacker.first, target_empire.first);
                    }
                }
                ss << "\n";
            }
        }
    }

    return ss.str();
}
示例#8
0
std::string InitialStealthEvent::DebugString() const {
    std::stringstream ss;
    ss << "InitialStealthEvent: ";
    if (target_empire_id_to_invisble_obj_id.size() > 4) {
        ss << target_empire_id_to_invisble_obj_id.size() << " events.";
    } else {
        for (const auto& attack_empire : target_empire_id_to_invisble_obj_id) {
            ss << " Attacking Empire: " << EmpireLink(attack_empire.first) << "\n";
            for (const auto& target_empire : attack_empire.second) {
                ss << " Target Empire: " << EmpireLink(target_empire.first) << " Targets: ";

                if (target_empire.second.size() > 4) {
                    ss << target_empire.second.size() << " attackers.";
                } else {
                    for (const auto& attacker : target_empire.second) {
                        ss << FighterOrPublicNameLink(ALL_EMPIRES, attacker.first, target_empire.first);
                    }
                }
                ss << "\n";
            }
        }
    }

    return ss.str();
}
示例#9
0
std::string FightersAttackFightersEvent::CombatLogDescription(int viewing_empire_id) const {
    if (events.empty())
        return "";

    const auto& events_to_show = events;
    auto num_events_remaining = events.size();
    std::stringstream ss;

    // Use show_events_for_empire to show events in this order: viewing empire, ALL_EMPIRES and
    // then the remainder.
    auto show_events_for_empire =
        [&ss, &num_events_remaining, &events_to_show, &viewing_empire_id]
        (boost::optional<int> show_attacker) {
            int attacker_empire;
            int target_empire;
            for (const auto& index_and_event : events_to_show) {
                std::tie(attacker_empire, target_empire) = index_and_event.first;

                // Skip if this is not the particular attacker requested
                if (show_attacker && *show_attacker != attacker_empire)
                    continue;

                // Skip if no particular attacker was requested and this empire is the viewing
                // empire or ALL_EMPIRES
                if (!show_attacker && (attacker_empire == viewing_empire_id || attacker_empire == ALL_EMPIRES))
                    continue;

                auto count = std::to_string(index_and_event.second);
                const auto&& attacker_link = FighterOrPublicNameLink(
                    viewing_empire_id, INVALID_OBJECT_ID, attacker_empire);
                const auto&& target_link = FighterOrPublicNameLink(
                    viewing_empire_id, INVALID_OBJECT_ID, target_empire);
                const std::string& template_str = UserString("ENC_COMBAT_ATTACK_REPEATED_STR");

                ss << str(FlexibleFormat(template_str) % count % attacker_link % target_link);
                if (--num_events_remaining > 0)
                    ss << "\n";
            }
        };

    // Sort the events by viewing empire, then ALL_EMPIRES and then other empires.
    show_events_for_empire(viewing_empire_id);
    show_events_for_empire(ALL_EMPIRES);
    show_events_for_empire(boost::none);

    return ss.str();
}
示例#10
0
std::string FighterAttackedEvent::CombatLogDescription(int viewing_empire_id) const {
    std::string attacked_by = FighterOrPublicNameLink(viewing_empire_id, attacked_by_object_id, attacker_owner_empire_id);
    std::string empire_coloured_attacked_fighter = EmpireColorWrappedText(attacked_owner_id, UserString("OBJ_FIGHTER"));

    const std::string& template_str = UserString("ENC_COMBAT_ATTACK_SIMPLE_STR");

    return str(FlexibleFormat(template_str)
                                % attacked_by
                                % empire_coloured_attacked_fighter);
}
示例#11
0
std::string FightersDestroyedEvent::CombatLogDescription(int viewing_empire_id) const {
    if (events.empty())
        return "";

    const auto& events_to_show = events;
    auto num_events_remaining = events.size();
    std::stringstream ss;

    // Use show_events_for_empire to show events in this order: viewing empire,
    // ALL_EMPIRES and then the remainder.
    auto show_events_for_empire =
        [&ss, &num_events_remaining, &events_to_show, &viewing_empire_id]
        (boost::optional<int> show_empire_id) {
            int count;
            int target_empire_id;
            for (const auto& index_and_event : events_to_show) {
                std::tie(target_empire_id, count) = index_and_event;

                // Skip if this is not the particular attacker requested
                if (show_empire_id && *show_empire_id != target_empire_id)
                    continue;

                // Skip if no particular empire was requested and this empire is the viewing
                // empire or ALL_EMPIRES
                if (!show_empire_id && (target_empire_id == viewing_empire_id || target_empire_id == ALL_EMPIRES))
                    continue;

                auto count_str = std::to_string(index_and_event.second);
                auto target_empire_link = EmpireLink(target_empire_id);
                const auto&& target_link = FighterOrPublicNameLink(
                    viewing_empire_id, INVALID_OBJECT_ID, target_empire_id);

                if (count == 1) {
                    const std::string& template_str = UserString("ENC_COMBAT_FIGHTER_INCAPACITATED_STR");
                    ss << str(FlexibleFormat(template_str) % target_empire_link % target_link);
                }else {
                    const std::string& template_str = UserString("ENC_COMBAT_FIGHTER_INCAPACITATED_REPEATED_STR");
                    ss << str(FlexibleFormat(template_str) % count_str % target_empire_link % target_link);
                }
                if (--num_events_remaining > 0)
                    ss << "\n";
            }
        };

    // Sort the events by viewing empire, then ALL_EMPIRES and then other empires.
    show_events_for_empire(viewing_empire_id);
    show_events_for_empire(ALL_EMPIRES);
    show_events_for_empire(boost::none);

    return ss.str();
}
示例#12
0
std::string StealthChangeEvent::CombatLogDescription(int viewing_empire_id) const {
    if (events.empty())
        return "";

    std::string desc = "";
    for (const std::map<int, std::vector<StealthChangeEventDetailPtr>>::value_type& target : events) {
        std::vector<std::string> uncloaked_attackers;
        for (const StealthChangeEventDetailPtr event : target.second) {
            uncloaked_attackers.push_back(FighterOrPublicNameLink(viewing_empire_id, event->attacker_id, event->attacker_empire_id));
        }

        if (!uncloaked_attackers.empty()) {
            if (!desc.empty())
                desc += "\n";
            std::vector<std::string> target_empire_link(1, EmpireLink(target.first));

            desc += FlexibleFormatList(target_empire_link, uncloaked_attackers
                                       , UserString("ENC_COMBAT_STEALTH_DECLOAK_ATTACK_MANY_EVENTS")
                                       , UserString("ENC_COMBAT_STEALTH_DECLOAK_ATTACK_1_EVENTS")).str();
        }
    }

    return desc;
}