From 2e2c4fe2e32be0b8852fbdf2743de46b4ac78bbf Mon Sep 17 00:00:00 2001 From: agentic-dev agent Date: Sun, 29 Nov 2026 12:31:01 +0000 Subject: [PATCH 1/7] Initialize two new item maturation features Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- init.sh | 4 ++ .../ItemMaturationServiceTests.cs | 48 ++++++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 init.sh diff --git a/init.sh b/init.sh new file mode 100644 index 0000000..24a0c26 --- /dev/null +++ b/init.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +set -eu + +dotnet build GildedRoseKata.sln --no-restore --verbosity quiet diff --git a/tests/Core.Tests/ProposedCode/ItemMaturationServiceTests.cs b/tests/Core.Tests/ProposedCode/ItemMaturationServiceTests.cs index 4690ec6..db122f4 100644 --- a/tests/Core.Tests/ProposedCode/ItemMaturationServiceTests.cs +++ b/tests/Core.Tests/ProposedCode/ItemMaturationServiceTests.cs @@ -35,4 +35,50 @@ public void Mature_UsesExpectedRulesForResolvedItemKinds(string name, int qualit result.Quality.Should().Be(expectedQuality); result.SellIn.Should().Be(expectedSellIn); } -} \ No newline at end of file + + [Theory] + [InlineData(10, 5, 13, 4)] + [InlineData(10, 4, 11, 3)] + [InlineData(10, 0, 7, -1)] + [InlineData(49, 5, 50, 4)] + [InlineData(2, 0, 0, -1)] + public void F001_PhoenixFeather_GainsMilestoneBonusAndCoolsAfterExpiry(int quality, int sellIn, int expectedQuality, int expectedSellIn) + { + var service = new ItemMaturationService(); + var item = new Item + { + Name = "Phoenix Feather", + Quality = quality, + SellIn = sellIn, + }; + + var result = service.Mature(item); + + result.Quality.Should().Be(expectedQuality); + result.SellIn.Should().Be(expectedSellIn); + } + + [Theory] + [InlineData(10, 11, 11, 10)] + [InlineData(10, 10, 12, 9)] + [InlineData(10, 6, 12, 5)] + [InlineData(10, 5, 13, 4)] + [InlineData(10, 1, 13, 0)] + [InlineData(10, 0, 0, -1)] + [InlineData(49, 5, 50, 4)] + public void F002_DragonfireWine_FermentsThroughStagesAndSpoilsAfterExpiry(int quality, int sellIn, int expectedQuality, int expectedSellIn) + { + var service = new ItemMaturationService(); + var item = new Item + { + Name = "Dragonfire Wine", + Quality = quality, + SellIn = sellIn, + }; + + var result = service.Mature(item); + + result.Quality.Should().Be(expectedQuality); + result.SellIn.Should().Be(expectedSellIn); + } +} From 99a095b341760ccab1d1cf881abed5e6c97f3e82 Mon Sep 17 00:00:00 2001 From: agentic-dev agent Date: Sun, 29 Nov 2026 12:32:08 +0000 Subject: [PATCH 2/7] Make Phoenix expiry case discriminate maturation rule Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- tests/Core.Tests/ProposedCode/ItemMaturationServiceTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Core.Tests/ProposedCode/ItemMaturationServiceTests.cs b/tests/Core.Tests/ProposedCode/ItemMaturationServiceTests.cs index db122f4..c1a9409 100644 --- a/tests/Core.Tests/ProposedCode/ItemMaturationServiceTests.cs +++ b/tests/Core.Tests/ProposedCode/ItemMaturationServiceTests.cs @@ -41,7 +41,7 @@ public void Mature_UsesExpectedRulesForResolvedItemKinds(string name, int qualit [InlineData(10, 4, 11, 3)] [InlineData(10, 0, 7, -1)] [InlineData(49, 5, 50, 4)] - [InlineData(2, 0, 0, -1)] + [InlineData(8, 0, 5, -1)] public void F001_PhoenixFeather_GainsMilestoneBonusAndCoolsAfterExpiry(int quality, int sellIn, int expectedQuality, int expectedSellIn) { var service = new ItemMaturationService(); From 28fb80a36c92057660682be133eeddeb132ba4c8 Mon Sep 17 00:00:00 2001 From: agentic-dev agent Date: Sun, 29 Nov 2026 12:39:05 +0000 Subject: [PATCH 3/7] Add Phoenix Feather maturation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/Core/ProposedCode/Domain/ItemKind.cs | 5 ++++- .../ProposedCode/Domain/ItemMaturingPolicy.cs | 22 ++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/Core/ProposedCode/Domain/ItemKind.cs b/src/Core/ProposedCode/Domain/ItemKind.cs index 199f351..7341096 100644 --- a/src/Core/ProposedCode/Domain/ItemKind.cs +++ b/src/Core/ProposedCode/Domain/ItemKind.cs @@ -16,6 +16,8 @@ public sealed record Backstage : ItemKind; public sealed record Conjured : ItemKind; + public sealed record PhoenixFeather : ItemKind; + public sealed record Sulfuras : ItemKind; public static ItemKind FromName(string itemName) @@ -28,8 +30,9 @@ public static ItemKind FromName(string itemName) "Backstage" => new Backstage(), "Conjured Mana Cake" => new Conjured(), "Conjured" => new Conjured(), + "Phoenix Feather" => new PhoenixFeather(), "Sulfuras, Hand of Ragnaros" => new Sulfuras(), _ => new Standard(), }; } -} \ No newline at end of file +} diff --git a/src/Core/ProposedCode/Domain/ItemMaturingPolicy.cs b/src/Core/ProposedCode/Domain/ItemMaturingPolicy.cs index 0221621..29e63dc 100644 --- a/src/Core/ProposedCode/Domain/ItemMaturingPolicy.cs +++ b/src/Core/ProposedCode/Domain/ItemMaturingPolicy.cs @@ -15,6 +15,7 @@ public ItemState Mature(ItemKind kind, ItemState state) ItemKind.AgedBrie => this.MatureAgedBrie(state), ItemKind.Backstage => this.MatureBackstage(state), ItemKind.Conjured => this.MatureConjured(state), + ItemKind.PhoenixFeather => this.MaturePhoenixFeather(state), ItemKind.Sulfuras => state, _ => this.MatureStandard(state), }; @@ -77,4 +78,23 @@ private ItemState MatureConjured(ItemState state) return new(newQuality, newSellIn); } -} \ No newline at end of file + + private ItemState MaturePhoenixFeather(ItemState state) + { + var newQuality = state.Quality.Increase(); + + if (state.SellIn.Value == 5) + { + newQuality = newQuality.Increase(2); + } + + var newSellIn = state.SellIn.NextDay(); + + if (newSellIn.IsExpired) + { + newQuality = newQuality.Decrease(4); + } + + return new(newQuality, newSellIn); + } +} From d7fc43bb6fa00e3d09a355faf636df74e652777a Mon Sep 17 00:00:00 2001 From: agentic-dev agent Date: Sun, 29 Nov 2026 12:40:08 +0000 Subject: [PATCH 4/7] Add Dragonfire Wine maturation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/Core/ProposedCode/Domain/ItemKind.cs | 3 +++ .../ProposedCode/Domain/ItemMaturingPolicy.cs | 20 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/Core/ProposedCode/Domain/ItemKind.cs b/src/Core/ProposedCode/Domain/ItemKind.cs index 7341096..dd0ab6f 100644 --- a/src/Core/ProposedCode/Domain/ItemKind.cs +++ b/src/Core/ProposedCode/Domain/ItemKind.cs @@ -18,6 +18,8 @@ public sealed record Conjured : ItemKind; public sealed record PhoenixFeather : ItemKind; + public sealed record DragonfireWine : ItemKind; + public sealed record Sulfuras : ItemKind; public static ItemKind FromName(string itemName) @@ -31,6 +33,7 @@ public static ItemKind FromName(string itemName) "Conjured Mana Cake" => new Conjured(), "Conjured" => new Conjured(), "Phoenix Feather" => new PhoenixFeather(), + "Dragonfire Wine" => new DragonfireWine(), "Sulfuras, Hand of Ragnaros" => new Sulfuras(), _ => new Standard(), }; diff --git a/src/Core/ProposedCode/Domain/ItemMaturingPolicy.cs b/src/Core/ProposedCode/Domain/ItemMaturingPolicy.cs index 29e63dc..0c7530b 100644 --- a/src/Core/ProposedCode/Domain/ItemMaturingPolicy.cs +++ b/src/Core/ProposedCode/Domain/ItemMaturingPolicy.cs @@ -16,6 +16,7 @@ public ItemState Mature(ItemKind kind, ItemState state) ItemKind.Backstage => this.MatureBackstage(state), ItemKind.Conjured => this.MatureConjured(state), ItemKind.PhoenixFeather => this.MaturePhoenixFeather(state), + ItemKind.DragonfireWine => this.MatureDragonfireWine(state), ItemKind.Sulfuras => state, _ => this.MatureStandard(state), }; @@ -97,4 +98,23 @@ private ItemState MaturePhoenixFeather(ItemState state) return new(newQuality, newSellIn); } + + private ItemState MatureDragonfireWine(ItemState state) + { + var newQuality = state.SellIn switch + { + _ when state.SellIn.IsBelow(6) => state.Quality.Increase(3), + _ when state.SellIn.IsBelow(11) => state.Quality.Increase(2), + _ => state.Quality.Increase(), + }; + + var newSellIn = state.SellIn.NextDay(); + + if (newSellIn.IsExpired) + { + newQuality = newQuality.Reset(); + } + + return new(newQuality, newSellIn); + } } From ffb8d71eb811a212b627edd4cb3fa99e76ef3ef1 Mon Sep 17 00:00:00 2001 From: agentic-dev agent Date: Sun, 29 Nov 2026 12:41:30 +0000 Subject: [PATCH 5/7] Handle already-expired Phoenix Feathers Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../ProposedCode/Domain/ItemMaturingPolicy.cs | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/Core/ProposedCode/Domain/ItemMaturingPolicy.cs b/src/Core/ProposedCode/Domain/ItemMaturingPolicy.cs index 0c7530b..6893ae8 100644 --- a/src/Core/ProposedCode/Domain/ItemMaturingPolicy.cs +++ b/src/Core/ProposedCode/Domain/ItemMaturingPolicy.cs @@ -82,18 +82,26 @@ private ItemState MatureConjured(ItemState state) private ItemState MaturePhoenixFeather(ItemState state) { - var newQuality = state.Quality.Increase(); + var newSellIn = state.SellIn.NextDay(); + var newQuality = state.Quality; - if (state.SellIn.Value == 5) + if (state.SellIn.IsExpired) { - newQuality = newQuality.Increase(2); + newQuality = newQuality.Decrease(4); } + else + { + newQuality = newQuality.Increase(); - var newSellIn = state.SellIn.NextDay(); + if (state.SellIn.Value == 5) + { + newQuality = newQuality.Increase(2); + } - if (newSellIn.IsExpired) - { - newQuality = newQuality.Decrease(4); + if (newSellIn.IsExpired) + { + newQuality = newQuality.Decrease(4); + } } return new(newQuality, newSellIn); From d64355fe6790b7c68e482adc3f5e8370234f4a3b Mon Sep 17 00:00:00 2001 From: agentic-dev agent Date: Sun, 29 Nov 2026 12:42:53 +0000 Subject: [PATCH 6/7] Make Phoenix Feather expiry rules explicit Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../ProposedCode/Domain/ItemMaturingPolicy.cs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/Core/ProposedCode/Domain/ItemMaturingPolicy.cs b/src/Core/ProposedCode/Domain/ItemMaturingPolicy.cs index 6893ae8..3cd48ee 100644 --- a/src/Core/ProposedCode/Domain/ItemMaturingPolicy.cs +++ b/src/Core/ProposedCode/Domain/ItemMaturingPolicy.cs @@ -83,25 +83,18 @@ private ItemState MatureConjured(ItemState state) private ItemState MaturePhoenixFeather(ItemState state) { var newSellIn = state.SellIn.NextDay(); - var newQuality = state.Quality; if (state.SellIn.IsExpired) { - newQuality = newQuality.Decrease(4); + return new(state.Quality.Decrease(4), newSellIn); } - else - { - newQuality = newQuality.Increase(); - if (state.SellIn.Value == 5) - { - newQuality = newQuality.Increase(2); - } + var dailyGain = state.SellIn.Value == 5 ? 3 : 1; + var newQuality = state.Quality.Increase(dailyGain); - if (newSellIn.IsExpired) - { - newQuality = newQuality.Decrease(4); - } + if (newSellIn.IsExpired) + { + newQuality = newQuality.Decrease(4); } return new(newQuality, newSellIn); From 70a22c32526976d82e64eaab749067d841e2af38 Mon Sep 17 00:00:00 2001 From: agentic-dev agent Date: Sun, 29 Nov 2026 12:44:02 +0000 Subject: [PATCH 7/7] Make Dragonfire expiry handling explicit Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../ProposedCode/Domain/ItemMaturingPolicy.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Core/ProposedCode/Domain/ItemMaturingPolicy.cs b/src/Core/ProposedCode/Domain/ItemMaturingPolicy.cs index 3cd48ee..506e98b 100644 --- a/src/Core/ProposedCode/Domain/ItemMaturingPolicy.cs +++ b/src/Core/ProposedCode/Domain/ItemMaturingPolicy.cs @@ -102,14 +102,20 @@ private ItemState MaturePhoenixFeather(ItemState state) private ItemState MatureDragonfireWine(ItemState state) { - var newQuality = state.SellIn switch + var newSellIn = state.SellIn.NextDay(); + + if (state.SellIn.IsExpired) { - _ when state.SellIn.IsBelow(6) => state.Quality.Increase(3), - _ when state.SellIn.IsBelow(11) => state.Quality.Increase(2), - _ => state.Quality.Increase(), - }; + return new(state.Quality.Reset(), newSellIn); + } - var newSellIn = state.SellIn.NextDay(); + var dailyGain = state.SellIn switch + { + _ when state.SellIn.IsBelow(6) => 3, + _ when state.SellIn.IsBelow(11) => 2, + _ => 1, + }; + var newQuality = state.Quality.Increase(dailyGain); if (newSellIn.IsExpired) {