diff --git a/includes/ajaxHandler/profile.class.php b/includes/ajaxHandler/profile.class.php index d08d86d0..c636a046 100644 --- a/includes/ajaxHandler/profile.class.php +++ b/includes/ajaxHandler/profile.class.php @@ -510,7 +510,7 @@ class AjaxProfile extends AjaxHandler 'level' => $pBase['level'], 'classs' => $pBase['class'], 'race' => $pBase['race'], - 'faction' => ChrRace::tryFrom($pBase['race'])?->getSide() ?? SIDE_NONE, + 'faction' => ChrRace::tryFrom($pBase['race'])?->getTeam() ?? TEAM_NEUTRAL, 'gender' => $pBase['gender'], 'skincolor' => $pBase['skincolor'], 'hairstyle' => $pBase['hairstyle'], diff --git a/includes/defines.php b/includes/defines.php index ff8e16fd..6738ab2a 100644 --- a/includes/defines.php +++ b/includes/defines.php @@ -487,6 +487,18 @@ enum ChrRace : int return SIDE_NONE; } + public function getTeam() : int + { + if ($this->isHorde() && $this->isAlliance()) + return TEAM_NEUTRAL; + else if ($this->isHorde()) + return TEAM_HORDE; + else if ($this->isAlliance()) + return TEAM_ALLIANCE; + else + return TEAM_NEUTRAL; + } + public function json() : string { return match ($this) @@ -530,6 +542,23 @@ enum ChrRace : int return SIDE_BOTH; } + + public static function teamFromMask(int $raceMask) : int + { + // Any + if (!$raceMask || ($raceMask & self::MASK_ALL) == self::MASK_ALL) + return TEAM_NEUTRAL; + + // Horde + if ($raceMask & self::MASK_HORDE && !($raceMask & self::MASK_ALLIANCE)) + return TEAM_HORDE; + + // Alliance + if ($raceMask & self::MASK_ALLIANCE && !($raceMask & self::MASK_HORDE)) + return TEAM_ALLIANCE; + + return TEAM_NEUTRAL; + } } // SpellFamilyNames