public void buyUnit(String unitName, Planet orderPlanet, Factory factory) {
		// TODO remake
		if (!getBase().isAvailableUnit(unitName)) {
			throw new IllegalArgumentException("This unit is not available.");
		}
		Price price = UnitCreator.getPrice(unitName);

		int mineralWorkersNeeded = price.getMinerals();
		int gasWorkersNeeded = price.getGas();
		if (mineralWorkersNeeded + gasWorkersNeeded > base.getWorkerPool()) {
			throw new IllegalStateException("Not enough available workers.");
		}

		if (mineralWorkersNeeded > 0) {
			List<Resource> mineralResources = getAvailableMiningArea(ResourceType.MINERALS);
			if (!enoughAvailableResources(mineralResources, mineralWorkersNeeded)) {
				throw new IllegalStateException("Not enough available minerals.");
			}

			for (int i = 1; i <= mineralWorkersNeeded; i++) {
				Resource chosenResource = Game.ihm.selectResourceToSendWorker(this, mineralResources, i, ResourceType.MINERALS);
				sendWorkerToMine(chosenResource);
			}
		}

		if (gasWorkersNeeded > 0) {
			List<Resource> gasResources = getAvailableMiningArea(ResourceType.GAS);
			if (!enoughAvailableResources(gasResources, mineralWorkersNeeded)) {
				throw new IllegalStateException("Not enough available gas.");
			}

			for (int i = 1; i <= mineralWorkersNeeded; i++) {
				Resource chosenResource = Game.ihm.selectResourceToSendWorker(this, gasResources, i, ResourceType.GAS);
				sendWorkerToMine(chosenResource);
			}
		}

		Unit unit = createUnit(unitName, factory);
		List<Area> buildableAreas = orderPlanet.getBuildableAreas(this);
		if (buildableAreas.isEmpty()) {
			throw new IllegalStateException("No space left to build a unit.");
		}
		Area selectedArea = Game.ihm.selectAreaToPlaceUnit(this, buildableAreas);
		selectedArea.addUnit(unit);
	}