From b3afde5cac8cbbbfe44c72a504a16b5056d6ff2c Mon Sep 17 00:00:00 2001 From: Dan Hemberger Date: Sat, 9 Sep 2017 00:40:09 -0700 Subject: [PATCH 1/3] SectorPlayers.inc: refactor CSS class logic Move the logic deciding what relational CSS class a player is to a free function to avoid code duplication. No functionality changes. --- .../engine/Default/includes/SectorPlayers.inc | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/templates/Default/engine/Default/includes/SectorPlayers.inc b/templates/Default/engine/Default/includes/SectorPlayers.inc index 6f3ca72b1..48bab401a 100644 --- a/templates/Default/engine/Default/includes/SectorPlayers.inc +++ b/templates/Default/engine/Default/includes/SectorPlayers.inc @@ -1,3 +1,18 @@ +traderNAPAlliance($other)) { + if ($other->canFight()) { + return "enemy"; + } else { + return "neutral"; + } + } else { + return "friendly"; + } +} +?> +
hasOtherTraders($ThisPlayer)) { $Players =& $PlayersContainer->getOtherTraders($ThisPlayer); @@ -58,29 +73,13 @@ if($PlayersContainer instanceof SmrPlanet) { if($ThisPlanet->getOwnerID() == $ThisPlayer->getAccountID()) { ?> Kick Examine
@@ -94,4 +93,4 @@ ?>WARNING: Sensors have detected the presence of cloaked vessels in this sector -
\ No newline at end of file +
From 26ab75611399b3a3f0f76a5fdadc3fd2678d896e Mon Sep 17 00:00:00 2001 From: Dan Hemberger Date: Sat, 9 Sep 2017 00:44:08 -0700 Subject: [PATCH 2/3] SectorPlayers.inc: change color of protected allies Currently, players are displayed in sector with the following colors: Enemies (newbie turns=NO): red Enemies (newbie turns=YES): yellow Allies (newbie turns=NO): green Allies (newbie turns=YES): green However, this often causes confusion when an ally is in newbie turns. It can make it difficult to count the number of allies who are able to fight or to determine if an ally has forgotten to leave newbie protection. We change the colors here to make it immediately visible if an ally is in newbie turns. Since you can already click "Examine" to inspect if the ally has newbie turns (it will say "Your target is under newbie protection!"), this change does not modify what information is available to players -- only how it is displayed. Display players with the following new colors: Enemies (newbie turns=NO): red Enemies (newbie turns=YES): yellow Allies (newbie turns=NO): green Allies (newbie turns=YES): yellow <-- changed --- .../Default/engine/Default/includes/SectorPlayers.inc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/templates/Default/engine/Default/includes/SectorPlayers.inc b/templates/Default/engine/Default/includes/SectorPlayers.inc index 48bab401a..0886263ee 100644 --- a/templates/Default/engine/Default/includes/SectorPlayers.inc +++ b/templates/Default/engine/Default/includes/SectorPlayers.inc @@ -1,14 +1,14 @@ traderNAPAlliance($other)) { - if ($other->canFight()) { - return "enemy"; + if ($other->canFight()) { + if ($player->traderNAPAlliance($other)) { + return "friendly"; } else { - return "neutral"; + return "enemy"; } } else { - return "friendly"; + return "neutral"; } } ?> From fad258c08ae061115602d5cd4fcd2a840e65703b Mon Sep 17 00:00:00 2001 From: Dan Hemberger Date: Mon, 2 Oct 2017 16:50:48 -0700 Subject: [PATCH 3/3] Move player relationship logic into SmrPlayer Change free function `getPlayerOptionClass` in SectorPlayer.inc into a method of class `SmrPlayer` called `getPlayerRelationship`. Also delete `SmrPlayer::{get,set}AttackColour` because these methods were never used and may be confused with `getPlayerRelationship`. --- lib/Default/SmrPlayer.class.inc | 21 ++++++++++--------- .../engine/Default/includes/SectorPlayers.inc | 19 ++--------------- 2 files changed, 13 insertions(+), 27 deletions(-) diff --git a/lib/Default/SmrPlayer.class.inc b/lib/Default/SmrPlayer.class.inc index f50467438..ac142d71b 100644 --- a/lib/Default/SmrPlayer.class.inc +++ b/lib/Default/SmrPlayer.class.inc @@ -465,16 +465,17 @@ class SmrPlayer extends AbstractSmrPlayer { $this->hasChanged=true; } - function getAttackColour() { - return $this->attackColour; - } - - function setAttackColour($colour) { - if($this->attackColour == $colour) - return; - $this->attackColour=$colour; - $this->hasChanged=true; -// $this->db->query('UPDATE player SET attack_warning = ' . $this->db->escapeString($this->attackColour) . ' WHERE ' . $this->SQL . ' LIMIT 1'); + function getPlayerRelationship(&$otherPlayer) { + // Returns the CSS class for the relationship between two players + if ($otherPlayer->canFight()) { + if ($this->traderNAPAlliance($otherPlayer)) { + return "friendly"; + } else { + return "enemy"; + } + } else { + return "neutral"; + } } function getBank() { diff --git a/templates/Default/engine/Default/includes/SectorPlayers.inc b/templates/Default/engine/Default/includes/SectorPlayers.inc index 0886263ee..68694b086 100644 --- a/templates/Default/engine/Default/includes/SectorPlayers.inc +++ b/templates/Default/engine/Default/includes/SectorPlayers.inc @@ -1,18 +1,3 @@ -canFight()) { - if ($player->traderNAPAlliance($other)) { - return "friendly"; - } else { - return "enemy"; - } - } else { - return "neutral"; - } -} -?> -
hasOtherTraders($ThisPlayer)) { $Players =& $PlayersContainer->getOtherTraders($ThisPlayer); @@ -73,13 +58,13 @@ function getPlayerOptionClass(&$player, &$other) { if($PlayersContainer instanceof SmrPlanet) { if($ThisPlanet->getOwnerID() == $ThisPlayer->getAccountID()) { ?> Kick Examine