public function testToArray() { $alpha = 20; $this->background->setAlpha($alpha); $color = '#ff0000'; $this->background->color($color); $options = $this->background->toArray(); $this->assertCount(2, $options); }
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); }
protected function tearDown() { CharClass::deleteAll(); Character::deleteAll(); Race::deleteAll(); Skill::deleteAll(); Stat::deleteAll(); Description::deleteAll(); Background::deleteAll(); }
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; }
/** * Deleted checked backgrounds. */ public function index_onDelete() { if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) { foreach ($checkedIds as $backgroundId) { if (!($background = Background::find($backgroundId))) { continue; } $background->delete(); } Flash::success(Lang::get('abnmt.theater::lang.backgrounds.delete_selected_success')); } else { Flash::error(Lang::get('abnmt.theater::lang.backgrounds.delete_selected_empty')); } return $this->listRefresh(); }
$background_object = new Background(); $return_boolean = $background_object->getNameList(); if ($return_boolean) { echo json_encode($background_object->data()); } else { echo 'Error getting background name list'; } break; case 'change_background': $background_object = new Background(); $array_of_fields = (array) json_decode($request_json); $background_object->change($array_of_fields, $request_id); echo 'OK'; break; case 'remove_background': $background_object = new Background(); $background_object->remove($request_id); echo 'OK'; break; case 'add_track_type': $track_type_object = new TrackType(); $array_of_fields = (array) json_decode($request_json); // remove the db_id (first) item in the array since we're adding a new one to the database table array_shift($array_of_fields); $track_type_object->add($array_of_fields); echo 'OK'; break; case 'get_track_type': $track_type_object = new TrackType(); $return_boolean = $track_type_object->get($request_id); if ($return_boolean) {
}); //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())); });
function test_find() { //Arrange $name = "Fighter"; $description = "stuff"; $id = 1; $test_class = new Background($name, $description, $id); $test_class->save(); $name2 = "Wizard"; $description2 = "other stuff"; $test_class2 = new Background($name2, $description2); $test_class2->save(); //Act $result = Background::find($test_class->getId()); //Assert $this->assertEquals($test_class, $result); }
public function actionBackgroundSave() { $this->checkLogin(); if ($_FILES['background']['name'] != null) { $name = $_FILES['background']['name']; $tmp = $_FILES['background']['tmp_name']; $size = $_FILES['background']['size']; if ($size > 0) { $ext = explode(".", $name); $ext = $ext[count($ext) - 1]; $ext = strtolower($ext); $name = microtime(); $name = str_replace(" ", "", $name); $name = str_replace(".", "", $name); if ($ext == "jpg" || $ext == "png") { if (move_uploaded_file($tmp, "upload/{$name}.{$ext}")) { $background = new Background(); $background->name = $name . "." . $ext; if ($background->save()) { $this->redirect(array("Site/Home")); } } } } } }
function testGetBackgrounds() { //Arrange $description_id = 1; $race_id = 1; $stat_id = 1; $test_character = new Character($description_id, $race_id, $stat_id); $test_character->save(); $name = "Noble"; $description = "stuff"; $id = 1; $test_background = new Background($name, $description, $id); $test_background->save(); $name2 = "Urchin"; $description2 = "other stuff"; $id2 = 2; $test_background2 = new Background($name2, $description2, $id2); $test_background2->save(); //Act $test_character->addBackground($test_background); $test_character->addBackground($test_background2); //Assert $this->assertEquals($test_character->getBackgrounds(), [$test_background, $test_background2]); }
public function get_backgrounds() { $backgrounds = Background::all(); return $backgrounds; }
/** * Concatenate the strings built in this class after the * main background definition in the parent. * @see Background::__toString() Background::__toString() * @return string the complete background string */ public function __toString() { return parent::__toString() . $this->disableViewAllGroupsForTeachers() . $this->enableQuickmail(); }
static function addData() { // SKILLS: $skill1 = new Skill("Acrobatics", "Balancing and tumbling", 1); $skill2 = new Skill("Animal Handling", "Using or interacting with domesticated animals.", 2); $skill3 = new Skill("Arcana", "Magic related lore and knowledge.", 3); $skill4 = new Skill("Athletics", "Climbing, jumping, and swimming.", 4); $skill5 = new Skill("Deception", "Hide the truth.", 5); $skill6 = new Skill("History", "Recall historical events.", 6); $skill7 = new Skill("Insight", "Determine a creature's true intentions.", 7); $skill8 = new Skill("Intimidation", "Influence by using threats.", 8); $skill9 = new Skill("Investigation", "Look for clues and find hidden things.", 9); $skill10 = new Skill("Medicine", "Stabilize the dying or diagnose a disease.", 10); $skill11 = new Skill("Nature", "Recall weather, plant, or animal lore.", 11); $skill12 = new Skill("Perception", "See, hear, or smell the presence or something.", 12); $skill13 = new Skill("Performance", "Ability in dancing, singing, or storytelling.", 13); $skill14 = new Skill("Persuasion", "Influence by using goodwill.", 14); $skill15 = new Skill("Religion", "Recall religious lore.", 15); $skill16 = new Skill("Sleight of Hand", "Concealing items or stealing things.", 16); $skill17 = new Skill("Stealth", "Sneaking or hiding.", 17); $skill18 = new Skill("Survival", "Track and hunt, avoid hazards, or predict weather.", 18); $skill1->save(); $skill2->save(); $skill3->save(); $skill4->save(); $skill5->save(); $skill6->save(); $skill7->save(); $skill8->save(); $skill9->save(); $skill10->save(); $skill11->save(); $skill12->save(); $skill13->save(); $skill14->save(); $skill15->save(); $skill16->save(); $skill17->save(); $skill18->save(); // RACES: $race1 = new Race("Good all around, well balanced, adventurer. Easy to role play and fits most roles well.", "Human", 1); $race2 = new Race("Tough and wise. Good clerics. Bearded and can live to over 400. A bit more open than mountain dwarves.", "Hill Dwarf", 2); $race3 = new Race("Strong and tough. Good fighters. Bearded and can live to over 400. Likes to keep to their own.", "Mountain Dwarf", 3); $race4 = new Race("Fast and intelligent. Good fighters, rogues or wizards. Bronze skin. Has air of superiority.", "High Elf", 4); $race5 = new Race("Fast and wise. Good clerics and fighters. Copper/green skin. Very in tune with nature.", "Wood Elf", 5); $race6 = new Race("Fast and charismatic. Good rogues. Easily overlooked. Wanderers. Around 3 feet tall.", "Lightfoot Halfling", 6); $race7 = new Race("Tough and fast. Good fighters or rogues. Strong natured and boisterous.", "Stout Halfling", 7); $race1->save(); $race2->save(); $race3->save(); $race4->save(); $race5->save(); $race6->save(); $race7->save(); // CLASSES: $class1 = new CharClass("Cleric", "Wise and charismatic. Typically a healer who wields divine power in the service of their diety.", 1); $class2 = new CharClass("Fighter", "Strong and tough or fast and tough. Master of combat and knowledgable in weapons and armor.", 2); $class3 = new CharClass("Rogue", "Fast and intelligent. Highly skilled and commonly duplicitous. Commonly a seeker of treasures.", 3); $class4 = new CharClass("Wizard", "Intelligent and wise. Weaves magic spells that manipulate reality using long studied arcane knowledge.", 4); $class1->save(); $class2->save(); $class3->save(); $class4->save(); // BACKGROUNDS: $background1 = new Background("Hermit", "Medicine and religion. Your life has been lonely and you have a secret knowledge.", 1); $background2 = new Background("Noble", "History and persuasion. Your life has been luxurious and you benefit from your position of privilege.", 2); $background3 = new Background("Soldier", "Athletics and intimidation. Your life has been touched by war and you are recognized by your military rank.", 3); $background4 = new Background("Urchin", "Sleight of Hand and Stealth. Your life has been impoverished and you are intimately familiar with city workings.", 4); $background1->save(); $background2->save(); $background3->save(); $background4->save(); }
$_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;