-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmother.php
60 lines (52 loc) · 1.17 KB
/
mother.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
<?php
/**
*
*/
class Mother extends Entity {
function __construct(Space $space) {
/** mother of ozone*/
parent::__construct($space, 'mother', 'create', 'moo');
$this->space->createGuid($this);
}
public function addTask(Action $action, $priority = 10){
array_push($this->tasks, array(
'action' => $action,
'priority' => $priority,
'retry' => 0
));
$this->MODE = Entity::WORKING;
}
public function removeTask($action){
foreach ($this->tasks as $index => $task) {
if ($task['action'] == $action) {
unset($this->tasks[$index]);
}
}
}
/**
* create a child
*
* @param string $type
* @param string $group
* @param string $name
* @return void
**/
public function create($type, $group, $name) {
switch ($type) {
case 'commander':
$child = new Commander($this->space, $type, $group, $name);
break;
case 'robot':
$child = new Robot($this->space, $type, $group, $name);
break;
default:
$child = new Entity($this->space, $type, $group, $name);
break;
}
$this->space->createGuid($child);
return $child;
}
public function work(){
}
}
?>