到目前为止,我正在尝试为游戏制作一个简单的战斗脚本,但是这段处理战斗的代码总是返回以下错误:
注意:使用未定义的常量 ime - 在第 17 行的 C:\Program Files (x86)\wamp\www\php\gozd.php 中假定为“ime”
注意:使用未定义的常量 napad - 在第 18 行的 C:\Program Files (x86)\wamp\www\php\gozd.php 中假定为“napad”
等等...我希望有人能发现问题?
if($_POST['action'] == 'Napadi') {
$igralec_ime = $_SESSION['username'];
$igralec = array (
ime => $igralec_ime,
napad => prikazi_stat('ofe',$igralec_ime),
obramba => prikazi_stat('def',$igralec_ime),
curhp => prikazi_stat('curhp',$igralec_ime)
);
$monster_ime = $_POST['monster'];
$monster = array (
ime => $monster_ime,
napad => prikazi_monster_stat('atk',$monster_ime),
obramba => prikazi_monster_stat('def',$monster_ime),
curhp => prikazi_monster_stat('maxhp',$monster_ime)
);
$combat = array();
$turns = 0;
while($igralec['curhp'] > 0 && $monster['curhp'] > 0) {
if($turns % 2 != 0) {
$napadalec = &$monster;
$branilec = &$igralec; }
else {
$napadalec = &$igralec;
$branilec = &$monster; }
$damage = 0;
if($napadalec['napad'] > $branilec['obramba']) {
$damage = $napadalec['napad'] - $branilec['obramba']; }
$branilec['curhp'] -= $damage;
$combat[$turns] = array(
napadalec => $napadalec['ime'],
branilec => $branilec['ime'],
damage => $damage
);
$turns++; }
update_stat('curhp',$igralec_ime,$igralec['curhp']);
if($igralec['curhp'] > 0) {
update_stat('cek',$igralec_ime,prikazi_stat('cek',$igralec_ime)+ prikazi_monster_stat('cek',$monster_ime));
$zmaga = 1;
$cekini = prikazi_monster_stat('cek',$monster_ime); }
else {
$zguba = 1; } }