|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
abstract class AbstractSmrCombatWeapon { |
|
4
|
|
|
/** |
|
5
|
|
|
* Reduce the damage done to planets by this factor |
|
6
|
|
|
*/ |
|
7
|
|
|
const PLANET_DAMAGE_MOD = 0.2; |
|
8
|
|
|
|
|
9
|
|
|
protected bool $damageRollover; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Return the max weapon damage possible in a single round. |
|
13
|
|
|
*/ |
|
14
|
|
|
public function getMaxDamage() : int { |
|
15
|
|
|
return max($this->getShieldDamage(), $this->getArmourDamage()); |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
abstract public function getBaseAccuracy() : int; |
|
19
|
|
|
abstract public function getName() : string; |
|
20
|
|
|
abstract public function getShieldDamage() : int; |
|
21
|
|
|
abstract public function getArmourDamage() : int; |
|
22
|
|
|
|
|
23
|
|
|
public function isDamageRollover() : bool { |
|
24
|
|
|
return $this->damageRollover; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
public function canShootForces() : bool { |
|
28
|
|
|
return true; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function canShootPorts() : bool { |
|
32
|
|
|
return true; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function canShootPlanets() : bool { |
|
36
|
|
|
return true; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function canShootTraders() : bool { |
|
40
|
|
|
return true; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function getDamage() : array { |
|
44
|
|
|
return array('MaxDamage' => $this->getMaxDamage(), 'Shield' => $this->getShieldDamage(), 'Armour' => $this->getArmourDamage(), 'Rollover' => $this->isDamageRollover()); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
abstract public function getModifiedDamageAgainstForces(AbstractSmrPlayer $weaponPlayer, SmrForce $forces) : array; |
|
48
|
|
|
abstract public function getModifiedDamageAgainstPort(AbstractSmrPlayer $weaponPlayer, SmrPort $port) : array; |
|
49
|
|
|
abstract public function getModifiedDamageAgainstPlanet(AbstractSmrPlayer $weaponPlayer, SmrPlanet $planet) : array; |
|
50
|
|
|
abstract public function getModifiedPortDamageAgainstPlayer(SmrPort $port, AbstractSmrPlayer $targetPlayer) : array; |
|
51
|
|
|
abstract public function getModifiedDamageAgainstPlayer(AbstractSmrPlayer $weaponPlayer, AbstractSmrPlayer $targetPlayer) : array; |
|
52
|
|
|
abstract public function getModifiedForceDamageAgainstPlayer(SmrForce $forces, AbstractSmrPlayer $targetPlayer) : array; |
|
53
|
|
|
abstract public function getModifiedPlanetDamageAgainstPlayer(SmrPlanet $planet, AbstractSmrPlayer $targetPlayer) : array; |
|
54
|
|
|
|
|
55
|
|
|
protected function doPlayerDamageToForce(array $return, AbstractSmrPlayer $weaponPlayer, SmrForce $forces) : array { |
|
56
|
|
|
$return['WeaponDamage'] = $this->getModifiedDamageAgainstForces($weaponPlayer, $forces); |
|
57
|
|
|
$return['ActualDamage'] = $forces->doWeaponDamage($return['WeaponDamage']); |
|
58
|
|
|
if ($return['ActualDamage']['KillingShot']) { |
|
59
|
|
|
$return['KillResults'] = $forces->killForcesByPlayer($weaponPlayer); |
|
60
|
|
|
} |
|
61
|
|
|
return $return; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
protected function doPlayerDamageToPlayer(array $return, AbstractSmrPlayer $weaponPlayer, AbstractSmrPlayer $targetPlayer) : array { |
|
65
|
|
|
$return['WeaponDamage'] = $this->getModifiedDamageAgainstPlayer($weaponPlayer, $targetPlayer); |
|
66
|
|
|
$return['ActualDamage'] = $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']); |
|
67
|
|
|
|
|
68
|
|
|
if ($return['ActualDamage']['KillingShot']) { |
|
69
|
|
|
$return['KillResults'] = $targetPlayer->killPlayerByPlayer($weaponPlayer); |
|
70
|
|
|
} |
|
71
|
|
|
return $return; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
protected function doPlayerDamageToPort(array $return, AbstractSmrPlayer $weaponPlayer, SmrPort $port) : array { |
|
75
|
|
|
$return['WeaponDamage'] = $this->getModifiedDamageAgainstPort($weaponPlayer, $port); |
|
76
|
|
|
$return['ActualDamage'] = $port->doWeaponDamage($return['WeaponDamage']); |
|
77
|
|
|
if ($return['ActualDamage']['KillingShot']) { |
|
78
|
|
|
$return['KillResults'] = $port->killPortByPlayer($weaponPlayer); |
|
79
|
|
|
} |
|
80
|
|
|
return $return; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
protected function doPlayerDamageToPlanet(array $return, AbstractSmrPlayer $weaponPlayer, SmrPlanet $planet, bool $delayed) : array { |
|
84
|
|
|
$return['WeaponDamage'] = $this->getModifiedDamageAgainstPlanet($weaponPlayer, $planet); |
|
85
|
|
|
$return['ActualDamage'] = $planet->doWeaponDamage($return['WeaponDamage'], $delayed); |
|
86
|
|
|
if ($return['ActualDamage']['KillingShot']) { |
|
87
|
|
|
$return['KillResults'] = $planet->killPlanetByPlayer($weaponPlayer); |
|
88
|
|
|
} |
|
89
|
|
|
return $return; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
protected function doPortDamageToPlayer(array $return, SmrPort $port, AbstractSmrPlayer $targetPlayer) : array { |
|
93
|
|
|
$return['WeaponDamage'] = $this->getModifiedPortDamageAgainstPlayer($port, $targetPlayer); |
|
94
|
|
|
$return['ActualDamage'] = $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']); |
|
95
|
|
|
|
|
96
|
|
|
if ($return['ActualDamage']['KillingShot']) { |
|
97
|
|
|
$return['KillResults'] = $targetPlayer->killPlayerByPort($port); |
|
98
|
|
|
} |
|
99
|
|
|
return $return; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
protected function doPlanetDamageToPlayer(array $return, SmrPlanet $planet, AbstractSmrPlayer $targetPlayer) : array { |
|
103
|
|
|
$return['WeaponDamage'] = $this->getModifiedPlanetDamageAgainstPlayer($planet, $targetPlayer); |
|
104
|
|
|
$return['ActualDamage'] = $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']); |
|
105
|
|
|
|
|
106
|
|
|
if ($return['ActualDamage']['KillingShot']) { |
|
107
|
|
|
$return['KillResults'] = $targetPlayer->killPlayerByPlanet($planet); |
|
108
|
|
|
} |
|
109
|
|
|
return $return; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
protected function doForceDamageToPlayer(array $return, SmrForce $forces, AbstractSmrPlayer $targetPlayer) : array { |
|
113
|
|
|
$return['WeaponDamage'] = $this->getModifiedForceDamageAgainstPlayer($forces, $targetPlayer); |
|
114
|
|
|
$return['ActualDamage'] = $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']); |
|
115
|
|
|
|
|
116
|
|
|
if ($return['ActualDamage']['KillingShot']) { |
|
117
|
|
|
$return['KillResults'] = $targetPlayer->killPlayerByForces($forces); |
|
118
|
|
|
} |
|
119
|
|
|
return $return; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
abstract public function shootForces(AbstractSmrPlayer $weaponPlayer, SmrForce $forces) : array; |
|
123
|
|
|
abstract public function shootPlayer(AbstractSmrPlayer $weaponPlayer, AbstractSmrPlayer $targetPlayer) : array; |
|
124
|
|
|
abstract public function shootPlayerAsForce(SmrForce $forces, AbstractSmrPlayer $targetPlayer) : array; |
|
125
|
|
|
} |
|
126
|
|
|
|