More refactoring of code.
This commit is contained in:
@@ -116,7 +116,7 @@ namespace Game.BattleGrounds
|
||||
_ProcessOfflineQueue();
|
||||
_ProcessPlayerPositionBroadcast(diff);
|
||||
// after 47 Time.Minutes without one team losing, the arena closes with no winner and no rating change
|
||||
if (isArena())
|
||||
if (IsArena())
|
||||
{
|
||||
if (GetElapsedTime() >= 47 * Time.Minute * Time.InMilliseconds)
|
||||
{
|
||||
@@ -298,7 +298,7 @@ namespace Game.BattleGrounds
|
||||
EndBattleground(GetPrematureWinner());
|
||||
m_PrematureCountDown = false;
|
||||
}
|
||||
else if (!Global.BattlegroundMgr.isTesting())
|
||||
else if (!Global.BattlegroundMgr.IsTesting())
|
||||
{
|
||||
uint newtime = m_PrematureCountDownTimer - diff;
|
||||
// announce every Time.Minute
|
||||
@@ -324,7 +324,7 @@ namespace Game.BattleGrounds
|
||||
// *********************************************************
|
||||
ModifyStartDelayTime((int)diff);
|
||||
|
||||
if (!isArena())
|
||||
if (!IsArena())
|
||||
SetRemainingTime(300000);
|
||||
|
||||
if (m_ResetStatTimer > 5000)
|
||||
@@ -341,7 +341,7 @@ namespace Game.BattleGrounds
|
||||
// Send packet every 10 seconds until the 2nd field reach 0
|
||||
if (m_CountdownTimer >= 10000)
|
||||
{
|
||||
uint countdownMaxForBGType = isArena() ? BattlegroundConst.ArenaCountdownMax : BattlegroundConst.BattlegroundCountdownMax;
|
||||
uint countdownMaxForBGType = IsArena() ? BattlegroundConst.ArenaCountdownMax : BattlegroundConst.BattlegroundCountdownMax;
|
||||
|
||||
StartTimer timer = new StartTimer();
|
||||
timer.Type = TimerType.Pvp;
|
||||
@@ -409,7 +409,7 @@ namespace Game.BattleGrounds
|
||||
SetStartDelayTime(StartDelayTimes[BattlegroundConst.EventIdFourth]);
|
||||
|
||||
// Remove preparation
|
||||
if (isArena())
|
||||
if (IsArena())
|
||||
{
|
||||
//todo add arena sound PlaySoundToAll(SOUND_ARENA_START);
|
||||
foreach (var guid in GetPlayers().Keys)
|
||||
@@ -655,7 +655,7 @@ namespace Game.BattleGrounds
|
||||
|
||||
if (winner == Team.Alliance)
|
||||
{
|
||||
if (isBattleground())
|
||||
if (IsBattleground())
|
||||
SendBroadcastText(BattlegroundBroadcastTexts.AllianceWins, ChatMsg.BgSystemNeutral);
|
||||
|
||||
PlaySoundToAll((uint)BattlegroundSounds.AllianceWins);
|
||||
@@ -663,7 +663,7 @@ namespace Game.BattleGrounds
|
||||
}
|
||||
else if (winner == Team.Horde)
|
||||
{
|
||||
if (isBattleground())
|
||||
if (IsBattleground())
|
||||
SendBroadcastText(BattlegroundBroadcastTexts.HordeWins, ChatMsg.BgSystemNeutral);
|
||||
|
||||
PlaySoundToAll((uint)BattlegroundSounds.HordeWins);
|
||||
@@ -676,7 +676,7 @@ namespace Game.BattleGrounds
|
||||
|
||||
PreparedStatement stmt = null;
|
||||
ulong battlegroundId = 1;
|
||||
if (isBattleground() && WorldConfig.GetBoolValue(WorldCfg.BattlegroundStoreStatisticsEnable))
|
||||
if (IsBattleground() && WorldConfig.GetBoolValue(WorldCfg.BattlegroundStoreStatisticsEnable))
|
||||
{
|
||||
stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_PVPSTATS_MAXID);
|
||||
SQLResult result = DB.Characters.Query(stmt);
|
||||
@@ -722,7 +722,7 @@ namespace Game.BattleGrounds
|
||||
{
|
||||
//needed cause else in av some creatures will kill the players at the end
|
||||
player.CombatStop();
|
||||
player.GetHostileRefManager().deleteReferences();
|
||||
player.GetHostileRefManager().DeleteReferences();
|
||||
}
|
||||
|
||||
// remove temporary currency bonus auras before rewarding player
|
||||
@@ -732,7 +732,7 @@ namespace Game.BattleGrounds
|
||||
uint winnerKills = player.GetRandomWinner() ? WorldConfig.GetUIntValue(WorldCfg.BgRewardWinnerHonorLast) : WorldConfig.GetUIntValue(WorldCfg.BgRewardWinnerHonorFirst);
|
||||
uint loserKills = player.GetRandomWinner() ? WorldConfig.GetUIntValue(WorldCfg.BgRewardLoserHonorLast) : WorldConfig.GetUIntValue(WorldCfg.BgRewardLoserHonorFirst);
|
||||
|
||||
if (isBattleground() && WorldConfig.GetBoolValue(WorldCfg.BattlegroundStoreStatisticsEnable))
|
||||
if (IsBattleground() && WorldConfig.GetBoolValue(WorldCfg.BattlegroundStoreStatisticsEnable))
|
||||
{
|
||||
stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_PVPSTATS_PLAYER);
|
||||
var score = PlayerScores.LookupByKey(player.GetGUID());
|
||||
@@ -810,7 +810,7 @@ namespace Game.BattleGrounds
|
||||
{
|
||||
//variable kills means how many honorable kills you scored (so we need kills * honor_for_one_kill)
|
||||
uint maxLevel = Math.Min(GetMaxLevel(), 80U);
|
||||
return Formulas.hk_honor_at_level(maxLevel, kills);
|
||||
return Formulas.HKHonorAtLevel(maxLevel, kills);
|
||||
}
|
||||
|
||||
void BlockMovement(Player player)
|
||||
@@ -867,7 +867,7 @@ namespace Game.BattleGrounds
|
||||
player.ClearAfkReports();
|
||||
|
||||
// if arena, remove the specific arena auras
|
||||
if (isArena())
|
||||
if (IsArena())
|
||||
{
|
||||
bgTypeId = BattlegroundTypeId.AA; // set the bg type to all arenas (it will be used for queue refreshing)
|
||||
|
||||
@@ -895,7 +895,7 @@ namespace Game.BattleGrounds
|
||||
}
|
||||
DecreaseInvitedCount(team);
|
||||
//we should update Battleground queue, but only if bg isn't ending
|
||||
if (isBattleground() && GetStatus() < BattlegroundStatus.WaitLeave)
|
||||
if (IsBattleground() && GetStatus() < BattlegroundStatus.WaitLeave)
|
||||
{
|
||||
// a player has left the Battleground, so there are free slots . add to queue
|
||||
AddToBGFreeSlotQueue();
|
||||
@@ -1007,7 +1007,7 @@ namespace Game.BattleGrounds
|
||||
player.RemoveAurasByType(AuraType.Mounted);
|
||||
|
||||
// add arena specific auras
|
||||
if (isArena())
|
||||
if (IsArena())
|
||||
{
|
||||
player.RemoveArenaEnchantments(EnchantmentSlot.Temp);
|
||||
|
||||
@@ -1026,7 +1026,7 @@ namespace Game.BattleGrounds
|
||||
{
|
||||
player.CastSpell(player, BattlegroundConst.SpellPreparation, true); // reduces all mana cost of spells.
|
||||
|
||||
uint countdownMaxForBGType = isArena() ? BattlegroundConst.ArenaCountdownMax : BattlegroundConst.BattlegroundCountdownMax;
|
||||
uint countdownMaxForBGType = IsArena() ? BattlegroundConst.ArenaCountdownMax : BattlegroundConst.BattlegroundCountdownMax;
|
||||
StartTimer timer = new StartTimer();
|
||||
timer.Type = TimerType.Pvp;
|
||||
timer.TimeRemaining = countdownMaxForBGType - (GetElapsedTime() / 1000);
|
||||
@@ -1120,7 +1120,7 @@ namespace Game.BattleGrounds
|
||||
RemovePlayer(player, guid, GetPlayerTeam(guid));
|
||||
|
||||
// 1 player is logging out, if it is the last, then end arena!
|
||||
if (isArena())
|
||||
if (IsArena())
|
||||
if (GetAlivePlayersCountByTeam(player.GetBGTeam()) <= 1 && GetPlayersCountByTeam(GetOtherTeam(player.GetBGTeam())) != 0)
|
||||
EndBattleground(GetOtherTeam(player.GetBGTeam()));
|
||||
}
|
||||
@@ -1129,7 +1129,7 @@ namespace Game.BattleGrounds
|
||||
// This method should be called only once ... it adds pointer to queue
|
||||
void AddToBGFreeSlotQueue()
|
||||
{
|
||||
if (!m_InBGFreeSlotQueue && isBattleground())
|
||||
if (!m_InBGFreeSlotQueue && IsBattleground())
|
||||
{
|
||||
Global.BattlegroundMgr.AddToBGFreeSlotQueue(m_TypeID, this);
|
||||
m_InBGFreeSlotQueue = true;
|
||||
@@ -1251,7 +1251,7 @@ namespace Game.BattleGrounds
|
||||
if (bgScore == null) // player not found...
|
||||
return false;
|
||||
|
||||
if (type == ScoreType.BonusHonor && doAddHonor && isBattleground())
|
||||
if (type == ScoreType.BonusHonor && doAddHonor && IsBattleground())
|
||||
player.RewardHonor(null, 1, (int)value);
|
||||
else
|
||||
bgScore.UpdateScore(type, value);
|
||||
@@ -1640,7 +1640,7 @@ namespace Game.BattleGrounds
|
||||
}
|
||||
}
|
||||
|
||||
if (!isArena())
|
||||
if (!IsArena())
|
||||
{
|
||||
// To be able to remove insignia -- ONLY IN Battlegrounds
|
||||
victim.AddUnitFlag(UnitFlags.Skinnable);
|
||||
@@ -1869,9 +1869,9 @@ namespace Game.BattleGrounds
|
||||
public void SetRandom(bool isRandom) { m_IsRandom = isRandom; }
|
||||
uint GetInvitedCount(Team team) { return (team == Team.Alliance) ? m_InvitedAlliance : m_InvitedHorde; }
|
||||
|
||||
public bool isArena() { return m_IsArena; }
|
||||
public bool isBattleground() { return !m_IsArena; }
|
||||
public bool isRated() { return m_IsRated; }
|
||||
public bool IsArena() { return m_IsArena; }
|
||||
public bool IsBattleground() { return !m_IsArena; }
|
||||
public bool IsRated() { return m_IsRated; }
|
||||
|
||||
public Dictionary<ObjectGuid, BattlegroundPlayer> GetPlayers() { return m_Players; }
|
||||
uint GetPlayersSize() { return (uint)m_Players.Count; }
|
||||
|
||||
@@ -134,9 +134,9 @@ namespace Game.BattleGrounds
|
||||
header.QueueID = bg.GetQueueId();
|
||||
header.RangeMin = (byte)bg.GetMinLevel();
|
||||
header.RangeMax = (byte)bg.GetMaxLevel();
|
||||
header.TeamSize = (byte)(bg.isArena() ? arenaType : 0);
|
||||
header.TeamSize = (byte)(bg.IsArena() ? arenaType : 0);
|
||||
header.InstanceID = bg.GetClientInstanceID();
|
||||
header.RegisteredMatch = bg.isRated();
|
||||
header.RegisteredMatch = bg.IsRated();
|
||||
header.TournamentRules = false;
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ namespace Game.BattleGrounds
|
||||
// create a copy of the BG template
|
||||
Battleground bg = bg_template.GetCopy();
|
||||
|
||||
bool isRandom = bgTypeId != originalBgTypeId && !bg.isArena();
|
||||
bool isRandom = bgTypeId != originalBgTypeId && !bg.IsArena();
|
||||
|
||||
bg.SetBracket(bracketEntry);
|
||||
bg.SetInstanceID(Global.MapMgr.GenerateInstanceId());
|
||||
@@ -282,7 +282,7 @@ namespace Game.BattleGrounds
|
||||
bg.SetQueueId((ulong)bgTypeId | 0x1F10000000000000);
|
||||
|
||||
// Set up correct min/max player counts for scoreboards
|
||||
if (bg.isArena())
|
||||
if (bg.IsArena())
|
||||
{
|
||||
uint maxPlayersPerTeam = 0;
|
||||
switch (arenaType)
|
||||
@@ -857,8 +857,8 @@ namespace Game.BattleGrounds
|
||||
|
||||
public BattlegroundQueue GetBattlegroundQueue(BattlegroundQueueTypeId bgQueueTypeId) { return m_BattlegroundQueues[(int)bgQueueTypeId]; }
|
||||
|
||||
public bool isArenaTesting() { return m_ArenaTesting; }
|
||||
public bool isTesting() { return m_Testing; }
|
||||
public bool IsArenaTesting() { return m_ArenaTesting; }
|
||||
public bool IsTesting() { return m_Testing; }
|
||||
|
||||
public BattlegroundTypeId GetBattleMasterBG(uint entry)
|
||||
{
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace Game.BattleGrounds
|
||||
//add players from group to ginfo
|
||||
if (grp)
|
||||
{
|
||||
for (GroupReference refe = grp.GetFirstMember(); refe != null; refe = refe.next())
|
||||
for (GroupReference refe = grp.GetFirstMember(); refe != null; refe = refe.Next())
|
||||
{
|
||||
Player member = refe.GetSource();
|
||||
if (!member)
|
||||
@@ -385,7 +385,7 @@ namespace Game.BattleGrounds
|
||||
BattlegroundBracketId bracket_id = bg.GetBracketId();
|
||||
|
||||
// set ArenaTeamId for rated matches
|
||||
if (bg.isArena() && bg.isRated())
|
||||
if (bg.IsArena() && bg.IsRated())
|
||||
bg.SetArenaTeamIdForTeam(ginfo.Team, ginfo.ArenaTeamId);
|
||||
|
||||
ginfo.RemoveInviteTime = GameTime.GetGameTimeMS() + BattlegroundConst.InviteAcceptWaitTime;
|
||||
@@ -644,7 +644,7 @@ namespace Game.BattleGrounds
|
||||
return false;
|
||||
}
|
||||
//allow 1v0 if debug bg
|
||||
if (Global.BattlegroundMgr.isTesting() && (m_SelectionPools[TeamId.Alliance].GetPlayerCount() != 0 || m_SelectionPools[TeamId.Horde].GetPlayerCount() != 0))
|
||||
if (Global.BattlegroundMgr.IsTesting() && (m_SelectionPools[TeamId.Alliance].GetPlayerCount() != 0 || m_SelectionPools[TeamId.Horde].GetPlayerCount() != 0))
|
||||
return true;
|
||||
//return true if there are enough players in selection pools - enable to work .debug bg command correctly
|
||||
return m_SelectionPools[TeamId.Alliance].GetPlayerCount() >= minPlayers && m_SelectionPools[TeamId.Horde].GetPlayerCount() >= minPlayers;
|
||||
@@ -745,7 +745,7 @@ namespace Game.BattleGrounds
|
||||
foreach (var bg in bgQueues)
|
||||
{
|
||||
// DO NOT allow queue manager to invite new player to rated games
|
||||
if (!bg.isRated() && bg.GetTypeID() == bgTypeId && bg.GetBracketId() == bracket_id &&
|
||||
if (!bg.IsRated() && bg.GetTypeID() == bgTypeId && bg.GetBracketId() == bracket_id &&
|
||||
bg.GetStatus() > BattlegroundStatus.WaitQueue && bg.GetStatus() < BattlegroundStatus.WaitLeave)
|
||||
{
|
||||
// clear selection pools
|
||||
@@ -787,18 +787,18 @@ namespace Game.BattleGrounds
|
||||
uint MinPlayersPerTeam = bg_template.GetMinPlayersPerTeam();
|
||||
uint MaxPlayersPerTeam = bg_template.GetMaxPlayersPerTeam();
|
||||
|
||||
if (bg_template.isArena())
|
||||
if (bg_template.IsArena())
|
||||
{
|
||||
MaxPlayersPerTeam = arenaType;
|
||||
MinPlayersPerTeam = (uint)(Global.BattlegroundMgr.isArenaTesting() ? 1 : arenaType);
|
||||
MinPlayersPerTeam = (uint)(Global.BattlegroundMgr.IsArenaTesting() ? 1 : arenaType);
|
||||
}
|
||||
else if (Global.BattlegroundMgr.isTesting())
|
||||
else if (Global.BattlegroundMgr.IsTesting())
|
||||
MinPlayersPerTeam = 1;
|
||||
|
||||
m_SelectionPools[TeamId.Alliance].Init();
|
||||
m_SelectionPools[TeamId.Horde].Init();
|
||||
|
||||
if (bg_template.isBattleground())
|
||||
if (bg_template.IsBattleground())
|
||||
{
|
||||
if (CheckPremadeMatch(bracket_id, MinPlayersPerTeam, MaxPlayersPerTeam))
|
||||
{
|
||||
@@ -826,7 +826,7 @@ namespace Game.BattleGrounds
|
||||
{
|
||||
// if there are enough players in pools, start new Battleground or non rated arena
|
||||
if (CheckNormalMatch(bg_template, bracket_id, MinPlayersPerTeam, MaxPlayersPerTeam)
|
||||
|| (bg_template.isArena() && CheckSkirmishForSameFaction(bracket_id, MinPlayersPerTeam)))
|
||||
|| (bg_template.IsArena() && CheckSkirmishForSameFaction(bracket_id, MinPlayersPerTeam)))
|
||||
{
|
||||
// we successfully created a pool
|
||||
Battleground bg2 = Global.BattlegroundMgr.CreateNewBattleground(bgTypeId, bracketEntry, (ArenaTypes)arenaType, false);
|
||||
@@ -846,7 +846,7 @@ namespace Game.BattleGrounds
|
||||
bg2.StartBattleground();
|
||||
}
|
||||
}
|
||||
else if (bg_template.isArena())
|
||||
else if (bg_template.IsArena())
|
||||
{
|
||||
// found out the minimum and maximum ratings the newly added team should battle against
|
||||
// arenaRating is the rating of the latest joined team, or 0
|
||||
@@ -1166,7 +1166,7 @@ namespace Game.BattleGrounds
|
||||
player.RemoveBattlegroundQueueId(m_BgQueueTypeId);
|
||||
bgQueue.RemovePlayer(m_PlayerGuid, true);
|
||||
//update queues if Battleground isn't ended
|
||||
if (bg && bg.isBattleground() && bg.GetStatus() != BattlegroundStatus.WaitLeave)
|
||||
if (bg && bg.IsBattleground() && bg.GetStatus() != BattlegroundStatus.WaitLeave)
|
||||
Global.BattlegroundMgr.ScheduleQueueUpdate(0, 0, m_BgQueueTypeId, m_BgTypeId, bg.GetBracketId());
|
||||
|
||||
BattlefieldStatusNone battlefieldStatus;
|
||||
|
||||
Reference in New Issue
Block a user