|
|
|
@ -76,6 +76,63 @@ class Tracker { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function add($gameName, $tagLine, &$message): bool { |
|
|
|
|
$request = new RiotRequest("riot/account/v1/accounts/by-riot-id/$gameName/$tagLine"); |
|
|
|
|
$request->useRouting(); |
|
|
|
|
$result = $request->run(); |
|
|
|
|
|
|
|
|
|
if ($request->responseCode === 200){ |
|
|
|
|
if (!key_exists($result->puuid, $this->accounts)){ |
|
|
|
|
$account = new Account(); |
|
|
|
|
$account->puuid = $result->puuid; |
|
|
|
|
$account->gameName = $result->gameName; |
|
|
|
|
$account->tagLine = $result->tagLine; |
|
|
|
|
$this->accounts[$account->puuid] = $account; |
|
|
|
|
|
|
|
|
|
$this->conn->prepare(" |
|
|
|
|
INSERT INTO `accounts` |
|
|
|
|
(`puuid`, `gameName`, `tagLine`) |
|
|
|
|
VALUES (?, ?, ?) |
|
|
|
|
")->execute([$account->puuid, $account->gameName, $account->tagLine]); |
|
|
|
|
|
|
|
|
|
$message = "Success."; |
|
|
|
|
return true; |
|
|
|
|
} else { |
|
|
|
|
$message = "Riot ID already added."; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
$message = "Riot ID not found."; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
public function remove($gameName, $tagLine, &$message): bool { |
|
|
|
|
$request = new RiotRequest("riot/account/v1/accounts/by-riot-id/$gameName/$tagLine"); |
|
|
|
|
$request->useRouting(); |
|
|
|
|
$result = $request->run(); |
|
|
|
|
|
|
|
|
|
if ($request->responseCode === 200){ |
|
|
|
|
if (key_exists($result->puuid, $this->accounts)){ |
|
|
|
|
unset($this->accounts[$result->puuid]); |
|
|
|
|
unset($this->entries[$result->puuid]); |
|
|
|
|
|
|
|
|
|
$this->conn->query(" |
|
|
|
|
DELETE FROM `accounts` |
|
|
|
|
WHERE puuid = '$result->puuid'; |
|
|
|
|
"); |
|
|
|
|
|
|
|
|
|
$message = "Success."; |
|
|
|
|
return true; |
|
|
|
|
} else { |
|
|
|
|
$message = "Riot ID was not added."; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
$message = "Riot ID not found."; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class Account { |
|
|
|
@ -87,8 +144,8 @@ class Account { |
|
|
|
|
* @param Elo[] $eloEntries |
|
|
|
|
*/ |
|
|
|
|
public function addNewEloEntry(array &$eloEntries): void { |
|
|
|
|
$summonerId = (new RiotRequest("lol/summoner/v4/summoners/by-puuid/$this->puuid"))->run()->id; |
|
|
|
|
$fetchedLeagues = (new RiotRequest("lol/league/v4/entries/by-summoner/$summonerId"))->run(); |
|
|
|
|
$summonerId = (new RiotRequest("lol/summoner/v4/summoners/by-puuid/$this->puuid"))->run($isEUNE)->id; |
|
|
|
|
$fetchedLeagues = (new RiotRequest("lol/league/v4/entries/by-summoner/$summonerId", $isEUNE))->run(); |
|
|
|
|
|
|
|
|
|
$currentElo = end($eloEntries); |
|
|
|
|
|
|
|
|
|