-
Notifications
You must be signed in to change notification settings - Fork 1
/
Map.php
108 lines (91 loc) 路 2.66 KB
/
Map.php
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
<?php
namespace cs\Map;
use cs\Core\Box;
use cs\Core\Floor;
use cs\Core\Point;
use cs\Core\Wall;
abstract class Map
{
/** @var Point[] */
protected array $spawnPositionAttacker = [];
/** @var Point[] */
protected array $spawnPositionDefender = [];
/**
* @param Point[] $positions
*/
public function setAttackersSpawnPositions(array $positions): void
{
$this->spawnPositionAttacker = $positions;
}
/**
* @param Point[] $positions
*/
public function setDefendersSpawnPositions(array $positions): void
{
$this->spawnPositionDefender = $positions;
}
/**
* @return Wall[]
*/
public function getWalls(): array
{
return [
(new Wall(new Point(0, 0, -1), true, 99999))->setPenetrable(false),
(new Wall(new Point(-1, 0, 0), false, 99999))->setPenetrable(false),
];
}
/**
* @return Floor[]
*/
public function getFloors(): array
{
return [
(new Floor(new Point(), 99999, 99999))->setPenetrable(false),
];
}
/**
* @return Point[]
*/
public function getSpawnPositionAttacker(): array
{
return $this->spawnPositionAttacker;
}
/**
* @return Point[]
*/
public function getSpawnPositionDefender(): array
{
return $this->spawnPositionDefender;
}
public function getSpawnRotationAttacker(): int
{
return 0;
}
public function getSpawnRotationDefender(): int
{
return 0;
}
public function getBombMaxBlastDistance(): int
{
return 1000;
}
public abstract function getBuyArea(bool $forAttackers): Box;
public abstract function getPlantArea(): Box;
/**
* @return array<string,mixed>
*/
public function toArray(): array
{
return [
'floors' => array_map(fn(Floor $o) => $o->toArray(), $this->getFloors()),
'walls' => array_map(fn(Wall $o) => $o->toArray(), $this->getWalls()),
'spawnAttackers' => array_map(fn(Point $o) => $o->toArray(), $this->getSpawnPositionAttacker()),
'spawnDefenders' => array_map(fn(Point $o) => $o->toArray(), $this->getSpawnPositionDefender()),
'buyAreaAttackers' => $this->getBuyArea(true)->toArray(),
'buyAreaDefenders' => $this->getBuyArea(false)->toArray(),
'plantArea' => $this->getPlantArea()->toArray(),
'spawnRotationAttackers' => $this->getSpawnRotationAttacker(),
'spawnRotationDefenders' => $this->getSpawnRotationDefender(),
];
}
}