示例#1
0
 function test_addData_backgroundCheck()
 {
     Initial::addData();
     $background = Background::getAll();
     $result = new Background("Hermit", "Medicine and religion. Your life has been lonely and you have a secret knowledge.", 1);
     $this->assertEquals($background[0], $result);
 }
示例#2
0
 static function find($search_id)
 {
     $found_background = null;
     $backgrounds = Background::getAll();
     foreach ($backgrounds as $background) {
         $background_id = $background->getId();
         if ($background_id == $search_id) {
             $found_background = $background;
         }
     }
     return $found_background;
 }
示例#3
0
 function test_deleteAll()
 {
     //Arrange
     $name = "Fighter";
     $description = "stuff";
     $test_class = new Background($name, $description);
     $test_class->save();
     $name2 = "Wizard";
     $description2 = "other stuff";
     $test_class2 = new Background($name2, $description2);
     $test_class2->save();
     //Act
     Background::deleteAll();
     $result = Background::getAll();
     //Assert
     $this->assertEquals([], $result);
 }
示例#4
0
文件: app.php 项目: Camolot/dnd
});
//race page
//renders race page
$app->get('/race', function () use($app) {
    return $app['twig']->render('race.html.twig', array('races' => Race::getAll()));
});
//carry race id to class page
$app->post('/class', function () use($app) {
    $_SESSION['race'] = $_POST['race_id'];
    return $app['twig']->render('class.html.twig', array('classes' => CharClass::getAll()));
});
//class page
//carry race id and class id to background page
$app->post('/background', function () use($app) {
    $_SESSION['class'] = $_POST['class_id'];
    return $app['twig']->render('background.html.twig', array('backgrounds' => Background::getAll()));
});
//background page
//carry race id, class id, background id to stats page
$app->post('/stats', function () use($app) {
    $_SESSION['background'] = $_POST['background_id'];
    $race_id = $_SESSION['race'];
    $race_find = Race::find($race_id);
    $race = getName($race_find);
    $class_id = $_SESSION['class'];
    $class_find = CharClass::find($class_id);
    $classname = getName($class_find);
    $stats = statRoll();
    $assigned_stats = assignRolls($six_rolls, $classname, $race);
    return $app['twig']->render('stats.html.twig', array('stat' => Stat::getAll()));
});
示例#5
0
文件: app.php 项目: civilianemail/dnd
    $_SESSION['eye_color'] = $_POST['eye_color'];
    $_SESSION['hair_color'] = $_POST['hair_color'];
    $_SESSION['skin_tone'] = $_POST['skin_tone'];
    $_SESSION['alignment'] = $_POST['alignment'];
    $_SESSION['other'] = $_POST['other'];
    $found_race = Race::find($_SESSION['race']);
    $found_race->getName();
    $found_class = CharClass::find($_SESSION['class']);
    $found_class->getName();
    $found_background = Background::find($_SESSION['background']);
    $found_background->getName();
    return $app['twig']->render('summary.html.twig', array('race' => $found_race, 'class' => $found_class, 'background' => $found_background, 'str' => $_SESSION['str'], 'dex' => $_SESSION['dex'], 'con' => $_SESSION['con'], 'wis' => $_SESSION['wis'], 'int' => $_SESSION['int'], 'cha' => $_SESSION['cha'], 'skills' => $_SESSION['skill'], 'name' => $_SESSION['name'], 'age' => $_SESSION['age'], 'gender' => $_SESSION['gender'], 'height' => $_SESSION['height'], 'eye_color' => $_SESSION['eye_color'], 'hair_color' => $_SESSION['hair_color'], 'skin_tone' => $_SESSION['skin_tone'], 'alignment' => $_SESSION['alignment'], 'other' => $_SESSION['other'], 'races' => Race::getAll(), 'classes' => CharClass::getAll(), 'backgrounds' => Background::getAll()));
});
//return to race page and save to database
$app->get('/summary', function () use($app) {
    Finalize::run();
    return $app['twig']->render('race.html.twig');
});
//print page
//render print page
$app->get('/print', function () use($app) {
    $character = Finalize::run();
    $found_race = Race::find($_SESSION['race']);
    $found_race->getName();
    $found_class = CharClass::find($_SESSION['class']);
    $found_class->getName();
    $found_background = Background::find($_SESSION['background']);
    $found_background->getName();
    return $app['twig']->render('print.html.twig', array("character" => $character, 'race' => $found_race, 'class' => $found_class, 'background' => $found_background, 'str' => $_SESSION['str'], 'dex' => $_SESSION['dex'], 'con' => $_SESSION['con'], 'wis' => $_SESSION['wis'], 'int' => $_SESSION['int'], 'cha' => $_SESSION['cha'], 'skills' => $_SESSION['skill'], 'name' => $_SESSION['name'], 'age' => $_SESSION['age'], 'gender' => $_SESSION['gender'], 'height' => $_SESSION['height'], 'eye_color' => $_SESSION['eye_color'], 'hair_color' => $_SESSION['hair_color'], 'skin_tone' => $_SESSION['skin_tone'], 'alignment' => $_SESSION['alignment'], 'other' => $_SESSION['other'], 'races' => Race::getAll(), 'classes' => CharClass::getAll(), 'backgrounds' => Background::getAll()));
});
return $app;