Skip to content

Commit

Permalink
[493] Arena teams should be working now with refactored TrinityCore`s…
Browse files Browse the repository at this point in the history
… DB.
  • Loading branch information
Shadez committed Apr 8, 2011
1 parent bf3528d commit 6d45f12
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 48 deletions.
112 changes: 65 additions & 47 deletions includes/classes/class.arenateams.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @package World of Warcraft Armory
* @version Release 4.50
* @revision 485
* @revision 493
* @copyright (c) 2009-2011 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -37,6 +37,11 @@
public $players;
public $guid;
private $gameid = false;
private $m_server;

public function Arenateams() {
$this->m_server = Armory::$currentRealmInfo['type'];
}

/**
* Builds team info
Expand All @@ -50,10 +55,20 @@ public function InitTeam() {
return false;
}
if($this->teamname != null) {
$arenaInfo = Armory::$cDB->selectRow("SELECT `arenateamid`, `captainguid`, `type`, `name` FROM `arena_team` WHERE `name`='%s' LIMIT 1", $this->teamname);
if($this->m_server == SERVER_MANGOS) {
$arenaInfo = Armory::$cDB->selectRow("SELECT `arenateamid`, `captainguid`, `type`, `name` FROM `arena_team` WHERE `name` = '%s' LIMIT 1", $this->teamname);
}
else {
$arenaInfo = Armory::$cDB->selectRow("SELECT `arenaTeamId` AS `arenateamid`, `captainGuid` AS `captainguid`, `type`, `name` FROM `arena_team` WHERE `name` = '%s' LIMIT 1", $this->teamname);
}
}
elseif($this->arenateamid != 0) {
$arenaInfo = Armory::$cDB->selectRow("SELECT `arenateamid`, `captainguid`, `type`, `name` FROM `arena_team` WHERE `arenateamid`='%d' LIMIT 1", $this->arenateamid);
if ($this->m_server == SERVER_MANGOS) {
$arenaInfo = Armory::$cDB->selectRow("SELECT `arenateamid`, `captainguid`, `type`, `name` FROM `arena_team` WHERE `arenateamid` = %d LIMIT 1", $this->arenateamid);
}
else {
$arenaInfo = Armory::$cDB->selectRow("SELECT `arenaTeamId` AS `arenateamid`, `captainGuid` AS `captainguid`, `type`, `name` FROM `arena_team` WHERE `arenaTeamId` = %d LIMIT 1", $this->arenateamid);
}
}
if(!$arenaInfo || !isset($arenaInfo)) {
Armory::Log()->writeError('%s : unable to find arenateam %s (id: %d)!', __METHOD__, $this->teamname, $this->arenateamid);
Expand All @@ -80,25 +95,33 @@ public function GetArenaTeamInfo() {
return false;
}
$arenateaminfo = array();
switch(Armory::$currentRealmInfo['type']) {
switch($this->m_server) {
case SERVER_MANGOS:
$sql = "
`games_week` AS `gamesPlayed`,
`wins_week` AS `gamesWon`,
`rank` AS `ranking`,
$arenateaminfo['data'] = Armory::$cDB->selectRow("
SELECT
`rating`,
`games_week` AS `gamesPlayed`,
`wins_week` AS `gamesWon`,
`rank` AS `ranking`,
`games_season` AS `seasonGamesPlayed`,
`wins_season` AS `seasonGamesWon`";
`wins_season` AS `seasonGamesWon`
FROM `arena_team_stats`
WHERE `arenateamid`=%d", $this->arenateamid);
break;
case SERVER_TRINITY:
$sql = "
`games` AS `gamesPlayed`,
`wins` AS `gamesWon`,
`rank` AS `ranking`,
`played` AS `seasonGamesPlayed`,
`wins2` AS `seasonGamesWon`";
$arenateaminfo['data'] = Armory::$cDB->selectRow("
SELECT
`rating`,
`weekGames` AS `gamesPlayed`,
`weekWeens` AS `gamesWon`,
`rank` AS `ranking`,
`seasonGames` AS `seasonGamesPlayed`,
`seasonWins` AS `seasonGamesWon`
FROM `arena_team`
WHERE `arenateamid`=%d", $this->arenateamid);
$sql = "";
break;
}
$arenateaminfo['data'] = Armory::$cDB->selectRow("SELECT `rating`, %s FROM `arena_team_stats` WHERE `arenateamid`=%d", $sql, $this->arenateamid);
if(!$arenateaminfo['data']) {
Armory::Log()->writeError('%s : unable to get data from DB for arenateam %d (%s)', __METHOD__, $this->arenateamid, $this->teamname);
return false;
Expand Down Expand Up @@ -177,7 +200,7 @@ public function GetCharacterArenaTeamInfo() {
* @return bool
**/
public function GetTeamList() {
if(Armory::$currentRealmInfo['type'] == SERVER_MANGOS) {
if($this->m_server == SERVER_MANGOS) {
$this->players = Armory::$cDB->select("
SELECT
`arena_team_member`.`played_season` AS `seasonGamesPlayed`,
Expand All @@ -192,7 +215,7 @@ public function GetTeamList() {
LEFT JOIN `characters` AS `characters` ON `characters`.`guid`=`arena_team_member`.`guid`
WHERE `arena_team_member`.`arenateamid`=%d", $this->arenateamid);
}
elseif(Armory::$currentRealmInfo['type'] == SERVER_TRINITY) {
elseif($this->m_server == SERVER_TRINITY) {
switch($this->teamtype) {
case 2:
default:
Expand All @@ -207,9 +230,9 @@ public function GetTeamList() {
}
$this->players = Armory::$cDB->select("
SELECT
`arena_team_member`.`played_season` AS `seasonGamesPlayed`,
`arena_team_member`.`wons_season` AS `seasonGamesWon`,
`character_arena_stats`.`personal_rating` AS `contribution`,
`arena_team_member`.`seasonGames` AS `seasonGamesPlayed`,
`arena_team_member`.`seasonWins` AS `seasonGamesWon`,
`character_arena_stats`.`personalRating` AS `contribution`,
`characters`.`guid`,
`characters`.`name`,
`characters`.`race` AS `raceId`,
Expand All @@ -218,8 +241,8 @@ public function GetTeamList() {
FROM `arena_team_member` AS `arena_team_member`
LEFT JOIN `characters` AS `characters` ON `characters`.`guid`=`arena_team_member`.`guid`
LEFT JOIN `character_arena_stats` AS `character_arena_stats` ON `character_arena_stats`.`guid`=`arena_team_member`.`guid`
WHERE `arena_team_member`.`arenateamid`=%d
AND `character_arena_stats`.`slot`=%d", $this->arenateamid, $slot);
WHERE `arena_team_member`.`arenateamid` = %d
AND `character_arena_stats`.`slot` = %d", $this->arenateamid, $slot);
}
if(!$this->players) {
Armory::Log()->writeLog('%s : unable to get player list for arena team %d (%s)', __METHOD__, $this->arenateamid, $this->teamname);
Expand Down Expand Up @@ -254,7 +277,7 @@ public function BuildArenaLadderList($type, $page, $num = false, $order = 'ratin
foreach(Armory::$realmData as $realm_info) {
$db = new ArmoryDatabaseHandler($realm_info['host_characters'], $realm_info['user_characters'], $realm_info['pass_characters'], $realm_info['name_characters'], $realm_info['charset_characters']);
$current_count = $db->selectCell("SELECT COUNT(`arena_team`.`arenateamid`) FROM `arena_team` AS `arena_team` LEFT JOIN `arena_team_stats` AS `arena_team_stats` ON `arena_team_stats`.`arenateamid` = `arena_team`.`arenateamid` WHERE `arena_team`.`type` = %d AND `arena_team_stats`.`rank` > 0", $type);
$summary = $current_count+$summary;
$summary += $current_count;
}
return $summary;
}
Expand Down Expand Up @@ -288,16 +311,16 @@ public function BuildArenaLadderList($type, $page, $num = false, $order = 'ratin
case SERVER_TRINITY:
$realmArenaTeamInfo = $db->select("
SELECT
`arena_team`.`arenateamid`,
`arena_team`.`arenaTeamId` AS `arenateamid`,
`arena_team`.`name`,
`arena_team_stats`.`rating`,
`arena_team_stats`.`games` AS `gamesPlayed`,
`arena_team_stats`.`wins` AS `gamesWon`,
`arena_team_stats`.`rank` AS `ranking`,
`arena_team_stats`.`played` AS `seasonGamesPlayed`,
`arena_team_stats`.`wins2` AS `seasonGamesWon`,
`arena_team_stats`.`weekGames` AS `gamesPlayed`,
`arena_team_stats`.`weekWins` AS `gamesWon`,
`arena_team_stats`.`rank` AS `ranking`,
`arena_team_stats`.`seasonGames` AS `seasonGamesPlayed`,
`arena_team_stats`.`seasonWins` AS `seasonGamesWon`,
`characters`.`race`,
`arena_team_stats`.`played`-`arena_team_stats`.`wins2` AS `lose`
`arena_team_stats`.`seasonGames`-`arena_team_stats`.`seasonWins` AS `lose`
FROM `arena_team` AS `arena_team`
LEFT JOIN `arena_team_stats` AS `arena_team_stats` ON `arena_team_stats`.`arenateamid`=`arena_team`.`arenateamid`
LEFT JOIN `characters` AS `characters` ON `characters`.`guid`=`arena_team`.`captainguid`
Expand All @@ -322,35 +345,31 @@ public function BuildArenaLadderList($type, $page, $num = false, $order = 'ratin
`arena_team_stats`.`wins_season` AS `seasonGamesWon`,
`characters`.`race`
FROM `arena_team` AS `arena_team`
LEFT JOIN `arena_team_stats` AS `arena_team_stats` ON `arena_team_stats`.`arenateamid`=`arena_team`.`arenateamid`
LEFT JOIN `characters` AS `characters` ON `characters`.`guid`=`arena_team`.`captainguid`
LEFT JOIN `arena_team_stats` AS `arena_team_stats` ON `arena_team_stats`.`arenateamid`=`arena_team`.`arenaTeamId`
LEFT JOIN `characters` AS `characters` ON `characters`.`guid`=`arena_team`.`captainGuid`
WHERE `arena_team`.`type`=%d AND `arena_team_stats`.`rank` > 0
ORDER BY %s %s LIMIT %d, 20", $type, $order, $sort, $page);
break;
case SERVER_TRINITY:
$realmArenaTeamInfo = $db->select("
SELECT
`arena_team`.`arenateamid`,
`arena_team`.`arenaTeamId` AS `arenateamid`,
`arena_team`.`name`,
`arena_team_stats`.`rating`,
`arena_team_stats`.`games` AS `gamesPlayed`,
`arena_team_stats`.`wins` AS `gamesWon`,
`arena_team_stats`.`rank` AS `ranking`,
`arena_team_stats`.`played` AS `seasonGamesPlayed`,
`arena_team_stats`.`wins2` AS `seasonGamesWon`,
`arena_team_stats`.`weekGames` AS `gamesPlayed`,
`arena_team_stats`.`weekWins` AS `gamesWon`,
`arena_team_stats`.`rank` AS `ranking`,
`arena_team_stats`.`seasonGames` AS `seasonGamesPlayed`,
`arena_team_stats`.`seasonWins` AS `seasonGamesWon`,
`characters`.`race`
FROM `arena_team` AS `arena_team`
LEFT JOIN `arena_team_stats` AS `arena_team_stats` ON `arena_team_stats`.`arenateamid`=`arena_team`.`arenateamid`
LEFT JOIN `characters` AS `characters` ON `characters`.`guid`=`arena_team`.`captainguid`
LEFT JOIN `arena_team_stats` AS `arena_team_stats` ON `arena_team_stats`.`arenateamid`=`arena_team`.`arenaTeamId`
LEFT JOIN `characters` AS `characters` ON `characters`.`guid`=`arena_team`.`captainGuid`
WHERE `arena_team`.`type`=%d AND `arena_team_stats`.`rank` > 0
ORDER BY %s %s LIMIT %d, 20", $type, $order, $sort, $page);
break;
}
}
if(!$realmArenaTeamInfo || !is_array($realmArenaTeamInfo)) {
Armory::Log()->writeLog('%s : loop finished, no arena teams found (order: %s, type: %d, page: %d, sort: %s, db_name: %s).', __METHOD__, $order, $type, $page, $sort, $realm_info['name_characters']);
continue;
}
foreach($realmArenaTeamInfo as $team) {
$result_areanteams[$i]['data'] = $team;
$result_areanteams[$i]['data']['num'] = $i+1;
Expand All @@ -371,7 +390,6 @@ public function BuildArenaLadderList($type, $page, $num = false, $order = 'ratin
}
}
if(!isset($result_areanteams[0]['data'])) {
Armory::Log()->writeLog('%s : unable to find any arena teams', __METHOD__);
return false;
}
return $result_areanteams;
Expand Down Expand Up @@ -575,7 +593,7 @@ public function TeamExists($teamId) {
**/
public function BuildGameChart() {
if(!$this->arenateamid) {
Armory::Log()->writeError('%s : arenateamid not provided', __METHOD__);
Armory::Log()->writeError('%s : arenateamid was not provided', __METHOD__);
return false;
}
$game_ids = Armory::$cDB->select("SELECT DISTINCT `gameid` FROM `armory_game_chart` WHERE `teamid`=%d", $this->arenateamid);
Expand Down
2 changes: 1 addition & 1 deletion includes/revision_nr.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
define('ARMORY_REVISION', 492);
define('ARMORY_REVISION', 493);
define('DB_VERSION', 'armory_r489');
define('CONFIG_VERSION', '2001201101');
?>

2 comments on commit 6d45f12

@kliver
Copy link

@kliver kliver commented on 6d45f12 Apr 8, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New TrintityCore Commit... TrinityCore/TrinityCore@7935c2f

@Shadez
Copy link
Owner Author

@Shadez Shadez commented on 6d45f12 Apr 9, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What a hell is going on..
Updated in [495], thank you!

Please sign in to comment.