/// <summary> /// Executes this command. /// </summary> public override int Execute(LogicLevel level) { if (this._shieldData != null) { int cooldownSecs = level.GetCooldownManager().GetCooldownSeconds(this._shieldData.GetGlobalID()); if (cooldownSecs <= 0) { LogicClientAvatar playerAvatar = level.GetPlayerAvatar(); if (this._shieldData.GetScoreLimit() > playerAvatar.GetScore() || this._shieldData.GetScoreLimit() <= 0) { if (playerAvatar.HasEnoughDiamonds(this._shieldData.GetDiamondsCost(), true, level)) { LogicGameMode gameMode = level.GetGameMode(); playerAvatar.UseDiamonds(this._shieldData.GetDiamondsCost()); int shieldTime = gameMode.GetShieldRemainingSeconds() + this._shieldData.TimeH * 3600; int guardTime = gameMode.GetGuardRemainingSeconds(); int maintenanceTime = 0; if (this._shieldData.TimeH <= 0) { if (shieldTime > 0) { return(-2); } guardTime += this._shieldData.GuardTimeH * 3600; } else { LogicLeagueData leagueData = playerAvatar.GetLeagueTypeData(); if (playerAvatar.GetShieldCostAmount() != 0) { playerAvatar.SetShieldCostAmount(0); } guardTime += leagueData.VillageGuardInMins * 60; } if (shieldTime <= 0) { maintenanceTime = LogicMath.Min(LogicDataTables.GetGlobals().GetPersonalBreakLimitSeconds() + this._shieldData.GuardTimeH * 3600, gameMode.GetMaintenanceRemainingSeconds() + this._shieldData.GuardTimeH * 3600); } else { maintenanceTime = shieldTime + LogicDataTables.GetGlobals().GetPersonalBreakLimitSeconds(); } gameMode.SetMaintenanceRemainingSeconds(maintenanceTime); gameMode.SetShieldRemainingSeconds(shieldTime); gameMode.SetGuardRemainingSeconds(guardTime); level.GetCooldownManager().AddCooldown(this._shieldData.GetGlobalID(), this._shieldData.GetCooldownSecs()); return(0); } } } } return(-1); }