| 40 | } |
| 41 | |
| 42 | bool EntityDamageTeam::canDamage(EntityDamageTeam victim, bool victimIsSelf) const { |
| 43 | if (victimIsSelf) { |
| 44 | if (type == TeamType::Indiscriminate) |
| 45 | return true; |
| 46 | } else if (type == TeamType::Friendly) { |
| 47 | if (victim.type == TeamType::Enemy || victim.type == TeamType::Passive || victim.type == TeamType::Environment || victim.type == TeamType::Indiscriminate) |
| 48 | return true; |
| 49 | } else if (type == TeamType::Enemy) { |
| 50 | if (victim.type == TeamType::Friendly || victim.type == TeamType::PVP || victim.type == TeamType::Indiscriminate) |
| 51 | return true; |
| 52 | else if (victim.type == TeamType::Enemy && team != victim.team) |
| 53 | return true; |
| 54 | } else if (type == TeamType::PVP) { |
| 55 | if (victim.type == TeamType::Enemy || victim.type == TeamType::Passive || victim.type == TeamType::Environment || victim.type == TeamType::Indiscriminate) |
| 56 | return true; |
| 57 | else if (victim.type == TeamType::PVP && (team == 0 || team != victim.team)) |
| 58 | return true; |
| 59 | } else if (type == TeamType::Passive) { |
| 60 | // never deal damage |
| 61 | } else if (type == TeamType::Ghostly) { |
| 62 | // never deal damage |
| 63 | } else if (type == TeamType::Environment) { |
| 64 | if (victim.type == TeamType::Friendly || victim.type == TeamType::PVP || victim.type == TeamType::Indiscriminate) |
| 65 | return true; |
| 66 | } else if (type == TeamType::Indiscriminate) { |
| 67 | if (victim.type == TeamType::Friendly || victim.type == TeamType::Enemy || victim.type == TeamType::PVP |
| 68 | || victim.type == TeamType::Passive |
| 69 | || victim.type == TeamType::Environment |
| 70 | || victim.type == TeamType::Indiscriminate) |
| 71 | return true; |
| 72 | } else if (type == TeamType::Assistant) { |
| 73 | if (victim.type == TeamType::Enemy || victim.type == TeamType::Passive || victim.type == TeamType::Environment || victim.type == TeamType::Indiscriminate) |
| 74 | return true; |
| 75 | } |
| 76 | |
| 77 | return false; |
| 78 | } |
| 79 | |
| 80 | bool EntityDamageTeam::operator==(EntityDamageTeam const& rhs) const { |
| 81 | return tie(type, team) == tie(rhs.type, rhs.team); |
no outgoing calls
no test coverage detected