本文整理汇总了PHP中Character类的典型用法代码示例。如果您正苦于以下问题:PHP Character类的具体用法?PHP Character怎么用?PHP Character使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Character类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: changeName
function changeName()
{
global $Config, $DB, $lang, $user;
include 'core/SDL/class.character.php';
$Character = new Character();
if (empty($_POST['newname'])) {
output_message('error', $lang['char_rename_newname']);
return FALSE;
}
if ($Config->get('module_charrename') == 0) {
output_message('error', 'Nice try hacking, but not good enough.');
return FALSE;
}
if ($user['web_points'] >= $Config->get('module_charrename_pts')) {
if ($Character->checkNameExists($_POST['newname']) == FALSE) {
if ($Character->isOnline($_POST['id']) == FALSE) {
if ($Character->setName($_POST['id'], $_POST['newname']) == TRUE) {
$DB->query("UPDATE `mw_account_extend` SET \n\t\t\t\t\t\t`web_points`=(`web_points` - " . $Config->get('module_charrename_pts') . "), \n\t\t\t\t\t\t`points_spent`=(`points_spent` + " . $Config->get('module_charrename_pts') . ") \n\t\t\t\t\t WHERE `account_id` = " . $user['id'] . " LIMIT 1");
output_message('success', $lang['char_rename_success'] . ' Redirecting...<meta http-equiv=refresh content="3;url=?p=account&sub=rename">');
}
} else {
output_message('validation', $lang['char_is_online']);
}
} else {
output_message('validation', $lang['char_name_exists']);
}
} else {
output_message('validation', $lang['not_enough_points']);
}
}
示例2: attack
/**
* @inheritdoc
*/
public function attack(Character $victim)
{
//shoots target
$victim->weaken(self::SHOOT_ATTACK_HP);
//performs default attack as well
$this->character->attack($victim);
return $this;
}
示例3: process_remove_character
function process_remove_character($char_id)
{
$character = new Character($char_id);
if ($character->SetCampaign(null)) {
return "Removed character " . $character->cname . ".";
}
return "Unable to remove character " . $character->cname . ".";
}
示例4: process_accept_join
function process_accept_join(&$campaign, $char_id)
{
$character = new Character($char_id);
$character->RemoveJoinRequest();
if ($character->SetCampaign($campaign->id)) {
return "Character " . $character->cname . " added to campaign.";
}
return "Unable to add character " . $character->cname . " to campaign.";
}
示例5: actionPvpCurrent
public function actionPvpCurrent($realm)
{
$model = new Character('pvp_current');
$model->unsetAttributes();
if (isset($_GET['Character'])) {
$model->attributes = $_GET['Character'];
}
$this->render('pvp', array('model' => $model, 'current' => true));
}
示例6: getRConfig
public static function getRConfig($param)
{
$model = new Character();
if ($model->getFConfig($param) == 1) {
return "<span class='yes'>" . Yii::t('' . Yii::app()->request->cookies['language']->value . '', 'Yes') . "</span>";
} else {
return "<span class='no'>" . Yii::t('' . Yii::app()->request->cookies['language']->value . '', 'No') . "</span>";
}
}
示例7: run
public function run()
{
$character = new Character();
$character->name = 'Ellerion';
$character->class = 'Mage';
$character->race = 'Human';
$character->realm = 'Darkspear';
$character->file = '';
$character->save();
}
示例8: max_damage
public function max_damage(Character $enemy = null)
{
$dam = 1 + $this->strength * 2 + $this->damage;
// Mirror some of their enemy's strength
if ($this->has_trait('partial_match_strength') && $enemy instanceof Character) {
$add = max(0, floor($enemy->strength() / 3));
// Enemy str/3 or at minimum 0
$dam = $dam + $add;
}
return $dam;
}
示例9: 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;
}
示例10: getChararcterById
public function getChararcterById($guid)
{
$this->db->select('name, race, class, gender, level, playerBytes, playerBytes2')->where('guid', $guid);
$query = $this->db->get('characters');
if ($query->rowCount() > 0) {
$row = $this->db->fetch($query);
$character = new Character($guid);
$character->setName($row->name)->setClass($row->class)->setGender($row->gender)->setRace($row->race)->setLevel($row->level);
return $character;
} else {
return NULL;
}
}
示例11: init
public static function init()
{
self::$classCRC32Cache = new IdentityHashMap();
self::$CLASS_TO_SERIALIZER_INSTANCE = new IdentityHashMap();
self::$NO_SUCH_SERIALIZER = new SerializabilityUtilEx_NoSuchSerializer();
self::$SERIALIZED_PRIMITIVE_TYPE_NAMES = new HashMap();
self::$TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES = new HashSet();
self::$SERIALIZED_PRIMITIVE_TYPE_NAMES->put(Boolean::typeClass()->getFullName(), "Z");
self::$SERIALIZED_PRIMITIVE_TYPE_NAMES->put(Byte::typeClass()->getFullName(), "B");
self::$SERIALIZED_PRIMITIVE_TYPE_NAMES->put(Character::typeClass()->getFullName(), "C");
self::$SERIALIZED_PRIMITIVE_TYPE_NAMES->put(Double::typeClass()->getFullName(), "D");
self::$SERIALIZED_PRIMITIVE_TYPE_NAMES->put(Float::typeClass()->getFullName(), "F");
self::$SERIALIZED_PRIMITIVE_TYPE_NAMES->put(Integer::typeClass()->getFullName(), "I");
self::$SERIALIZED_PRIMITIVE_TYPE_NAMES->put(Long::typeClass()->getFullName(), "J");
self::$SERIALIZED_PRIMITIVE_TYPE_NAMES->put(Short::typeClass()->getFullName(), "S");
self::$TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES->add(Boolean::clazz());
self::$TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES->add(Byte::clazz());
self::$TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES->add(Character::clazz());
self::$TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES->add(Double::clazz());
//TODO Exception class
//self::$TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES->add(Exception::clazz());
self::$TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES->add(Float::clazz());
self::$TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES->add(Integer::clazz());
self::$TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES->add(Long::clazz());
self::$TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES->add(Object::clazz());
self::$TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES->add(Short::clazz());
self::$TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES->add(String::clazz());
self::$TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES->add(Classes::classOf('Throwable'));
}
示例12: 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);
}
示例13: testContainsOnlyTheSpecifiedRange
public function testContainsOnlyTheSpecifiedRange()
{
$generator = Character::ascii();
$this->assertTrue($generator->contains(""));
$this->assertTrue($generator->contains("A"));
$this->assertTrue($generator->contains("b"));
$this->assertFalse($generator->contains("é"));
}
示例14: 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;
}
示例15: getFulfillers
/**
* Get a list of Fulfillers with API credentials.
*
* @return array
*/
protected function getFulfillers()
{
// Get all fulfillers who have API credentials.
$fulfillers = Character::whereNotNull('key_id')->whereNotNull('v_code')->whereHas('roles', function ($q) {
$q->where('name', '=', 'fulfiller');
})->get();
return $fulfillers;
}