Skip to content

Commit

Permalink
SmrPlanet: clean up Owner methods (#913)
Browse files Browse the repository at this point in the history
* Remove `isClaimed` (duplicate of `hasOwner`).
* Rename `removeClaimed` to `removeOwner` (since all other similar
  method names refer to the "owner").
  • Loading branch information
hemberger authored Nov 6, 2020
1 parent d7448c3 commit 34c4d98
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
4 changes: 2 additions & 2 deletions engine/Default/planet_attack_processing.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
if (!$planet->exists()) {
create_error('This planet does not exist.');
}
if (!$planet->isClaimed()) {
if (!$planet->hasOwner()) {
create_error('This planet is not claimed.');
}

Expand Down Expand Up @@ -75,7 +75,7 @@

if ($planet->isDestroyed()) {
$db->query('UPDATE player SET land_on_planet = \'FALSE\' WHERE sector_id = ' . $db->escapeNumber($planet->getSectorID()) . ' AND game_id = ' . $db->escapeNumber($player->getGameID()));
$planet->removeClaimed();
$planet->removeOwner();
$planet->removePassword();

// Prepare message for planet owners
Expand Down
14 changes: 5 additions & 9 deletions lib/Default/SmrPlanet.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ public function hasOwner() {
return $this->ownerID != 0;
}

public function removeOwner() {
$this->setOwnerID(0);
}

public function setOwnerID($claimerID) {
if ($this->ownerID == $claimerID) {
return;
Expand Down Expand Up @@ -1025,14 +1029,6 @@ public function getInhabitableTime() {
return $this->inhabitableTime;
}

public function isClaimed() {
return $this->ownerID > 0;
}

public function removeClaimed() {
$this->setOwnerID(0);
}

public function getExamineHREF() {
return SmrSession::getNewHREF(create_container('skeleton.php', 'planet_examine.php'));
}
Expand Down Expand Up @@ -1297,7 +1293,7 @@ public function &killPlanetByPlayer(AbstractSmrPlayer $killer) {

//kick everyone from planet
$this->db->query('UPDATE player SET land_on_planet = \'FALSE\' WHERE ' . $this->SQL);
$this->removeClaimed();
$this->removeOwner();
$this->removePassword();
return $return;
}
Expand Down
4 changes: 2 additions & 2 deletions templates/Default/engine/Default/planet_financial.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<p>&nbsp;</p> <?php

// Print bond properties if the planet is claimed
if (!$ThisPlanet->isClaimed()) {
if (!$ThisPlanet->hasOwner()) {
echo "This planet must be claimed before you can bond funds here.<br /><br />";
} else { ?>
You are able to transfer these credits into a planetary bond.<br />
Expand All @@ -34,7 +34,7 @@
</span><?php

// Allow the player to bond if the planet is claimed
if ($ThisPlanet->isClaimed()) { ?>
if ($ThisPlanet->hasOwner()) { ?>
<div class="buttonA">
<a id="bondFunds" class="buttonA" href="<?php echo $ThisPlanet->getBondConfirmationHREF(); ?>">Bond Funds</a>
</div>&nbsp; <?php
Expand Down

0 comments on commit 34c4d98

Please sign in to comment.