-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJumpsAndFallsTable.php
More file actions
165 lines (153 loc) · 5.18 KB
/
Copy pathJumpsAndFallsTable.php
File metadata and controls
165 lines (153 loc) · 5.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<?php declare(strict_types = 1);
namespace DrdPlus\Tables\Activities;
use DrdPlus\Calculations\SumAndRound;
use DrdPlus\Codes\Environment\LandingSurfaceCode;
use DrdPlus\Codes\JumpMovementCode;
use DrdPlus\Codes\JumpTypeCode;
use DrdPlus\BaseProperties\Agility;
use DrdPlus\Tables\Measurements\Distance\Distance;
use DrdPlus\Tables\Measurements\Weight\Weight;
use DrdPlus\Tables\Measurements\Wounds\Wounds;
use DrdPlus\Tables\Measurements\Wounds\WoundsBonus;
use DrdPlus\Tables\Partials\AbstractFileTable;
use DrdPlus\Tables\Properties\AthleticsInterface;
use DrdPlus\Tables\Properties\BodyWeightInterface;
use DrdPlus\Tables\Properties\SpeedInterface;
use DrdPlus\Tables\Tables;
use Granam\DiceRolls\Templates\Rolls\Roll1d6;
use Granam\Integer\PositiveInteger;
/**
* See PPH page 119 right column, @link https://pph.drdplus.info/#tabulka_skoku
*/
class JumpsAndFallsTable extends AbstractFileTable
{
/**
* @return string
*/
protected function getDataFileName(): string
{
return __DIR__ . '/data/jumps_and_falls.csv';
}
/**
* @return array
*/
protected function getExpectedDataHeaderNamesToTypes(): array
{
return [
JumpMovementCode::STANDING_JUMP => self::INTEGER,
JumpMovementCode::FLYING_JUMP => self::INTEGER,
];
}
public const JUMP_TYPE = 'jump_type';
/**
* @return array
*/
protected function getRowsHeader(): array
{
return [
self::JUMP_TYPE,
];
}
/**
* @param JumpTypeCode $jumpTypeCode
* @param Distance $ranDistance
* @return int
*/
public function getModifierToJump(JumpTypeCode $jumpTypeCode, Distance $ranDistance): int
{
return $this->getValue($jumpTypeCode, $this->getJumpMovementCodeByRanDistance($ranDistance));
}
/**
* @param Distance $ranDistance
* @return string
*/
private function getJumpMovementCodeByRanDistance(Distance $ranDistance): string
{
if ($ranDistance->getMeters() >= 5) {
return JumpMovementCode::FLYING_JUMP;
}
return JumpMovementCode::STANDING_JUMP;
}
/**
* @param SpeedInterface $speed
* @param AthleticsInterface $athletics
* @param JumpTypeCode $jumpTypeCode
* @param Distance $ranDistance
* @param Roll1d6 $roll1D6
* @return int
*/
public function getJumpLength(
SpeedInterface $speed,
AthleticsInterface $athletics,
JumpTypeCode $jumpTypeCode,
Distance $ranDistance,
Roll1d6 $roll1D6
): int
{
return $this->getModifierToJump($jumpTypeCode, $ranDistance)
+ SumAndRound::half($speed->getValue())
+ $athletics->getAthleticsBonus()->getValue()
+ $roll1D6->getValue();
}
/**
* @param Distance $fallHeight
* @param BodyWeightInterface $bodyWeight
* @param Weight|null $weightOfItemsOverwhelmedBy
* @param Roll1d6 $roll1D6
* @param bool $itIsControlledJump
* @param Agility $agility
* @param AthleticsInterface $athletics
* @param LandingSurfaceCode $landingSurfaceCode
* @param PositiveInteger $bodyArmorProtection
* @param bool $hitToHead
* @param PositiveInteger $helmProtection
* @param Tables $tables
* @return Wounds
*/
public function getWoundsFromJumpOrFall(
Distance $fallHeight,
BodyWeightInterface $bodyWeight,
?Weight $weightOfItemsOverwhelmedBy,
Roll1d6 $roll1D6,
bool $itIsControlledJump,
Agility $agility,
AthleticsInterface $athletics,
LandingSurfaceCode $landingSurfaceCode,
PositiveInteger $bodyArmorProtection,
bool $hitToHead,
PositiveInteger $helmProtection,
Tables $tables
): Wounds
{
$meters = $fallHeight->getMeters();
if ($itIsControlledJump) {
$meters -= 2;
}
$powerOfWound = $meters + SumAndRound::half($bodyWeight->getValue()) - 5 + $roll1D6->getValue();
if ($weightOfItemsOverwhelmedBy && $weightOfItemsOverwhelmedBy->getBonus()->getValue() > 0 /* ignore negative values */) {
$powerOfWound += $weightOfItemsOverwhelmedBy->getBonus()->getValue();
}
$armorProtection = $bodyArmorProtection;
if ($hitToHead) {
/** same as @link https://pph.drdplus.info/#zraneni */
$powerOfWound += 2;
$armorProtection = $helmProtection;
}
$powerOfWound += $tables->getLandingSurfacesTable()->getBaseOfWoundsModifier(
$landingSurfaceCode,
$agility,
$armorProtection
)->getValue();
$convertedPowerOfWounds = (new WoundsBonus(SumAndRound::round($powerOfWound), $tables->getWoundsTable()))
->getWounds()->getValue();
$convertedAgilityAndAthletics = (new WoundsBonus(
$agility->getValue() + $athletics->getAthleticsBonus()->getValue(),
$tables->getWoundsTable())
)->getWounds()->getValue();
$woundsValue = $convertedPowerOfWounds - $convertedAgilityAndAthletics;
if ($woundsValue < 0) {
$woundsValue = 0;
}
return new Wounds($woundsValue, $tables->getWoundsTable());
}
}