Skip to content

Commit

Permalink
Notes, comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
will-ca committed Jan 17, 2022
1 parent e0f0fe3 commit 241f89e
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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})'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion core/src/com/unciv/models/modscripting/ScriptedModRules.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
3 changes: 3 additions & 0 deletions core/src/com/unciv/scripting/ScriptingState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
2 changes: 1 addition & 1 deletion core/src/com/unciv/ui/consolescreen/ConsoleScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 241f89e

Please sign in to comment.