Completed
Push — work-fleets ( a1ac53...2c97e5 )
by SuperNova.WS
05:44
created

FleetValidator::disableMissionDestroy()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
/**
4
 * Class FleetValidator
5
 */
6
class FleetValidator {
7
  /**
8
   * @var Fleet $fleet
9
   */
10
  protected $fleet;
11
12
  /**
13
   * FleetValidator constructor.
14
   *
15
   * @param Fleet $fleet
16
   */
17
  public function __construct($fleet) {
18
    $this->fleet = $fleet;
19
  }
20
21
  /**
22
   *
23
   */
24
  public function validate() {
25
    $checklist = sn_get_groups('mission_checks');
26
    try {
27
      // TODO - Do the restrictMission checks
28
29
      // TODO - Кое-какие проверки дают FLIGHT_ALLOWED - ЧТО НЕПРАВДА В ДАННОМ СЛУЧАЕ!!!
30
      // На странице 1 некоторые проверки ДОЛЖНЫ БЫТЬ опущены - иначе будет некрасиво
31
      // А вот здесь надо проверять много дополнительной хуйни
32
      $this->checkMissionRestrictions($checklist);
33
34
      // 2nd level restrictions
35
      // Still cheap
36
      $this->restrict2ToAllowedMissions();
37
      $this->restrict2ToAllowedPlanetTypes();
38
    } catch (Exception $e) {
39
      if ($e->getCode() != FLIGHT_ALLOWED) {
40
        pdie(classLocale::$lang['fl_attack_error'][$e->getCode()]);
41
      } else {
42
        pdump('FLIGHT_ALLOWED', FLIGHT_ALLOWED);
43
      }
44
    }
45
  }
46
47
  /**
48
   * @param array $checklist
49
   *
50
   * @throws Exception
51
   */
52
  public function checkMissionRestrictions($checklist) {
53
    foreach ($checklist as $condition => $action) {
54
      $checkResult = call_user_func(array($this, $condition));
55
56
      if (is_array($action) && !empty($action[$checkResult])) {
57
        $action = $action[$checkResult];
58
      }
59
60
      if (is_array($action)) {
61
        $this->checkMissionRestrictions($action);
62
      } elseif (!$checkResult) {
63
        throw new Exception($action, $action);
64
      }
65
    }
66
  }
67
68
69
  /**
70
   * @throws Exception
71
   */
72
  protected function restrict2ToAllowedMissions() {
73
    if (empty($this->fleet->allowed_missions[$this->fleet->mission_type])) {
74
      throw new Exception('FLIGHT_MISSION_IMPOSSIBLE', FLIGHT_MISSION_IMPOSSIBLE);
75
    }
76
  }
77
78
  /**
79
   * @throws Exception
80
   */
81
  protected function restrict2ToAllowedPlanetTypes() {
82
    if (empty($this->fleet->allowed_planet_types[$this->fleet->targetVector->type])) {
83
      throw new Exception('FLIGHT_MISSION_IMPOSSIBLE', FLIGHT_MISSION_IMPOSSIBLE);
84
    }
85
  }
86
87
88
  /**
89
   * @return bool
90
   */
91
  protected function checkSpeedPercentOld() {
92
    return in_array($this->fleet->oldSpeedInTens, array(10, 9, 8, 7, 6, 5, 4, 3, 2, 1));
93
  }
94
95
  /**
96
   * @return bool
97
   */
98
  protected function checkSenderNoVacation() {
99
    return empty($this->fleet->dbOwnerRow['vacation']) || $this->fleet->dbOwnerRow['vacation'] >= SN_TIME_NOW;
100
  }
101
102
  /**
103
   * @return bool
104
   */
105
  protected function checkTargetNoVacation() {
106
    return empty($this->fleet->dbTargetOwnerRow['vacation']) || $this->fleet->dbTargetOwnerRow['vacation'] >= SN_TIME_NOW;
107
  }
108
109
  /**
110
   * @return bool
111
   */
112
  protected function checkMultiAccount() {
113
    return sys_is_multiaccount($this->fleet->dbOwnerRow, $this->fleet->dbTargetOwnerRow);
114
  }
115
116
  /**
117
   * @return bool
118
   */
119
  protected function checkTargetNotSource() {
120
    return !$this->fleet->targetVector->isEqualToPlanet($this->fleet->dbSourcePlanetRow);
121
  }
122
123
  /**
124
   * @return bool
125
   */
126
  protected function checkTargetInUniverse() {
127
    return $this->fleet->targetVector->isInUniverse();
128
  }
129
130
  /**
131
   * @return bool
132
   */
133
  protected function checkUnitsPositive() {
134
    return $this->fleet->shipsAllPositive();
135
  }
136
137
  /**
138
   * @return bool
139
   */
140
  protected function checkOnlyFleetUnits() {
141
    return $this->fleet->shipsAllFlying();
142
  }
143
144
  /**
145
   * @return bool
146
   */
147
  protected function checkOnlyFlyingUnits() {
148
    return $this->fleet->shipsAllMovable();
149
  }
150
151
  /**
152
   * @return bool
153
   */
154
  protected function checkEnoughFleetSlots() {
155
    return FleetList::fleet_count_flying($this->fleet->getPlayerOwnerId()) < GetMaxFleets($this->fleet->dbOwnerRow);
156
  }
157
158
159
  /**
160
   * @return bool
161
   */
162
  protected function checkEnoughCapacity($includeResources = true) {
163
    $checkVia = $this->fleet->travelData['consumption'];
164
    $checkVia = ceil(($includeResources ? array_sum($this->fleet->resource_list) : 0) + $checkVia);
165
166
    return
167
      !empty($this->fleet->travelData) &&
168
      is_array($this->fleet->travelData) &&
169
      floor($this->fleet->travelData['capacity']) >= $checkVia;
170
  }
171
172
  /**
173
   * @return bool
174
   */
175
  protected function checkNotTooFar() {
176
    return $this->checkEnoughCapacity(false);
177
  }
178
179
  /**
180
   * @return bool
181
   */
182
  protected function checkDebrisExists() {
183
    return is_array($this->fleet->dbTargetRow) && ($this->fleet->dbTargetRow['debris_metal'] + $this->fleet->dbTargetRow['debris_crystal'] > 0);
184
  }
185
186
187
188
189
190
191
192
193
194
195
196
197
  // Resources checks
198
199
  /**
200
   * @return bool
201
   */
202
  protected function checkResourcesPositive() {
203
    foreach ($this->fleet->resource_list as $resourceId => $resourceAmount) {
204
      if ($resourceAmount < 0) {
205
        return false;
206
      }
207
    }
208
209
    return true;
210
  }
211
212
  /**
213
   * @return bool
214
   */
215
  protected function checkCargo() {
216
    return array_sum($this->fleet->resource_list) >= 1;
217
  }
218
219
  /**
220
   * @return bool
221
   */
222
  protected function checkSourceEnoughFuel() {
223
    $deuteriumOnPlanet = mrc_get_level($this->fleet->dbOwnerRow, $this->fleet->dbSourcePlanetRow, RES_DEUTERIUM);
224
225
    return $deuteriumOnPlanet < ceil($this->fleet->travelData['consumption']);
226
  }
227
228
  /**
229
   * @return bool
230
   */
231
  protected function checkSourceEnoughResources() {
232
    $fleetResources = $this->fleet->resource_list;
233
    $fleetResources[RES_DEUTERIUM] = ceil($fleetResources[RES_DEUTERIUM] + $this->fleet->travelData['consumption']);
234
    foreach ($fleetResources as $resourceId => $resourceAmount) {
235
      if (mrc_get_level($this->fleet->dbOwnerRow, $this->fleet->dbSourcePlanetRow, $resourceId) < ceil($fleetResources[$resourceId])) {
236
        return false;
237
      }
238
    }
239
240
    return true;
241
  }
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
  // Target vector checks (????????)
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
268
269
  /**
270
   * @return bool
271
   */
272
  protected function checkKnownSpace() {
273
    return $this->fleet->targetVector->isInKnownSpace();
274
  }
275
276
  /**
277
   * @return bool
278
   */
279
  protected function checkTargetExists() {
280
    return !empty($this->fleet->dbTargetRow['id']);
281
  }
282
283
  /**
284
   * @return bool
285
   */
286
  protected function checkTargetIsPlanet() {
287
    return $this->fleet->targetVector->type == PT_PLANET;
288
  }
289
290
  /**
291
   * @return bool
292
   */
293
  protected function checkTargetIsDebris() {
294
    return $this->fleet->targetVector->type == PT_DEBRIS;
295
  }
296
297
  /**
298
   * @return bool
299
   */
300
  protected function checkTargetIsMoon() {
301
    return $this->fleet->targetVector->type == PT_MOON;
302
  }
303
304
305
306
307
308
309
  // Ships checks
310
311
  /**
312
   * @return bool
313
   */
314
  protected function checkFleetNotEmpty() {
315
    return $this->fleet->shipsGetTotal() >= 1;
316
  }
317
318
319
  /**
320
   * @return bool
321
   */
322
  protected function checkSourceEnoughShips() {
323
    return $this->fleet->shipsIsEnoughOnPlanet();
324
  }
325
326
327
  /**
328
   * @return bool
329
   */
330
  protected function checkHaveColonizer() {
331
    // Colonization fleet should have at least one colonizer
332
    return $this->fleet->shipsGetTotalById(SHIP_COLONIZER) >= 1;
333
  }
334
335
  /**
336
   * @return bool
337
   */
338
  protected function checkHaveRecyclers() {
339
    $recyclers = 0;
340
    foreach (sn_get_groups('flt_recyclers') as $recycler_id) {
341
      $recyclers += $this->fleet->shipsGetTotalById($recycler_id);
342
    }
343
344
    return $recyclers >= 1;
345
  }
346
347
  /**
348
   * @return bool
349
   */
350
  protected function checkSpiesOnly() {
351
    return $this->fleet->shipsGetTotalById(SHIP_SPY) == $this->fleet->shipsGetTotal();
352
  }
353
354
  /**
355
   * @return bool
356
   */
357
  protected function checkNotOnlySpies() {
358
    return !$this->checkSpiesOnly();
359
  }
360
361
  /**
362
   * @return bool
363
   */
364
  protected function checkNoMissiles() {
365
    return
366
      $this->fleet->shipsGetTotalById(UNIT_DEF_MISSILE_INTERPLANET) == 0
367
      &&
368
      $this->fleet->shipsGetTotalById(UNIT_DEF_MISSILE_INTERCEPTOR) == 0;
369
  }
370
371
372
  /**
373
   * @return bool
374
   */
375
  protected function checkTargetOwn() {
376
    return $this->fleet->dbTargetRow['id_owner'] == $this->fleet->dbSourcePlanetRow['id_owner'];
377
  }
378
379
  /**
380
   * @return bool
381
   */
382
  protected function forceTargetOwn() {
383
    if ($result = $this->checkTargetOwn()) {
384
      // Spying can't be done on owner's planet/moon
385
      unset($this->fleet->allowed_missions[MT_SPY]);
386
      // Attack can't be done on owner's planet/moon
387
      unset($this->fleet->allowed_missions[MT_ATTACK]);
388
      // ACS can't be done on owner's planet/moon
389
      unset($this->fleet->allowed_missions[MT_ACS]);
390
      // Destroy can't be done on owner's moon
391
      unset($this->fleet->allowed_missions[MT_DESTROY]);
392
      unset($this->fleet->allowed_missions[MT_MISSILE]);
393
    } else {
394
      // Relocate can be done only on owner's planet/moon
395
      unset($this->fleet->allowed_missions[MT_RELOCATE]);
396
397
    }
398
399
    return $result; // this->getPlayerOwnerId();
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
400
  }
401
402
  /**
403
   * @return bool
404
   */
405
  protected function checkTargetOther() {
406
    return !$this->checkTargetOwn();
407
  }
408
409
410
  /**
411
   * @return bool
412
   */
413
  protected function alwaysFalse() {
414
    return false;
415
  }
416
417
418
  /**
419
   * @return bool
420
   */
421
  protected function checkTargetAllyDeposit() {
422
    $result = mrc_get_level($this->fleet->dbTargetOwnerRow, $this->fleet->dbTargetRow, STRUC_ALLY_DEPOSIT) >= 1;
423
    if (!$result) {
424
      unset($this->fleet->allowed_missions[MT_HOLD]);
425
    }
426
427
    return $result;
428
  }
429
430
431
  /**
432
   * Forces missions that can flight to OWN planets
433
   *
434
   * @return bool
435
   */
436
  protected function forceMissionsOwn() {
437
    $result =
438
      !$this->fleet->mission_type
439
      ||
440
      in_array($this->fleet->mission_type, array(
441
        MT_HOLD,
442
        MT_RECYCLE,
443
        MT_RELOCATE,
444
        MT_TRANSPORT,
445
      ));
446
447
    unset($this->fleet->allowed_missions[MT_ATTACK]);
448
    unset($this->fleet->allowed_missions[MT_COLONIZE]);
449
    unset($this->fleet->allowed_missions[MT_EXPLORE]);
450
    unset($this->fleet->allowed_missions[MT_ACS]);
451
    unset($this->fleet->allowed_missions[MT_SPY]);
452
    unset($this->fleet->allowed_missions[MT_DESTROY]);
453
    unset($this->fleet->allowed_missions[MT_MISSILE]);
454
455
    return $result;
456
  }
457
458
  /**
459
   * Check mission type OR no mission - and limits available missions to this type if positive
460
   *
461
   * @param int $missionType
462
   *
463
   * @return bool
464
   */
465
  protected function forceMission($missionType) {
466
    $result = !$this->fleet->mission_type || $this->fleet->mission_type == $missionType;
467
    if ($result) {
468
      $this->fleet->allowed_missions = array(
469
        $missionType => $this->fleet->exists_missions[$missionType],
470
      );
471
    } else {
472
      unset($this->fleet->allowed_missions[$missionType]);
473
    }
474
475
    return $result;
476
  }
477
478
  /**
479
   * @return bool
480
   */
481
  protected function forceMissionExplore() {
482
    return $this->forceMission(MT_EXPLORE);
483
  }
484
485
  /**
486
   * @return bool
487
   */
488
  protected function forceMissionColonize() {
489
    return $this->forceMission(MT_COLONIZE);
490
  }
491
492
  /**
493
   * @return bool
494
   */
495
  protected function forceMissionRecycle() {
496
    return $this->forceMission(MT_RECYCLE);
497
  }
498
499
  /**
500
   * @return bool
501
   */
502
  protected function forceMissionMissile() {
503
    return $this->forceMission(MT_MISSILE);
504
  }
505
506
  /**
507
   * Just checks mission type
508
   *
509
   * @param int $missionType
510
   *
511
   * @return bool
512
   */
513
  protected function checkMissionNonRestrict($missionType) {
514
    return $this->fleet->mission_type == $missionType;
515
  }
516
517
518
  /**
519
   * @return bool
520
   */
521
  protected function checkNotEmptyMission() {
522
    return !empty($this->fleet->mission_type);
523
  }
524
525
  /**
526
   * @return bool
527
   */
528
  protected function checkMissionRelocate() {
529
    return $this->checkMissionNonRestrict(MT_RELOCATE);
530
  }
531
532
  /**
533
   * @return bool
534
   */
535
  protected function checkMissionHoldNonUnique() {
536
    $result = $this->checkMissionNonRestrict(MT_HOLD);
537
538
    return $result;
539
  }
540
541
  /**
542
   * @return bool
543
   */
544
  protected function checkMissionTransport() {
545
    return $this->checkMissionNonRestrict(MT_TRANSPORT);
546
  }
547
548
  /**
549
   * @return bool
550
   */
551
  protected function checkMissionTransportReal() {
552
    return
553
      $this->checkRealFlight()
554
      &&
555
      $this->checkMissionTransport();
556
  }
557
558
559
  /**
560
   * @return bool
561
   */
562
  protected function forceMissionSpy() {
563
    return $this->forceMission(MT_SPY);
564
  }
565
566
  /**
567
   * @return bool
568
   */
569
  protected function checkRealFlight() {
570
    return $this->fleet->isRealFlight;
571
  }
572
573
574
  /**
575
   * @return bool
576
   */
577
  protected function unsetMissionSpyComplex() {
578
    unset($this->fleet->allowed_missions[MT_SPY]);
579
    if ($this->fleet->mission_type == MT_SPY) {
580
      if ($this->checkRealFlight()) {
581
        return false;
582
      }
583
      $this->fleet->mission_type = MT_NONE;
584
    }
585
586
    return true;
587
  }
588
589
590
  /**
591
   * @return bool
592
   */
593
  protected function checkMissionExists() {
594
    return !empty($this->fleet->exists_missions[$this->fleet->mission_type]);
595
  }
596
597
  /**
598
   * @return bool
599
   */
600
  protected function checkPlayerInactiveOrNotNoob() {
601
    return
602
      $this->checkTargetNotActive()
603
      ||
604
      $this->checkTargetNotNoob();
605
  }
606
607
  /**
608
   * @return bool
609
   */
610
  protected function checkTargetActive() {
611
    return
612
      empty($this->fleet->dbTargetOwnerRow['onlinetime'])
613
      ||
614
      SN_TIME_NOW - $this->fleet->dbTargetOwnerRow['onlinetime'] >= PLAYER_TIME_ACTIVE_SECONDS;
615
  }
616
617
  /**
618
   * @return bool
619
   */
620
  // TODO - REDO MAIN FUNCTION
621
  protected function checkTargetNotActive() {
622
    return !$this->checkTargetActive();
623
  }
624
625
626
  /**
627
   * @return bool
628
   */
629
  protected function checkSameAlly() {
630
    return !empty($this->fleet->dbTargetOwnerRow['ally_id']) && $this->fleet->dbTargetOwnerRow['ally_id'] == $this->fleet->dbOwnerRow['ally_id'];
631
  }
632
633
  /**
634
   * @return bool
635
   */
636
  protected function checkTargetNoob() {
637
    $user_points = $this->fleet->dbTargetOwnerRow['total_points'];
638
    $enemy_points = $this->fleet->dbTargetOwnerRow['total_points'];
639
640
    return
641
      // Target is under Noob Protection but Fleet owner is not
642
      (
643
        classSupernova::$config->game_noob_points
644
        &&
645
        $enemy_points <= classSupernova::$config->game_noob_points
646
        &&
647
        $user_points > classSupernova::$config->game_noob_points
648
      ) || (
649
        classSupernova::$config->game_noob_factor
650
        &&
651
        $user_points > $enemy_points * classSupernova::$config->game_noob_factor
652
      );
653
  }
654
655
  /**
656
   * @return bool
657
   */
658
  // TODO - REDO MAIN FUNCTION
659
  protected function checkTargetNotNoob() {
660
    return !$this->checkTargetNoob();
661
  }
662
663
664
  /**
665
   * @return bool
666
   */
667
  protected function checkMissionHoldReal() {
668
    return
669
      $this->checkRealFlight()
670
      &&
671
      $this->checkMissionHoldNonUnique();
672
  }
673
674
  /**
675
   * @return bool
676
   */
677
  protected function checkMissionHoldOnNotNoob() {
678
    return
679
      $this->checkTargetNotActive()
680
      ||
681
      ($this->checkSameAlly() && classSupernova::$config->ally_help_weak)
682
      ||
683
      $this->checkTargetNotNoob();
684
  }
685
686
687
  // Missiles
688
689
  /**
690
   * @return bool
691
   */
692
  protected function checkOnlyAttackMissiles() {
693
    $missilesAttack = $this->fleet->shipsGetTotalById(UNIT_DEF_MISSILE_INTERPLANET);
694
695
    return $missilesAttack != 0 && $missilesAttack == $this->fleet->shipsGetTotal();
696
  }
697
698
  /**
699
   * @return bool
700
   */
701
  protected function checkSiloLevel() {
702
    $sn_data_mip = get_unit_param(UNIT_DEF_MISSILE_INTERPLANET);
703
704
    return mrc_get_level($this->fleet->dbOwnerRow, $this->fleet->dbSourcePlanetRow, STRUC_SILO) >= $sn_data_mip[P_REQUIRE][STRUC_SILO];
705
  }
706
707
  /**
708
   * @return bool
709
   */
710
  protected function checkSameGalaxy() {
711
    return $this->fleet->targetVector->galaxy == $this->fleet->dbSourcePlanetRow['galaxy'];
712
  }
713
714
  /**
715
   * @return bool
716
   */
717
  protected function checkMissileDistance() {
718
    return abs($this->fleet->dbSourcePlanetRow['system'] - $this->fleet->targetVector->system) <= flt_get_missile_range($this->fleet->dbOwnerRow);
719
  }
720
721
  /**
722
   * @return bool
723
   */
724
  protected function checkMissileTarget() {
725
    return empty($this->fleet->targetedUnitId) || in_array($this->fleet->targetedUnitId, sn_get_groups('defense_active'));
726
  }
727
728
729
  /**
730
   * @return int
731
   */
732
  protected function checkExpeditionsMax() {
733
    return get_player_max_expeditons($this->fleet->dbOwnerRow);
734
  }
735
736
  /**
737
   * @return bool
738
   */
739
  protected function checkExpeditionsFree() {
740
    return get_player_max_expeditons($this->fleet->dbOwnerRow) > FleetList::fleet_count_flying($this->fleet->dbOwnerRow['id'], MT_EXPLORE);
741
  }
742
743
  /**
744
   * @return bool
745
   */
746
  protected function checkCaptainSent() {
747
    return $this->fleet->captainId >= 1;
748
  }
749
750
  /**
751
   * @return bool
752
   */
753
  protected function checkCaptainExists() {
754
    return !empty($this->fleet->captain) && is_array($this->fleet->captain);
755
  }
756
757
  /**
758
   * @return bool
759
   */
760
  protected function checkCaptainOnPlanet() {
761
    return $this->fleet->captain['unit_location_type'] == LOC_PLANET;
762
  }
763
764
  /**
765
   * @return bool
766
   */
767
  protected function checkCaptainNotRelocating() {
768
    if ($this->fleet->mission_type == MT_RELOCATE) {
769
      $arriving_captain = mrc_get_level($this->fleet->dbOwnerRow, $this->fleet->dbTargetRow, UNIT_CAPTAIN, true);
770
    } else {
771
      $arriving_captain = false;
772
    }
773
774
    return empty($arriving_captain) || !is_array($arriving_captain);
775
  }
776
777
778
779
780
781
782
783
784
  /**
785
   * @return bool
786
   */
787
  protected function checkMissionDestroyReal() {
788
    return
789
      $this->checkRealFlight()
790
      &&
791
      $this->checkMissionNonRestrict(MT_DESTROY);
792
  }
793
794
  /**
795
   * @return bool
796
   */
797
  protected function checkHaveReapers() {
798
    $unitsTyped = 0;
799
    foreach (sn_get_groups('flt_reapers') as $unit_id) {
800
      $unitsTyped += $this->fleet->shipsGetTotalById($unit_id);
801
    }
802
803
    return $unitsTyped >= 1;
804
  }
805
806
807
  /**
808
   * @return bool
809
   */
810
  protected function checkMissionDestroyAllowed(){
811
    $result =
812
      $this->checkTargetIsMoon()
813
      &&
814
      $this->checkHaveReapers();
815
816
    if(!$result) {
817
      unset($this->fleet->allowed_missions[MT_DESTROY]);
818
    }
819
820
    return $result;
821
  }
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
  /**
859
   * Checks if mission can be MT_DESTROY in any point
860
   *
861
   * First check - exact MT_DESTROY set as mission_type - fleet pages 2 and 3
862
   * Second check - empty MT_DESTROY
863
   *
864
   * @return bool
865
   */
866
  protected function checkMissionDestroyOrEmptyNotReal() {
867
    $result = $this->checkMissionNonRestrict(MT_DESTROY)
868
      ||
869
      (empty($this->fleet->mission_type) && !$this->checkRealFlight());
870
871
    if(!$result) {
872
      unset($this->fleet->allowed_missions[MT_DESTROY]);
873
    }
874
875
    return $result;
876
  }
877
878
  protected function disableMissionDestroy() {
879
    unset($this->fleet->allowed_missions[MT_DESTROY]);
880
    return true;
881
  }
882
883
}
884