当前位置: 首页>>代码示例>>PHP>>正文


PHP Character::addBackground方法代码示例

本文整理汇总了PHP中Character::addBackground方法的典型用法代码示例。如果您正苦于以下问题:PHP Character::addBackground方法的具体用法?PHP Character::addBackground怎么用?PHP Character::addBackground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Character的用法示例。


在下文中一共展示了Character::addBackground方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGetBackgrounds

 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]);
 }
开发者ID:civilianemail,项目名称:dnd,代码行数:24,代码来源:CharacterTest.php

示例2: run


//.........这里部分代码省略.........
             $skill_id = 1;
         } elseif ($proficiency == "Animal Handling") {
             $skill_id = 2;
         } elseif ($proficiency == "Arcana") {
             $skill_id = 3;
         } elseif ($proficiency == "Athletics") {
             $skill_id = 4;
         } elseif ($proficiency == "Deception") {
             $skill_id = 5;
         } elseif ($proficiency == "History") {
             $skill_id = 6;
         } elseif ($proficiency == "Insight") {
             $skill_id = 7;
         } elseif ($proficiency == "Intimidation") {
             $skill_id = 8;
         } elseif ($proficiency == "Investigation") {
             $skill_id = 9;
         } elseif ($proficiency == "Medicine") {
             $skill_id = 10;
         } elseif ($proficiency == "Nature") {
             $skill_id = 11;
         } elseif ($proficiency == "Perception") {
             $skill_id = 12;
         } elseif ($proficiency == "Performance") {
             $skill_id = 13;
         } elseif ($proficiency == "Persuasion") {
             $skill_id = 14;
         } elseif ($proficiency == "Religion") {
             $skill_id = 15;
         } elseif ($proficiency == "Sleight of Hand") {
             $skill_id = 16;
         } elseif ($proficiency == "Stealth") {
             $skill_id = 17;
         } elseif ($proficiency == "Survival") {
             $skill_id = 18;
         }
         array_push($skill_ids, $skill_id);
     }
     // MAKES A RACE VARIABLE, SPEED :
     if ($_SESSION['race'] == 1) {
         $race = "human";
         $speed = 30;
         $race_id = 1;
     } elseif ($_SESSION['race'] == 2) {
         $race = "hill dwarf";
         $speed = 25;
         $race_id = 2;
     } elseif ($_SESSION['race'] == 3) {
         $race = "mountain dwarf";
         $speed = 25;
         $race_id = 3;
     } elseif ($_SESSION['race'] == 4) {
         $race = "high elf";
         $speed = 30;
         $race_id = 4;
     } elseif ($_SESSION['race'] == 5) {
         $race = "wood elf";
         $speed = 35;
         $race_id = 5;
     } elseif ($_SESSION['race'] == 6) {
         $race = "lightfoot halfling";
         $speed = 25;
         $race_id = 6;
     } elseif ($_SESSION['race'] == 7) {
         $race = "stout halfling";
         $speed = 25;
         $race_id = 7;
     }
     // MAKE STAT CLASS :
     $stat = new Stat($ac, 1, 1, 1, 1, $cha, $con, 1, $dex, 1, $initiative, 1, $int, 1, 1, $max_hp, 1, 1, 1, 1, 1, 1, 1, $speed, 1, 1, $str, 1, $wis);
     $stat->save();
     $stat->updateAcrobatics($proficiency_array);
     $stat->updateAnimalHandling($proficiency_array);
     $stat->updateArcana($proficiency_array);
     $stat->updateAthletics($proficiency_array);
     $stat->updateDeception($proficiency_array);
     $stat->updateHistory($proficiency_array);
     $stat->updateInsight($proficiency_array);
     $stat->updateIntimidation($proficiency_array);
     $stat->updateInvestigation($proficiency_array);
     $stat->updateMedicine($proficiency_array);
     $stat->updateNature($proficiency_array);
     $stat->updatePerception($proficiency_array);
     $stat->updatePerformance($proficiency_array);
     $stat->updatePersuasion($proficiency_array);
     $stat->updateReligion($proficiency_array);
     $stat->updateSleightOfHand($proficiency_array);
     $stat->updateStealth($proficiency_array);
     $stat->updateSurvival($proficiency_array);
     $stat_id = $stat->getId();
     // CREATE CHARACTER, ADD JOINS :
     $character = new Character($description_id, $race_id, $stat_id);
     $character->save();
     $character->addCharClass($class_id);
     $character->addBackground($background_id);
     foreach ($skill_ids as $id) {
         $character->addSkill($id);
     }
     return $character;
 }
开发者ID:civilianemail,项目名称:dnd,代码行数:101,代码来源:Finalize.php


注:本文中的Character::addBackground方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。