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


PHP Character::save方法代码示例

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


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

示例1: run

 public function run()
 {
     $character = new Character();
     $character->name = 'Ellerion';
     $character->class = 'Mage';
     $character->race = 'Human';
     $character->realm = 'Darkspear';
     $character->file = '';
     $character->save();
 }
开发者ID:john5652,项目名称:Blog,代码行数:10,代码来源:CharactersTableSeeder.php

示例2: storeCharacter

 public function storeCharacter()
 {
     $character = new Character();
     $character->name = Input::get('name');
     $character->class = Input::get('class');
     $character->realm = Input::get('realm');
     $character->file = Input::get('file');
     $character->race = Input::get('race');
     $character->save();
     return Redirect::action('ItemsController@index');
 }
开发者ID:john5652,项目名称:Blog,代码行数:11,代码来源:ItemsController.php

示例3: Character

 function character_post()
 {
     if (!$this->post('name') || !$this->post('campaign')) {
         $this->response(NULL, 400);
     }
     // Only allow new/edit characters when a user is logged in
     if (!$this->user->exists()) {
         $this->response(NULL, 401);
     }
     if (!$this->post('id')) {
         // New character
         $character = new Character();
         $character->player_id = $this->user->id;
     } else {
         // Edit character
         $character = new Character($this->post('id'));
     }
     $character->name = $this->post('name');
     $character->number = $this->post('number');
     $character->level = $this->post('level');
     $character->faction = $this->post('faction');
     $character->class = $this->post('class');
     $character->campaign = $this->post('campaign');
     $character->save();
     $this->response(NULL, 200);
 }
开发者ID:TetsujinOni,项目名称:PFS-Scenariotracker,代码行数:26,代码来源:V1.php

示例4: basename

    if ($_FILES) {
        $uploads_directory = 'img/uploads/';
        $filename = $uploads_directory . basename($_FILES['file']['name']);
        if (move_uploaded_file($_FILES['file']['tmp_name'], $filename)) {
            echo '<p> The file ' . basename($_FILES['file']['name']) . ' has been uploaded</p>';
        } else {
            echo "Sorry, there was an error uploading your file.";
        }
    }
    $create_character = new Character();
    $create_character->name = Input::get('name');
    $create_character->realm = Input::get('realm');
    $create_character->class = Input::get('class');
    $create_character->race = Input::get('race');
    $create_character->character_img = $filename;
    $create_character->save();
}
?>
	
<!DOCTYPE html>
<html>
<head>
	<title>Character Creation</title>
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
	<link rel="stylesheet" href="/css/main.css">
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

	<style>

	body {
开发者ID:CodeBreakerz,项目名称:adlister.dev,代码行数:31,代码来源:character.create.php

示例5: transferExperience

 public function transferExperience(Character $to)
 {
     $from = Character::find(Input::get("from"));
     if ($from != null && $to != null) {
         $to->experience += $from->availableExperience();
         $from->experience -= $from->availableExperience();
         $to->save();
         $from->save();
         Cache::forget("character-experience-" . $to->id);
         Cache::forget("character-experience-" . $from->id);
         return Redirect::to("dashboard/storyteller/characters");
     } else {
         return Response::json(['success' => false, 'message' => 'Invalid data.']);
     }
 }
开发者ID:AcceptableIce,项目名称:Larp3,代码行数:15,代码来源:StorytellerCharacterController.php

示例6: array

 /**
  * Moves a character in a specific direction.
  *
  * @param string|int direction or area_id where character is heading
  *
  * @return redirects to /game/maps, even if the character isn't moved.
  */
 function game_move($direction = null)
 {
     if (!isset($direction) && empty($direction)) {
         $this->redirect('/game/maps');
     }
     $updateModels = array('Character');
     $this->Area->contain();
     $conditions = array('Area.id' => $this->characterInfo['area_id']);
     $currentArea = $this->Area->find('first', array('conditions' => $conditions));
     $conditions = array();
     $conditions['Area.access'] = 1;
     switch ($direction) {
         case "left":
             if ($currentArea['Area']['restriction'] == 'left') {
                 $this->redirect('/game/maps');
                 exit;
             }
             $conditions['Area.map_id'] = $currentArea['Area']['map_id'];
             $conditions['Area.x'] = $currentArea['Area']['x'] - 1;
             $conditions['Area.y'] = $currentArea['Area']['y'];
             break;
         case "right":
             if ($currentArea['Area']['restriction'] == 'right') {
                 $this->redirect('/game/maps');
                 exit;
             }
             $conditions['Area.map_id'] = $currentArea['Area']['map_id'];
             $conditions['Area.x'] = $currentArea['Area']['x'] + 1;
             $conditions['Area.y'] = $currentArea['Area']['y'];
             break;
         case "up":
             if ($currentArea['Area']['restriction'] == 'up') {
                 $this->redirect('/game/maps');
                 exit;
             }
             $conditions['Area.map_id'] = $currentArea['Area']['map_id'];
             $conditions['Area.y'] = $currentArea['Area']['y'] - 1;
             $conditions['Area.x'] = $currentArea['Area']['x'];
             break;
         case "down":
             if ($currentArea['Area']['restriction'] == 'down') {
                 $this->redirect('/game/maps');
                 exit;
             }
             $conditions['Area.map_id'] = $currentArea['Area']['map_id'];
             $conditions['Area.y'] = $currentArea['Area']['y'] + 1;
             $conditions['Area.x'] = $currentArea['Area']['x'];
             break;
         default:
             if ($direction == $currentArea['Area']['travel_to']) {
                 $conditions['Area.id'] = $currentArea['Area']['travel_to'];
                 $direction = $this->characterInfo['last_move'];
                 $updateModels[] = 'Map';
             }
     }
     $areaTo = $this->Area->find('first', array('conditions' => $conditions));
     if (!empty($areaTo)) {
         $data['Character']['id'] = $this->characterInfo['id'];
         $data['Character']['area_id'] = $areaTo['Area']['id'];
         $data['Character']['last_move'] = $direction;
         App::import('Model', 'Character');
         $Character = new Character();
         $Character->save($data['Character'], array('validate' => false));
         $this->updateGame($updateModels);
     }
     $this->redirect('/game/maps');
 }
开发者ID:MortalROs,项目名称:Naxasius-Game-Engine,代码行数:74,代码来源:areas_controller.php

示例7: testGetSkills

 function testGetSkills()
 {
     //Arrange
     $description_id = 1;
     $race_id = 1;
     $stat_id = 1;
     $test_character = new Character($description_id, $race_id, $stat_id);
     $test_character->save();
     $name = "Acrobatics";
     $description = "stuff";
     $id = 1;
     $test_skill = new Skill($name, $description, $id);
     $test_skill->save();
     $name2 = "Athletics";
     $description2 = "other stuff";
     $id2 = 2;
     $test_skill2 = new Skill($name2, $description2, $id2);
     $test_skill2->save();
     //Act
     $test_character->addSkill($test_skill);
     $test_character->addSkill($test_skill2);
     //Assert
     $this->assertEquals($test_character->getSkills(), [$test_skill, $test_skill2]);
 }
开发者ID:civilianemail,项目名称:dnd,代码行数:24,代码来源:CharacterTest.php

示例8: run

 static function run()
 {
     // DESCRIPTION :
     $description = new Description($_SESSION['name'], $_SESSION['gender'], $_SESSION['age'], $_SESSION['alignment'], $_SESSION['height'], $_SESSION['eye_color'], $_SESSION['hair_color'], $_SESSION['skin_tone'], $_SESSION['other'], null);
     $description->save();
     $description_id = $description->getId();
     // STAT VARIABLES :
     $dex = $_SESSION['dex'];
     $dex_mod = Stat::getModifier($dex);
     $con = $_SESSION['con'];
     $con_mod = Stat::getModifier($con);
     $str = $_SESSION['str'];
     $str_mod = Stat::getModifier($str);
     $wis = $_SESSION['wis'];
     $wis_mod = Stat::getModifier($wis);
     $int = $_SESSION['int'];
     $int_mod = Stat::getModifier($int);
     $cha = $_SESSION['cha'];
     $cha_mod = Stat::getModifier($cha);
     $initiative = $dex_mod;
     // MAKES A CLASS VARIABLE, MAXHP, AC, BACKGROUND ID :
     if ($_SESSION['class'] == 1) {
         $class = "cleric";
         $class_hp = 8;
         $class_id = 1;
     } elseif ($_SESSION['class'] == 2) {
         $class = "fighter";
         $class_hp = 10;
         $class_id = 2;
     } elseif ($_SESSION['class'] == 3) {
         $class = "rogue";
         $class_hp = 8;
         $class_id = 3;
     } elseif ($_SESSION['class'] == 4) {
         $class = "wizard";
         $class_hp = 6;
         $class_id = 4;
     }
     $max_hp = $con_mod + $class_hp;
     $ac = 10 + $dex_mod;
     $proficiency_array = $_SESSION['skill'];
     $background_id = $_SESSION['background'];
     $proficiency_array = $_SESSION['skill'];
     $skill_ids = array();
     foreach ($proficiency_array as $proficiency) {
         if ($proficiency == "Acrobatics") {
             $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;
//.........这里部分代码省略.........
开发者ID:civilianemail,项目名称:dnd,代码行数:101,代码来源:Finalize.php

示例9: save

 public function save()
 {
     $user = Auth::user();
     $character = Character::find(Input::get('characterId'));
     if (!$character) {
         $character = new Character();
         $characterIsNew = true;
     }
     if (!isset($character->user_id)) {
         $character->user_id = $user->id;
     }
     $character->name = Input::get("sheet.name");
     $character->save();
     CharacterVersion::where('character_id', $character->id)->where('version', '>', $character->approved_version)->delete();
     $version = CharacterVersion::createNewVersion($character, Input::has("comment") ? Input::get("comment") : null);
     if ($version->isNewCharacter()) {
         $version->setHasDroppedMorality(Input::get("sheet.hasDroppedMorality") == "true");
     }
     try {
         $version->setEditingUser($user);
         if (Input::get("sheet.sect.selected")) {
             $version->setSect(RulebookSect::find(Input::get("sheet.sect.selected")), RulebookSect::find(Input::get("sheet.sect.displaying")));
         }
         if (Input::get("sheet.clan.selected")) {
             $version->setClan(RulebookClan::find(Input::get("sheet.clan.selected")), RulebookClan::find(Input::get("sheet.clan.displaying")));
         }
         $version->setClanOptions(Input::get("sheet.clanOptions.0"), Input::get("sheet.clanOptions.1"), Input::get("sheet.clanOptions.2"));
         if (Input::get("sheet.nature")) {
             $version->setNature(RulebookNature::find(Input::get("sheet.nature")));
         }
         if (Input::get("sheet.willpower")) {
             $version->setWillpower(Input::get("sheet.willpower.dots"), Input::get("sheet.willpower.traits"));
         }
         if (Input::get("sheet.attributes")) {
             $version->setAttributes(Input::get("sheet.attributes.physicals"), Input::get("sheet.attributes.mentals"), Input::get("sheet.attributes.socials"));
         }
         foreach ((array) Input::get("sheet.abilities") as $ability) {
             if (array_key_exists("specialization", $ability)) {
                 $version->addAbilityWithSpecialization(RulebookAbility::find($ability["id"]), $ability["count"], $ability["specialization"], $ability["name"]);
             } else {
                 $version->addAbility(RulebookAbility::find($ability["id"]), $ability["count"], $ability["name"]);
             }
         }
         foreach ((array) Input::get("sheet.disciplines") as $discipline) {
             $version->updateDiscipline(RulebookDiscipline::find($discipline["id"]), $discipline["count"], array_key_exists("path", $discipline) ? $discipline["path"] : 0);
         }
         foreach ((array) Input::get("newRituals") as $newRitualData) {
             $version->addRitualToBook($newRitualData["name"], $newRitualData["description"], $newRitualData["type"]);
         }
         foreach ((array) Input::get("sheet.rituals") as $ritualId) {
             $version->addRitual($ritualId);
         }
         if (Input::get("sheet.path")) {
             $version->updatePath(RulebookPath::find(Input::get("sheet.path")), Input::get("sheet.virtues.0"), Input::get("sheet.virtues.1"), Input::get("sheet.virtues.2"), Input::get("sheet.virtues.3"));
         }
         foreach ((array) Input::get("sheet.merits") as $meritData) {
             $version->addMerit(RulebookMerit::find($meritData["id"]), array_key_exists("description", $meritData) ? $meritData["description"] : null);
         }
         foreach ((array) Input::get("sheet.flaws") as $flawData) {
             $version->addFlaw(RulebookFlaw::find($flawData["id"]), array_key_exists("description", $flawData) ? $flawData["description"] : null);
         }
         foreach ((array) Input::get("sheet.derangements") as $derangementData) {
             $version->addDerangement(RulebookDerangement::find($derangementData["id"]), array_key_exists("description", $derangementData) ? $derangementData["description"] : null);
         }
         foreach ((array) Input::get("sheet.backgrounds") as $backgroundData) {
             $version->addBackground(RulebookBackground::find($backgroundData["id"]), $backgroundData["count"], array_key_exists("description", $backgroundData) ? $backgroundData["description"] : null);
         }
         foreach ((array) Input::get("sheet.elderPowers") as $elderData) {
             $version->addElderPower($elderData);
         }
         foreach ((array) Input::get("sheet.comboDisciplines") as $comboData) {
             $version->addComboDiscipline($comboData);
         }
         $version->clearUntouchedRecords();
     } catch (Exception $e) {
         throw $e;
     }
     return $version;
 }
开发者ID:AcceptableIce,项目名称:Larp3,代码行数:79,代码来源:SaveController.php


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