diff --git a/android/assets/scripting/enginefiles/python/unciv_lib/wrapping.py b/android/assets/scripting/enginefiles/python/unciv_lib/wrapping.py index 1cf6bd9de9bfc..e6a6148bf053a 100644 --- a/android/assets/scripting/enginefiles/python/unciv_lib/wrapping.py +++ b/android/assets/scripting/enginefiles/python/unciv_lib/wrapping.py @@ -5,6 +5,8 @@ # TODO: Definitely CProfile this. +# Random.sample, collection ABCs sequence? + class ForeignRequestMethod: """Decorator and descriptor protocol implementation for methods of ForeignObject subclasses that return values from foreign requests.""" def __init__(self, func): diff --git a/android/assets/scripting/enginefiles/python/unciv_scripting_examples/EventPopup.py b/android/assets/scripting/enginefiles/python/unciv_scripting_examples/EventPopup.py index ef1e4f6534be0..b32c333be0500 100644 --- a/android/assets/scripting/enginefiles/python/unciv_scripting_examples/EventPopup.py +++ b/android/assets/scripting/enginefiles/python/unciv_scripting_examples/EventPopup.py @@ -117,7 +117,7 @@ def EVENT_POPUP_DEMOARGS(): ( (f"Let Chaos reign! (+{omniboost} {real(Fonts.gold.toString())}, {real(Fonts.culture.toString())}, {real(Fonts.science.toString())})", None), (f"(+{sum(omniproductionboosts)} {real(Fonts.production.toString())} spread across all your cities.)", None), - (f"All cities enter resistance for +{omniresistance} turns.", GdxColours['SCARLET']) + (f"All your cities enter resistance for +{omniresistance} turns.", GdxColours['SCARLET']) ): modApiHelpers.lambdifyCombine([ modApiHelpers.lambdifyReadPathcode(civInfo, f'.addGold({omniboost})'), diff --git a/android/assets/scripting/enginefiles/python/unciv_scripting_examples/Merfolk.py b/android/assets/scripting/enginefiles/python/unciv_scripting_examples/Merfolk.py index 52ccbd8310846..09be7ebd96c40 100644 --- a/android/assets/scripting/enginefiles/python/unciv_scripting_examples/Merfolk.py +++ b/android/assets/scripting/enginefiles/python/unciv_scripting_examples/Merfolk.py @@ -29,6 +29,12 @@ #civInfo.addNotification("Test", civInfo.cities[0].location, apiHelpers.Jvm.arrayOfString(["StatIcons/Gold"])) +#import random; [random.sample([*gameInfo.civilizations], 1)[0].placeUnitNearTile(t.position, random.sample(gameInfo.ruleSet.units.keys(), 1)[0]) for t in gameInfo.tileMap.values] + +# import random; [civInfo.placeUnitNearTile(t.position, unitgetter()) for unitgetter in (lambda: random.sample(gameInfo.ruleSet.units.keys(), 1)[0], lambda: random.sample(('Missile Cruiser', 'Nuclear Submarine'), 1)[0], lambda: 'Worker', lambda: 'Guided Missile') for t in gameInfo.tileMap.values]; ([setattr(unit, 'action', random.sample(('Sleep', 'Automate', 'Fortify 0', 'Explore'), 1)[0]) for unit in apiHelpers.Jvm.toList(civInfo.getCivUnits())], civInfo.addGold(99999)) + +# [setattr(unit, 'action', 'Sleep') for unit in apiHelpers.Jvm.toList(civInfo.getIdleUnits())] + def moveCity(): tileInfo.owningCity = city #Seems to be used for rendering only. #city.tiles.add(tile) Causes exception in worker thread in next turn. diff --git a/core/src/com/unciv/models/modscripting/ScriptedModRules.kt b/core/src/com/unciv/models/modscripting/ScriptedModRules.kt index 440593aa23f04..3c72798593726 100644 --- a/core/src/com/unciv/models/modscripting/ScriptedModRules.kt +++ b/core/src/com/unciv/models/modscripting/ScriptedModRules.kt @@ -5,11 +5,14 @@ import com.badlogic.gdx.utils.JsonReader import com.badlogic.gdx.utils.JsonValue import com.unciv.scripting.ScriptingState + +// TODO: Make sure DropBox multiplayer doesn't provide quick and easy arbitrary code execution for would-be attackers? + class ScriptedModLoadable(val modRules: ScriptedModRules) { } -class ScriptedModRules {// See, try to follow conventions of, TilesetAndMod maybe? +class ScriptedModRules {// See, try to follow conventions of, TilesetAndMod and TilesetCache/ModOptions, maybe? // Getting this deserializing from JSON was a humongous, humongous pain. GDX seems to take only three levels of nested mappings before it stops knowing what to do with the arrays at the deepest level. I could have just used KotlinX instead as I'm bringing in the dependency anyway, but for some reason I seem to want to align the parts of the scripting API that interact with the existing codebase with the tools that are already used. diff --git a/core/src/com/unciv/scripting/ScriptingState.kt b/core/src/com/unciv/scripting/ScriptingState.kt index 648396ec120fa..6243b18d2d4de 100644 --- a/core/src/com/unciv/scripting/ScriptingState.kt +++ b/core/src/com/unciv/scripting/ScriptingState.kt @@ -26,6 +26,9 @@ import kotlin.collections.ArrayList // See https://github.com/yairm210/Unciv/pull/5592/commits/a1f51e08ab782ab46bda220e0c4aaae2e8ba21a4 for example of running locking operation in separate thread. + +// TODO: + /** * Self-contained instance of scripting API use. * diff --git a/core/src/com/unciv/ui/consolescreen/ConsoleScreen.kt b/core/src/com/unciv/ui/consolescreen/ConsoleScreen.kt index c56668010f68c..07a123c48d16e 100644 --- a/core/src/com/unciv/ui/consolescreen/ConsoleScreen.kt +++ b/core/src/com/unciv/ui/consolescreen/ConsoleScreen.kt @@ -221,7 +221,7 @@ class ConsoleScreen(var closeAction: () -> Unit): BaseScreen() { } var termbutton = ImageGetter.getImage("OtherIcons/Stop") val terminable = backend.userTerminable // Grey out if not terminable. - if (!terminable) { + if (!terminable) { // TODO: There's a Button.disable() extension function. termbutton.setColor(0.7f, 0.7f, 0.7f, 0.3f) // termbutton.color.a = 0.3f }