Code Duplication    Length = 53-53 lines in 2 locations

includes/classes/Fleet.php 2 locations

@@ 1336-1388 (lines=53) @@
1333
  /** @throws Exception */
1334
  protected function restrictFriendOrFoe() {
1335
    // Checking target owner
1336
    if($this->dbTargetRow['id'] == $this->getPlayerOwnerId()) {
1337
      // Spying can't be done on owner's planet/moon
1338
      unset($this->allowed_missions[MT_SPY]);
1339
      // Attack can't be done on owner's planet/moon
1340
      unset($this->allowed_missions[MT_ATTACK]);
1341
      // ACS can't be done on owner's planet/moon
1342
      unset($this->allowed_missions[MT_ACS]);
1343
      // Destroy can't be done on owner's moon
1344
      unset($this->allowed_missions[MT_DESTROY]);
1345
1346
      $this->restrictToNoMissiles();
1347
1348
      // MT_RELOCATE
1349
      // No checks
1350
      // TODO - check captain
1351
1352
      // MT_HOLD
1353
      // TODO - Check for Allies Deposit for HOLD
1354
1355
      // MT_TRANSPORT
1356
1357
    } else {
1358
      // Relocate can be done only on owner's planet/moon
1359
      unset($this->allowed_missions[MT_RELOCATE]);
1360
1361
      // TODO - check for moratorium
1362
1363
      // MT_HOLD
1364
      // TODO - Check for Allies Deposit for HOLD
1365
      // TODO - Noob protection for HOLD depends on server settings
1366
1367
      // MT_SPY
1368
      $this->restrictToNotOnlySpiesOrMissionSpy();
1369
1370
      // TODO - check noob protection
1371
1372
      // TODO - check bashing
1373
1374
      // No missions except MT_MISSILE should have any missiles in fleet
1375
      $this->restrictMissionMissile();
1376
      $this->restrictToNoMissiles();
1377
      // Beyond this point no mission can have a missile in fleet
1378
1379
      // MT_DESTROY
1380
      $this->restrictMissionDestroy();
1381
1382
      // MT_ACS
1383
      $this->restrictMissionACS();
1384
1385
      // MT_ATTACK - no checks
1386
1387
      // MT_TRANSPORT - no checks
1388
    }
1389
  }
1390
1391
  protected function restrictToNotSource() {
@@ 1967-2019 (lines=53) @@
1964
      $this->restrictTargetExistsOrMissionColonize();
1965
      $this->restrictNotDebrisOrMissionRecycle();
1966
      // TODO - START $this->restrictFriendOrFoe();
1967
      if($this->dbTargetRow['id'] == $this->getPlayerOwnerId()) {
1968
        // Spying can't be done on owner's planet/moon
1969
        unset($this->allowed_missions[MT_SPY]);
1970
        // Attack can't be done on owner's planet/moon
1971
        unset($this->allowed_missions[MT_ATTACK]);
1972
        // ACS can't be done on owner's planet/moon
1973
        unset($this->allowed_missions[MT_ACS]);
1974
        // Destroy can't be done on owner's moon
1975
        unset($this->allowed_missions[MT_DESTROY]);
1976
1977
        $this->restrictToNoMissiles();
1978
1979
        // MT_RELOCATE
1980
        // No checks
1981
        // TODO - check captain
1982
1983
        // MT_HOLD
1984
        // TODO - Check for Allies Deposit for HOLD
1985
1986
        // MT_TRANSPORT
1987
1988
      } else {
1989
        // Relocate can be done only on owner's planet/moon
1990
        unset($this->allowed_missions[MT_RELOCATE]);
1991
1992
        // TODO - check for moratorium
1993
1994
        // MT_HOLD
1995
        // TODO - Check for Allies Deposit for HOLD
1996
        // TODO - Noob protection for HOLD depends on server settings
1997
1998
        // MT_SPY
1999
        $this->restrictToNotOnlySpiesOrMissionSpy();
2000
2001
        // TODO - check noob protection
2002
2003
        // TODO - check bashing
2004
2005
        // No missions except MT_MISSILE should have any missiles in fleet
2006
        $this->restrictMissionMissile();
2007
        $this->restrictToNoMissiles();
2008
        // Beyond this point no mission can have a missile in fleet
2009
2010
        // MT_DESTROY
2011
        $this->restrictMissionDestroy();
2012
2013
        // MT_ACS
2014
        $this->restrictMissionACS();
2015
2016
        // MT_ATTACK - no checks
2017
2018
        // MT_TRANSPORT - no checks
2019
      }
2020
      // TODO - END $this->restrictFriendOrFoe();
2021
2022