This commit is contained in:
aozhiwei 2024-04-01 11:07:45 +08:00
parent 4148a80d83
commit cb4307018f

View File

@ -10,7 +10,7 @@
static void IncIntMap(std::map<int, int>& int_map, int key)
{
auto itr = int_map.find(key);
if (itr == int_map.end()) {
if (itr != int_map.end()) {
++itr->second;
} else {
int_map[key] = 1;
@ -20,7 +20,7 @@ static void IncIntMap(std::map<int, int>& int_map, int key)
static void DecIntMap(std::map<int, int>& int_map, int key)
{
auto itr = int_map.find(key);
if (itr == int_map.end()) {
if (itr != int_map.end()) {
--itr->second;
if (itr->second < 0) {
itr->second = 0;
@ -28,6 +28,16 @@ static void DecIntMap(std::map<int, int>& int_map, int key)
}
}
static int GetIntMap(std::map<int, int>& int_map, int key)
{
auto itr = int_map.find(key);
if (itr != int_map.end()) {
return itr->second;
} else {
return 0;
}
}
InGameVoice::InGameVoice(Room* room)
{
room_ = room;
@ -285,16 +295,106 @@ void InGameVoice::TriggerEvent(Human* killer, Human* deader)
{
bool is_first_boold = global_kills_ == 1;
{
int val = global_kills_;
mt::InGameVoice::Traverse
(
room_->IsMobaModeRoom(),
InGameVoiceEventType_e::kGlobalKills,
[this, killer, deader] (const mt::InGameVoice* meta) -> bool
[this, killer, deader, val] (const mt::InGameVoice* meta) -> bool
{
if (meta->MatchCond(global_kills_)) {
if (meta->MatchCond(val)) {
Notify(killer, deader, meta);
}
return true;
});
}
{
if (!is_first_boold) {
int val = GetIntMap(personal_kills_, killer->GetUniId());
mt::InGameVoice::Traverse
(
room_->IsMobaModeRoom(),
InGameVoiceEventType_e::kPersonalExceptFirstBooldKills,
[this, killer, deader, val] (const mt::InGameVoice* meta) -> bool
{
if (meta->MatchCond(val)) {
Notify(killer, deader, meta);
}
return true;
});
}
}
{
if (!is_first_boold) {
mt::InGameVoice::Traverse
(
room_->IsMobaModeRoom(),
InGameVoiceEventType_e::kMyTeamateBeKill,
[this, killer, deader] (const mt::InGameVoice* meta) -> bool
{
Notify(killer, deader, meta);
return true;
});
}
}
{
if (!is_first_boold) {
mt::InGameVoice::Traverse
(
room_->IsMobaModeRoom(),
InGameVoiceEventType_e::kEnemyTeamBekill,
[this, killer, deader] (const mt::InGameVoice* meta) -> bool
{
Notify(killer, deader, meta);
return true;
});
}
}
{
if (!is_first_boold) {
if (deader->GetTeam()->AllIsDead()) {
mt::InGameVoice::Traverse
(
room_->IsMobaModeRoom(),
InGameVoiceEventType_e::kTeamAllDead,
[this, killer, deader] (const mt::InGameVoice* meta) -> bool
{
Notify(killer, deader, meta);
return true;
});
}
}
}
{
if (!is_first_boold) {
int val = GetIntMap(personal_series_kills_, killer->GetUniId());
mt::InGameVoice::Traverse
(
room_->IsMobaModeRoom(),
InGameVoiceEventType_e::kSeriesKills,
[this, killer, deader, val] (const mt::InGameVoice* meta) -> bool
{
if (meta->MatchCond(val)) {
Notify(killer, deader, meta);
}
return true;
});
}
}
{
if (!is_first_boold) {
int val = GetIntMap(personal_nodead_series_kills_, killer->GetUniId());
mt::InGameVoice::Traverse
(
room_->IsMobaModeRoom(),
InGameVoiceEventType_e::kNoDeadSeriesKills,
[this, killer, deader, val] (const mt::InGameVoice* meta) -> bool
{
if (meta->MatchCond(val)) {
Notify(killer, deader, meta);
}
return true;
});
}
}
}