# Short room-graph program with clipped roof ends and fitted domestic interiors.
import argparse
from pathlib import Path
from hearth.randomness import Scope
from hearth.components import Blueprint, RoomSpec, FacadeDesign, InteriorDesign
from hearth.components.roofcraft import RoofDesign
from hearth.lodges import lodge_scene
from hearth.persistence import export_scene


def hearth_house(seed):
    rng = Scope(seed).stream('hearth-house-layout')
    rooms = [RoomSpec(0, 0, 0, 'living'), RoomSpec(1, 0, 0, 'kitchen'), RoomSpec(0, 1, 0, 'library')]
    if rng.choice((False, True)):
        rooms.append(RoomSpec(1, 1, 0, 'workshop'))
    upper = rng.choice((((0, 0),), ((1, 0),), ((0, 0), (1, 0))))
    rooms.extend(RoomSpec(x, z, 1, 'bedroom') for x, z in upper)
    return Blueprint(tuple(rooms), bay=rng.choice((11, 13)), roof_axis=rng.choice(('auto', 'x', 'z')), roof_design=RoofDesign(rng.choice(((1, 2), (2, 1))), rng.choice((7, 10)), end_hips=rng.choice(((0, 2), (2, 2), (3, 1)))), attic_purpose=rng.choice(('bedroom', 'library')), porch_bays=2, porch_depth=5, balcony=len(upper) == 2 and rng.choice((False, True)), chimney=True, facade_design=FacadeDesign(), rail_material='dark_oak', interior_design=InteriorDesign(table_length=rng.choice((3, 4))))


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--seed', type=int, default=0)
    parser.add_argument('--environment-seed', type=int, default=0)
    parser.add_argument('--output', type=Path, default=Path('hearth-house.litematic'))
    args = parser.parse_args()
    export_scene(lodge_scene(hearth_house(args.seed), args.seed, args.environment_seed), args.output)
