Esempio n. 1
0
 function testFind()
 {
     $name = "John Doe";
     $password = "******";
     $email = "*****@*****.**";
     $signed_in = 0;
     $test_user = new User($name, $password, $email, $signed_in);
     $test_user->save();
     $course_title = "Literature";
     $subject = "English";
     $course_description = "Deconstructing English literature.";
     $user_id = $test_user->getId();
     $test_course = new Course($course_title, $subject, $course_description, $user_id);
     $test_course->save();
     $unit_title = "Into the Wild";
     $unit_description = "The life and death of Chris McCandless.";
     $course_id = $test_course->getId();
     $test_unit = new Unit($unit_title, $unit_description, $course_id);
     $test_unit->save();
     $lesson_title = "Into the Wild: Chapter 1";
     $objective = "Students will read and discuss Chapter 1";
     $materials = "Books, discussion packets, pencils";
     $body = "Lorem ipsum etc etc blah blah blah blah...";
     $unit_id = $test_unit->getId();
     $test_lesson = new Lesson($lesson_title, $objective, $materials, $body, $unit_id);
     $test_lesson->save();
     $lesson_title2 = "The Catcher in the Rye: Chapter 3";
     $objective2 = "Students will read and discuss Chapter 3";
     $materials2 = "Books, essay prompts, pens";
     $body2 = "Blah blah blah etc etc lorem ipsum...";
     $test_lesson2 = new Lesson($lesson_title2, $objective2, $materials2, $body, $unit_id);
     $test_lesson2->save();
     $result = Lesson::find($test_lesson->getId());
     $this->assertEquals($test_lesson, $result);
 }
 $techName = $termConn->getTranslation($techName, $_SESSION['language']);
 if ($techUpgradable) {
     $techName .= "(" . ($techLevel + 1) . ")";
 }
 $message = "La investigación de " . $techName . " ha concluído.";
 $messageConn->insertMessage(0, $playerId, "Tecnología investigada.", $message);
 $technologyConn->updateTechnologyLink($techId, $playerId, 0, 0, '*', $techLevel + 1, 0);
 if ($techIsAge) {
     $playerConn->updatePlayerAge($playerId, $techEndAge);
     if (!isset($allUnits)) {
         $unitsArr = $unitConn->getAllUnits();
         $allUnits = array();
         $trainingTimes = array();
         foreach ($unitsArr as $unitArr) {
             $unit = new Unit($unitArr[0], $unitArr[1], $unitArr[2], $unitArr[3], $unitArr[4], $unitArr[5], $unitArr[6], $unitArr[7], $unitArr[8], $unitArr[9], $unitArr[10], $unitArr[11], $unitArr[12], $unitArr[13], $unitArr[14], $unitArr[15]);
             $allUnits[$unit->getId()] = $unit;
         }
     }
     foreach ($allUnits as $unit) {
         if ($unit->getUpgradesTo() > 0 && $unit->getAutoUpgrade() && $unit->getEndAge() == $techEndAge) {
             $unitConn->upgradeUnit($playerId, $unit->getId(), $divisionConn);
             require HOME . "controllers/batch/recalculate_productions.php";
         }
     }
     //NO BUILDINGS AUTOUPGRADE CODE SINCE THERE IS NONE YET. I'LL DO IT WHEN THE TIME IS RIGHT.
 }
 //Now we switch technologyId and apply aditional technology effects
 switch ($techId) {
     //On farms(4) turns every existent hunt camp into farms
     case 4:
         $buildingConn->upgradeBuilding($playerId, 6);
$timeLeft = $divisionMovement->getTime() - ($_SERVER['REQUEST_TIME'] - $divisionMovement->getStartDateTime());
$isAttack = $divisionMovement->getOwnerId() != $endSectorOwnerId;
foreach ($unitList as $i => $unitId) {
    if ($quantityList[$i] > 0) {
        if ($timeLeft <= 0) {
            $sectorArr = $sectorConn->getSectorByCoordinates($endSectorX, $endSectorY);
            $endSector = new Sector($sectorArr[0], $sectorArr[1], $sectorArr[2], $sectorArr[3], $sectorArr[4], $sectorArr[5], $sectorArr[6], $sectorArr[7], explode(",", $sectorArr[8]), explode(",", $sectorArr[9]), $sectorArr[10]);
            $sectorArr = $sectorConn->getSectorByCoordinates($startSectorX, $startSectorY);
            $startSector = new Sector($sectorArr[0], $sectorArr[1], $sectorArr[2], $sectorArr[3], $sectorArr[4], $sectorArr[5], $sectorArr[6], $sectorArr[7], explode(",", $sectorArr[8]), explode(",", $sectorArr[9]), $sectorArr[10]);
            if (!isset($allUnits)) {
                $allUnitsArr = $unitConn->getAllUnits();
                $allUnits = array();
                $trainingTimes = array();
                foreach ($allUnitsArr as $unitArr) {
                    $unit = new Unit($unitArr[0], $unitArr[1], $unitArr[2], $unitArr[3], $unitArr[4], $unitArr[5], $unitArr[6], $unitArr[7], $unitArr[8], explode(",", $unitArr[9]), explode(",", $unitArr[10]), explode(",", $unitArr[11]), $unitArr[12], $unitArr[13], $unitArr[14], $unitArr[15]);
                    $allUnits[$unit->getId()] = $unit;
                }
            }
            $unit = $allUnits[$unitId];
            $capitolSectorArr = $sectorConn->getCapitolSector($playerId);
            if ($capitolSectorArr) {
                $capitolSector = new Sector($capitolSectorArr[0], $capitolSectorArr[1], $capitolSectorArr[2], $capitolSectorArr[3], $capitolSectorArr[4], $capitolSectorArr[5], $capitolSectorArr[6], $capitolSectorArr[7], explode(",", $capitolSectorArr[8]), explode(",", $capitolSectorArr[9]), $capitolSectorArr[10]);
                $capitolX = $capitolSector->getCoordinateX();
                $capitolY = $capitolSector->getCoordinateY();
                $distanceFromCapitol = $startSector->getDistanceFrom($capitolX, $capitolY);
                //var_dump($distanceFromCapitol);
            } else {
                $ownedSectors = Sector::getOwnedSectors($allSectors, $playerId);
                $distanceFromCapitol = Sector::getMaxDistance($ownedSectors);
            }
            $unitStartCosts = $unit->getEfectiveManteinanceCosts($distanceFromCapitol);
Esempio n. 4
0
foreach ($battleModsArr as $battleModArr) {
    $battleModName = $terms[$battleModArr[1]];
    $battleMod = new BattleMod($battleModArr[0], $battleModName, $battleModArr[2], $battleModArr[3], $battleModArr[4], $battleModArr[5]);
    $battleMods[$battleMod->getId()] = $battleMod;
}
//Saves battleModLinks as $posessorUnit->targetUnit->battleMod applied to it
$battleModLinksArr = $battleModConn->getAllBattleModLinks();
foreach ($battleModLinksArr as $battleModLinkArr) {
    $battleModLinks[$battleModLinkArr[2]][$battleMods[$battleModLinkArr[1]]->getTargetClassId()] = $battleMods[$battleModLinkArr[1]];
}
$unitsArr = $unitConn->getAllUnits();
foreach ($unitsArr as $unitArr) {
    $unitName = $terms[$unitArr[1]]->getString();
    $unitDescription = $terms[$unitArr[13]]->getString();
    $unit = new Unit($unitArr[0], $unitName, $unitArr[2], $unitArr[3], $unitArr[4], $unitArr[5], $unitArr[6], $unitArr[7], $unitArr[8], explode(",", $unitArr[9]), explode(",", $unitArr[10]), explode(",", $unitArr[11]), $unitArr[12], $unitDescription, $unitArr[14], $unitArr[15]);
    if (isset($battleModLinks[$unit->getId()])) {
        $unit->setBattleMods($battleModLinks[$unit->getId()]);
    }
    $units[$unit->getId()] = $unit;
}
$staticData->setUnits($units);
$technologiesArr = $technologyConn->getAllTechnologies();
foreach ($technologiesArr as $technologyArr) {
    $techName = $terms[$technologyArr[1]]->getString();
    $techDescription = $terms[$technologyArr[11]]->getString();
    $technology = new Technology($technologyArr[0], $techName, $technologyArr[2], $technologyArr[3], $technologyArr[4], explode(",", $technologyArr[5]), explode(",", $technologyArr[6]), $technologyArr[7], $technologyArr[8], $technologyArr[9], $technologyArr[10], $techDescription, $technologyArr[12]);
    $technologies[$technology->getId()] = $technology;
}
$staticData->setTechnologies($technologies);
$productionModsArr = $productionModConn->getAllProductionMods();
$productionModLinks = array();