This commit is contained in:
Forrest 2026-10-07 14:50:55 -04:00
parent 215e24e246
commit bbd8012fff
16 changed files with 510 additions and 213 deletions

View file

@ -197,8 +197,8 @@ pack (`assets/farm/ithappy/farm/prefabs/assets/`).
until the next phase and a line filling over it, a hint line under it (what tonight brings,
enemies on the farm), and a banner at each phase
change ("Night 3: Breakers at the fences"), with the dusk hint under it from dusk into the
night. `ReviewPanel` is the morning review: last night's losses per category, what's left, what
needs repair, materials, and tonight's title; "Start the day" ends it. Playtest findings
night. `ReviewPanel` is the morning review, a wooden sign with last night's results on it;
"Start the day" ends it. Playtest findings
and tuning notes: [`game/PLAYTEST.md`](game/PLAYTEST.md).
* **Menus and saving** — `Main` (`game/scripts/main.gd`, `game/scenes/main.tscn`) hosts the farm
@ -234,9 +234,10 @@ pack (`assets/farm/ithappy/farm/prefabs/assets/`).
`game/tools/build_ui_theme.gd`) is the project's default theme, with a gold focus ring so
keyboard and gamepad players always see where they are.
* **Results and endings** — the morning screen (`ReviewPanel`) opens with last night's results:
a taken / recovered / lost table per category, enemies defeated by type, damage, and materials
gathered and spent (all counted in `FarmState.night_events`, kept per night in `night_log`).
* **Results and endings** — the morning screen (`ReviewPanel`) is a hand-drawn wooden sign with
a sheet of paper nailed to it, the day on its top beam: last night's taken / recovered / lost
per category, then the enemies defeated by type and the materials gathered, each row with its
icon (all counted in `FarmState.night_events`, kept per night in `night_log`).
`EndPanel` is the failure screen (the cause, the night and its plan, what's left, the totals,
Retry the night and Main menu) and, after the farmers' return, the final assessment:
`Assessment` (`assessment.gd`) scores the share of each category kept (weights and rating
@ -581,7 +582,7 @@ The cycle suite plays one whole day and night on the real farm: the morning revi
HUD, a day's gathering and building, no thieves by day, the dusk warnings, the lighting of each
phase, the night plan's arrival times and targets at random points all along the edge, the dawn retreat, everything carrying
into the next morning (structures and their damage, materials less what was carried off, losses
in every category, health), the morning screen's results table and lines, and an exact retry.
in every category, health), the morning screen's results tables, and an exact retry.
The save suite covers saving and loading reproducing the farm state field for field, missing,
damaged, rule-breaking, non-morning, newer, and too-old saves refused with a reason, a version 2
save upgraded, the autosave every morning, retry restoring the saved morning, the save deleted

Binary file not shown.

After

Width:  |  Height:  |  Size: 825 KiB

View file

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dpociv7go51qj"
path="res://.godot/imported/splash-screen.png-1de9db1ece1fc99466b4ea83cac321e4.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/pictures/screens/splash-screen.png"
dest_files=["res://.godot/imported/splash-screen.png-1de9db1ece1fc99466b4ea83cac321e4.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View file

@ -30,7 +30,7 @@ marked with the step that implements them.
| Phase | Length | What happens | Enforced |
|---|---|---|---|
| Morning | Untimed | The morning screen: last night's results (taken, recovered, and lost per category; enemies defeated; damage; materials gathered and spent); what's left; what needs repair (and whether the pen is open); materials; tonight. Autosaved. The day starts when the player presses "Start the day". | Now |
| Morning | Untimed | The morning screen: last night's results (taken, recovered, and lost per category; enemies defeated; materials gathered). Autosaved. The day starts when the player presses "Start the day". | Now |
| Day | 180 s | Safe. Gather, build, repair, upgrade. | Now (timer) |
| Dusk | 30 s | Still safe. The banner names tonight ("Dusk: Breakers at the fences"), with tonight's hint under it. The phase HUD lists what tonight brings ("Tonight, from every side: crows and supply thieves"), not where: they arrive anywhere along the farm's edge. Nothing is marked on the farm itself. Last chance to prepare. | Now |
| Night | 150 s (night 30, the last, 180 s) | Enemies attack to steal farm assets or damage defenses. They arrive as the night's plan says (below). The HUD list and the hint stay up for the first 12 s of the night. | Now |
@ -245,7 +245,6 @@ they roam the whole farm and are never lost on their own.
following it) walk through the gate, but wandering animals and enemies can't.
- **The pen is open** when there's a way out that crosses no structure: nothing built yet, or a
gate or fence broken or taken down.
- The morning review says so.
- At night (night and dawn), one calm penned animal gets out of an open pen every 10 s. It's
loose at once (no longer penned): it walks out through the opening at 1.1 m/s, then roams like
any loose animal. The night's record counts it as strayed.
@ -522,7 +521,7 @@ Counted from each morning to the end of its dawn grace, and recorded when the da
The morning screen opens with the last night's record. Its table shows taken, recovered, and
lost per category; animals taken include those that got out of an open pen (loose, not lost).
Under the table come the enemies, the damage, and the materials. The final assessment adds up
Under the table come the enemies defeated and the materials gathered. The final assessment adds up
all the nights.
Decided in Step 8: a farm whose supplies were *spent* rather than stolen is not stripped. The

View file

@ -33,7 +33,6 @@
[ext_resource type="PackedScene" uid="uid://diltek1802a3d" path="res://assets/farm/ithappy/farm/prefabs/assets/prop/fence_004.tscn" id="30_50kde"]
[ext_resource type="PackedScene" uid="uid://dk00oyv7occ3t" path="res://assets/farm/ithappy/farm/prefabs/assets/prop/fence_005.tscn" id="31_fk54y"]
[ext_resource type="PackedScene" uid="uid://ef3pluccqsj4" path="res://assets/farm/ithappy/farm/prefabs/assets/prop/fence_006.tscn" id="32_ec1uo"]
[ext_resource type="PackedScene" uid="uid://bhko6le6hyqdh" path="res://assets/farm/ithappy/farm/prefabs/assets/tower/tower_017.tscn" id="32_mcuoy"]
[ext_resource type="PackedScene" uid="uid://djjak33vjenrq" path="res://assets/farm/ithappy/farm/prefabs/assets/tower/tower_006.tscn" id="33_6imja"]
[ext_resource type="PackedScene" uid="uid://cksi123hahlwt" path="res://assets/farm/ithappy/farm/prefabs/assets/tower/tower_015.tscn" id="34_1xeci"]
[ext_resource type="PackedScene" uid="uid://fiq5v48wi5dq" path="res://assets/farm/ithappy/farm/prefabs/assets/hangar/hangar_006.tscn" id="35_kxx7v"]
@ -73,6 +72,7 @@
[ext_resource type="Script" uid="uid://kmuyj86rfjj2" path="res://game/scripts/build_hud.gd" id="110_build_hud"]
[ext_resource type="PackedScene" uid="uid://by8kem53iwrx5" path="res://game/scenes/forest.tscn" id="111_ii3ah"]
[ext_resource type="Script" uid="uid://bp7dq566avk2v" path="res://game/scripts/phase_hud.gd" id="111_phase_hud"]
[ext_resource type="PackedScene" uid="uid://cdh4vup8yhona" path="res://game/scenes/mountain_bg.tscn" id="111_pjvu8"]
[ext_resource type="Script" uid="uid://cwll33writ0hq" path="res://game/scripts/review_panel.gd" id="112_review"]
[ext_resource type="Script" uid="uid://cq4ipv3nc7ual" path="res://game/scripts/upgrade_panel.gd" id="114_upgrades"]
[ext_resource type="Script" uid="uid://bpl66stkcn1rr" path="res://game/scripts/farm_zones.gd" id="200_farm_zones"]
@ -151,10 +151,16 @@ light_color = Color(1, 0.96, 0.88, 1)
shadow_enabled = true
directional_shadow_max_distance = 60.0
[node name="Forest" parent="." unique_id=583378842 instance=ExtResource("111_ii3ah")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -36.34638, 0.014064312, 22.026741)
[node name="Mountain_BG" parent="." unique_id=712740986 instance=ExtResource("111_pjvu8")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -23.65242, -74.95628, -184.25908)
[node name="Ground" type="StaticBody3D" parent="." unique_id=691831102]
[node name="Mesh" type="MeshInstance3D" parent="Ground" unique_id=1760393230]
transform = Transform3D(5, 0, 0, 0, 5, 0, 0, 0, 5, 0.015407562, -1.9073486e-06, 0.063042164)
transform = Transform3D(5, 0, 0, 0, 5, 0, 0, 0, 5, 0.022212982, 0.13436699, -0.1319766)
mesh = SubResource("PlaneMesh_ground")
[node name="Collision" type="CollisionShape3D" parent="Ground" unique_id=1754409527]
@ -307,12 +313,6 @@ transform = Transform3D(0.6929245, 0, -0.72101015, 0, 1, 0, 0.72101015, 0, 0.692
[node name="fir_tree_003_054" parent="Level" unique_id=35732109 instance=ExtResource("22_fir_small")]
transform = Transform3D(0.57116103, 0, 0.82083803, 0, 1, 0, -0.82083803, 0, 0.57116103, 33.870407, 0, -59.815567)
[node name="tower_017_001" parent="Level" unique_id=388734766 instance=ExtResource("32_mcuoy")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 59.76274, 13.690586, 59.845093)
[node name="tower_017_002" parent="Level" unique_id=1458149038 instance=ExtResource("32_mcuoy")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 59.76274, 5.2851205, 59.845093)
[node name="tower_006_001" parent="Level" unique_id=1837325354 instance=ExtResource("33_6imja")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 8.192261, -0.0187985, -57.297478)
@ -961,75 +961,39 @@ transform = Transform3D(-1, 0, 1.509958e-07, 0, 1, 0, -1.509958e-07, 0, -1, 60.3
[node name="fir_tree_011_050" parent="Level" unique_id=174006482 instance=ExtResource("22_te2xx")]
transform = Transform3D(0.99776584, 0, 0.06680785, 0, 1, 0, -0.06680785, 0, 0.99776584, -46.058502, 0, -12.789995)
[node name="tower_017_003" parent="Level" unique_id=903624507 instance=ExtResource("32_mcuoy")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -46.43509, 13.690586, 59.845093)
[node name="tower_017_004" parent="Level" unique_id=997090232 instance=ExtResource("32_mcuoy")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -46.43509, 5.2851205, 59.845093)
[node name="fence_020_889" parent="Level" unique_id=997851647 instance=ExtResource("48_nml3e")]
transform = Transform3D(-1, 0, 1.509958e-07, 0, 1, 0, -1.509958e-07, 0, -1, -45.801132, -0.099999905, -36.089153)
[node name="fir_tree_011_051" parent="Level" unique_id=1040178272 instance=ExtResource("22_te2xx")]
transform = Transform3D(0.99776584, 0, 0.06680785, 0, 1, 0, -0.06680785, 0, 0.99776584, -52.181244, 0, -12.789995)
[node name="tower_017_005" parent="Level" unique_id=222983665 instance=ExtResource("32_mcuoy")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -52.55783, 13.690586, 59.845093)
[node name="tower_017_006" parent="Level" unique_id=851127148 instance=ExtResource("32_mcuoy")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -52.55783, 5.2851205, 59.845093)
[node name="fence_020_890" parent="Level" unique_id=551422416 instance=ExtResource("48_nml3e")]
transform = Transform3D(-1, 0, 1.509958e-07, 0, 1, 0, -1.509958e-07, 0, -1, -51.923874, -0.099999905, -36.089153)
[node name="fir_tree_011_052" parent="Level" unique_id=1803321936 instance=ExtResource("22_te2xx")]
transform = Transform3D(-0.99776584, 0, -0.06680776, 0, 1, 0, 0.06680776, 0, -0.99776584, -51.011314, 0, 18.052942)
[node name="tower_017_007" parent="Level" unique_id=1445984028 instance=ExtResource("32_mcuoy")]
transform = Transform3D(-1, 0, 8.742278e-08, 0, 1, 0, -8.742278e-08, 0, -1, -50.634724, 13.690586, -54.582146)
[node name="tower_017_008" parent="Level" unique_id=1877729373 instance=ExtResource("32_mcuoy")]
transform = Transform3D(-1, 0, 8.742278e-08, 0, 1, 0, -8.742278e-08, 0, -1, -50.634724, 5.2851205, -54.582146)
[node name="fence_020_891" parent="Level" unique_id=1130220561 instance=ExtResource("48_nml3e")]
transform = Transform3D(1, 0, -2.3841858e-07, 0, 1, 0, 2.3841858e-07, 0, 1, -51.26869, -0.09999989, 41.3521)
[node name="fir_tree_011_053" parent="Level" unique_id=256348565 instance=ExtResource("22_te2xx")]
transform = Transform3D(0.06107361, 0, -0.99813324, 0, 1, 0, 0.99813324, 0, 0.06107361, 15.627649, 0, -78.130325)
[node name="tower_017_010" parent="Level" unique_id=1703102465 instance=ExtResource("32_mcuoy")]
transform = Transform3D(-0.005745978, 0, -0.9999835, 0, 1, 0, 0.9999835, 0, -0.005745978, -57.004074, 5.2851205, -78.92427)
[node name="fence_020_892" parent="Level" unique_id=757812371 instance=ExtResource("48_nml3e")]
transform = Transform3D(0.005746129, 0, 0.9999835, 0, 1, 0, -0.9999835, 0, 0.005746129, 38.924942, -0.099999905, -77.73909)
[node name="fir_tree_011_054" parent="Level" unique_id=819521885 instance=ExtResource("22_te2xx")]
transform = Transform3D(0.06107361, 0, -0.99813324, 0, 1, 0, 0.99813324, 0, 0.06107361, 15.66283, 0, -84.25296)
[node name="tower_017_012" parent="Level" unique_id=1822671636 instance=ExtResource("32_mcuoy")]
transform = Transform3D(-0.005745978, 0, -0.9999835, 0, 1, 0, 0.9999835, 0, -0.005745978, -56.968895, 5.2851205, -85.046906)
[node name="fence_020_893" parent="Level" unique_id=1781493640 instance=ExtResource("48_nml3e")]
transform = Transform3D(0.005746129, 0, 0.9999835, 0, 1, 0, -0.9999835, 0, 0.005746129, 38.960125, -0.099999905, -83.861725)
[node name="fir_tree_011_055" parent="Level" unique_id=407399440 instance=ExtResource("22_te2xx")]
transform = Transform3D(-0.061073523, 0, 0.99813336, 0, 1, 0, -0.99813336, 0, -0.061073523, -15.186321, 0, -83.260284)
[node name="tower_017_014" parent="Level" unique_id=1972360519 instance=ExtResource("32_mcuoy")]
transform = Transform3D(0.0057460656, 0, 0.9999835, 0, 1, 0, -0.9999835, 0, 0.0057460656, 57.445404, 5.2851205, -82.46634)
[node name="fence_020_894" parent="Level" unique_id=764287368 instance=ExtResource("48_nml3e")]
transform = Transform3D(-0.0057462165, 0, -0.9999835, 0, 1, 0, 0.9999835, 0, -0.0057462165, -38.483612, -0.099999875, -83.65152)
[node name="tower_017_016" parent="Level" unique_id=529786641 instance=ExtResource("32_mcuoy")]
transform = Transform3D(-0.7111581, 0, -0.7030321, 0, 1, 0, 0.7030321, 0, -0.7111581, -52.116375, 5.2851205, -68.83154)
[node name="tower_017_018" parent="Level" unique_id=729429105 instance=ExtResource("32_mcuoy")]
transform = Transform3D(-0.7111581, 0, -0.7030321, 0, 1, 0, 0.7030321, 0, -0.7111581, -47.762142, 5.2851205, -73.13603)
[node name="fence_020_895" parent="Level" unique_id=1900430497 instance=ExtResource("48_nml3e")]
transform = Transform3D(-0.7111583, 0, -0.7030319, 0, 1, 0, 0.7030319, 0, -0.7111583, -35.67776, -0.099999845, -59.078274)
[node name="fence_020_888" parent="Level" unique_id=649069833 instance=ExtResource("48_nml3e")]
transform = Transform3D(-1, 0, 1.509958e-07, 0, 1, 0, -1.509958e-07, 0, -1, 58.346024, -0.099999905, -36.089153)
@ -1045,7 +1009,6 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0, -13)
[node name="Camera" type="Camera3D" parent="." unique_id=863952848 node_paths=PackedStringArray("target")]
physics_interpolation_mode = 2
transform = Transform3D(0.70710677, -0.5416752, 0.45451948, 0, 0.64278764, 0.76604444, -0.70710677, -0.5416752, 0.45451948, 10.272312, 13.256711, -5.7276883)
visible = false
current = true
fov = 40.0
script = ExtResource("2_camera")
@ -2307,7 +2270,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -8.885292, 0.44, 29.848099)
script = ExtResource("201_farm_zone")
display_name = "Lettuce Field"
size = Vector2(32, 30)
tint = Color(0.55, 0.85, 0.35, 1)
tint = Color(0.27285054, 0.21135898, 0.17824817, 0)
[node name="Plot7" type="Node3D" parent="Zones/LettuceField" unique_id=621056271]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -9.547501, 0, -9.694386)
@ -3292,7 +3255,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 29.726284, 0.31, 29.685516)
script = ExtResource("201_farm_zone")
display_name = "Corn Field"
size = Vector2(32, 30)
tint = Color(0.95, 0.75, 0.15, 1)
tint = Color(0.5759576, 0.4579603, 0.39442328, 0)
[node name="Plot13" type="Node3D" parent="Zones/CornField" unique_id=2115929267]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -10.038496, 0, -9.828474)
@ -5259,6 +5222,3 @@ upgrade_panel = NodePath("../Hud/UpgradePanel")
shed_panel = NodePath("../Hud/ShedPanel")
sun = NodePath("../Sun")
world_environment = NodePath("../WorldEnvironment")
[node name="Forest" parent="." unique_id=583378842 instance=ExtResource("111_ii3ah")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -36.34638, 0.014064312, 22.026741)

View file

@ -0,0 +1,18 @@
[gd_scene format=3 uid="uid://cdh4vup8yhona"]
[ext_resource type="PackedScene" uid="uid://dchxnujm6lth7" path="res://assets/farm/ithappy/farm/prefabs/assets/mountain/mountain_001.tscn" id="1_bfu26"]
[ext_resource type="PackedScene" uid="uid://cormo4fdjm0g4" path="res://assets/farm/ithappy/farm/prefabs/assets/mountain/mountain_007.tscn" id="2_sqgw0"]
[ext_resource type="PackedScene" uid="uid://dwqedpdoufq6x" path="res://assets/farm/ithappy/farm/prefabs/assets/mountain/mountain_009.tscn" id="3_y8bj2"]
[node name="Mountain_BG" type="Node3D" unique_id=712740986]
[node name="mountain_0012" parent="." unique_id=1631310907 instance=ExtResource("1_bfu26")]
[node name="mountain_0072" parent="." unique_id=1423043224 instance=ExtResource("2_sqgw0")]
transform = Transform3D(0.10973431, 0, -0.993961, 0, 1, 0, 0.993961, 0, 0.10973431, -143.52051, 28.517334, 343.27423)
[node name="mountain_0092" parent="." unique_id=1155752578 instance=ExtResource("3_y8bj2")]
transform = Transform3D(3, 0, 0, 0, 3, 0, 0, 0, 3, -406.44122, 92.03946, 52.2984)
[node name="mountain_0093" parent="." unique_id=1716997050 instance=ExtResource("3_y8bj2")]
transform = Transform3D(-2.8395534, 0, -0.9679553, 0, 3, 0, 0.9679553, 0, -2.8395534, 243.11324, 75.845, 248.03665)

View file

@ -297,10 +297,8 @@ func _ready() -> void:
if phase_hud != null:
phase_hud.setup(campaign, waves, enemies)
if review_panel != null:
review_panel.setup(campaign, structures)
review_panel.animals = animals
review_panel.waves = waves
review_panel.refresh()
review_panel.setup(campaign)
if hud != null:
hud.setup(scarecrow, campaign, combat)
hud.build = build
@ -771,7 +769,7 @@ func _on_phase_changed(phase: CampaignController.Phase, _previous: CampaignContr
if shed_panel != null:
shed_panel.close()
if review_panel != null:
review_panel.refresh() # after the farm is back in sync (the pen's gate)
review_panel.refresh()
## End of the dawn grace: whoever is still on the farm leaves (carrying their loot off), and

View file

@ -1,93 +1,144 @@
class_name ReviewPanel
extends CenterContainer
## The morning screen (the untimed MORNING phase), between one night and the next day:
## * Last night's results (from the night's log entry): per category what was taken,
## recovered, and lost; enemies defeated by type and how many got away with loot; damage
## (the scarecrow's, structures hit, broken, and repaired); materials gathered and spent
## over the day and night.
## * This morning: what's left (crops, animals, supplies, the scarecrow's health), what needs
## repair (damaged structures keep their health bars on the farm), the pen's gate, the
## materials on hand, and tonight's plan.
## "Start the day" (focused, so Enter / A work) ends it. The first morning explains the vacation
## instead of results.
## The morning screen (the untimed MORNING phase), between one night and the next day: a wooden
## sign, hand-drawn (Sketch) over the dimmed farm, the day on its top beam and a sheet of paper
## nailed under it with last night's results (from the night's log entry):
## * per category (crops, animals, supplies): what was taken, recovered, and lost;
## * the enemies defeated, by type;
## * the materials gathered over the day and night.
## Each row has its icon; a type or material with none isn't listed. "Start the day" (focused,
## so Enter / A work) ends it. The first morning explains the vacation instead of results.
const CATEGORIES := ["Crops", "Animals", "Supplies"]
const GOLD := Color(0.95, 0.82, 0.45)
const GREY := Color(0.7, 0.72, 0.68)
const RED := Color(1.0, 0.5, 0.42)
const ENEMY_TYPES := [EnemySystem.TYPE_CROW, EnemySystem.TYPE_THIEF, EnemySystem.TYPE_BREAKER, EnemySystem.TYPE_UFO]
## The sign's layout around its paper: the posts and beam ends either side of it, the top beam
## (the title is written on it), and the bottom beam.
const SIDE := 64.0
const BEAM := 92.0
const BOTTOM := 70.0
const WIDTH := 880.0
var campaign: CampaignController
var structures: StructureSystem
## Set by FarmSim: whether the pen is open, and tonight's plan.
var animals: AnimalSystem
## Set by FarmSim: the night plans (last night's title).
var waves: WaveDirector
var _board: PanelContainer
var _title: Label
var _last_head: Label
var _rule: HSeparator
var _grid: GridContainer
var _cells := {} # "Crops/taken" -> Label
var _results: Label
var _rule: HSeparator
var _morning_head: Label
var _body: Label
var _lists: HBoxContainer
var _enemies := {} # type -> [icon, name, count]
var _no_enemies: Label
var _materials := {} # material -> [icon, name, count]
var _no_materials: Label
var _intro: Label
var _start: Button
func setup(p_campaign: CampaignController, p_structures: StructureSystem) -> void:
func setup(p_campaign: CampaignController) -> void:
campaign = p_campaign
structures = p_structures
campaign.phase_changed.connect(func(_p: CampaignController.Phase, _prev: CampaignController.Phase) -> void: refresh())
refresh()
func _ready() -> void:
set_anchors_preset(Control.PRESET_FULL_RECT)
var panel := PanelContainer.new()
panel.add_theme_stylebox_override("panel", backing())
add_child(panel)
var margin := MarginContainer.new()
for side in ["left", "right", "top", "bottom"]:
margin.add_theme_constant_override("margin_" + side, 30)
panel.add_child(margin)
theme = UiTheme.sketch()
_board = PanelContainer.new()
var margins := StyleBoxEmpty.new()
margins.content_margin_left = SIDE
margins.content_margin_right = SIDE
margins.content_margin_bottom = BOTTOM
_board.add_theme_stylebox_override("panel", margins)
_board.draw.connect(_draw_board)
add_child(_board)
var column := VBoxContainer.new()
column.add_theme_constant_override("separation", 0)
_board.add_child(column)
_title = Label.new()
Sketch.style(_title, 48)
_title.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
_title.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
_title.custom_minimum_size = Vector2(0.0, BEAM)
column.add_child(_title)
var sheet := MarginContainer.new()
for side: String in ["left", "right"]:
sheet.add_theme_constant_override("margin_" + side, 48)
sheet.add_theme_constant_override("margin_top", 26)
sheet.add_theme_constant_override("margin_bottom", 32)
column.add_child(sheet)
var box := VBoxContainer.new()
box.add_theme_constant_override("separation", 12)
margin.add_child(box)
_title = _label(box, 38)
_last_head = _label(box, 26, GOLD)
_grid = GridContainer.new()
_grid.columns = 4
_grid.add_theme_constant_override("h_separation", 48)
_grid.add_theme_constant_override("v_separation", 2)
box.add_child(_grid)
for head in ["", "Taken", "Recovered", "Lost"]:
_label(_grid, 20, GREY).text = head
for cat: String in CATEGORIES:
_label(_grid, 22).text = cat
for col in ["taken", "recovered", "lost"]:
var l := _label(_grid, 22)
l.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
_cells["%s/%s" % [cat, col]] = l
_results = _label(box, 21)
_results.custom_minimum_size = Vector2(760.0, 0.0)
_results.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
box.custom_minimum_size = Vector2(WIDTH, 0.0)
box.add_theme_constant_override("separation", 10)
sheet.add_child(box)
_last_head = _ink(box, 38)
_last_head.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
_rule = HSeparator.new()
_rule.add_theme_stylebox_override("separator", SketchBox.new(Color(0, 0, 0, 0), Color(Sketch.PAPER_INK, 0.5), 2.0, true))
box.add_child(_rule)
_morning_head = _label(box, 26, GOLD)
_morning_head.text = "This morning"
_body = _label(box, 21)
_body.custom_minimum_size = Vector2(760.0, 0.0)
_body.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
_grid = GridContainer.new()
_grid.columns = 5
_grid.size_flags_horizontal = Control.SIZE_SHRINK_CENTER
_grid.add_theme_constant_override("h_separation", 18)
_grid.add_theme_constant_override("v_separation", 4)
box.add_child(_grid)
_grid.add_child(Control.new())
_grid.add_child(Control.new())
for head: String in ["Taken", "Recovered", "Lost"]:
var l := _ink(_grid, 28, Sketch.PAPER_DIM)
l.text = head
l.custom_minimum_size = Vector2(150.0, 0.0)
l.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
for i in CATEGORIES.size():
var cat: String = CATEGORIES[i]
_grid.add_child(SketchIcon.new(LootSystem.CATEGORY_KEYS[i], 52.0))
var label := _ink(_grid, 32)
label.text = cat
label.custom_minimum_size = Vector2(150.0, 0.0)
for col: String in ["taken", "recovered", "lost"]:
var l := _ink(_grid, 34)
l.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
_cells["%s/%s" % [cat, col]] = l
box.add_child(_spacer(8.0))
_lists = HBoxContainer.new()
_lists.alignment = BoxContainer.ALIGNMENT_CENTER
_lists.add_theme_constant_override("separation", 90)
box.add_child(_lists)
var enemies := _list(_lists, "Enemies defeated")
for t: int in ENEMY_TYPES:
var plural := EnemySystem.PLURALS[t]
_enemies[t] = _list_row(enemies, EnemySystem.TYPE_NAMES[t], plural[0].to_upper() + plural.substr(1))
_no_enemies = _ink(enemies, 30, Sketch.PAPER_DIM)
_no_enemies.text = "None"
var materials := _list(_lists, "Materials gathered")
for m in ResourceStore.MATERIALS:
_materials[m] = _list_row(materials, m, m.capitalize())
_no_materials = _ink(materials, 30, Sketch.PAPER_DIM)
_no_materials.text = "Nothing"
_intro = _ink(box, 28)
_intro.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
_intro.add_theme_constant_override("paragraph_spacing", 14)
_start = Button.new()
_start.text = "Start the day"
_start.custom_minimum_size = Vector2(260.0, 56.0)
_start.add_theme_font_size_override("font_size", 24)
_start.custom_minimum_size = Vector2(300.0, 62.0)
_start.add_theme_font_size_override("font_size", 32)
_start.size_flags_horizontal = Control.SIZE_SHRINK_CENTER
var wood := {
"normal": SketchBox.new(Sketch.WOOD, Sketch.INK, 2.5),
"hover": SketchBox.new(Sketch.WOOD.lightened(0.15), Sketch.INK, 2.5),
"pressed": SketchBox.new(Sketch.WOOD.darkened(0.2), Sketch.GOLD, 2.5),
}
for key: String in wood:
_start.add_theme_stylebox_override(key, wood[key])
_start.pressed.connect(func() -> void: campaign.begin_day())
box.add_child(_spacer(6.0))
box.add_child(_start)
visible = false
## The dark, nearly opaque panel behind the morning screen, the menus, and the end screens.
## The dark, nearly opaque panel behind the menus and the end screens.
static func backing() -> StyleBoxFlat:
var bg := StyleBoxFlat.new()
bg.bg_color = Color(0.1, 0.12, 0.1)
@ -107,40 +158,25 @@ func refresh() -> void:
var s := campaign.state
var nights := campaign.config.campaign_nights
var first := s.night_log.is_empty()
for n: Control in [_last_head, _grid, _results, _rule, _morning_head]:
for n: Control in [_last_head, _rule, _grid, _lists]:
n.visible = not first
var lines: Array[String] = []
_intro.visible = first
if first:
_title.text = "The farmers are away"
lines.append("Keep the farm safe for %d nights until they come home: the crops, the animals in the pen, and the supplies in the shed." % nights)
lines.append("By day, gather wood, scrap, and straw (hold E), store them at the barn, and build defenses (B). There's more to gather off the farm, to the north, east, and south.")
lines.append("At night, stab aliens with your pitchfork (left mouse), scare them off (Q), and pick up anything they drop. Animals roam loose until you lead them into the pen: walk up to one and it follows you. The supply shed sells a corn shooter (switch weapons with Tab or the number keys), and more weapons arrive there over the days.")
_intro.text = "\n".join([
"Keep the farm safe for %d nights until they come home: the crops, the animals in the pen, and the supplies in the shed." % nights,
"By day, gather wood, scrap, and straw (hold E), store them at the barn, and build defenses (B). There's more to gather off the farm, to the north, east, and south.",
"At night, stab aliens with your pitchfork (left mouse), scare them off (Q), and pick up anything they drop. Animals roam loose until you lead them into the pen: walk up to one and it follows you. The supply shed sells a corn shooter (switch weapons with Tab or the number keys), and more weapons arrive there over the days.",
])
else:
var e: Dictionary = s.night_log[s.night_log.size() - 1]
_title.text = "Morning of day %d of %d" % [s.night, nights]
var plan := waves.plan_for(int(e["night"])) if waves != null else null
_last_head.text = "Night %d: %s" % [e["night"], plan.title] if plan != null and plan.title != "" else "Night %d" % e["night"]
_fill_grid(e)
_results.text = "\n".join(result_lines(e, s))
lines.append("Left: %d of %d crops, %d of %d animals, %d supplies. Scarecrow: %d of %d HP." % [s.crops, s.crops_total,
s.animals, s.animals_total, s.supplies, s.scarecrow_hp, s.scarecrow_max_hp])
lines.append(_damage_line())
if animals != null and animals.pen_open and s.animals > 0:
lines.append("The pen is open: put a gate in its opening (B) before nightfall, or the animals in it will get out and roam loose.")
var r := s.resources
if s.coop: # each scarecrow carries its own
lines.append("In the shed: %s. %s's pouch: %s. %s's pouch: %s." % [_or_none(ResourceStore.describe(r.shed)),
Avatar.NAMES[0], _or_none(ResourceStore.describe(r.pouch_of(0))), Avatar.NAMES[1], _or_none(ResourceStore.describe(r.pouch_of(1)))])
else:
lines.append("In the shed: %s. In the pouch: %s." % [_or_none(ResourceStore.describe(r.shed)), _or_none(ResourceStore.describe(r.pouch))])
var plan := waves.tonight() if waves != null else null
if plan != null and plan.title != "":
if structures != null and structures.has_workbench():
lines.append("Tonight: %s. Upgrades: %d of %d levels." % [plan.title, Upgrades.levels_bought(campaign.config, s),
Upgrades.levels_total(campaign.config)])
else: # #9: the Workbench hasn't been granted yet -- it arrives once Night 1 is survived
lines.append("Tonight: %s. The work area will be set up once you survive tonight." % plan.title)
_body.text = "\n".join(lines)
_fill_list(_enemies, _no_enemies, func(t: int) -> int: return int(e.get("killed_" + EnemySystem.TYPE_NAMES[t], 0)))
_fill_list(_materials, _no_materials, func(m: String) -> int: return int(e.get("gathered_" + m, 0)))
_board.queue_redraw()
_start.grab_focus.call_deferred()
@ -152,6 +188,16 @@ func grid_text() -> String:
return "\n".join(rows)
## The enemies listed, "Crows 12, Aliens 3" (or "None"), for tests.
func enemies_text() -> String:
return _list_text(_enemies, _no_enemies)
## The materials listed, "Wood 8, Straw 4" (or "Nothing"), for tests.
func materials_text() -> String:
return _list_text(_materials, _no_materials)
## Per category: (taken, recovered, lost) in a night's log entry. Animals taken include those
## that got out of an open pen (loose, not lost).
static func category_counts(e: Dictionary) -> Dictionary:
@ -162,30 +208,6 @@ static func category_counts(e: Dictionary) -> Dictionary:
}
## Enemies, damage, and materials of a night's log entry.
static func result_lines(e: Dictionary, s: FarmState) -> Array[String]:
var out: Array[String] = []
var enemies := "Enemies defeated: %s." % Assessment.enemies_line(e)
if int(e["escaped"]) > 0:
enemies = enemies.trim_suffix(".") + "; %d got away with loot." % int(e["escaped"])
out.append(enemies)
var damage := PackedStringArray()
damage.append("the scarecrow took %d" % int(e["scarecrow_damage"]) if int(e["scarecrow_damage"]) > 0 else "the scarecrow wasn't hurt")
if int(e["patches"]) > 0:
damage.append("patched up %d %s" % [int(e["patches"]), "time" if int(e["patches"]) == 1 else "times"])
if int(e["structures_damaged"]) > 0:
damage.append("structures took %d damage" % int(e["structures_damaged"]))
if int(e["structures_destroyed"]) > 0:
damage.append("%d broken" % int(e["structures_destroyed"]))
if int(e["repairs"]) > 0:
damage.append("%d repaired" % int(e["repairs"]))
out.append("Damage: %s." % ", ".join(damage))
out.append("Materials: gathered %s; spent %s." % [Assessment.materials_line(e, "gathered_"), Assessment.materials_line(e, "spent_")])
if s != null and int(e["structures_built"]) + int(e["upgrades_bought"]) > 0:
out.append("Built %d, upgrades bought %d." % [int(e["structures_built"]), int(e["upgrades_bought"])])
return out
func _fill_grid(e: Dictionary) -> void:
var counts := category_counts(e)
for cat: String in CATEGORIES:
@ -193,31 +215,113 @@ func _fill_grid(e: Dictionary) -> void:
for k in 3:
var l: Label = _cells["%s/%s" % [cat, ["taken", "recovered", "lost"][k]]]
l.text = str(c[k])
l.add_theme_color_override("font_color", RED if k == 2 and int(c[k]) > 0 else Color(0.92, 0.92, 0.88))
var color := Sketch.PAPER_INK if int(c[k]) > 0 else Sketch.PAPER_DIM
l.add_theme_color_override("font_color", Sketch.PAPER_RED if k == 2 and int(c[k]) > 0 else color)
func _damage_line() -> String:
if structures == null or structures.count() == 0:
return "Nothing built yet."
var damaged := {}
for e in campaign.state.structures:
if int(e["hp"]) < structures.max_hp(e["type"]):
damaged[e["type"]] = int(damaged.get(e["type"], 0)) + 1
if damaged.is_empty():
return "No repairs needed."
var parts: Array[String] = []
for t in damaged:
parts.append("%d %s%s" % [damaged[t], StructureSystem.NAMES[t].to_lower(), "s" if int(damaged[t]) > 1 else ""])
return "Needs repair (marked with health bars): %s." % ", ".join(parts)
## Shows the rows of rows (key -> [icon, name, count]) with a count above 0 (count_of(key)), or
## none when there aren't any.
func _fill_list(rows: Dictionary, none: Label, count_of: Callable) -> void:
var any := false
for key: Variant in rows:
var n: int = count_of.call(key)
for c: Control in rows[key]:
c.visible = n > 0
(rows[key][2] as Label).text = str(n)
any = any or n > 0
none.visible = not any
func _label(parent: Node, font_size: int, color: Color = Color(0.92, 0.92, 0.88)) -> Label:
func _list_text(rows: Dictionary, none: Label) -> String:
var parts := PackedStringArray()
for key: Variant in rows:
var cells: Array = rows[key]
if (cells[2] as Control).visible:
parts.append("%s %s" % [(cells[1] as Label).text, (cells[2] as Label).text])
return ", ".join(parts) if not parts.is_empty() else none.text
## A headed table of icon, name, and count; returns the grid the rows go in.
func _list(parent: Control, heading: String) -> GridContainer:
var column := VBoxContainer.new()
column.add_theme_constant_override("separation", 4)
parent.add_child(column)
var head := _ink(column, 30, Sketch.PAPER_DIM)
head.text = heading
var grid := GridContainer.new()
grid.columns = 3
grid.add_theme_constant_override("h_separation", 14)
grid.add_theme_constant_override("v_separation", 0)
column.add_child(grid)
return grid
func _list_row(grid: GridContainer, icon: String, text: String) -> Array:
var i := SketchIcon.new(icon, 46.0)
grid.add_child(i)
var l := _ink(grid, 30)
l.text = text
l.custom_minimum_size = Vector2(150.0, 0.0)
var n := _ink(grid, 32)
n.custom_minimum_size = Vector2(44.0, 0.0)
n.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
return [i, l, n]
func _draw() -> void:
draw_rect(Rect2(Vector2.ZERO, size), Color(0.0, 0.0, 0.0, 0.35)) # dims the farm behind
## The sign behind the board's contents: two posts, the paper between them, a beam across its top
## (under the title) and one across its bottom, nails, and leaves.
func _draw_board() -> void:
var b := _board
var w := b.size.x
var h := b.size.y
var paper := Rect2(SIDE - 14.0, BEAM - 26.0, w - 2.0 * SIDE + 28.0, h - BEAM - BOTTOM + 52.0)
var posts: Array[float] = [SIDE + 34.0, w - SIDE - 34.0]
for k in 2:
b.draw_set_transform(Vector2(posts[k], h * 0.5 + 8.0), PI * 0.5)
Sketch.plank(b, Rect2(-h * 0.5 - 44.0, -27.0, h + 88.0, 54.0), Sketch.WOOD.darkened(0.08), 601.0 + k)
b.draw_set_transform_matrix(Transform2D.IDENTITY)
Sketch.paper(b, paper, 611.0)
Sketch.plank(b, Rect2(0.0, h - BOTTOM - 4.0, w, 62.0), Sketch.WOOD.darkened(0.04), 621.0)
Sketch.plank(b, Rect2(-24.0, 0.0, w + 48.0, BEAM), Sketch.WOOD, 631.0)
for x: float in [paper.position.x + 26.0, paper.end.x - 26.0]:
Sketch.nail(b, Vector2(x, paper.position.y + 46.0))
for k in 2:
Sketch.nail(b, Vector2(posts[k], BEAM * 0.5), 6.0)
Sketch.nail(b, Vector2(posts[k], h - BOTTOM + 27.0), 6.0)
Sketch.leaf(b, Vector2(28.0, 18.0), 46.0, -2.5, 641.0)
Sketch.leaf(b, Vector2(34.0, 22.0), 40.0, -1.4, 642.0)
Sketch.leaf(b, Vector2(w - 26.0, 16.0), 50.0, -0.5, 643.0)
Sketch.leaf(b, Vector2(w - 30.0, 24.0), 38.0, 0.4, 644.0, Sketch.LEAF.lightened(0.12))
Sketch.leaf(b, Vector2(posts[0] - 20.0, h - BOTTOM + 40.0), 42.0, 2.6, 645.0, Sketch.LEAF.darkened(0.1))
static func _spacer(height: float) -> Control:
var c := Control.new()
c.custom_minimum_size = Vector2(0.0, height)
return c
## A Label in ink on the paper (no outline).
func _ink(parent: Node, font_size: int, color: Color = Sketch.PAPER_INK) -> Label:
var l := Label.new()
l.add_theme_font_size_override("font_size", font_size)
l.add_theme_color_override("font_color", color)
Sketch.style(l, font_size, color, 0)
parent.add_child(l)
return l
static func _or_none(text: String) -> String:
return text if text != "" else "nothing"
## An icon (Sketch.ICONS) drawn in a square, side long, centered in the control.
class SketchIcon extends Control:
var id := ""
func _init(p_id: String, side: float) -> void:
id = p_id
custom_minimum_size = Vector2(side, side)
mouse_filter = Control.MOUSE_FILTER_IGNORE
func _draw() -> void:
var side := minf(size.x, size.y)
Sketch.icon(self, id, Rect2((size - Vector2(side, side)) * 0.5, Vector2(side, side)))

View file

@ -5,8 +5,10 @@ extends RefCounted
## (Gochi Hand, assets/fonts, SIL OFL) with a dark outline so text reads over the farm, wobbly
## sketched outlines (each edge drawn twice, slightly off, overshooting its corners), painted
## fills (a flat color, a lighter dab, a darker rim), and painted icons for the weapons, the
## materials, the backpack, the sun and moon, and the scarecrow's portrait. Every wobble comes
## from a hash of a seed, so a shape is drawn the same way each frame (no flicker).
## materials, the backpack, the sun and moon, the scarecrow's portrait, what thieves take (crops,
## animals, supplies), and the enemies; and the morning screen's wooden sign (planks, a nailed
## sheet of paper, leaves). Every wobble comes from a hash of a seed, so a shape is drawn the
## same way each frame (no flicker).
## Icons are designed in a 100 x 100 box and scaled to the rect they're drawn in.
const FONT_PATH := "res://assets/fonts/GochiHand-Regular.ttf"
@ -25,9 +27,19 @@ const RULE := Color(0.98, 0.97, 0.92, 0.35)
const SLOT := Color(0.1, 0.24, 0.1, 0.62)
const GOLD := Color(1.0, 0.86, 0.35)
const TEXT_OUTLINE := 8
## Icon ids (icon()): ScarecrowCombat.WEAPON_IDS, ResourceStore.MATERIALS, and these.
## Text written on paper (the morning sign): ink without an outline, a faded ink for headings and
## nothing-to-report, and a red for losses.
const PAPER := Color(0.96, 0.87, 0.64)
const PAPER_INK := Color(0.24, 0.15, 0.07)
const PAPER_DIM := Color(0.5, 0.38, 0.24)
const PAPER_RED := Color(0.74, 0.14, 0.08)
const WOOD := Color(0.6, 0.38, 0.2)
const LEAF := Color(0.42, 0.64, 0.22)
## Icon ids (icon()): ScarecrowCombat.WEAPON_IDS, ResourceStore.MATERIALS, LootSystem.CATEGORY_KEYS,
## EnemySystem.TYPE_NAMES, and these.
const ICONS: Array[String] = ["pitchfork", "corn_shooter", "pumpkin_bomb", "potato_cannon", "shurikens",
"propane_torch", "alien_ray", "wood", "scrap", "straw", "alien_goop", "backpack", "sun", "moon", "portrait"]
"propane_torch", "alien_ray", "wood", "scrap", "straw", "alien_goop", "backpack", "sun", "moon", "portrait",
"crops", "animals", "supplies", "crow", "thief", "breaker", "ufo"]
static var _font: Font
@ -207,6 +219,91 @@ static func stroke(ci: CanvasItem, a: Vector2, b: Vector2, color: Color, width:
line(ci, a, b, color, width, seed, 0.8)
## A painted wooden beam lying along r's width: bark-edged, grain lines along it, a knot, and the
## sawn end grain (a pale ring) at each end.
static func plank(ci: CanvasItem, r: Rect2, color: Color, seed: float) -> void:
var t := r.size.y
var pts := PackedVector2Array()
var n := clampi(int(r.size.x / 60.0), 2, 24)
for i in n + 1:
pts.append(Vector2(lerpf(r.position.x, r.end.x, float(i) / n), r.position.y) + Vector2(0.0, noise(seed + i) * t * 0.06))
for i in n + 1:
pts.append(Vector2(lerpf(r.end.x, r.position.x, float(i) / n), r.end.y) + Vector2(0.0, noise(seed + 40.0 + i) * t * 0.06))
ci.draw_colored_polygon(pts, color)
ci.draw_colored_polygon(_band(r, 0.1, 0.36, seed + 20.0), Color(color.lightened(0.2), 0.7))
ci.draw_colored_polygon(_band(r, 0.74, 0.94, seed + 30.0), Color(color.darkened(0.22), 0.7))
var grain := Color(color.darkened(0.4), 0.85)
for k in 4:
var y := r.position.y + t * (0.24 + 0.17 * k + noise(seed + 70.0 + k) * 0.04)
var x0 := r.position.x + t * 0.4 + r.size.x * (0.05 + 0.15 * absf(noise(seed + 80.0 + k)))
var x1 := r.end.x - t * 0.4 - r.size.x * (0.05 + 0.15 * absf(noise(seed + 90.0 + k)))
line(ci, Vector2(x0, y), Vector2(x1, y), grain, 2.0, seed + 100.0 + k, 1.6)
var knot := Vector2(lerpf(r.position.x, r.end.x, 0.3 + 0.4 * absf(noise(seed + 110.0))), r.get_center().y)
paint(ci, blob(knot, t * 0.16, t * 0.1, seed + 111.0), color.darkened(0.25), seed + 112.0, 1.5)
outline(ci, pts, Color(color.darkened(0.62), 0.95), 3.0, seed + 0.5, 0.8, 1)
for x: float in [r.position.x, r.end.x]:
var end := Vector2(x, r.get_center().y)
paint(ci, blob(end, t * 0.16, t * 0.5, seed + x * 0.01, 0.06), color.lightened(0.32), seed + 113.0, 2.0)
circle(ci, end, t * 0.2, Color(color.darkened(0.2), 0.8), 1.5, seed + 114.0)
## A strip along a plank (r) between fractions a and b of its thickness, short of its ends.
static func _band(r: Rect2, a: float, b: float, seed: float) -> PackedVector2Array:
var t := r.size.y
var x0 := r.position.x + t * 0.3
var x1 := r.end.x - t * 0.3
var top := line_points(Vector2(x0, r.position.y + t * a), Vector2(x1, r.position.y + t * a), seed, t * 0.04)
var bottom := line_points(Vector2(x1, r.position.y + t * b), Vector2(x0, r.position.y + t * b), seed + 1.0, t * 0.04)
top.append_array(bottom)
return top
## A sheet of paper with soft, torn edges, browned toward them, and a stain or two.
static func paper(ci: CanvasItem, r: Rect2, seed: float, color: Color = PAPER) -> void:
var edge := _torn(r, seed, 0.0)
ci.draw_colored_polygon(edge, color.darkened(0.12))
ci.draw_colored_polygon(_torn(r, seed + 50.0, 13.0), color)
for k in 2:
var at := r.position + r.size * Vector2(0.12 + 0.76 * k, 0.8 - 0.6 * k) + jitter(seed + 5.0 + k, 30.0)
ci.draw_colored_polygon(blob(at, 46.0, 34.0, seed + 6.0 + k, 0.12), Color(color.darkened(0.2), 0.18))
outline(ci, edge, Color(color.darkened(0.6), 0.9), 2.5, seed + 1.0, 0.8, 1)
var crease := Vector2(r.end.x, lerpf(r.position.y, r.end.y, 0.35 + 0.3 * absf(noise(seed + 3.0))))
line(ci, crease, crease + Vector2(-r.size.x * 0.12, 8.0), Color(color.darkened(0.35), 0.6), 2.0, seed + 4.0)
## Points around r, every edge ripped a little; inset pulls them toward the middle.
static func _torn(r: Rect2, seed: float, inset: float) -> PackedVector2Array:
var inner := r.grow(-inset)
var c := [inner.position, Vector2(inner.end.x, inner.position.y), inner.end, Vector2(inner.position.x, inner.end.y)]
var pts := PackedVector2Array()
for side in 4:
var a: Vector2 = c[side]
var b: Vector2 = c[(side + 1) % 4]
var n := maxi(int(a.distance_to(b) / 34.0), 2)
for i in n:
pts.append(a.lerp(b, float(i) / n) + jitter(seed + side * 31.0 + i, 3.0))
return pts
## A leaf from base, length long, pointing along angle.
static func leaf(ci: CanvasItem, base: Vector2, length: float, angle: float, seed: float, color: Color = LEAF) -> void:
var dir := Vector2.from_angle(angle)
var side := dir.orthogonal() * length * 0.38
var tip := base + dir * length
var mid := base + dir * length * 0.45
var pts := _bezier(base, mid + side, tip, 8)
pts.append_array(_bezier(tip, mid - side, base, 8).slice(1, -1))
paint(ci, pts, color, seed, 2.0)
line(ci, base, tip - dir * length * 0.15, Color(color.darkened(0.45), 0.9), 1.6, seed + 1.0, 1.0)
## A nail head.
static func nail(ci: CanvasItem, at: Vector2, radius: float = 5.0) -> void:
ci.draw_circle(at, radius + 1.5, INK)
ci.draw_circle(at, radius, Color(0.5, 0.48, 0.45))
ci.draw_circle(at - Vector2(radius, radius) * 0.3, radius * 0.4, Color(0.8, 0.78, 0.74))
static func _bezier(a: Vector2, q: Vector2, b: Vector2, n: int) -> PackedVector2Array:
var pts := PackedVector2Array()
for i in n + 1:
@ -345,6 +442,85 @@ static func _icon(ci: CanvasItem, id: String) -> void:
paint(ci, PackedVector2Array([Vector2(31, 42), Vector2(69, 41), Vector2(65, 11), Vector2(35, 12)]), Color(0.62, 0.42, 0.22), 190.0)
paint(ci, PackedVector2Array([Vector2(32, 35), Vector2(68, 34), Vector2(68, 41), Vector2(32, 42)]), Color(0.42, 0.26, 0.14), 191.0, 0.0)
paint(ci, blob(Vector2(50, 43), 44.0, 8.0, 192.0, 0.03, 28, -0.06), Color(0.72, 0.52, 0.28), 193.0)
"crops": # an ear of corn in its husk
paint(ci, blob(Vector2(50, 42), 16.0, 32.0, 201.0, 0.03), Color(0.98, 0.82, 0.24), 202.0)
for row in 6:
for col in 3:
ci.draw_circle(Vector2(43.0 + col * 7.0 + (row % 2) * 2.0, 22.0 + row * 8.0), 2.3, Color(0.86, 0.6, 0.1))
paint(ci, PackedVector2Array([Vector2(48, 94), Vector2(26, 78), Vector2(16, 42), Vector2(32, 54), Vector2(46, 72)]), LEAF.lightened(0.1), 203.0, 2.0)
paint(ci, PackedVector2Array([Vector2(52, 94), Vector2(54, 72), Vector2(68, 54), Vector2(84, 42), Vector2(74, 78)]), LEAF.darkened(0.08), 204.0, 2.0)
"animals": # a pig
var pink := Color(0.98, 0.66, 0.72)
paint(ci, PackedVector2Array([Vector2(18, 44), Vector2(22, 12), Vector2(46, 30)]), pink.darkened(0.12), 211.0, 2.0)
paint(ci, PackedVector2Array([Vector2(82, 44), Vector2(78, 12), Vector2(54, 30)]), pink.darkened(0.12), 212.0, 2.0)
paint(ci, blob(Vector2(50, 57), 38.0, 33.0, 213.0, 0.03), pink, 214.0)
paint(ci, blob(Vector2(50, 67), 16.0, 11.0, 215.0, 0.03), Color(0.93, 0.5, 0.58), 216.0, 2.0)
for k: float in [-1.0, 1.0]:
ci.draw_circle(Vector2(50.0 + 6.0 * k, 67.0), 3.2, Color(0.45, 0.16, 0.2))
ci.draw_circle(Vector2(50.0 + 15.0 * k, 46.0), 4.2, INK)
ci.draw_circle(Vector2(51.4 + 15.0 * k, 44.6), 1.4, Color.WHITE)
"supplies": # a sack tied at the neck
var burlap := Color(0.8, 0.64, 0.4)
paint(ci, PackedVector2Array([Vector2(36, 34), Vector2(64, 34), Vector2(80, 54), Vector2(84, 80), Vector2(70, 93),
Vector2(30, 93), Vector2(16, 80), Vector2(20, 54)]), burlap, 221.0)
paint(ci, PackedVector2Array([Vector2(38, 36), Vector2(28, 14), Vector2(43, 23), Vector2(50, 11), Vector2(57, 23),
Vector2(72, 14), Vector2(62, 36)]), burlap.lightened(0.08), 222.0, 2.0)
stroke(ci, Vector2(34.0, 35.0), Vector2(66.0, 35.0), Color(0.55, 0.36, 0.18), 4.0, 223.0)
line(ci, Vector2(32, 58), Vector2(40, 84), burlap.darkened(0.3), 2.0, 224.0)
line(ci, Vector2(66, 58), Vector2(62, 82), burlap.darkened(0.3), 2.0, 225.0)
"crow":
var black := Color(0.15, 0.15, 0.19)
var beak := Color(0.98, 0.72, 0.18)
paint(ci, PackedVector2Array([Vector2(32, 60), Vector2(6, 72), Vector2(10, 84), Vector2(38, 72)]), black, 231.0, 2.0)
for x: float in [44.0, 54.0]:
line(ci, Vector2(x, 74.0), Vector2(x - 2.0, 92.0), beak.darkened(0.2), 3.0, 232.0 + x, 0.6)
paint(ci, blob(Vector2(46, 60), 27.0, 18.0, 233.0, 0.04, 28, -0.25), black, 234.0)
paint(ci, blob(Vector2(68, 37), 15.0, 14.0, 235.0), black, 236.0)
paint(ci, PackedVector2Array([Vector2(80, 32), Vector2(97, 41), Vector2(80, 46)]), beak, 237.0, 1.5)
paint(ci, PackedVector2Array([Vector2(28, 52), Vector2(56, 45), Vector2(62, 58), Vector2(38, 70)]), black.lightened(0.2), 238.0, 2.0)
ci.draw_circle(Vector2(71, 34), 4.2, Color(1.0, 0.95, 0.8))
ci.draw_circle(Vector2(72, 34), 2.2, INK)
"thief": # an alien
var skin := Color(0.58, 0.52, 0.72)
for k: float in [-1.0, 1.0]:
line(ci, Vector2(50.0 + 10.0 * k, 26.0), Vector2(50.0 + 22.0 * k, 9.0), INK, 3.0, 241.0 + k, 0.6)
paint(ci, blob(Vector2(50.0 + 23.0 * k, 8.0), 5.5, 5.5, 243.0 + k), Color(0.55, 0.95, 0.35), 245.0 + k, 1.5)
var head := PackedVector2Array()
for i in 32:
var a := TAU * i / 32.0
var down := maxf(sin(a), 0.0)
head.append(Vector2(50, 52) + Vector2(cos(a) * 33.0 * (1.0 - 0.5 * down), sin(a) * (40.0 if sin(a) > 0.0 else 30.0))
+ jitter(247.0 + i, 0.6))
paint(ci, head, skin, 248.0)
for k: float in [-1.0, 1.0]:
paint(ci, blob(Vector2(50.0 + 14.0 * k, 55.0), 12.0, 7.5, 249.0 + k, 0.03, 20, -0.5 * k), INK, 251.0 + k, 0.0)
ci.draw_circle(Vector2(47.0 + 14.0 * k, 52.5), 2.2, Color(0.85, 1.0, 0.75))
line(ci, Vector2(45, 78), Vector2(55, 78), skin.darkened(0.55), 2.5, 253.0, 0.6)
"breaker": # an alien robot
var rust := Color(0.8, 0.38, 0.24)
var metal := Color(0.58, 0.6, 0.64)
line(ci, Vector2(50, 24), Vector2(50, 9), INK, 3.5, 261.0, 0.5)
paint(ci, blob(Vector2(50, 9), 6.0, 6.0, 262.0), Color(1.0, 0.85, 0.3), 263.0, 1.5)
for k: float in [-1.0, 1.0]:
paint(ci, PackedVector2Array([Vector2(50.0 + 30.0 * k, 40), Vector2(50.0 + 41.0 * k, 41), Vector2(50.0 + 41.0 * k, 63),
Vector2(50.0 + 30.0 * k, 64)]), metal, 264.0 + k, 2.0)
paint(ci, PackedVector2Array([Vector2(18, 24), Vector2(82, 22), Vector2(84, 82), Vector2(16, 84)]), rust, 266.0)
for k: float in [-1.0, 1.0]:
paint(ci, blob(Vector2(50.0 + 16.0 * k, 46.0), 10.0, 10.0, 267.0 + k), Color(1.0, 0.86, 0.32), 269.0 + k, 2.5)
ci.draw_circle(Vector2(50.0 + 16.0 * k, 46.0), 3.5, INK)
ci.draw_circle(Vector2(50.0 + 30.0 * k, 30.0), 2.2, rust.darkened(0.5))
ci.draw_circle(Vector2(50.0 + 30.0 * k, 76.0), 2.2, rust.darkened(0.5))
paint(ci, PackedVector2Array([Vector2(30, 63), Vector2(70, 62), Vector2(70, 74), Vector2(30, 75)]), Color(0.3, 0.14, 0.1), 271.0, 2.0)
for i in 4:
line(ci, Vector2(38.0 + i * 8.0, 64.0), Vector2(38.0 + i * 8.0, 73.0), metal, 2.0, 272.0 + i, 0.4)
"ufo":
ci.draw_colored_polygon(PackedVector2Array([Vector2(38, 66), Vector2(62, 66), Vector2(80, 98), Vector2(20, 98)]), Color(0.7, 1.0, 0.5, 0.4))
paint(ci, blob(Vector2(50, 46), 21.0, 19.0, 281.0), Color(0.62, 0.9, 0.95), 282.0)
paint(ci, blob(Vector2(50, 62), 34.0, 8.0, 283.0, 0.02), Color(0.42, 0.44, 0.5), 284.0, 2.0)
paint(ci, blob(Vector2(50, 56), 46.0, 12.0, 285.0, 0.02), Color(0.7, 0.72, 0.78), 286.0)
for i in 5:
ci.draw_circle(Vector2(18.0 + i * 16.0, 57.0 + absf(i - 2.0) * -1.5), 3.6, Color(1.0, 0.86, 0.35))
ci.draw_circle(Vector2(43, 38), 3.5, Color(1.0, 1.0, 1.0, 0.85))
## Points along a circle (center c, radius r) between where it crosses another circle (o, ro),

View file

@ -183,16 +183,16 @@ func _dawn_and_morning(r: GameTestRunner, sim: FarmSim, review: ReviewPanel, bef
"animal losses are recorded and no sack is left in transit")
r.check(s.scarecrow_hp == 7, "the scarecrow's health carries over")
r.check(review.visible and review._title.text == "Morning of day 2 of %d" % sim.config.campaign_nights and review._last_head.visible
and review._last_head.text == "Night 1: Crows at the crops" and review._body.text.contains("Needs repair"),
"the morning screen shows last night's results and what needs repair")
and review._last_head.text == "Night 1: Crows at the crops", "the morning screen shows last night's results")
var rows := ReviewPanel.category_counts(e)
r.check(review.grid_text() == "Crops %d %d %d\nAnimals %d %d %d\nSupplies %d %d %d" % (rows["Crops"] + rows["Animals"] + rows["Supplies"])
and review._body.text.contains("%d of %d animals" % [s.animals, s.animals_total]), "with every category's taken, recovered, and lost")
var killed := int(e["killed_crow"]) + int(e["killed_thief"]) + int(e["killed_breaker"])
r.check(review._results.text.contains("Enemies defeated: ") and review._results.text.contains("Materials: gathered 2 wood")
and (killed == 0) == review._results.text.contains("defeated: none") and int(e["gathered_wood"]) == 2
and int(e["structures_built"]) == 2 and int(e["structures_damaged"]) >= 6, "enemies defeated, damage, and the day's gathering and building")
r.info("morning screen:\n" + review.grid_text() + "\n" + review._results.text + "\n" + review._body.text)
r.check(review.grid_text() == "Crops %d %d %d\nAnimals %d %d %d\nSupplies %d %d %d" % (rows["Crops"] + rows["Animals"] + rows["Supplies"]),
"with every category's taken, recovered, and lost")
var killed := int(e["killed_crow"]) + int(e["killed_thief"]) + int(e["killed_breaker"]) + int(e["killed_ufo"])
r.check((killed == 0) == (review.enemies_text() == "None") and (int(e["killed_crow"]) == 0 or review.enemies_text().contains("Crows %d" % int(e["killed_crow"])))
and review.materials_text().begins_with("Wood 2") and int(e["gathered_wood"]) == 2
and int(e["structures_built"]) == 2 and int(e["structures_damaged"]) >= 6, "the enemies defeated and the day's gathering ('%s'; '%s')" % [
review.enemies_text(), review.materials_text()])
r.info("morning screen:\n" + review.grid_text() + "\nEnemies: " + review.enemies_text() + "\nMaterials: " + review.materials_text())
func _retry(r: GameTestRunner, sim: FarmSim) -> void:

View file

@ -396,15 +396,12 @@ func _night_jump(r: GameTestRunner, farm: Node3D, sim: FarmSim) -> void:
f3.physical_keycode = KEY_F3
f3.pressed = true
debug._unhandled_input(f3)
var tonight := sim.waves.plan_for(2).title
var body := (sim.review_panel._body as Label).text
r.check(c.state == s and s.night == 2 and s.nights_survived == 1 and s.phase == P.MORNING,
"F3: the morning of day 2 (%d survived)" % s.nights_survived)
r.check(s.structure(fence).size() > 0 and s.resources.shed == shed and s.scarecrow_hp == s.scarecrow_max_hp - 1
and s.crops_total == crops and st.has_workbench(),
"the farm is as it was (the fence, the shed, the scarecrow's HP), and the Workbench is granted")
r.check(c.morning_snapshot() == s.to_dict() and sim.review_panel.visible and body.contains("Tonight: %s." % tonight),
"the retry snapshot and the review panel are day 2's")
r.check(c.morning_snapshot() == s.to_dict() and sim.review_panel.visible, "the retry snapshot is day 2's, and the review panel is up")
debug._unhandled_input(f3)
r.check(s.night == 3 and s.nights_survived == 2 and s.crops_total == crops + 30 and sim.loot.count(LootSystem.Status.DORMANT) == dormant - 30,
"F3 again: day 3, and the field due after night 2 sprouts (%d crops)" % s.crops_total)

View file

@ -394,7 +394,6 @@ func _breach(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void:
inside = inside and pen.has_point(sim.animals.position(id))
r.check(inside and _at_loose_spots(sim) and sim.animals.pen_open,
"every penned animal is in the pen and every loose one at its spot (the pen still open: the gate is gone)")
r.check(sim.review_panel._body.text.contains("The pen is open"), "the morning review says the pen is open")
var e: Dictionary = s.night_log[s.night_log.size() - 1]
r.check(e["animals_lost"] == 0 and e["animals_strayed"] >= 2, "the night's record: %s" % [e])
# Retry: lose one to a thief tonight (the only way to lose an animal), fall, and the morning

View file

@ -1 +1 @@
1791391041.240062
1791398176.6069093

File diff suppressed because one or more lines are too long

View file

@ -110,8 +110,8 @@
"semantic_hash": "6a47d64fcc136324ca395065a707ef76"
},
"README.md": {
"mtime": 1791393501.969425,
"ast_hash": "90978ad6c28b7cfbfb405ad9c53e44fc",
"mtime": 1791398708.9809115,
"ast_hash": "c435c638ada5c61ef9feda41c1db6e52",
"semantic_hash": ""
},
"assets/audio/CREDITS.md": {
@ -195,8 +195,8 @@
"semantic_hash": ""
},
"game/RULES.md": {
"mtime": 1791324211.66601,
"ast_hash": "949e5f8c69ded04111b4e99c9282a0bb",
"mtime": 1791398708.9815342,
"ast_hash": "f9f2c16f6b31663a1810c6a0e7a245c1",
"semantic_hash": ""
},
"plan.md": {
@ -1018,5 +1018,10 @@
"mtime": 1791388644.636634,
"ast_hash": "0076d8ae11b1245bda7b3ce2c92d96e1",
"semantic_hash": ""
},
"assets/pictures/screens/splash-screen.png": {
"mtime": 1791395446.9523106,
"ast_hash": "4296651d924c855564f2252183430b3e",
"semantic_hash": ""
}
}

View file

@ -17,7 +17,7 @@ version="1.0.2"
config/name="Harvest-Season"
run/main_scene="res://game/scenes/main.tscn"
config/features=PackedStringArray("4.7", "Forward Plus")
boot_splash/image="uid://cfgcs7r67fcis"
boot_splash/image="uid://dpociv7go51qj"
config/icon="res://icon.svg"
[audio]