我刚开始使用类,但是当我执行包含该类的页面时,我的脚本就停止了。另外,代码和功能本身并不完整,只是在一些基础上添加了一些代码。
class doVersus
{
private var $p1health;
private var $p2health;
private var $dmg;
public var $longlog;
function __construct($hp1m, $hp1c, $hp2m, $hp2c, $stg, $prev_log, $hp2n)
{
if($stg==0)
{
$longlog = "The battle has begun..<br>".$_GET['user'];
//startBattle($hp1m, $hp1c, $hp2m, $hp2c, $stg, $prev_log, $hp2n);
echo $longlog;
}else{
$longlog = $longlog."TURN: ".$stg."<br>";
//startBattle($hp1m, $hp1c, $hp2m, $hp2c, $stg, $prev_log, $hp2n);
echo $longLog;
}
private function startBattle($hp1m, $hp1c, $hp2m, $hp2c, $stg, $prev_log, $hp2n)
{
if($hp1c<0 || $hp2c<0)
{
$longlog = $longlog."The battle has ended!<br>"
stopBattle($hp1c, $hp2c);
}else{
echo $longlog;
}
}
private function doDmg($a)
{
$longlog = $longlog." strikes ".$hp2n." with ".$dmg." normal damage";
}
private function stopBattle($a, $b)
{
echo $longlog." Battle has ended.";
}
}