コード例 #1
0
ファイル: CharacterTest.php プロジェクト: civilianemail/dnd
 function test_deleteAll()
 {
     //Arrange
     $description_id = 1;
     $race_id = 1;
     $stat_id = 1;
     $test_character = new Character($description_id, $race_id, $stat_id);
     $test_character->save();
     $description_id2 = 2;
     $race_id2 = 2;
     $stat_id2 = 2;
     $test_character2 = new Character($description_id2, $race_id2, $stat_id2);
     $test_character2->save();
     //Act
     Character::deleteAll();
     $result = Character::getAll();
     //Assert
     $this->assertEquals([], $result);
 }
コード例 #2
0
ファイル: Character.php プロジェクト: civilianemail/dnd
 static function find($search_id)
 {
     $found_character = null;
     $characters = Character::getAll();
     foreach ($characters as $character) {
         $character_id = $character->getId();
         if ($character_id == $search_id) {
             $found_character = $character;
         }
     }
     return $found_character;
 }
コード例 #3
0
ファイル: app.php プロジェクト: Camolot/dnd
if (empty($_SESSION['temporary_character'])) {
    $_SESSION['temporary_character'] = array($_SESSION['race'] => "", $_SESSION['class'] => "", $_SESSION['background'] => "", $_SESSION['str'] => "", $_SESSION['dex'] => "", $_SESSION['con'] => "", $_SESSION['wis'] => "", $_SESSION['int'] => "", $_SESSION['cha'] => "", $_SESSION['name'] => "", $_SESSION['age'] => "", $_SESSION['gender'] => "", $_SESSION['height'] => "", $_SESSION['weight'] => "", $_SESSION['eye_color'] => "", $_SESSION['hair_color'] => "", $_SESSION['skin_tone'] => "", $_SESSION['alignment'] => "", $_SESSION['other_information'] => "");
}
$app = new Silex\Application();
$app['debug'] = true;
$server = 'mysql:host=localhost:8889;dbname=dnd';
$username = '******';
$password = '******';
$DB = new PDO($server, $username, $password);
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
use Symfony\Component\HttpFoundation\Request;
Request::enableHttpMethodParameterOverride();
//landing page
//renders homepage
$app->get('/', function () use($app) {
    return $app['twig']->render('home.html.twig', array('characters' => Character::getAll()));
});
//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'];