mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-24 22:59:34 +07:00
Units can only upgrade within your borders (thanks Noam!)
This commit is contained in:
@ -812,6 +812,8 @@
|
|||||||
German:"Die Zivilisation [civName] wurde vernichtet!"
|
German:"Die Zivilisation [civName] wurde vernichtet!"
|
||||||
Dutch:"De [civName] beschaving is vernietigt!" //civname has to be an adjective
|
Dutch:"De [civName] beschaving is vernietigt!" //civname has to be an adjective
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"A [greatPerson] has been born!":{}
|
||||||
|
|
||||||
|
|
||||||
// Save and load game
|
// Save and load game
|
||||||
|
@ -15,8 +15,6 @@ import com.unciv.models.gamebasics.tile.ResourceType
|
|||||||
import com.unciv.models.gamebasics.tile.TileResource
|
import com.unciv.models.gamebasics.tile.TileResource
|
||||||
import com.unciv.models.gamebasics.unit.UnitType
|
import com.unciv.models.gamebasics.unit.UnitType
|
||||||
import com.unciv.models.stats.Stats
|
import com.unciv.models.stats.Stats
|
||||||
import com.unciv.ui.Trade
|
|
||||||
import com.unciv.ui.TradeType
|
|
||||||
import com.unciv.ui.utils.getRandom
|
import com.unciv.ui.utils.getRandom
|
||||||
import com.unciv.ui.utils.tr
|
import com.unciv.ui.utils.tr
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
@ -236,7 +234,7 @@ class CivilizationInfo {
|
|||||||
fun addGreatPerson(greatPerson: String) {
|
fun addGreatPerson(greatPerson: String) {
|
||||||
val randomCity = cities.getRandom()
|
val randomCity = cities.getRandom()
|
||||||
placeUnitNearTile(cities.getRandom().location, greatPerson)
|
placeUnitNearTile(cities.getRandom().location, greatPerson)
|
||||||
addNotification("A $greatPerson has been born!", randomCity.location, Color.GOLD)
|
addNotification("A [$greatPerson] has been born!".tr(), randomCity.location, Color.GOLD)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun placeUnitNearTile(location: Vector2, unitName: String): MapUnit {
|
fun placeUnitNearTile(location: Vector2, unitName: String): MapUnit {
|
||||||
@ -286,78 +284,4 @@ class CivilizationInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class DiplomaticStatus{
|
|
||||||
Peace,
|
|
||||||
War
|
|
||||||
}
|
|
||||||
|
|
||||||
class DiplomacyManager() {
|
|
||||||
@Transient lateinit var civInfo:CivilizationInfo
|
|
||||||
lateinit var otherCivName:String
|
|
||||||
|
|
||||||
constructor(civilizationInfo: CivilizationInfo, OtherCivName:String) : this() {
|
|
||||||
civInfo=civilizationInfo
|
|
||||||
otherCivName=OtherCivName
|
|
||||||
}
|
|
||||||
// var status:DiplomaticStatus = DiplomaticStatus.War
|
|
||||||
var trades = ArrayList<Trade>()
|
|
||||||
|
|
||||||
fun goldPerTurn():Int{
|
|
||||||
var goldPerTurnForUs = 0
|
|
||||||
for(trade in trades) {
|
|
||||||
for (offer in trade.ourOffers.filter { it.type == TradeType.Gold_Per_Turn })
|
|
||||||
goldPerTurnForUs -= offer.amount
|
|
||||||
for (offer in trade.theirOffers.filter { it.type == TradeType.Gold_Per_Turn })
|
|
||||||
goldPerTurnForUs += offer.amount
|
|
||||||
}
|
|
||||||
return goldPerTurnForUs
|
|
||||||
}
|
|
||||||
|
|
||||||
fun resourcesFromTrade(): Counter<TileResource> {
|
|
||||||
val counter = Counter<TileResource>()
|
|
||||||
for(trade in trades){
|
|
||||||
for(offer in trade.ourOffers)
|
|
||||||
if(offer.type==TradeType.Strategic_Resource || offer.type==TradeType.Luxury_Resource)
|
|
||||||
counter.add(GameBasics.TileResources[offer.name]!!,-offer.amount)
|
|
||||||
for(offer in trade.theirOffers)
|
|
||||||
if(offer.type==TradeType.Strategic_Resource || offer.type==TradeType.Luxury_Resource)
|
|
||||||
counter.add(GameBasics.TileResources[offer.name]!!,offer.amount)
|
|
||||||
}
|
|
||||||
return counter
|
|
||||||
}
|
|
||||||
|
|
||||||
fun removeUntenebleTrades(){
|
|
||||||
val negativeCivResources = civInfo.getCivResources().filter { it.value<0 }.map { it.key.name }
|
|
||||||
for(trade in trades.toList()) {
|
|
||||||
for (offer in trade.ourOffers) {
|
|
||||||
if (offer.type in listOf(TradeType.Luxury_Resource, TradeType.Strategic_Resource)
|
|
||||||
&& offer.name in negativeCivResources){
|
|
||||||
trades.remove(trade)
|
|
||||||
val otherCivTrades = otherCiv().diplomacy[civInfo.civName]!!.trades
|
|
||||||
otherCivTrades.removeAll{ it.equals(trade.reverse()) }
|
|
||||||
civInfo.addNotification("One of our trades with [$otherCivName] has been cut short!".tr(),null, Color.GOLD)
|
|
||||||
otherCiv().addNotification("One of our trades with [${civInfo.civName}] has been cut short!".tr(),null, Color.GOLD)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun nextTurn(){
|
|
||||||
for(trade in trades.toList()){
|
|
||||||
for(offer in trade.ourOffers.union(trade.theirOffers).filter { it.duration>0 })
|
|
||||||
offer.duration--
|
|
||||||
|
|
||||||
if(trade.ourOffers.all { it.duration<=0 } && trade.theirOffers.all { it.duration<=0 }) {
|
|
||||||
trades.remove(trade)
|
|
||||||
civInfo.addNotification("One of our trades with [$otherCivName] has ended!".tr(),null, Color.YELLOW)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
removeUntenebleTrades()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun otherCiv() = civInfo.gameInfo.civilizations.first{it.civName==otherCivName}
|
|
||||||
// fun declareWar(){
|
|
||||||
// status = DiplomaticStatus.War
|
|
||||||
// otherCiv().diplomacy[civInfo.civName]!!.status = DiplomaticStatus.War
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
85
core/src/com/unciv/logic/civilization/DiplomacyManager.kt
Normal file
85
core/src/com/unciv/logic/civilization/DiplomacyManager.kt
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
package com.unciv.logic.civilization
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Color
|
||||||
|
import com.unciv.models.Counter
|
||||||
|
import com.unciv.models.gamebasics.GameBasics
|
||||||
|
import com.unciv.models.gamebasics.tile.TileResource
|
||||||
|
import com.unciv.ui.Trade
|
||||||
|
import com.unciv.ui.TradeType
|
||||||
|
import com.unciv.ui.utils.tr
|
||||||
|
|
||||||
|
enum class DiplomaticStatus{
|
||||||
|
Peace,
|
||||||
|
War
|
||||||
|
}
|
||||||
|
|
||||||
|
class DiplomacyManager() {
|
||||||
|
@Transient lateinit var civInfo: CivilizationInfo
|
||||||
|
lateinit var otherCivName:String
|
||||||
|
|
||||||
|
constructor(civilizationInfo: CivilizationInfo, OtherCivName:String) : this() {
|
||||||
|
civInfo=civilizationInfo
|
||||||
|
otherCivName=OtherCivName
|
||||||
|
}
|
||||||
|
// var status:DiplomaticStatus = DiplomaticStatus.War
|
||||||
|
var trades = ArrayList<Trade>()
|
||||||
|
|
||||||
|
fun goldPerTurn():Int{
|
||||||
|
var goldPerTurnForUs = 0
|
||||||
|
for(trade in trades) {
|
||||||
|
for (offer in trade.ourOffers.filter { it.type == TradeType.Gold_Per_Turn })
|
||||||
|
goldPerTurnForUs -= offer.amount
|
||||||
|
for (offer in trade.theirOffers.filter { it.type == TradeType.Gold_Per_Turn })
|
||||||
|
goldPerTurnForUs += offer.amount
|
||||||
|
}
|
||||||
|
return goldPerTurnForUs
|
||||||
|
}
|
||||||
|
|
||||||
|
fun resourcesFromTrade(): Counter<TileResource> {
|
||||||
|
val counter = Counter<TileResource>()
|
||||||
|
for(trade in trades){
|
||||||
|
for(offer in trade.ourOffers)
|
||||||
|
if(offer.type== TradeType.Strategic_Resource || offer.type== TradeType.Luxury_Resource)
|
||||||
|
counter.add(GameBasics.TileResources[offer.name]!!,-offer.amount)
|
||||||
|
for(offer in trade.theirOffers)
|
||||||
|
if(offer.type== TradeType.Strategic_Resource || offer.type== TradeType.Luxury_Resource)
|
||||||
|
counter.add(GameBasics.TileResources[offer.name]!!,offer.amount)
|
||||||
|
}
|
||||||
|
return counter
|
||||||
|
}
|
||||||
|
|
||||||
|
fun removeUntenebleTrades(){
|
||||||
|
val negativeCivResources = civInfo.getCivResources().filter { it.value<0 }.map { it.key.name }
|
||||||
|
for(trade in trades.toList()) {
|
||||||
|
for (offer in trade.ourOffers) {
|
||||||
|
if (offer.type in listOf(TradeType.Luxury_Resource, TradeType.Strategic_Resource)
|
||||||
|
&& offer.name in negativeCivResources){
|
||||||
|
trades.remove(trade)
|
||||||
|
val otherCivTrades = otherCiv().diplomacy[civInfo.civName]!!.trades
|
||||||
|
otherCivTrades.removeAll{ it.equals(trade.reverse()) }
|
||||||
|
civInfo.addNotification("One of our trades with [$otherCivName] has been cut short!".tr(),null, Color.GOLD)
|
||||||
|
otherCiv().addNotification("One of our trades with [${civInfo.civName}] has been cut short!".tr(),null, Color.GOLD)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun nextTurn(){
|
||||||
|
for(trade in trades.toList()){
|
||||||
|
for(offer in trade.ourOffers.union(trade.theirOffers).filter { it.duration>0 })
|
||||||
|
offer.duration--
|
||||||
|
|
||||||
|
if(trade.ourOffers.all { it.duration<=0 } && trade.theirOffers.all { it.duration<=0 }) {
|
||||||
|
trades.remove(trade)
|
||||||
|
civInfo.addNotification("One of our trades with [$otherCivName] has ended!".tr(),null, Color.YELLOW)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
removeUntenebleTrades()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun otherCiv() = civInfo.gameInfo.civilizations.first{it.civName==otherCivName}
|
||||||
|
// fun declareWar(){
|
||||||
|
// status = DiplomaticStatus.War
|
||||||
|
// otherCiv().diplomacy[civInfo.civName]!!.status = DiplomaticStatus.War
|
||||||
|
// }
|
||||||
|
}
|
@ -58,7 +58,7 @@ class UnitActions {
|
|||||||
unit.currentMovement != 0f)
|
unit.currentMovement != 0f)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(unit.getBaseUnit().upgradesTo!=null) {
|
if(unit.getBaseUnit().upgradesTo!=null && tile.getOwner()==unit.civInfo) {
|
||||||
val upgradedUnit = GameBasics.Units[unit.getBaseUnit().upgradesTo!!]!!
|
val upgradedUnit = GameBasics.Units[unit.getBaseUnit().upgradesTo!!]!!
|
||||||
if (upgradedUnit.isBuildable(unit.civInfo)) {
|
if (upgradedUnit.isBuildable(unit.civInfo)) {
|
||||||
val goldCostOfUpgrade = (upgradedUnit.cost - unit.getBaseUnit().cost) * 2 + 10
|
val goldCostOfUpgrade = (upgradedUnit.cost - unit.getBaseUnit().cost) * 2 + 10
|
||||||
|
Reference in New Issue
Block a user