-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactor.php
More file actions
100 lines (85 loc) · 2.88 KB
/
actor.php
File metadata and controls
100 lines (85 loc) · 2.88 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
<?php
class Actor {
function __construct($type, $name, $effects, $stats, $inventory) {
$this->type = $type ?: 'unknown';
$this->name = $name ?: 'unknown';
$this->effects = $effects;
$this->stats = $stats;
$this->inventory = $inventory;
}
function checkStatus() {
if ($this->stats['hp'] < 0) {
$this->effects['alive'] = false;
}
}
function calculatePassiveStatChange() {
$this->stats['hpRegenRate'] = (($this->stats['fp'] / $this->stats['fp_max']) - 1 + ($this->stats['ep'] / $this->stats['ep_max'])) / 8;
$this->stats['epRegenRate'] = (($this->stats['fp'] / $this->stats['fp_max']) * 2) - 0.5;
$this->stats['hpCunsumeRate'] = (($this->stats['fp'] / $this->stats['fp_max']) * 2) - 1;
echo($this->epRegenRate);
$this->alterStat('hp', $this->stats['hpRegenRate']);
$this->alterStat('ep', $this->stats['epRegenRate']);
$this->alterStat('fp', -2);
$this->calculateWeight();
}
function calculateWeight() {
$weight = 3; //do dis
}
function sell() {
if ($this->alterInventory('food', -1) === true) {
$this->alterInventory('coppers', 1);
}
}
function wait() {
$this->alterStat('hp', 0.01);
$this->alterStat('ep', 0.5);
}
function eat() {
if ($this->alterInventory('food', -1) === true) {
$this->calculatePassiveStatChange();
$this->alterStat('fp', +10);
} else {
return false;
}
}
function rest() {
$this->alterStat('hp', 0.05);
$this->alterStat('ep', 2);
}
function forage() {
$this->alterStat('ep', -2);
$this->alterInventory('food', 1);
}
function alterStat($type, $amount) {
if ((isset($this->stats[$type . '_max'])) && (($this->stats[$type] + $amount) > $this->stats[$type . '_max'])) {
$this->stats[$type] = $this->stats[$type . '_max'];
} else {
$this->stats[$type] += $amount;
}
}
function alterInventory($type, $amount) {
if (($this->inventory[$type] + $amount) < 0) {
$this->inventory[$type] = 0;
return false;
} else {
$this->inventory[$type] += $amount;
}
return true;
}
function showFullStatus() {
if ($this->effects['alive'] == false) {
echo 'BEPIS';
} else {
foreach ($this->effects as $key => $value) {
echo '<pre>' . $key . ': ' . $value . '</pre>';
}
foreach ($this->stats as $key => $value) {
echo '<pre>' . $key . ': ' . $value . '</pre>';
}
echo 'Inventory';
foreach ($this->inventory as $key => $value) {
echo '<pre>' . $key . ': ' . $value . '</pre>';
}
}
}
}