本文整理汇总了PHP中Character::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Character::find方法的具体用法?PHP Character::find怎么用?PHP Character::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Character
的用法示例。
在下文中一共展示了Character::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_members
public function get_members(){
$find = Character::find()
->realm($this->realm->id)
->join("INNER", 'arena_team_member' ,array('weekgames','weekwins','seasongames','seasonwins','personalrating','arenateamid'),'guid')
->where(array('arena_team_member.arenateamid' => $this->arenateamid));
$members = $find->all();
return $members;
}
示例2: charname_unused
static function charname_unused($charname, $realmid){
$char = Character::find()->realm($realmid)->where(array('name' => $charname))->first();
if(isset($char->name) && $char->name == $charname){
return false;
} else {
return true;
}
}
示例3: testErase
function testErase(){
echo $this->char->erase();
var_dump($char->errors);
$this->assertEquals(isset(Character::find()->realm($this->source_realmid)->where(array('guid' => $this->guid))->first()->name),false);
echo $this->char->load_dump_to_realm($this->source_realmid);
var_dump($char->errors);
$this->assertEquals(isset(Character::find()->realm($this->source_realmid)->where(array('guid' => $this->guid))->first()->name),true);
}
示例4: get_members
public function get_members(){
$find = Character::find()
->realm($this->realm->id)
->join("INNER", 'guild_member' ,array('rank','guildid'),'guid')
->where(array('guild_member.guildid' => $this->guildid))
->order('guild_member.rank')
->limit(500);
$members = $find->all();
return $members;
}
示例5: afterSave
public function afterSave($created, $options)
{
// Mark the user as absent in all his games
// Get characters, so we can also have the game list
App::uses('Character', 'Model');
$Character = new Character();
$params = array();
$params['recursive'] = -1;
$params['fields'] = array('Character.id', 'Character.game_id', 'Character.level', 'Character.default_role_id');
$params['group'] = 'game_id';
$params['conditions']['user_id'] = $this->data['Availability']['user_id'];
$params['conditions']['main'] = 1;
if ($characters = $Character->find('all', $params)) {
App::uses('Event', 'Model');
$Event = new Event();
$Event->Behaviors->detach('Commentable');
App::uses('EventsCharacter', 'Model');
$EventsCharacter = new EventsCharacter();
foreach ($characters as $character) {
// Get events for this period
$params = array();
$params['recursive'] = -1;
$params['fields'] = array('Event.id');
$params['conditions']['game_id'] = $character['Character']['game_id'];
$params['conditions']['character_level <='] = $character['Character']['level'];
$params['conditions']['time_start >='] = $this->data['Availability']['start'] . ' 00:00:00';
$params['conditions']['time_start <='] = $this->data['Availability']['end'] . ' 23:59:59';
if ($events = $Event->find('all', $params)) {
foreach ($events as $event) {
// If already registered to this event, update it
$paramsEventsCharacter = array();
$paramsEventsCharacter['recursive'] = -1;
$paramsEventsCharacter['fields'] = array('id');
$paramsEventsCharacter['conditions']['event_id'] = $event['Event']['id'];
$paramsEventsCharacter['conditions']['user_id'] = $this->data['Availability']['user_id'];
if ($eventCharacter = $EventsCharacter->find('first', $paramsEventsCharacter)) {
$eventCharacter['EventsCharacter']['status'] = 0;
$EventsCharacter->save($eventCharacter['EventsCharacter']);
} else {
$toSave = array();
$toSave['event_id'] = $event['Event']['id'];
$toSave['user_id'] = $this->data['Availability']['user_id'];
$toSave['character_id'] = $character['Character']['id'];
$toSave['raids_role_id'] = $character['Character']['default_role_id'];
$toSave['comment'] = $this->data['Availability']['comment'];
$toSave['status'] = 0;
$EventsCharacter->__add($toSave);
}
}
}
}
}
return true;
}
示例6: removeCharacterForumPermission
public function removeCharacterForumPermission(Forum $forum)
{
$character = Character::find(Input::get('character'));
if ($character != null) {
ForumCharacterPermission::where(['character_id' => $character->id, 'forum_id' => $forum->id])->delete();
Cache::flush();
return Redirect::to("dashboard/storyteller/manage/forums/{$forum->id}/characters");
} else {
return Response::json(['success' => false, 'message' => 'Invalid data.']);
}
}
示例7: testUpdate
public function testUpdate()
{
require __DIR__ . '/config/database_test.php';
$db = new DatabaseConnection($host, $database, $user, $password);
$character1 = ['name' => 'Lion Woods', 'description' => 'A wonderful zombie that plays golf better than Tiger Woods', 'type' => 'zombie', 'dead' => '1', 'stage' => '2', 'hp' => '67'];
$character2 = ['name' => 'Guybrush Threepwood', 'description' => 'How appropriate. You fight like a cow', 'type' => 'pirate', 'dead' => '0', 'stage' => '5', 'hp' => '100'];
$id = Character::insert($db, $character1);
Character::update($db, $id, $character2);
$actual = Character::find($db, $id);
$character2['id'] = $id;
$expected = $character2;
$this->assertEquals($expected, $actual, 'Character::update() not working properly');
}
示例8: testPostControllerAndDeleteController
/**
* @expectedException StatusCodeException
* @expectedExceptionCode 404
*/
public function testPostControllerAndDeleteController()
{
require __DIR__ . '/config/database_test.php';
$controller = new CharacterController();
$actionMethodName = 'postCharacter';
$db = new DatabaseConnection($host, $database, $user, $password);
// Test PostController
$params = ['name' => 'Guybrush Threepwood', 'description' => 'How appropriate. You fight like a cow', 'type' => 'pirate', 'dead' => '0', 'stage' => '5', 'hp' => '100'];
$actual = call_user_func_array([$controller, $actionMethodName], [$db, $params]);
$id = $actual['id'];
unset($actual['id']);
$this->assertEquals($params, $actual, 'Inserted row not the same that expected');
// Testing DeleteController
$actionMethodName = 'deleteCharacter';
$actual = call_user_func_array([$controller, $actionMethodName], [$db, $id]);
Character::find($db, $id);
}
示例9: awardExperience
public function awardExperience(GameSession $session)
{
$ids = Input::get("ids");
$costumes = Input::get("costumes");
$nom1s = Input::get("nom1s");
$nom2s = Input::get("nom2s");
$overrides = Input::get("overrides");
$save = Input::get("save");
$missingCharacters = [];
foreach ($ids as $index => $id) {
$character = Character::find($id);
if ($character) {
$checkIn = GameSessionCheckIn::where(['session_id' => $session->id, 'character_id' => $character->id])->first();
$checkIn->costume = $costumes[$index] == "true" ? 1 : 0;
$checkIn->nominated = $nom1s[$index] == "true" ? 1 : 0;
$checkIn->nominated_twice = $nom2s[$index] == "true" ? 1 : 0;
$checkIn->bonus = $overrides[$index];
$checkIn->total_experience = 1 + ($checkIn->costume ? 1 : 0) + ($checkIn->nominated ? 1 : 0) + ($checkIn->nominated_twice ? 1 : 0) + $checkIn->bonus;
$checkIn->save();
if (!isset($save)) {
$owner = $character->owner;
$owner->sendMessage(null, "Experience awarded to " . $character->name, "The Storytellers have awarded your character " . $checkIn->total_experience . " Experience. You can now use the character editor to make changes to it at" . " your leisure. Remember, changes should be submitted by 6:00pm on the Wednesday" . " before a game to ensure that they have the chance to review them.");
$character->awardExperience($checkIn->total_experience);
$character->save();
}
} else {
$missingCharacters[] = $id;
}
}
if (!isset($save)) {
$session->submitted = true;
$session->save();
foreach (User::listStorytellers() as $st) {
$st->sendMessage(null, "Experience successfully awarded", "The action to award experience for the session on " . $session->date . " has completed." . (sizeof($missingCharacters) > 0 ? "\n\n" . sizeof($missingCharacters) . " characters were" . " not found (" . implode(",", $missingCharacters) . ")" : ''));
}
return Redirect::to("/dashboard");
} else {
return Redirect::to("/dashboard/storyteller/session/experience/{$session->id}");
}
}
示例10: previousVersion
public function previousVersion()
{
if ($this->version != 1) {
return Character::find($this->character_id)->version($this->version - 1)->first();
}
return null;
}
示例11: function
<div class="clan-title">
{{RulebookClan::find($q->hidden_id)->name}}
</div>
<div class="clan-members">
<?php
$member_query = DB::table('characters')->select('characters.id')->where('active', true)->join('characters_versions', function ($join) {
$join->on('characters_versions.character_id', '=', 'characters.id');
$join->on('characters_versions.version', '=', 'characters.approved_version');
})->join('characters_clan', function ($join) {
$join->on('characters.id', '=', 'characters_clan.character_id');
$join->on('characters_clan.version_id', '=', 'characters_versions.id');
})->where('characters_clan.hidden_id', $q->hidden_id)->orderBy('name');
?>
@foreach($member_query->get() as $member)
<?php
$character = Character::find($member->id);
?>
<div class="row clan-member">
@if($character->is_npc)
<div class="columns small-12 npc">
{{$character->printName()}}
<div class="position-list">
{{CharacterPosition::with('definition')->where('character_id', $character->id)->get()
->map(function($item, $key) { return $item->definition; })->implode('name', ', ')}}
</div>
</div>
@else
<div class="row">
<div class="columns small-6">
{{$character->printName()}}
</div>
示例12: erase
function erase($params){
$char = Character::find()->where(array('guid' => $params['guid']))->realm($params['rid'])->first();
if ($char->guid == $params['guid']) {
$bu_answer = $char->write_dump(true);
if(isset($params['hard']) && $params['hard'] == 1){
if($bu_answer != false){
$answer = $char->erase(true);
} else {
$this->render_ajax('error', 'Can\'t backup Char! Deleting process canceld (' . $char->errors[0] .')');
return false;
}
} else {
$answer = $char->erase(false);
}
if($answer != false){
Event::trigger(Event::TYPE_CHARACTER_DELETE, User::$current->account, $char, (isset($params['hard']) && $params['hard'] == 1 ? 'hard' : 'soft'));
$this->render_ajax('success', 'Char successfully erased! ' . $answer);
} else {
$this->render_ajax('error', 'Can\'t delete Char! ' . $char->errors[0]);
}
} else {
$this->render_ajax('error', 'Char not found!');
}
}
示例13: get_deleted_characters
function get_deleted_characters(){
$del_chars = array();
$realms = Realm::find()->available()->all();
foreach($realms as $realm){
$result = Character::find()->where(array('deleteinfos_account' => $this->id))->realm($realm->id)->all();
if(is_array($result))
$del_chars += $result;
}
return $del_chars;
}
示例14: cost
public function cost($character_id, $version = -1)
{
$character = Character::find($character_id);
return $this->getOptionCost($this->option1()->first(), $character, $version) + $this->getOptionCost($this->option2()->first(), $character, $version) + ($this->option3 == null ? 0 : $this->getOptionCost($this->option3()->first(), $character, $version));
}
示例15: 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.']);
}
}