fix: T2A cooking works without a craft menu (#2693)

## Summary
With T2A packet crafting menus enabled (`t2aCraftMenus`, default for pre-UOTD eras), cooking did nothing. Double-clicking a Skillet set a target, and `T2ACraftSystem.ShowMenu` had no Cooking branch, so the target was accepted and silently dropped. Nothing else could cook either: the old RunUO "use food on a heat source" code was never hooked up and was removed in #1054.

T2A cooking never used a menu, so this restores the item-on-item / item-on-heat-source flow:

- **Per-item handling:** each ingredient (`CookableFood`, `Dough`, `SweetDough`, `SackFlour`, `BowlFlour`, `JarHoney`) implements `IT2ACombinable.TryCombine` and switches on the target. `T2ACooking` holds the shared target, water, combine and heat-timer helpers.
- **Heat source:** all `CookableFood` (raw meats, fish, eggs, unbaked pies/quiche/pizzas, cookie and cake mix), dough → bread loaf, sweet dough → muffins. One unit is used up at the start, then a 5 s timer; the Cooking check runs from `CookingLevel` to 100 (bread and muffins use `DefCooking`'s range). The food burns on failure or if the cook moves more than 3 tiles away.
- **Combinations:**
  - Open flour sack or bowl of flour + water → dough
  - Dough + pear / peach / apple / pumpkin / eggs / meat / sausage → the matching unbaked pie, quiche or pizza
  - Dough + honey → sweet dough
  - Sweet dough + honey → cookie mix
  - Flour + sweet dough → cake mix
  - The honey and flour + sweet dough recipes work in either direction.
- **Water:** water drinks (pitchers), buckets, barrels, tubs and trough add-ons, in the pack, in hand, or on the ground within 2 tiles and in line of sight.
- **Cooking tools are passive:** with T2A menus on, a tool whose system has no T2A menu (`T2ACraftSystem.HasMenu`) falls through to `ShowCraftMenu`, which does nothing under T2A. No dead target is left.

Behaviour with T2A menus off is unchanged.

## Follow-ups
- Static troughs/barrels and open water aren't water sources here or for pitcher filling (no static water ID list exists); to be fixed separately.
- Whether a bowl of flour returns an empty bowl is unconfirmed (`//TODO`).
- Cooking tools that must merely be in the pack for some recipes are not modelled yet.

## Testing
- `dotnet build`: 0 warnings, 0 errors
- New `T2ACookingTests`: flour + water, closed sack refused, dough + apple, honey in both directions, cookie mix, cake mix, wrong target consumes nothing, water in another player's pack refused
- Not covered: the heat timer (untested); not yet exercised in game
This commit is contained in:
Kamron Batman 2026-10-20 23:37:28 -07:00 • committed by GitHub
parent ef8057d38e
commit 88859ac69e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 627 additions and 7 deletions

View file

@ -0,0 +1,145 @@
using Server;
using Server.Items;
using Server.Mobiles;
using Xunit;
namespace UOContent.Tests;
[Collection("Sequential UOContent Tests")]
public class T2ACookingTests
{
private static PlayerMobile CreatePlayer()
{
var m = new PlayerMobile(World.NewMobile);
m.DefaultMobileInit();
m.MoveToWorld(new Point3D(4200, 500, 0), Map.Felucca);
m.AddItem(new Backpack());
return m;
}
[Fact]
public void FlourAndWaterPitcher_MakeDough()
{
var player = CreatePlayer();
var pack = player.Backpack;
var sack = new SackFlour { ItemID = 0x103A };
var pitcher = new Pitcher(BeverageType.Water);
pack.AddItem(sack);
pack.AddItem(pitcher);
var sackBefore = sack.Quantity;
var pitcherBefore = pitcher.Quantity;
Assert.True(sack.TryCombine(player, pitcher));
Assert.Equal(sackBefore - 1, sack.Quantity);
Assert.Equal(pitcherBefore - 1, pitcher.Quantity);
Assert.Equal(1, pack.GetAmount(typeof(Dough)));
}
[Fact]
public void ClosedFlourSack_IsRefused()
{
var player = CreatePlayer();
var sack = new SackFlour();
var pitcher = new Pitcher(BeverageType.Water);
player.Backpack.AddItem(sack);
player.Backpack.AddItem(pitcher);
Assert.False(sack.TryCombine(player, pitcher));
Assert.Equal(20, sack.Quantity);
Assert.Equal(pitcher.MaxQuantity, pitcher.Quantity);
Assert.Equal(0, player.Backpack.GetAmount(typeof(Dough)));
}
[Fact]
public void DoughAndApple_MakeUnbakedApplePie()
{
var player = CreatePlayer();
var dough = new Dough();
var apple = new Apple();
player.Backpack.AddItem(dough);
player.Backpack.AddItem(apple);
Assert.True(dough.TryCombine(player, apple));
Assert.Equal(1, player.Backpack.GetAmount(typeof(UnbakedApplePie)));
Assert.Equal(0, player.Backpack.GetAmount(typeof(Apple)));
Assert.Equal(0, player.Backpack.GetAmount(typeof(Dough)));
}
[Fact]
public void HoneyRows_WorkInEitherDirection()
{
var player = CreatePlayer();
var pack = player.Backpack;
var dough = new Dough();
var honey = new JarHoney();
pack.AddItem(dough);
pack.AddItem(honey);
Assert.True(dough.TryCombine(player, honey));
Assert.Equal(1, pack.GetAmount(typeof(SweetDough)));
var dough2 = new Dough();
var honey2 = new JarHoney();
pack.AddItem(dough2);
pack.AddItem(honey2);
Assert.True(honey2.TryCombine(player, dough2));
Assert.Equal(2, pack.GetAmount(typeof(SweetDough)));
var sweet = pack.FindItemByType<SweetDough>();
var honey3 = new JarHoney();
pack.AddItem(honey3);
Assert.True(sweet.TryCombine(player, honey3));
Assert.Equal(1, pack.GetAmount(typeof(CookieMix)));
}
[Fact]
public void WrongTarget_ConsumesNothing()
{
var player = CreatePlayer();
var dough = new Dough();
var honey = new JarHoney();
player.Backpack.AddItem(dough);
player.Backpack.AddItem(honey);
var apple = new Apple();
player.Backpack.AddItem(apple);
var pitcher = new Pitcher(BeverageType.Water);
player.Backpack.AddItem(pitcher);
Assert.False(honey.TryCombine(player, apple));
Assert.False(dough.TryCombine(player, pitcher));
Assert.Equal(1, player.Backpack.GetAmount(typeof(Dough)));
Assert.Equal(1, player.Backpack.GetAmount(typeof(JarHoney)));
Assert.Equal(1, player.Backpack.GetAmount(typeof(Apple)));
}
[Fact]
public void BowlFlourAndSweetDough_MakeCakeMix()
{
var player = CreatePlayer();
var bowl = new BowlFlour();
var sweetDough = new SweetDough();
player.Backpack.AddItem(bowl);
player.Backpack.AddItem(sweetDough);
Assert.True(sweetDough.TryCombine(player, bowl));
Assert.True(bowl.Deleted);
Assert.True(sweetDough.Deleted);
Assert.Equal(1, player.Backpack.GetAmount(typeof(CakeMix)));
}
[Fact]
public void WaterInAnotherPlayersPack_IsRefused()
{
var player = CreatePlayer();
var other = CreatePlayer();
var sack = new SackFlour { ItemID = 0x103A };
var pitcher = new Pitcher(BeverageType.Water);
player.Backpack.AddItem(sack);
other.Backpack.AddItem(pitcher);
Assert.False(sack.TryCombine(player, pitcher));
Assert.Equal(20, sack.Quantity);
Assert.Equal(pitcher.MaxQuantity, pitcher.Quantity);
}
}