/// <summary> /// Executes this command. /// </summary> public override int Execute(LogicLevel level) { if (this._gameObjectIds.Count > 0) { int cost = 0; for (int i = 0; i < this._gameObjectIds.Count; i++) { LogicGameObject gameObject = level.GetGameObjectManager().GetGameObjectByID(this._gameObjectIds[i]); if (gameObject != null && gameObject.GetGameObjectType() == 0) { if (gameObject.GetData().GetVillageType() == level.GetVillageType()) { LogicBuilding building = (LogicBuilding)gameObject; if (!building.IsLocked()) { if (!LogicDataTables.GetGlobals().UseNewTraining() || building.GetUnitProductionComponent() == null) { if (building.CanBeBoosted()) { cost += building.GetBoostCost(); } continue; } return(-3); } return(-4); } return(-32); } return(-5); } LogicClientAvatar playerAvatar = level.GetPlayerAvatar(); if (cost > 0) { if (!playerAvatar.HasEnoughDiamonds(cost, true, level)) { return(-2); } playerAvatar.UseDiamonds(cost); } for (int i = 0; i < this._gameObjectIds.Count; i++) { LogicGameObject gameObject = level.GetGameObjectManager().GetGameObjectByID(this._gameObjectIds[i]); if (gameObject != null && gameObject.GetGameObjectType() == 0) { LogicBuilding building = (LogicBuilding)gameObject; if (building.GetMaxBoostTime() != 0) { building.Boost(); } } } return(0); } return(-1); }