Example #1
0
 public function WoW_ArenaTeam($realmID, $teamName, $teamID = 0)
 {
     if (!isset(WoWConfig::$Realms[$realmID])) {
         WoW_Log::WriteError('%s : realm %d was not found!', __METHOD__, $realmID);
         return false;
     }
     if (!$teamName && $teamID <= 0) {
         WoW_Log::WriteError('%s : teamName must be a string!', __METHOD__);
         return false;
     } elseif ($teamID > 0 && !$this->IsDBTeam($teamID)) {
         WoW_Log::WriteError('%s : team #%d was not found in DB!', __METHOD__, $teamID);
         return false;
     }
     DB::ConnectToDB(DB_CHARACTERS, $realmID);
     if (!DB::Characters()->TestLink()) {
         return false;
     }
     $this->m_teamId = $teamID;
     $this->m_teamName = $teamName;
     $this->m_realmId = $realmID;
     $this->m_realmName = WoWConfig::$Realms[$realmID]['name'];
     if ($this->m_teamId == 0) {
         $this->m_teamId = DB::Characters()->selectCell("SELECT `arenateamid` FROM `arena_team` WHERE `name` = '%s'", $this->m_teamName);
     }
     $this->LoadTeam();
 }
 public function GetTopTeams($format, $bg_id, $limit = 3, $offset = 0, $count = false)
 {
     if (!isset(WoWConfig::$BattleGroups[$bg_id])) {
         WoW_Log::WriteError('%s : battleGroupd #%d was not found!', __METHOD__, $bg_id);
         return false;
     }
     $realms = WoWConfig::$BattleGroups[$bg_id]['realms'];
     if (!$realms) {
         WoW_Log::WriteError('%s : no realms found for battleGroup #%d, using first available bg instead.', __METHOD__, $bg_id);
         $realms = WoWConfig::$BattleGroups[1]['realms'];
         if (!$realms) {
             WoW_Log::WriteError('%s : default BG has no realms, unable to continue.', __METHOD__);
             return false;
         }
     }
     $top_teams_data = array();
     $counter = 0;
     foreach ($realms as $realmId) {
         DB::ConnectToDB(DB_CHARACTERS, $realmId);
         if (!DB::Characters()->TestLink()) {
             continue;
         }
         if (WoW::GetServerType($realmId) == SERVER_MANGOS) {
             if ($count) {
                 $counter += DB::Characters()->selectCell("\n                    SELECT COUNT(*)\n                    FROM `arena_team` AS `a`\n                    LEFT JOIN `arena_team_stats` AS `b` ON `b`.`arenateamid` = `a`.`arenateamid`\n                    WHERE `a`.`type` = %d\n                    AND `b`.`rank` > 0 AND `b`.`rank` < 4", $format);
                 continue;
             }
             $teams = DB::Characters()->select("SELECT\n                `a`.`arenateamid` AS `id`,\n                `a`.`rank`,\n                `a`.`rating`,\n                '%d' AS `realmId`,\n                `b`.`type`\n                FROM `arena_team_stats` AS `a`\n                LEFT JOIN `arena_team` AS `b` ON `b`.`arenateamid` = `a`.`arenateamid`\n                WHERE `a`.`rank` > 0 AND `a`.`rank` < 4 AND `b`.`type` = %d ORDER BY `rank`, `rating` LIMIT %d, %d", $realmId, $format, $offset, $limit);
         } else {
             $teams = DB::Characters()->select("SELECT `arenaTeamId` AS `id`, `rank`, `rating`, '%d' AS `realmId`, `type` FROM `arena_team` WHERE `rank` > 0 AND `rank` < 4 AND `type` = %d ORDER BY `rank`, `rating` LIMIT %d, %d", $realmId, $format, $offset, $limit);
         }
         if (!$teams) {
             continue;
         }
         $top_teams_data[] = array('realmId' => $realmId, 'teamsId' => $teams);
     }
     if ($count) {
         return $counter;
     }
     // Find top 3 teams
     $top_teams = array();
     foreach ($top_teams_data as &$teams) {
         foreach ($teams['teamsId'] as &$team) {
             if (!isset($top_teams[$team['rank']])) {
                 $top_teams[$team['rank']] = $team;
             }
             if ($top_teams[$team['rank']]['rating'] < $team['rating']) {
                 $top_teams[$team['rank']] = $team;
             }
         }
     }
     // Create objects
     $top_teams_objects = array();
     foreach ($top_teams as &$team) {
         $top_teams_objects[] = new WoW_ArenaTeam($team['realmId'], '', $team['id']);
     }
     unset($top_teams, $top_teams_data, $team, $teams);
     return $top_teams_objects;
 }
Example #3
0
 public static function InitAuction()
 {
     if (!WoW_Account::IsLoggedIn()) {
         return false;
     }
     self::$active_guid = WoW_Account::GetActiveCharacterInfo('guid');
     if (self::$active_guid == 0) {
         return false;
     }
     self::$active_realm = WoW_Account::GetActiveCharacterInfo('realmId');
     self::$auction_initialized = true;
     DB::ConnectToDB(DB_CHARACTERS, self::$active_realm);
     self::$money_amount = DB::Characters()->selectCell("SELECT `money` FROM `characters` WHERE `guid` = %d", self::$active_guid);
     self::$won_money_amount = 0;
     self::LoadMyAuctions();
     self::LoadAuctionMails();
     self::HandleAuctionData();
     self::HandleSellingItems();
 }
Example #4
0
 public function GetTopTeams($format, $bg_id)
 {
     if (!isset(WoWConfig::$BattleGroups[$bg_id])) {
         WoW_Log::WriteError('%s : battleGroupd #%d was not found!', __METHOD__, $bg_id);
         return false;
     }
     $realms = WoWConfig::$BattleGroups[$bg_id]['realms'];
     if (!$realms) {
         WoW_Log::WriteError('%s : no realms found for battleGroup #%d, using first available bg instead.', __METHOD__, $bg_id);
         $realms = WoWConfig::$BattleGroups[1]['realms'];
         if (!$realms) {
             WoW_Log::WriteError('%s : default BG has no realms, unable to continue.', __METHOD__);
             return false;
         }
     }
     $top_teams_data = array();
     foreach ($realms as $realmId) {
         DB::ConnectToDB(DB_CHARACTERS, $realmId);
         if (!DB::Characters()->TestLink()) {
             continue;
         }
         $teams = DB::Characters()->select("SELECT `%s`, `rank`, `rating` FROM `arena_team` ORDER BY `rank` LIMIT 3", WoW::GetServerType($realmId) == SERVER_MANGOS ? 'arenateamid' : 'arenaTeamId');
         if (!$teams) {
             continue;
         }
         $top_teams_data[] = array('realmId' => $realmId, 'teamsId' => $teams);
     }
     // Find top 3 teams
     foreach ($top_teams_data as &$teams) {
         foreach ($teams['teamsId'] as &$team) {
             if (!isset($top_teams[$team['rank']])) {
                 $top_teams[$team['rank']] = $team;
             }
             if ($top_teams[$team['rank']]['rating'] < $team['rating']) {
                 $top_teams[$team['rank']] = $team;
             }
         }
     }
     print_r($top_teams);
 }
 public static function InitStatSystem()
 {
     if (!WoW_Characters::IsCorrect()) {
         WoW_Log::WriteError('%s : character was not found!', __METHOD__);
         return false;
     }
     DB::ConnectToDB(DB_CHARACTERS, WoW_Characters::GetRealmID());
     self::$stats_loaded = false;
     self::$m_attackTimer[BASE_ATTACK] = 0;
     self::$m_attackTimer[OFF_ATTACK] = 0;
     self::$m_attackTimer[RANGED_ATTACK] = 0;
     self::$m_modAttackSpeedPct[BASE_ATTACK] = 1.0;
     self::$m_modAttackSpeedPct[OFF_ATTACK] = 1.0;
     self::$m_modAttackSpeedPct[RANGED_ATTACK] = 1.0;
     for ($i = 0; $i < UNIT_MOD_END; ++$i) {
         self::$m_auraModifiersGroup[$i][BASE_VALUE] = 0.0;
         self::$m_auraModifiersGroup[$i][BASE_PCT] = 1.0;
         self::$m_auraModifiersGroup[$i][TOTAL_VALUE] = 0.0;
         self::$m_auraModifiersGroup[$i][TOTAL_PCT] = 1.0;
     }
     // implement 50% base damage from offhand
     self::$m_auraModifiersGroup[UNIT_MOD_DAMAGE_OFFHAND][TOTAL_PCT] = 0.5;
     for ($i = 0; $i < MAX_ATTACK; ++$i) {
         self::$m_weaponDamage[$i][MINDAMAGE] = BASE_MINDAMAGE;
         self::$m_weaponDamage[$i][MAXDAMAGE] = BASE_MAXDAMAGE;
     }
     for ($i = 0; $i < MAX_STATS; ++$i) {
         self::$m_createStats[$i] = 0;
     }
     self::$m_modMeleeHitChance = 0.0;
     self::$m_modRangedHitChance = 0.0;
     self::$m_modSpellHitChance = 0.0;
     self::$m_baseSpellCritChance = 5;
     for ($i = CR_WEAPON_SKILL; $i < MAX_COMBAT_RATING; ++$i) {
         self::$m_baseRatingValue[$i] = 0;
     }
     self::LoadInitialStats();
     self::LoadPlayerStats();
     self::HandleStats();
 }
Example #6
0
 /**
  * Loads friends list for active (primary) character
  * 
  * @access   public
  * @static   WoW_Account::LoadFriendsListForPrimaryCharacter()
  * @category Account Manager Class
  * @return   bool
  **/
 private static function LoadFriendsListForPrimaryCharacter()
 {
     if (!self::GetSessionInfo('wow_sid')) {
         return false;
     }
     if (!self::IsHaveActiveCharacter()) {
         return false;
     }
     if (self::$friends_data) {
         return true;
     }
     if (!self::IsCharactersLoaded()) {
         if (!self::LoadCharacters()) {
             return false;
         }
     }
     DB::ConnectToDB(DB_CHARACTERS, self::GetActiveCharacterInfo('realmId') | 1);
     self::$friends_data = DB::Characters()->select("\n        SELECT\n        `character_social`.`friend`,\n        `characters`.`guid`,\n        `characters`.`name`,\n        `characters`.`race` AS `race_id`,\n        `characters`.`class` AS `class_id`,\n        `characters`.`gender`,\n        `characters`.`level`\n         FROM `character_social`\n         JOIN `characters` ON `characters`.`guid` = `character_social`.`friend`\n         WHERE `character_social`.`guid` = %d", self::GetActiveCharacterInfo('guid'));
     return true;
 }
 private static function LoadProfessions()
 {
     if (!self::IsCorrect()) {
         WoW_Log::WriteError('%s : guild was not found.', __METHOD__);
         return false;
     }
     $skills_professions = array(SKILL_BLACKSMITHING, SKILL_LEATHERWORKING, SKILL_ALCHEMY, SKILL_HERBALISM, SKILL_MINING, SKILL_TAILORING, SKILL_ENGINERING, SKILL_ENCHANTING, SKILL_SKINNING, SKILL_JEWELCRAFTING, SKILL_INSCRIPTION);
     DB::ConnectToDB(DB_CHARACTERS, self::$guild_realmID, true, false);
     if (!DB::Characters()->TestLink()) {
         return false;
     }
     self::$guild_professions = DB::Characters()->select("SELECT * FROM `character_skills` WHERE `guid` IN (%s) AND `skill` IN (%s)", self::GetGuildMembersGUIDs(), $skills_professions);
     if (!is_array(self::$guild_professions)) {
         WoW_Log::WriteError('%s : no professions were found for guild %s (GUILDID: %d).', __METHOD__, self::GetGuildName(), self::GetGuildID());
         return false;
     }
     return true;
 }
 public static function PerformArenaTeamsSearch($limit = 0)
 {
     if (!self::$searchQuery) {
         return false;
     }
     $results = array();
     foreach (WoWConfig::$Realms as $realm) {
         DB::ConnectToDB(DB_CHARACTERS, $realm['id']);
         $current_result = DB::Characters()->select("\n            SELECT\n            `arena_team`.`arenateamid`,\n            `arena_team`.`name`,\n            `arena_team`.`captainguid`,\n            `arena_team`.`type`,\n            `arena_team_stats`.`rating`,\n            `characters`.`race` AS `raceId`\n            FROM `arena_team`\n            JOIN `characters` ON `characters`.`guid` = `arena_team`.`captainguid`\n            JOIN `arena_team_stats` ON `arena_team_stats`.`arenateamid` = `arena_team`.`arenateamid`\n            WHERE `arena_team`.`name` = '%s'%s\n            ", self::GetSearchQuery(), $limit > 0 ? ' LIMIT ' . $limit : null);
         if (!$current_result) {
             continue;
         }
         foreach ($current_result as $res) {
             $results[] = $res;
         }
     }
     return self::SetSearchResults('wowarenateam', $results);
 }
 public static function IsCorrect()
 {
     if (DB::Characters()->GetDatabaseInfo('hash') != self::$m_dbHash) {
         // Reconnect
         DB::ConnectToDB(DB_CHARACTERS, self::GetRealmID());
     }
     return self::$name != null && self::$guid > 0;
 }