Skip to content

Commit

Permalink
[FOCS] WIP convert buildings
Browse files Browse the repository at this point in the history
  • Loading branch information
Cjkjvfnby authored and o01eg committed Feb 22, 2025
1 parent 23d2546 commit 79f35be
Show file tree
Hide file tree
Showing 32 changed files with 1,397 additions and 847 deletions.
39 changes: 39 additions & 0 deletions default/scripting/buildings/BLACK_HOLE_COLLAPSER.focs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from focs._effects import (
BlackHole,
ContainedBy,
Contains,
CreateField,
Destroy,
EffectsGroup,
IsSource,
OwnedBy,
Planet,
Source,
Star,
)
from macros.base_prod import BUILDING_COST_MULTIPLIER
from macros.enqueue import ENQUEUE_BUILD_ONE_PER_PLANET

try:
from focs._buildings import *
except ModuleNotFoundError:
pass

BuildingType( # type: ignore[reportUnboundVariable]
name="BLD_BLACK_HOLE_COLLAPSER",
description="BLD_BLACK_HOLE_COLLAPSER_DESC",
buildcost=5000 * BUILDING_COST_MULTIPLIER,
buildtime=10,
location=(Planet() & OwnedBy(empire=Source.Owner) & ContainedBy(Contains(Planet() & Star(type=[BlackHole])))),
enqueuelocation=ENQUEUE_BUILD_ONE_PER_PLANET,
effectsgroups=[
EffectsGroup(
scope=IsSource,
effects=[
Destroy,
CreateField(type="FLD_SUBSPACE_RIFT", size=100),
],
),
],
icon="",
)
23 changes: 0 additions & 23 deletions default/scripting/buildings/BLACK_HOLE_COLLAPSER.focs.txt

This file was deleted.

75 changes: 75 additions & 0 deletions default/scripting/buildings/BLACK_HOLE_POW_GEN.focs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
from buildings.buildings import SPECIES_LIKES_OR_DISLIKES_BUILDING_STABILITY_EFFECTS
from focs._effects import (
BlackHole,
Contains,
EffectsGroup,
EmpireHasAdoptedPolicy,
Focus,
Happiness,
IsBuilding,
IsSource,
NamedReal,
OwnedBy,
Planet,
ResourceSupplyConnected,
SetTargetIndustry,
Source,
Star,
StatisticIf,
Target,
Value,
)
from macros.base_prod import BUILDING_COST_MULTIPLIER, INDUSTRY_PER_POP
from macros.enqueue import ENQUEUE_BUILD_ONE_PER_PLANET
from macros.priorities import (
TARGET_AFTER_SCALING_PRIORITY,
)

try:
from focs._buildings import *
except ModuleNotFoundError:
pass

BuildingType( # type: ignore[reportUnboundVariable]
name="BLD_BLACK_HOLE_POW_GEN",
description="BLD_BLACK_HOLE_POW_GEN_DESC",
buildcost=300
* BUILDING_COST_MULTIPLIER
* (
1
- 0.25
* StatisticIf(float, condition=IsSource & EmpireHasAdoptedPolicy(empire=Source.Owner, name="PLC_INDUSTRIALISM"))
),
buildtime=8,
tags=["ORBITAL"],
location=(
Planet()
& ~Contains(IsBuilding(name=["BLD_BLACK_HOLE_POW_GEN"]))
& OwnedBy(empire=Source.Owner)
& Star(type=[BlackHole])
),
enqueuelocation=ENQUEUE_BUILD_ONE_PER_PLANET,
effectsgroups=[
*SPECIES_LIKES_OR_DISLIKES_BUILDING_STABILITY_EFFECTS,
EffectsGroup(
scope=(
Planet()
& Focus(type=["FOCUS_INDUSTRY"])
& OwnedBy(empire=Source.Owner)
& Happiness(low=NamedReal(name="BLD_BLACK_HOLE_POW_GEN_MIN_STABILITY", value=20))
& ResourceSupplyConnected(empire=Source.Owner, condition=IsSource)
),
activation=Star(type=[BlackHole]),
stackinggroup="BLD_BLACK_HOLE_POW_GEN_PRIMARY_EFFECT",
priority=TARGET_AFTER_SCALING_PRIORITY,
effects=[
SetTargetIndustry(
value=Value
+ Target.Population
* NamedReal(name="BLD_BLACK_HOLE_POW_GEN_TARGET_INDUSTRY_PERPOP", value=1.0 * INDUSTRY_PER_POP)
)
],
),
],
icon="icons/building/blackhole.png",
)
37 changes: 0 additions & 37 deletions default/scripting/buildings/BLACK_HOLE_POW_GEN.focs.txt

This file was deleted.

83 changes: 83 additions & 0 deletions default/scripting/buildings/COLLECTIVE_NET.focs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
from buildings.buildings import SPECIES_LIKES_OR_DISLIKES_BUILDING_STABILITY_EFFECTS
from focs._effects import (
Contains,
EffectsGroup,
Focus,
Happiness,
IsBuilding,
NamedReal,
NamedRealLookup,
OwnedBy,
Planet,
SetTargetIndustry,
SetTargetResearch,
Ship,
Source,
Stationary,
Target,
TargetPopulation,
Value,
WithinDistance,
)
from macros.base_prod import BUILDING_COST_MULTIPLIER, INDUSTRY_PER_POP, RESEARCH_PER_POP
from macros.enqueue import ENQUEUE_BUILD_ONE_PER_PLANET
from macros.priorities import TARGET_AFTER_2ND_SCALING_PRIORITY

try:
from focs._buildings import *
except ModuleNotFoundError:
pass

BuildingType( # type: ignore[reportUnboundVariable]
name="BLD_COLLECTIVE_NET",
description="BLD_COLLECTIVE_NET_DESC",
buildcost=250 * BUILDING_COST_MULTIPLIER,
buildtime=10,
location=(
Planet()
& ~Contains(IsBuilding(name=["BLD_COLLECTIVE_NET"]))
& OwnedBy(empire=Source.Owner)
& TargetPopulation(low=1)
),
enqueuelocation=ENQUEUE_BUILD_ONE_PER_PLANET,
effectsgroups=[
*SPECIES_LIKES_OR_DISLIKES_BUILDING_STABILITY_EFFECTS,
EffectsGroup(
scope=(
Planet()
& OwnedBy(empire=Source.Owner)
& Focus(type=["FOCUS_INDUSTRY"])
& Happiness(low=NamedReal(name="BLD_COLLECTIVE_NET_MIN_STABILITY", value=15))
),
activation=~WithinDistance(distance=200, condition=Ship & Stationary),
stackinggroup="BLD_COLLECTIVE_NET_INDUSTRY_EFFECT",
priority=TARGET_AFTER_2ND_SCALING_PRIORITY,
effects=[
SetTargetIndustry(
value=Value
+ Target.Population
* NamedReal(name="BLD_COLLECTIVE_NET_TARGET_INDUSTRY_PERPOP", value=0.5 * INDUSTRY_PER_POP)
)
],
),
EffectsGroup(
scope=(
Planet()
& OwnedBy(empire=Source.Owner)
& Focus(type=["FOCUS_RESEARCH"])
& Happiness(low=NamedRealLookup(name="BLD_COLLECTIVE_NET_MIN_STABILITY"))
),
activation=WithinDistance(distance=200, condition=Ship & Stationary),
stackinggroup="BLD_COLLECTIVE_NET_RESEARCH_EFFECT",
priority=TARGET_AFTER_2ND_SCALING_PRIORITY,
effects=[
SetTargetResearch(
value=Value
+ Target.Population
* NamedReal(name="BLD_COLLECTIVE_NET_TARGET_RESEARCH_PERPOP", value=0.5 * RESEARCH_PER_POP)
)
],
),
],
icon="icons/building/psi-corps.png",
)
55 changes: 0 additions & 55 deletions default/scripting/buildings/COLLECTIVE_NET.focs.txt

This file was deleted.

44 changes: 44 additions & 0 deletions default/scripting/buildings/COLONY_BASE.focs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from focs._effects import (
Contains,
CreateShip,
Destroy,
EffectsGroup,
IsBuilding,
IsSource,
OwnedBy,
Planet,
Population,
Source,
)
from macros.base_prod import BUILDING_COST_MULTIPLIER
from macros.misc import MIN_RECOLONIZING_SIZE

try:
from focs._buildings import *
except ModuleNotFoundError:
pass

BuildingType( # type: ignore[reportUnboundVariable]
name="BLD_COLONY_BASE",
description="BLD_COLONY_BASE_DESC",
buildcost=45 * BUILDING_COST_MULTIPLIER,
buildtime=1,
location=(
Planet()
& ~Contains(IsBuilding(name=["BLD_COLONY_BASE"]))
& Population(low=MIN_RECOLONIZING_SIZE)
& OwnedBy(empire=Source.Owner)
),
# TODO: Disable colony base if there is no possibility in the current system
effectsgroups=[
EffectsGroup(
scope=IsSource,
effects=[CreateShip(designname="SD_COLONY_BASE", empire=Source.Owner, species=Source.Planet.Species)],
),
EffectsGroup(
scope=IsSource,
effects=[Destroy],
),
],
icon="icons/ship_hulls/colony_base_hull_small.png",
)
26 changes: 0 additions & 26 deletions default/scripting/buildings/COLONY_BASE.focs.txt

This file was deleted.

Loading

0 comments on commit 79f35be

Please sign in to comment.