content: /**
   * This file is part of Aion-Lightning <aion-lightning.org>.
   *
   *  Aion-Lightning is free software: you can redistribute it and/or modify
   *  it under the terms of the GNU General Public License as published by
   *  the Free Software Foundation, either version 3 of the License, or
   *  (at your option) any later version.
   *
   *  Aion-Lightning is distributed in the hope that it will be useful,
   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   *  GNU General Public License for more details. *
   *  You should have received a copy of the GNU General Public License
   *  along with Aion-Lightning.
   *  If not, see <http://www.gnu.org/licenses/>.
   */
  package com.aionemu.gameserver.services;
  
  import com.aionemu.gameserver.model.gameobjects.player.Player;
  import com.aionemu.gameserver.model.items.storage.StorageType;
  import com.aionemu.gameserver.network.aion.serverpackets.SM_CUBE_UPDATE;
  import com.aionemu.gameserver.network.aion.serverpackets.SM_SYSTEM_MESSAGE;
  import com.aionemu.gameserver.utils.PacketSendUtility;
  
  /**
   * @author ATracer
   * @author Simple
   * @reworked Luzien
   */
  public class CubeExpandService {
  
  	private static final int MIN_EXPAND = 0;
  	private static final int MAX_EXPAND = 15;
  
  	/**
  	 * Expands the cubes
  	 *
  	 * @param player
  	 * @param isCubeExpand
  	 */
  	public static void expand(Player player, boolean isCubeExpand) {
  		if (!canExpand(player)) {
  			return;
  		}
  		PacketSendUtility.sendPacket(player, new SM_SYSTEM_MESSAGE(1300431, "9")); // 9 Slots added
  		if (isCubeExpand) {
  			player.setCubeExpands(player.getCubeExpands() + 1);
  		}
  		PacketSendUtility.sendPacket(player, SM_CUBE_UPDATE.cubeSize(StorageType.CUBE, player));
  	}
  
  	/**
  	 * @param player
  	 * @return
  	 */
  	public static boolean canExpand(Player player) {
  		return validateNewSize(player.getCubeExpands() + 1);
  	}
  
  	/**
  	 * Checks if new player cube is not max
  	 *
  	 * @param level
  	 * @return true or false
  	 */
  	private static boolean validateNewSize(int level) {
  		// check min and max level
  		return !(level < MIN_EXPAND || level > MAX_EXPAND);
  	}
  }
  