Completed
Push — trunk ( 5a98ee...c2d255 )
by SuperNova.WS
04:09
created

flt_mission_attack()   D

Complexity

Conditions 9
Paths 4

Size

Total Lines 39
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 9
eloc 22
nc 4
nop 2
dl 0
loc 39
rs 4.909
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 10 and the first side effect is on line 3.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
require_once(SN_ROOT_PHYSICAL . 'includes/includes/ube_attack_calculate.php');
4
5
/*
6
  copyright © 2009-2014 Gorlum for http://supernova.ws
7
*/
8
9
10
function flt_planet_capture(&$fleet_row, &$combat_data) {
11
  $result = null;
12
13
  return sn_function_call('flt_planet_capture', array(&$fleet_row, &$combat_data, &$result));
14
}
15
16
function sn_flt_planet_capture(&$fleet_row, &$combat_data, &$result) {
0 ignored issues
show
Unused Code introduced by
The parameter $fleet_row is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

16
function sn_flt_planet_capture(/** @scrutinizer ignore-unused */ &$fleet_row, &$combat_data, &$result) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $combat_data is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

16
function sn_flt_planet_capture(&$fleet_row, /** @scrutinizer ignore-unused */ &$combat_data, &$result) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
17
  return $result;
18
}
19
20
function flt_mission_attack($mission_data, $save_report = true) {
0 ignored issues
show
Unused Code introduced by
The parameter $save_report is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

20
function flt_mission_attack($mission_data, /** @scrutinizer ignore-unused */ $save_report = true) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
21
  $fleet_row = $mission_data['fleet'];
22
  $destination_user = $mission_data['dst_user'];
23
  $destination_planet = $mission_data['dst_planet'];
24
25
  if (!$fleet_row) {
26
    return null;
27
  }
28
29
  if (
30
    // Нет данных о планете назначения или её владельце
31
    empty($destination_user) || empty($destination_planet) || !is_array($destination_user) || !is_array($destination_planet)
32
    ||
33
    // "Уничтожение" не на луну
34
    ($fleet_row['fleet_mission'] == MT_DESTROY && $destination_planet['planet_type'] != PT_MOON)
35
  ) {
36
    fleet_send_back($fleet_row);
37
38
    return null;
39
  }
40
41
  $acs_fleet_list = empty($fleet_row['fleet_group']) ? [$fleet_row] : fleet_list_by_group($fleet_row['fleet_group']);
42
  $fleet_list_on_hold = fleet_list_on_hold($fleet_row['fleet_end_galaxy'], $fleet_row['fleet_end_system'], $fleet_row['fleet_end_planet'], $fleet_row['fleet_end_type'], $fleet_row['fleet_start_time']);
43
44
  $ubePrepare = new \Ube\Ube4_1\Ube4_1Prepare();
45
  $combat_data = $ubePrepare->prepareFromMissionArray($mission_data, $fleet_list_on_hold, $acs_fleet_list);
46
47
  $ubeCalc = new \Ube\Ube4_1\Ube4_1Calc();
48
  $ubeCalc->sn_ube_combat($combat_data);
49
50
  flt_planet_capture($fleet_row, $combat_data);
51
52
  sn_ube_report_save($combat_data);
53
54
  ube_combat_result_apply($combat_data);
55
56
  sn_ube_message_send($combat_data);
57
58
  return $combat_data;
59
}
60