tactics = $tactics; } public function makeNew(string $name, int $ownerId): TacticInfo { return $this->tactics->insert($name, $ownerId); } public function makeNewDefault(int $ownerId): ?TacticInfo { return $this->tactics->insert(self::TACTIC_DEFAULT_NAME, $ownerId); } /** * Tries to retrieve information about a tactic * @param int $id tactic identifier * @return TacticInfo|null or null if the identifier did not match a tactic */ public function get(int $id): ?TacticInfo { return $this->tactics->get($id); } /** * Update the name of a tactic * @param int $id the tactic identifier * @param string $name the new name to set * @return ValidationFail[] failures, if any */ public function updateName(int $id, string $name, int $authId): array { $tactic = $this->tactics->get($id); if ($tactic == null) { return [ValidationFail::notFound("Could not find tactic")]; } if ($tactic->getOwnerId() != $authId) { return [ValidationFail::unauthorized()]; } $this->tactics->updateName($id, $name); return []; } }