ConstructionTask: placing a building enqueues construction #109
No reviewers
Labels
No labels
assets
bug
duplicate
enhancement
help wanted
invalid
question
testing
ui
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
liamjd/UntitledColonyBuilder!109
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "70-construction-task"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #70.
Buildings.place()now creates pawn-raised buildings asPLANNEDand enqueues aConstructionTasktargeting the building's entrance cell.Decisions taken (the issue asked for two of these to be noted here)
GameState.building_status_changed(building, old_status), notbuilding_built. #71 has to re-render onPLANNED -> UNDER_CONSTRUCTIONas well as on completion, which a completion-only signal cannot carry.Buildings.set_status()is the only place it is emitted.ctxis a typedTaskContext, not theDictionary#66 left as a TODO. The registries a task may touch are few and run-scoped, and a Dictionary costvar b: Buildings = ctx["buildings"]in every hook of every task type — with key typos failing at runtime inon_cancel(), the branch least likely to be exercised by hand. It carriesbuildingstoday; #75 adds the map for reachability.on_cancel()callsbuildings.remove();remove()does not cancel the task back, so the two cannot recurse. #72's demolish UI enters throughcancel().work()does not complete itself whenwork_remainingreaches zero. The manager owns completion, because that is where the status transition, the parent re-check and the archiving live — a task callingon_complete()directly would apply its effects and still be sitting in the queue.Buildings.tasksis public, matchingmap. Both are injected bygame.gd, and an injected collaborator behind a leading underscore is one the injector has to reach through.Entrances, finally wired
BuildingFootprint.doorstep()has existed since #55 but nothing ever called it, soBuilding.entrancewas stillVector2i.ZERO. It is nowanchor + doorstep(rotation_steps)— a grid cell likecells(), not an anchor-relative offset likeoffsets(). The doorstep is deliberately excluded from the footprint's cells, which is what makes it a legal cell for a builder to stand in; a test pins that it never enters_occupancy.build_days == 0.0means "not raised by pawns" — the Colony Centre lands already built — so that branch placesBUILTand enqueues nothing.Verification
481 passing, 0 failing, 1 pendingacross 482 tests. The one pending is the pre-existing #85 marker intest_task_tree.gd, untouched here.test/unit/test_construction_task.gdadds 19 tests, written before the implementation and red for the right reason first:ConstructionTaskenqueued, PENDING, targeting the entrance, holdingbuilding_idwork_remainingfromGameCalendar.days_to_ticks()— asserted against the calendar rather thanbuild_work_ticks(), so a skipped conversion fails rather than agreeing with itselfbuild_days == 0.0lands BUILT with an empty queueTaskManagerstill places, and stays quiet doing itwork()breaks ground; effort decrements; never goes below zerocomplete()raises the building and announces the transitioncount_of()and tripat_limit()Also fixed the stale assertion message in
test_buildings.gdthat still referenced "#54's follow-up", and therequired_rolltypo onTask.Not done here
work(). Until then the task is only exercised by tests; the tests use a_take_up()helper to move it throughclaim -> startbecauseCOMPLETEis unreachable fromPENDINGby design.next_for()still callstask._can_start()directly and re-checks children inline, duplicating thecan_start()wrapper onTask. Pre-existing, left alone to keep this branch to #70; worth a follow-up issue against #67.🤖 Generated with Claude Code