mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-19 03:05:59 +07:00
Feature#2081 (#2100)
* Unit can now only be purchased if no other unit of same type is stationed in city center #2081 * #2081 Added unique to landsknecht and changed condition for movement panelty * Refactored when statement to if #2081 * Only one plane at a time can be purchased to a maximum of 6 that are NOT transported in a single city #2081 * removed duplicate code #2081 * refactor canPurchase() and now track bought units in a city in a mutableList #2081 * refactor canPurchase() it basicly just tracks if the unit can be placed on the center tile! if it cant then we dont allow the purchase! #2081 * Changed wording of unique and added translations #2081 * Changed wording of unique #2081 * removed unneeded imports #2081 Co-authored-by: Yair Morgenstern <yairm210@hotmail.com>
This commit is contained in:
parent
d7ac7f9173
commit
e06d537688
@ -530,7 +530,7 @@
|
|||||||
"strength": 16,
|
"strength": 16,
|
||||||
"cost": 45,
|
"cost": 45,
|
||||||
"requiredTech": "Civil Service",
|
"requiredTech": "Civil Service",
|
||||||
"uniques": ["Bonus vs Mounted 50%"],
|
"uniques": ["Bonus vs Mounted 50%", "Can move immediately once bought" ],
|
||||||
"upgradesTo": "Musketman",
|
"upgradesTo": "Musketman",
|
||||||
"obsoleteTech": "Gunpowder",
|
"obsoleteTech": "Gunpowder",
|
||||||
"hurryCostModifier": 20,
|
"hurryCostModifier": 20,
|
||||||
|
@ -3092,6 +3092,10 @@ Calcutta =
|
|||||||
# Requires translation!
|
# Requires translation!
|
||||||
Lahore =
|
Lahore =
|
||||||
# Requires translation!
|
# Requires translation!
|
||||||
|
All healing effects doubled =
|
||||||
|
Can move immediately once bought =
|
||||||
|
# Requires translation!
|
||||||
|
# Multiplayer Turn Checker Service
|
||||||
Bangalore =
|
Bangalore =
|
||||||
# Requires translation!
|
# Requires translation!
|
||||||
Hyderabad =
|
Hyderabad =
|
||||||
|
@ -879,7 +879,32 @@ Bonus when performing air sweep [bonusAmount]% = [bonusAmount]% Bonus bei Luftra
|
|||||||
Dogfighting I = Kurvenkampf I
|
Dogfighting I = Kurvenkampf I
|
||||||
Dogfighting II = Kurvenkampf II
|
Dogfighting II = Kurvenkampf II
|
||||||
Dogfighting III = Kurvenkampf III
|
Dogfighting III = Kurvenkampf III
|
||||||
|
Bonus when intercepting [bonusAmount]% = [bonusAmount]% Bonus beim Abfangen
|
||||||
|
Interception I = Abfangen I
|
||||||
|
Interception II = Abfangen II
|
||||||
|
Interception III = Abfangen III
|
||||||
|
Siege I = Belagerung I
|
||||||
|
Siege II = Belagerung II
|
||||||
|
Siege III = Belagerung III
|
||||||
|
Evasion = Ausweichen
|
||||||
|
Reduces damage taken from interception by 50% = Reduziert den empfangenden Schaden durch Abfangen um 50%
|
||||||
|
Bonus when intercepting [amount]% = [amount]% Bonus beim Abfangen
|
||||||
|
Ambush I = Lufthinterhalt I
|
||||||
|
Ambush II = Lufthinterhalt II
|
||||||
|
Armor Plating I = Panzerung I
|
||||||
|
Armor Plating II = Panzerung II
|
||||||
|
Armor Plating III = Panzerung III
|
||||||
|
+25% Combat Bonus when defending = +25% Kampfbonus bei Verteidigung
|
||||||
|
Flight Deck I = Flugdeck I
|
||||||
|
Flight Deck II = Flugdeck II
|
||||||
|
Flight Deck III = Flugdeck III
|
||||||
|
Can carry 1 extra air unit = Kann 1 zusätzliche Lufteinheit tragen
|
||||||
|
Can carry 2 aircraft = Kann 2 Flugzeuge tragen
|
||||||
|
Haka War Dance = Haka-Kriegstanz
|
||||||
|
-10% combat strength for adjacent enemy units = -10% Kampfstärke für angrenzende feindliche Einheiten
|
||||||
|
Rejuvenation = Verjüngung
|
||||||
|
All healing effects doubled = Alle Heilungseffekte verdoppelt
|
||||||
|
Can move immediately once bought = Kann sich nach dem Kauf sofort bewegen
|
||||||
# Multiplayer Turn Checker Service
|
# Multiplayer Turn Checker Service
|
||||||
|
|
||||||
Multiplayer options = Multiplayer Einstellungen
|
Multiplayer options = Multiplayer Einstellungen
|
||||||
|
@ -852,7 +852,6 @@ Bonus when performing air sweep [bonusAmount]% =
|
|||||||
Dogfighting I =
|
Dogfighting I =
|
||||||
Dogfighting II =
|
Dogfighting II =
|
||||||
Dogfighting III =
|
Dogfighting III =
|
||||||
|
|
||||||
# Multiplayer Turn Checker Service
|
# Multiplayer Turn Checker Service
|
||||||
|
|
||||||
Multiplayer options =
|
Multiplayer options =
|
||||||
|
@ -312,7 +312,7 @@ class CityConstructions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun purchaseConstruction(constructionName: String): Boolean {
|
fun purchaseConstruction(constructionName: String): Boolean {
|
||||||
if (!getConstruction(constructionName).postBuildEvent(this))
|
if (!getConstruction(constructionName).postBuildEvent(this, true))
|
||||||
return false // nothing built - no pay
|
return false // nothing built - no pay
|
||||||
|
|
||||||
cityInfo.civInfo.gold -= getConstruction(constructionName).getGoldCost(cityInfo.civInfo)
|
cityInfo.civInfo.gold -= getConstruction(constructionName).getGoldCost(cityInfo.civInfo)
|
||||||
|
@ -17,6 +17,7 @@ import com.unciv.logic.trade.TradeOffer
|
|||||||
import com.unciv.logic.trade.TradeType
|
import com.unciv.logic.trade.TradeType
|
||||||
import com.unciv.models.ruleset.tile.ResourceSupplyList
|
import com.unciv.models.ruleset.tile.ResourceSupplyList
|
||||||
import com.unciv.models.ruleset.tile.ResourceType
|
import com.unciv.models.ruleset.tile.ResourceType
|
||||||
|
import com.unciv.models.ruleset.unit.BaseUnit
|
||||||
import com.unciv.models.stats.Stats
|
import com.unciv.models.stats.Stats
|
||||||
import com.unciv.ui.utils.withoutItem
|
import com.unciv.ui.utils.withoutItem
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@ -582,5 +583,18 @@ class CityInfo {
|
|||||||
for(otherCiv in civsWithCloseCities)
|
for(otherCiv in civsWithCloseCities)
|
||||||
otherCiv.getDiplomacyManager(civInfo).setFlag(DiplomacyFlags.SettledCitiesNearUs,30)
|
otherCiv.getDiplomacyManager(civInfo).setFlag(DiplomacyFlags.SettledCitiesNearUs,30)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun canPurchase(construction : IConstruction) : Boolean {
|
||||||
|
if (construction is BaseUnit)
|
||||||
|
{
|
||||||
|
val tile = getCenterTile()
|
||||||
|
if (construction.unitType.isCivilian())
|
||||||
|
return tile.civilianUnit == null
|
||||||
|
if (construction.unitType.isAirUnit())
|
||||||
|
return tile.airUnits.filter { !it.isTransported }.size < 6
|
||||||
|
else return tile.militaryUnit == null
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
//endregion
|
//endregion
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ interface IConstruction : INamed {
|
|||||||
fun getGoldCost(civInfo: CivilizationInfo): Int
|
fun getGoldCost(civInfo: CivilizationInfo): Int
|
||||||
fun isBuildable(construction: CityConstructions): Boolean
|
fun isBuildable(construction: CityConstructions): Boolean
|
||||||
fun shouldBeDisplayed(construction: CityConstructions): Boolean
|
fun shouldBeDisplayed(construction: CityConstructions): Boolean
|
||||||
fun postBuildEvent(construction: CityConstructions): Boolean // Yes I'm hilarious.
|
fun postBuildEvent(construction: CityConstructions, wasBought: Boolean = false): Boolean // Yes I'm hilarious.
|
||||||
fun canBePurchased(): Boolean
|
fun canBePurchased(): Boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ open class SpecialConstruction(override var name: String, val description: Strin
|
|||||||
throw Exception("Impossible!")
|
throw Exception("Impossible!")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun postBuildEvent(construction: CityConstructions): Boolean {
|
override fun postBuildEvent(construction: CityConstructions, wasBought: Boolean): Boolean {
|
||||||
throw Exception("Impossible!")
|
throw Exception("Impossible!")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,7 +338,7 @@ class Building : NamedStats(), IConstruction{
|
|||||||
return getRejectionReason(construction)==""
|
return getRejectionReason(construction)==""
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun postBuildEvent(construction: CityConstructions): Boolean {
|
override fun postBuildEvent(construction: CityConstructions, wasBought: Boolean): Boolean {
|
||||||
val civInfo = construction.cityInfo.civInfo
|
val civInfo = construction.cityInfo.civInfo
|
||||||
|
|
||||||
if ("Spaceship part" in uniques) {
|
if ("Spaceship part" in uniques) {
|
||||||
|
@ -151,7 +151,7 @@ class BaseUnit : INamed, IConstruction {
|
|||||||
return getRejectionReason(construction) == ""
|
return getRejectionReason(construction) == ""
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun postBuildEvent(construction: CityConstructions): Boolean {
|
override fun postBuildEvent(construction: CityConstructions, wasBought: Boolean): Boolean {
|
||||||
val unit = construction.cityInfo.civInfo.placeUnitNearTile(construction.cityInfo.location, name)
|
val unit = construction.cityInfo.civInfo.placeUnitNearTile(construction.cityInfo.location, name)
|
||||||
if(unit==null) return false // couldn't place the unit, so there's actually no unit =(
|
if(unit==null) return false // couldn't place the unit, so there's actually no unit =(
|
||||||
|
|
||||||
@ -165,6 +165,10 @@ class BaseUnit : INamed, IConstruction {
|
|||||||
&& construction.cityInfo.containsBuildingUnique("All newly-trained melee, mounted, and armored units in this city receive the Drill I promotion"))
|
&& construction.cityInfo.containsBuildingUnique("All newly-trained melee, mounted, and armored units in this city receive the Drill I promotion"))
|
||||||
unit.promotions.addPromotion("Drill I", isFree = true)
|
unit.promotions.addPromotion("Drill I", isFree = true)
|
||||||
|
|
||||||
|
//movement penalty
|
||||||
|
if(!unit.hasUnique("Can move directly once bought") && wasBought)
|
||||||
|
unit.currentMovement = 0f
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,7 +306,9 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
|
|||||||
if (construction == null || !construction.canBePurchased()
|
if (construction == null || !construction.canBePurchased()
|
||||||
|| !construction.isBuildable(cityConstructions)
|
|| !construction.isBuildable(cityConstructions)
|
||||||
|| !UncivGame.Current.worldScreen.isPlayersTurn
|
|| !UncivGame.Current.worldScreen.isPlayersTurn
|
||||||
|| city.isPuppet || city.isInResistance()) {
|
|| city.isPuppet || city.isInResistance()
|
||||||
|
|| !city.canPurchase(construction)
|
||||||
|
) {
|
||||||
button.setText("Buy".tr())
|
button.setText("Buy".tr())
|
||||||
button.disable()
|
button.disable()
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user