<commit_before>package de.dakror.arise.layer;

import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Composite;
import java.awt.Cursor;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.dnd.DragSource;
import java.awt.event.MouseEvent;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.net.MalformedURLException;
import java.net.URL;

import org.json.JSONException;
import org.json.JSONObject;

import de.dakror.arise.game.Game;
import de.dakror.arise.game.building.Building;
import de.dakror.arise.game.building.Lumberjack;
import de.dakror.arise.game.building.Mine;
import de.dakror.arise.game.building.Quarry;
import de.dakror.arise.game.world.City;
import de.dakror.arise.settings.Resources;
import de.dakror.arise.settings.Resources.Resource;
import de.dakror.arise.ui.BuildingButton;
import de.dakror.arise.ui.ResourceLabel;
import de.dakror.gamesetup.GameFrame;
import de.dakror.gamesetup.layer.Alert;
import de.dakror.gamesetup.layer.Layer;
import de.dakror.gamesetup.ui.ClickEvent;
import de.dakror.gamesetup.ui.Component;
import de.dakror.gamesetup.ui.button.IconButton;
import de.dakror.gamesetup.util.Helper;

/**
 * @author Dakror
 */
public class CityLayer extends Layer
{
	public static Resources resources;
	public static boolean allBuildingsEnabled;
	JSONObject data;
	City city;
	
	Building activeBuilding;
	
	BufferedImage cache;
	
	public CityLayer(City city)
	{
		modal = true;
		this.city = city;
		try
		{
			data = new JSONObject(Helper.getURLContent(new URL("http://dakror.de/arise/city?userid=" + Game.userID + "&worldid=" + Game.worldID + "&id=" + city.getId())));
			resources = new Resources();
			resources.set(Resource.WOOD, data.getInt("WOOD"));
			resources.set(Resource.GOLD, data.getInt("GOLD"));
			resources.set(Resource.STONE, data.getInt("STONE"));
			placeBuildings();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}
	
	@Override
	public void init()
	{
		try
		{
			IconButton map = new IconButton((Game.getWidth() - 64) / 2, 20, 64, 64, "system/map.png");
			map.addClickEvent(new ClickEvent()
			{
				@Override
				public void trigger()
				{
					Game.currentGame.removeLayer(CityLayer.this);
					Game.world.updateWorld();
				}
			});
			map.tooltip = "Weltkarte";
			map.mode2 = true;
			components.add(map);
			
			BuildingButton lumberjack = new BuildingButton(15, Game.getHeight() - 64, 48, 48, Game.getImage("system/icons.png").getSubimage(72, 0, 24, 24), new Lumberjack(0, 0, 0));
			lumberjack.addClickEvent(new ClickEvent()
			{
				@Override
				public void trigger()
				{
					activeBuilding = new Lumberjack(0, 0, 0);
				}
			});
			components.add(lumberjack);
			
			BuildingButton mine = new BuildingButton(15 + 64, Game.getHeight() - 64, 48, 48, Game.getImage("system/icons.png").getSubimage(50, 24, 24, 24), new Mine(0, 0, 0));
			mine.addClickEvent(new ClickEvent()
			{
				@Override
				public void trigger()
				{
					activeBuilding = new Mine(0, 0, 0);
				}
			});
			components.add(mine);
			
			BuildingButton quarry = new BuildingButton(15 + 128, Game.getHeight() - 64, 48, 48, Game.getImage("system/icons.png").getSubimage(24, 24, 24, 24), new Quarry(0, 0, 0));
			quarry.addClickEvent(new ClickEvent()
			{
				@Override
				public void trigger()
				{
					activeBuilding = new Quarry(0, 0, 0);
				}
			});
			components.add(quarry);
			
			ResourceLabel wood = new ResourceLabel(20, 20, resources, Resource.WOOD);
			components.add(wood);
			
			ResourceLabel stone = new ResourceLabel(190 + wood.getX(), 20, resources, Resource.STONE);
			components.add(stone);
			
			ResourceLabel gold = new ResourceLabel(400 + wood.getX(), 20, resources, Resource.GOLD);
			components.add(gold);
			
			ResourceLabel buildings = new ResourceLabel(70 + wood.getX(), 60, resources, Resource.BUILDINGS);
			buildings.off = (data.getInt("LEVEL") + 1) * City.BUILDINGS_SCALE;
			components.add(buildings);
			
			ResourceLabel people = new ResourceLabel(270 + wood.getX(), 60, resources, Resource.PEOPLE);
			people.off = 20;
			components.add(people);
			
			updateBuildingbar();
			
			cache = new BufferedImage(Game.getWidth(), Game.getHeight(), BufferedImage.TYPE_INT_ARGB);<commit_msg>minor visual fix<commit_after>package de.dakror.arise.layer;

import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Composite;
import java.awt.Cursor;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.dnd.DragSource;
import java.awt.event.MouseEvent;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.net.MalformedURLException;
import java.net.URL;

import org.json.JSONException;
import org.json.JSONObject;

import de.dakror.arise.game.Game;
import de.dakror.arise.game.building.Building;
import de.dakror.arise.game.building.Lumberjack;
import de.dakror.arise.game.building.Mine;
import de.dakror.arise.game.building.Quarry;
import de.dakror.arise.game.world.City;
import de.dakror.arise.settings.Resources;
import de.dakror.arise.settings.Resources.Resource;
import de.dakror.arise.ui.BuildingButton;
import de.dakror.arise.ui.ResourceLabel;
import de.dakror.gamesetup.GameFrame;
import de.dakror.gamesetup.layer.Alert;
import de.dakror.gamesetup.layer.Layer;
import de.dakror.gamesetup.ui.ClickEvent;
import de.dakror.gamesetup.ui.Component;
import de.dakror.gamesetup.ui.button.IconButton;
import de.dakror.gamesetup.util.Helper;

/**
 * @author Dakror
 */
public class CityLayer extends Layer
{
	public static Resources resources;
	public static boolean allBuildingsEnabled;
	JSONObject data;
	City city;
	
	Building activeBuilding;
	
	BufferedImage cache;
	
	public CityLayer(City city)
	{
		modal = true;
		this.city = city;
		try
		{
			data = new JSONObject(Helper.getURLContent(new URL("http://dakror.de/arise/city?userid=" + Game.userID + "&worldid=" + Game.worldID + "&id=" + city.getId())));
			resources = new Resources();
			resources.set(Resource.WOOD, data.getInt("WOOD"));
			resources.set(Resource.GOLD, data.getInt("GOLD"));
			resources.set(Resource.STONE, data.getInt("STONE"));
			placeBuildings();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}
	
	@Override
	public void init()
	{
		try
		{
			IconButton map = new IconButton((Game.getWidth() - 64) / 2, 20, 64, 64, "system/map.png");
			map.addClickEvent(new ClickEvent()
			{
				@Override
				public void trigger()
				{
					Game.currentGame.removeLayer(CityLayer.this);
					Game.world.updateWorld();
				}
			});
			map.tooltip = "Weltkarte";
			map.mode2 = true;
			components.add(map);
			
			BuildingButton lumberjack = new BuildingButton(15, Game.getHeight() - 64, 48, 48, Game.getImage("system/icons.png").getSubimage(72, 0, 24, 24), new Lumberjack(0, 0, 0));
			lumberjack.addClickEvent(new ClickEvent()
			{
				@Override
				public void trigger()
				{
					activeBuilding = new Lumberjack(0, 0, 0);
				}
			});
			components.add(lumberjack);
			
			BuildingButton mine = new BuildingButton(15 + 72, Game.getHeight() - 64, 48, 48, Game.getImage("system/icons.png").getSubimage(50, 24, 24, 24), new Mine(0, 0, 0));
			mine.addClickEvent(new ClickEvent()
			{
				@Override
				public void trigger()
				{
					activeBuilding = new Mine(0, 0, 0);
				}
			});
			components.add(mine);
			
			BuildingButton quarry = new BuildingButton(15 + 144, Game.getHeight() - 64, 48, 48, Game.getImage("system/icons.png").getSubimage(24, 24, 24, 24), new Quarry(0, 0, 0));
			quarry.addClickEvent(new ClickEvent()
			{
				@Override
				public void trigger()
				{
					activeBuilding = new Quarry(0, 0, 0);
				}
			});
			components.add(quarry);
			
			ResourceLabel wood = new ResourceLabel(20, 20, resources, Resource.WOOD);
			components.add(wood);
			
			ResourceLabel stone = new ResourceLabel(190 + wood.getX(), 20, resources, Resource.STONE);
			components.add(stone);
			
			ResourceLabel gold = new ResourceLabel(400 + wood.getX(), 20, resources, Resource.GOLD);
			components.add(gold);
			
			ResourceLabel buildings = new ResourceLabel(70 + wood.getX(), 60, resources, Resource.BUILDINGS);
			buildings.off = (data.getInt("LEVEL") + 1) * City.BUILDINGS_SCALE;
			components.add(buildings);
			
			ResourceLabel people = new ResourceLabel(270 + wood.getX(), 60, resources, Resource.PEOPLE);
			people.off = 20;
			components.add(people);
			
			updateBuildingbar();
			
			cache = new BufferedImage(Game.getWidth(), Game.getHeight(), BufferedImage.TYPE_INT_ARGB);
{'fraction_non_alphanumeric': 0.13748378728923477, 'fraction_numerical': 0.02523287348190072, 'mean_word_length': 3.9923484402589757, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7243528', 'n_tokens_mistral': 3486, 'n_tokens_neox': 2882, 'n_words': 577}