public static function getBuildingFromName($id, $race, $locationX = 0, $locationY = 0) { $rn = $race->getName(); if (class_exists('Dolumar_Races_' . $rn . '_Dolumar_Buildings_' . $id)) { $c = 'Dolumar_Races_' . $rn . '_Dolumar_Buildings_' . $id; return new $c($locationX, $locationY); //eval ('$c = new ($locationX, $locationY);'); } elseif (class_exists('Dolumar_Buildings_' . $id)) { $c = 'Dolumar_Buildings_' . $id; $c = new $c($locationX, $locationY); //eval ('$c = new Dolumar_Buildings_'.$id.' ($locationX, $locationY);'); } else { $c = new self($locationX, $locationY); } $c->setRace($race); return $c; }
/** * Creates a character with attributes * * @param $name string Name of the character * @param $level integer Level of the character * @param $class string Class of the character * @param $race string Race of the character * @param $gender string Gender of the character * @return Charac The newly created instance of Charac */ public static function withAttributes($name, $level, $class, $race, $gender) { $instance = new self(); $instance->setName($name); $instance->setLevel($level); $instance->setClass($class); $instance->setRace($race); $instance->setGender($gender); return $instance; }