Dedimania some more improvements

This commit is contained in:
kremsy 2017-05-22 16:31:09 +02:00
parent a0753ea451
commit e7df439276
2 changed files with 14 additions and 5 deletions

View File

@ -55,6 +55,10 @@ class DedimaniaData {
$this->serverBuild = $serverVersion->build; $this->serverBuild = $serverVersion->build;
} }
public function sessionIdSet(){
return $this->sessionId != '';
}
/** /**
* Sort the Records * Sort the Records
*/ */

View File

@ -93,7 +93,7 @@ class DedimaniaWebHandler implements TimerListener {
* @return bool * @return bool
*/ */
public function fetchDedimaniaRecords($reset = true) { public function fetchDedimaniaRecords($reset = true) {
if (!isset($this->dedimaniaData) || !$this->dedimaniaData->sessionId) { if (!isset($this->dedimaniaData) || !$this->dedimaniaData->sessionIdSet()) {
return false; return false;
} }
@ -169,7 +169,7 @@ class DedimaniaWebHandler implements TimerListener {
* Checks If a Dedimania Session exists, if not create a new oen * Checks If a Dedimania Session exists, if not create a new oen
*/ */
public function checkDedimaniaSession() { //TODO complete check and refactor public function checkDedimaniaSession() { //TODO complete check and refactor
if (!$this->dedimaniaData->sessionId) { if (!$this->dedimaniaData->sessionIdSet()) {
$this->openDedimaniaSession(); $this->openDedimaniaSession();
return; return;
} }
@ -215,6 +215,10 @@ class DedimaniaWebHandler implements TimerListener {
* Handle EndMap Callback * Handle EndMap Callback
*/ */
public function submitChallengeTimes() { public function submitChallengeTimes() {
if (!$this->dedimaniaData->sessionIdSet()) {
return;
}
if (!$this->getDedimaniaData()->recordsExisting()) { if (!$this->getDedimaniaData()->recordsExisting()) {
return; return;
} }
@ -307,7 +311,7 @@ class DedimaniaWebHandler implements TimerListener {
* @param Player $player * @param Player $player
*/ */
public function handlePlayerConnect(Player $player) { public function handlePlayerConnect(Player $player) {
if (!isset($this->dedimaniaData)) { if (!isset($this->dedimaniaData) || !$this->dedimaniaData->sessionIdSet()) {
return; return;
} }
@ -359,9 +363,10 @@ class DedimaniaWebHandler implements TimerListener {
* @param Player $player * @param Player $player
*/ */
public function handlePlayerDisconnect(Player $player) { //TODO move into webhandler public function handlePlayerDisconnect(Player $player) { //TODO move into webhandler
if (!isset($this->dedimaniaData)) { if (!isset($this->dedimaniaData) || !$this->dedimaniaData->sessionIdSet()) {
return; return;
} }
$this->dedimaniaData->removePlayer($player->login); $this->dedimaniaData->removePlayer($player->login);
// Send Dedimania request // Send Dedimania request
@ -402,7 +407,7 @@ class DedimaniaWebHandler implements TimerListener {
$serverInfo = $this->getServerInfo(); $serverInfo = $this->getServerInfo();
$playerList = $this->getPlayerList(); $playerList = $this->getPlayerList();
$votesInfo = $this->getVotesInfo(); $votesInfo = $this->getVotesInfo();
if (!$serverInfo || !$votesInfo || !$playerList || !isset($this->dedimaniaData) || !$this->dedimaniaData->sessionId) { if (!$serverInfo || !$votesInfo || !$playerList || !isset($this->dedimaniaData) || !$this->dedimaniaData->sessionIdSet()) {
return; return;
} }