From 9253c40085e9b0a707080097f8a8692bffbf4920 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Fri, 23 Feb 2018 15:36:13 +0200 Subject: [PATCH] Added Kotlin! --- android/build.gradle | 2 +- build.gradle | 17 ++++++++++++----- core/build.gradle | 2 +- .../logic/civilization/CivilizationInfo.java | 9 ++++++--- .../com/unciv/models/gamebasics/Building.java | 2 +- desktop/build.gradle | 2 +- html/build.gradle | 2 +- 7 files changed, 23 insertions(+), 13 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 5a8f9736..f40fdd0f 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,6 +1,6 @@ android { buildToolsVersion "26.0.2" - compileSdkVersion 25 + compileSdkVersion 26 sourceSets { main { manifest.srcFile 'AndroidManifest.xml' diff --git a/build.gradle b/build.gradle index e77ba8f3..34548cbc 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,11 @@ buildscript { - + + ext.kotlinVersion = '1.2.21' + + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" + } + repositories { mavenLocal() @@ -39,7 +45,7 @@ allprojects { } project(":desktop") { - apply plugin: "java" + apply plugin: "kotlin" dependencies { @@ -53,6 +59,7 @@ project(":desktop") { project(":android") { apply plugin: "android" + apply plugin: "kotlin-android" configurations { natives } @@ -75,7 +82,7 @@ project(":android") { } project(":ios") { - apply plugin: "java" + apply plugin: "kotlin" apply plugin: "robovm" @@ -107,13 +114,13 @@ project(":html") { } project(":core") { - apply plugin: "java" + apply plugin: "kotlin" dependencies { compile "com.badlogicgames.gdx:gdx:$gdxVersion" compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion" - + compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion" } } diff --git a/core/build.gradle b/core/build.gradle index 03cd1bea..dad943e3 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -1,4 +1,4 @@ -apply plugin: "java" +apply plugin: "kotlin" sourceCompatibility = 1.6 [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' diff --git a/core/src/com/unciv/logic/civilization/CivilizationInfo.java b/core/src/com/unciv/logic/civilization/CivilizationInfo.java index 65b1a9a6..da0f4305 100644 --- a/core/src/com/unciv/logic/civilization/CivilizationInfo.java +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.java @@ -91,15 +91,18 @@ public class CivilizationInfo { String greatPerson = greatPeople.getNewGreatPerson(); if(greatPerson!=null) { - CityInfo randomCity = cities.getRandom(); - placeUnitNearTile(cities.getRandom().cityLocation, greatPerson); - gameInfo.addNotification("A " + greatPerson + " has been born!", randomCity.cityLocation); } goldenAges.nextTurn(happiness); } + public void addGreatPerson(String greatPerson){ + CityInfo randomCity = cities.getRandom(); + placeUnitNearTile(cities.getRandom().cityLocation, greatPerson); + gameInfo.addNotification("A " + greatPerson + " has been born!", randomCity.cityLocation); + } + public CivStats getStatsForNextTurn() { CivStats statsForTurn = new CivStats(); for (CityInfo city : cities) { diff --git a/core/src/com/unciv/models/gamebasics/Building.java b/core/src/com/unciv/models/gamebasics/Building.java index 68aac902..f3ba8502 100644 --- a/core/src/com/unciv/models/gamebasics/Building.java +++ b/core/src/com/unciv/models/gamebasics/Building.java @@ -215,7 +215,7 @@ public class Building extends NamedStats implements IConstruction, ICivilopedia constructions.builtBuildings.add(providesFreeBuilding); if (freeTechs != 0) civInfo.tech.freeTechs += freeTechs; if("EmpireEntersGoldenAge".equals(unique)) civInfo.goldenAges.enterGoldenAge(); - if("FreeGreatArtistAppears".equals(unique)) civInfo.greatPeople.addGreatPerson("Great Artist"); + if("FreeGreatArtistAppears".equals(unique)) civInfo.addGreatPerson("Great Artist"); if("WorkerConstruction".equals(unique)){ civInfo.placeUnitNearTile(constructions.cityInfo.cityLocation,"Worker"); civInfo.placeUnitNearTile(constructions.cityInfo.cityLocation,"Worker"); diff --git a/desktop/build.gradle b/desktop/build.gradle index d1f5360a..829bbff2 100644 --- a/desktop/build.gradle +++ b/desktop/build.gradle @@ -1,4 +1,4 @@ -apply plugin: "java" +apply plugin: "kotlin" sourceCompatibility = 1.6 sourceSets.main.java.srcDirs = [ "src/" ] diff --git a/html/build.gradle b/html/build.gradle index 4eb5f2f8..6330f507 100644 --- a/html/build.gradle +++ b/html/build.gradle @@ -1,6 +1,6 @@ import de.richsource.gradle.plugins.gwt.GwtSuperDev -apply plugin: "java" +apply plugin: "kotlin" apply plugin: "jetty" gwt {