mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-10 10:58:13 +07:00
Unit gifting (#4557)
* wonder splash screens * wonder splash screens atlas * reset to master * add basic gifting to city states and major civs * actual gifting of the unit * add gift icon to atlas * adjust relationship decay * add strings to jsons * AI and player return same object
This commit is contained in:
parent
f5a95fad18
commit
118c1fc888
BIN
android/Images/OtherIcons/Present.png
Normal file
BIN
android/Images/OtherIcons/Present.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 1.0 MiB After Width: | Height: | Size: 1.0 MiB |
@ -231,6 +231,8 @@ Your arrogant demands are in bad taste =
|
||||
Your use of nuclear weapons is disgusting! =
|
||||
# Requires translation!
|
||||
You have stolen our lands! =
|
||||
# Requires translation!
|
||||
You gave us units! =
|
||||
|
||||
# Requires translation!
|
||||
Demands =
|
||||
@ -1022,6 +1024,8 @@ Health =
|
||||
# Requires translation!
|
||||
Disband unit =
|
||||
# Requires translation!
|
||||
Gift unit =
|
||||
# Requires translation!
|
||||
Explore =
|
||||
# Requires translation!
|
||||
Stop exploration =
|
||||
|
@ -124,6 +124,7 @@ You refused to stop settling cities near us = Ni vägrade sluta bygga städer n
|
||||
Your arrogant demands are in bad taste = Era arroganta krav är smaklösa
|
||||
Your use of nuclear weapons is disgusting! = Ert kärnvapensbruk är vidrigt!
|
||||
You have stolen our lands! = Ni har stulit vårt land!
|
||||
You gave us units! = Ni har gett oss enheter!
|
||||
|
||||
Demands = Krav
|
||||
Please don't settle new cities near us. = Var god och bygg inte nya städer nära oss.
|
||||
@ -540,6 +541,7 @@ Found city = Grunda stad
|
||||
Promote = Befordra
|
||||
Health = Hälsa
|
||||
Disband unit = Hemförlova enhet
|
||||
Gift unit = Skänk enhet
|
||||
Explore = Utforska
|
||||
Stop exploration = Avsluta utforskning
|
||||
Pillage = Plundra
|
||||
|
@ -124,6 +124,7 @@ You refused to stop settling cities near us =
|
||||
Your arrogant demands are in bad taste =
|
||||
Your use of nuclear weapons is disgusting! =
|
||||
You have stolen our lands! =
|
||||
You gave us units! =
|
||||
|
||||
Demands =
|
||||
Please don't settle new cities near us. =
|
||||
@ -541,6 +542,7 @@ Found city =
|
||||
Promote =
|
||||
Health =
|
||||
Disband unit =
|
||||
Gift unit =
|
||||
Explore =
|
||||
Stop exploration =
|
||||
Pillage =
|
||||
|
@ -57,7 +57,8 @@ enum class DiplomaticModifiers{
|
||||
DeclaredFriendshipWithOurAllies,
|
||||
DenouncedOurEnemies,
|
||||
OpenBorders,
|
||||
FulfilledPromiseToNotSettleCitiesNearUs
|
||||
FulfilledPromiseToNotSettleCitiesNearUs,
|
||||
GaveUsUnits
|
||||
}
|
||||
|
||||
class DiplomacyManager() {
|
||||
@ -486,6 +487,7 @@ class DiplomacyManager() {
|
||||
revertToZero(DiplomaticModifiers.DenouncedOurAllies, 1 / 4f)
|
||||
revertToZero(DiplomaticModifiers.DenouncedOurEnemies, 1 / 4f)
|
||||
revertToZero(DiplomaticModifiers.Denunciation, 1 / 8f) // That's personal, it'll take a long time to fade
|
||||
revertToZero(DiplomaticModifiers.GaveUsUnits, 1 / 4f)
|
||||
|
||||
setFriendshipBasedModifier()
|
||||
|
||||
|
@ -658,6 +658,17 @@ class MapUnit {
|
||||
.forEach { unit -> unit.destroy() }
|
||||
}
|
||||
|
||||
fun gift(recipient: CivilizationInfo) {
|
||||
civInfo.removeUnit(this)
|
||||
civInfo.updateViewableTiles()
|
||||
// all transported units should be destroyed as well
|
||||
currentTile.getUnits().filter { it.isTransported && isTransportTypeOf(it) }
|
||||
.toList() // because we're changing the list
|
||||
.forEach { unit -> unit.destroy() }
|
||||
assignOwner(recipient)
|
||||
recipient.updateViewableTiles()
|
||||
}
|
||||
|
||||
fun removeFromTile() = currentTile.removeUnit(this)
|
||||
|
||||
fun moveThroughTile(tile: TileInfo) {
|
||||
|
@ -36,5 +36,6 @@ enum class UnitActionType(val value: String) {
|
||||
HurryWonder("Hurry Wonder"),
|
||||
ConductTradeMission("Conduct Trade Mission"),
|
||||
FoundReligion("Found a Religion"),
|
||||
DisbandUnit("Disband unit")
|
||||
DisbandUnit("Disband unit"),
|
||||
GiftUnit("Gift unit")
|
||||
}
|
@ -430,6 +430,7 @@ class DiplomacyScreen(val viewingCiv:CivilizationInfo):CameraStageBaseScreen() {
|
||||
UnacceptableDemands -> "Your arrogant demands are in bad taste"
|
||||
UsedNuclearWeapons -> "Your use of nuclear weapons is disgusting!"
|
||||
StealingTerritory -> "You have stolen our lands!"
|
||||
GaveUsUnits -> "You gave us units!"
|
||||
}
|
||||
text = text.tr() + " "
|
||||
if (modifier.value > 0) text += "+"
|
||||
|
@ -67,6 +67,7 @@ object UnitActions {
|
||||
addSpreadReligionActions(unit, actionList, tile)
|
||||
actionList += getImprovementConstructionActions(unit, tile)
|
||||
addDisbandAction(actionList, unit, worldScreen)
|
||||
addGiftAction(unit, actionList, tile)
|
||||
|
||||
return actionList
|
||||
}
|
||||
@ -611,4 +612,42 @@ object UnitActions {
|
||||
// Can't pillage friendly tiles, just like you can't attack them - it's an 'act of war' thing
|
||||
return tileOwner == null || tileOwner == unit.civInfo || unit.civInfo.isAtWarWith(tileOwner)
|
||||
}
|
||||
|
||||
private fun addGiftAction(unit: MapUnit, actionList: ArrayList<UnitAction>, tile: TileInfo) {
|
||||
val getGiftAction = getGiftAction(unit, tile)
|
||||
if (getGiftAction != null) actionList += getGiftAction
|
||||
}
|
||||
|
||||
fun getGiftAction(unit: MapUnit, tile: TileInfo): UnitAction? {
|
||||
val recipient = tile.getOwner()
|
||||
// We need to be in another civs territory.
|
||||
if (recipient == null || recipient.isCurrentPlayer()) return null
|
||||
|
||||
// City States only take miliary units (and GPs for certain civs)
|
||||
if (recipient.isCityState()) {
|
||||
if (unit.isGreatPerson()) return null // Unless Sweden
|
||||
else if (!unit.baseUnit().matchesFilter("Military")) return null
|
||||
}
|
||||
// If gifting to major civ they need to be friendly
|
||||
else if (!tile.isFriendlyTerritory(unit.civInfo)) return null
|
||||
|
||||
if (unit.currentMovement <= 0)
|
||||
return UnitAction(UnitActionType.GiftUnit, uncivSound = UncivSound.Silent, action = null)
|
||||
|
||||
val giftAction = {
|
||||
if (recipient.isCityState()) {
|
||||
if (unit.isGreatPerson())
|
||||
recipient.getDiplomacyManager(unit.civInfo).influence += 90
|
||||
else
|
||||
recipient.getDiplomacyManager(unit.civInfo).influence += 5
|
||||
recipient.updateAllyCivForCityState()
|
||||
}
|
||||
else recipient.getDiplomacyManager(unit.civInfo).addModifier(DiplomaticModifiers.GaveUsUnits, 5f)
|
||||
|
||||
unit.gift(recipient)
|
||||
// UncivGame.Current.worldScreen.shouldUpdate = true
|
||||
}
|
||||
|
||||
return UnitAction(UnitActionType.GiftUnit, uncivSound = UncivSound.Silent, action = giftAction)
|
||||
}
|
||||
}
|
||||
|
@ -61,6 +61,7 @@ class UnitActionsTable(val worldScreen: WorldScreen) : Table() {
|
||||
"Stop exploration" -> return UnitIconAndKey(ImageGetter.getImage("OtherIcons/Stop"), 'x')
|
||||
"Pillage" -> return UnitIconAndKey(ImageGetter.getImage("OtherIcons/Pillage"), 'p')
|
||||
"Disband unit" -> return UnitIconAndKey(ImageGetter.getImage("OtherIcons/DisbandUnit"))
|
||||
"Gift unit" -> return UnitIconAndKey(ImageGetter.getImage("OtherIcons/Present"))
|
||||
else -> return UnitIconAndKey(ImageGetter.getImage("OtherIcons/Star"))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user