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']); } }
/** * @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; }
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 . "."; }
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."; }
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)); }
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>"; } }
public function run() { $character = new Character(); $character->name = 'Ellerion'; $character->class = 'Mage'; $character->race = 'Human'; $character->realm = 'Darkspear'; $character->file = ''; $character->save(); }
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; }
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; }
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; } }
public function __construct(\Database\Table $table, $name, $length = 255) { parent::__construct($table, $name); $this->size->setRange(0, 255); $this->setSize($length); $this->default->setLimit($length); }
public function play() { parent::play(); # Est protégé contre le Condottiere # Ses quartier religieux raportent $this->districtGold($this->player); }
public function play() { parent::play(); # Détruit un quartier # Ses quartiers militaires rapportent $this->districtGold($this->player); }
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')); }
public function __construct($hp, $dmg, $armour) { parent::__construct(); $this->hp = $hp; $this->dmg = $dmg; $this->armour = $armour; }
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); }
public function testContainsOnlyTheSpecifiedRange() { $generator = Character::ascii(); $this->assertTrue($generator->contains("")); $this->assertTrue($generator->contains("A")); $this->assertTrue($generator->contains("b")); $this->assertFalse($generator->contains("é")); }
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; }
/** * 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; }
public function play() { parent::play(); # Gagne une pièce d'or $this->player->gold++; # Ses quartier marchands raportent $this->districtGold($this->player); }
/** * Check WalletJournal for new deposits and save to storage. * * @param int $lastRefID The last entry on a page of the WalletJournal, used to find the start of the next page. * @return void */ protected function saveNewDeposits($lastRefID = null) { // Setup PhealNG and make a call to the Corporation's WalletJournal endpoint to grab some entries. Config::get('phealng'); $pheal = new Pheal(Config::get('phealng.keyID'), Config::get('phealng.vCode')); $query = $pheal->corpScope->WalletJournal(array('fromID' => $lastRefID)); // Allow mass assignment so we can add records to our secure Deposit model. Eloquent::unguard(); // Create an empty array to store RefIDs (so that we can find the lowest one later). $refIDs = array(); foreach ($query->entries as $entry) { // Store all refIDs, even those that aren't related Player Donations. array_push($refIDs, $entry->refID); // Only check Player Donations. if ($entry->refTypeID == 10) { // If the Character doesn't already exist in our storage, let's add it. $character = Character::firstOrNew(array('id' => $entry->ownerID1, 'name' => $entry->ownerName1)); if (empty($character['original'])) { $this->newCharacters++; } // If the refID exists in storage, ignore that entry. Otherwise, save it. $deposit = Deposit::firstOrNew(array('ref_id' => $entry->refID)); if (empty($deposit['original'])) { $deposit->depositor_id = $entry->ownerID1; $deposit->amount = $entry->amount; $deposit->reason = trim($entry->reason); $deposit->sent_at = $entry->date; // Now that we know if the Deposit is new or not, we can se the Character's updated balance. $character->balance = $character->balance + $entry->amount; if ($character->save() && $deposit->save()) { $this->newDeposits++; $this->iskAdded += $entry->amount; } } else { if (!empty($deposit['original'])) { $this->existingDeposits++; } } } else { $this->nonDeposits++; } } // Recurse through the function, using a new starting point each time. When the API stops returning entries min // will throw an ErrorException. Instead of returning the Exception, we return a report and save it to the log. try { $this->saveNewDeposits(min($refIDs)); } catch (Exception $e) { $output = "Unrelated entries ignored: " . $this->nonDeposits . "\n"; $output .= "Existing Deposits ignored: " . $this->existingDeposits . "\n"; $output .= "New Deposits saved: " . $this->newDeposits . "\n"; $output .= "New (inactive) Characters added: " . $this->newCharacters . "\n"; $output .= "Total deposited since last fetch: " . $this->iskAdded . " isk\n"; Log::info($output); echo $output; } }
protected function tearDown() { CharClass::deleteAll(); Character::deleteAll(); Race::deleteAll(); Skill::deleteAll(); Stat::deleteAll(); Description::deleteAll(); Background::deleteAll(); }
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; }
public static function init() { self::$TYPE_NAMES[' Z'] = Boolean::typeClass(); self::$TYPE_NAMES[' B'] = Byte::typeClass(); self::$TYPE_NAMES[' C'] = Character::typeClass(); self::$TYPE_NAMES[' D'] = Double::typeClass(); self::$TYPE_NAMES[' F'] = Float::typeClass(); self::$TYPE_NAMES[' I'] = Integer::typeClass(); self::$TYPE_NAMES[' J'] = Long::typeClass(); self::$TYPE_NAMES[' S'] = Short::typeClass(); }
public static function getAChars($acc) { $chars = Character::model()->findAll(array('select' => 'Name', 'condition' => 'AccountID=:memb___id', 'params' => array(':memb___id' => $acc))); foreach ($chars as $key => $char) { if ($key + 1 != sizeof($chars)) { echo CHtml::link($char->Name, array('char', 'id' => $char->Name), array('class' => 'char-link', 'title' => $char->Name)) . ', '; } else { echo CHtml::link($char->Name, array('char', 'id' => $char->Name), array('class' => 'char-link', 'title' => $char->Name)); } } }
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.']); } }
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'); }
function reCustomize() { global $Config, $DB, $lang, $user; include 'core/SDL/class.character.php'; $Character = new Character(); if ($Config->get('module_charcustomize') == 0) { output_message('error', 'Nice try hacking, but not good enough.'); return FALSE; } // Check to see the user has enough points if ($user['web_points'] >= $Config->get('module_charcustomize_pts')) { if ($Character->setCustomize($_POST['id']) == TRUE) { $DB->query("UPDATE `mw_account_extend` SET \n\t\t\t\t`web_points`=(`web_points` - " . $Config->get('module_charcustomize_pts') . "), \n\t\t\t\t`points_spent`=(`points_spent` + " . $Config->get('module_charcustomize_pts') . ") \n\t\t\t WHERE `account_id` = " . $user['id'] . " LIMIT 1"); output_message('success', $lang['char_recustomize_success']); echo "<br /><br />"; } else { output_message('warning', $lang['char_recustomize_already_set']); echo "<br /><br />"; } } else { output_message('validation', $lang['not_enough_points']); } }
function import() { try { $page = isset($_GET['page']) ? $_GET['page'] : null; if ($page == 0) { del_feature(); } $results = get_writing($page); $size = sizeof($results); foreach ($results as $r) { $f = new Feature(); $w = json_decode($r->writing); $char_id = $r->char_id; $features = $f->make_feature($w); //获取特征 $dic = new Dictionary(); $dict_feature = $dic->get_feature($char_id); //获取数据库中已存的特征值 $dict_feature = isset($dict_feature) ? json_decode($dict_feature) : null; $t = new Trainer(); $t->train($features, $dict_feature); $c = new Character(); $first_stroke_type = $c->get_first_stroke_type($w); //首笔的笔画类型(横竖撇点折) $int_strokes = sizeof($w->s); //笔画数 $dic->update_character($char_id, json_encode($t->train_features), $int_strokes, $first_stroke_type); } if ($size > 0) { echo "<meta HTTP-EQUIV=REFRESH CONTENT='5;URL=import.php?page=" . ($page + 1) . "'>"; } else { echo "导入完成"; } } catch (Exception $e) { echo $e->getMessage(); } }
public function play() { parent::play(); # Devient le premier joueur $game = Game::getGame(); foreach ($game->players as $playerTmp) { $playerTmp->crown = false; if ($playerTmp->character instanceof self) { $player = $playerTmp; $playerTmp->crown = true; } } # Ses quartiers nobles raportent $this->districtGold($this->player); }