"beta5/player" )); } public function run($player, $allyName) { // Check if the player ID is not null if (is_null($player)) { return self::playerNotFound; } $player = (int) $player; // Check if the player is valid $playerRecord = $this->players->call('get', $player); if (is_null($playerRecord)) { return self::playerNotFound; } // Check if the player is on vacation if ($this->players->call('isOnVacation', $player)) { return self::playerOnVacation; } // Check the ally's name $allyName = preg_replace('/\s+/', ' ', trim($allyName)); if ($allyName == "") { return self::noAllyName; } elseif (strlen($allyName) > 15) { return self::invalidAllyName; } // Check the ally's record $ally = $this->players->call('getPlayerId', $allyName); if (is_null($ally)) { return self::allyNotFound; } elseif ($ally == $player) { return self::allyIsPlayer; } // Check the enemy list if ($this->players->call('isEnemy', $player, $ally)) { return self::allyIsEnemy; } // Check the blacklist if ($this->players->call('checkTAListBan', $ally, $player)) { return self::playerBlacklisted; } // Check the player's current TA list $taList = $this->players->call('getAllies', $player); if (count($taList) == 5) { return self::maxPlayerTrust; } foreach ($taList as $id => $data) { if ($data['id'] == $ally) { return self::allyAlreadyListed; } } // Check the reverse TA list $taList = $this->players->call('isAllyOf', $ally); if (count($taList) == 5) { return self::maxAllyTrust; } // Add to the player's list $this->players->call('addAlly', $player, $ally); // Return all trusted allies data return $this->game->action('getTrustedAllies', $player); } } ?>