Refactor writing/formatting systems
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
from mcpacker.format.report.mobspawnreport import MobSpawnReport
|
||||
from mcpacker.model.core.ecology.biomefilter import BiomeFilter as BF
|
||||
from mcpacker.model.core.fauna.mob import Mob
|
||||
from mcpacker.model.core.fauna.mobspawn import MobSpawn
|
||||
from mcpacker.model.core.geology.mineral import Mineral
|
||||
from mcpacker.model.core.geology.replacement import Replacement
|
||||
from mcpacker.model.core.habitat import Habitat
|
||||
from mcpacker.model.modpack import AugmentFunc
|
||||
from mcpacker.model.modpack import ModPack
|
||||
from pytest import fixture
|
||||
|
||||
import mcpacker.model.core.altitude as AL
|
||||
import mcpacker.model.core.ecology.flora as FL
|
||||
import mcpacker.model.core.ecology.geology as GE
|
||||
import mcpacker.model.core.ecology.heat as HE
|
||||
import mcpacker.model.core.ecology.humidity as HU
|
||||
import mcpacker.model.core.ecology.soil as SO
|
||||
import mcpacker.model.core.ecology.water as WA
|
||||
import mcpacker.model.core.fauna.active as AC
|
||||
import mcpacker.model.core.fauna.group as GR
|
||||
import mcpacker.model.core.fauna.location as LO
|
||||
import mcpacker.model.core.scarcity as SC
|
||||
import mcpacker.model.core.season as SE
|
||||
import textwrap
|
||||
|
||||
|
||||
# Fixtures #########################################################################################
|
||||
|
||||
@fixture(name="addMobs")
|
||||
def defineAddMobs():
|
||||
def addMobs(pack:ModPack):
|
||||
pack.world.mobs.add(Mob("minecraft:chicken", AC.DIURNAL))
|
||||
|
||||
yield addMobs
|
||||
|
||||
@fixture(name="addMobSpawns")
|
||||
def defineAddMobSpawnss():
|
||||
def addMobSpawns(pack:ModPack):
|
||||
mobs = pack.world.mobs
|
||||
spawns = pack.world.mobSpawns
|
||||
|
||||
pack.world.mobSpawns.add(
|
||||
MobSpawn(mobs["minecraft:chicken"],
|
||||
Habitat(
|
||||
altitude = AL.span(AL.LOWLANDS, AL.UPLANDS),
|
||||
biomeFilter = BF([HE.TROPICAL, HU.WET, FL.within(FL.CANOPY, FL.CLEARING)]),
|
||||
seasons = SE.SUMMER,
|
||||
group = GR.TROUP,
|
||||
scarcity = SC.COMMON,
|
||||
).derive(
|
||||
seasons = SE.exclude(SE.SUMMER),
|
||||
scarcity = SC.UNCOMMON
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
yield addMobSpawns
|
||||
|
||||
@fixture(name="pack")
|
||||
def createPack(addMobs:AugmentFunc, addMobSpawns:AugmentFunc):
|
||||
yield ModPack("testModPack").augment(addMobs).augment(addMobSpawns)
|
||||
|
||||
@fixture(name="report")
|
||||
def createReport(pack:ModPack):
|
||||
yield MobSpawnReport(pack).compose()
|
||||
|
||||
|
||||
# Tests ############################################################################################
|
||||
|
||||
def test_write(report:MobSpawnReport):
|
||||
assert str(report).strip() == textwrap.dedent("""
|
||||
# Mob: minecraft:chicken
|
||||
|
||||
* habitat 1
|
||||
* altitude: lowlands-uplands
|
||||
* biomeFilter:
|
||||
* Heat: tropical
|
||||
* Humidity: wet
|
||||
* Flora: any of: canopy, forest, clearing
|
||||
* seasons: summer
|
||||
* group: troup
|
||||
* location: outside
|
||||
* scarcity: common
|
||||
* habitat 2
|
||||
* altitude: lowlands-uplands
|
||||
* biomeFilter:
|
||||
* Heat: tropical
|
||||
* Humidity: wet
|
||||
* Flora: any of: canopy, forest, clearing
|
||||
* seasons: spring, autumn, winter
|
||||
* group: troup
|
||||
* location: outside
|
||||
* scarcity: uncommon
|
||||
""").strip()
|
||||
Reference in New Issue
Block a user