From ae2bc83c24257e393484ea55146c5d24d471a13d Mon Sep 17 00:00:00 2001 From: NiemandKG <74151950+NiemandKG@users.noreply.github.com> Date: Thu, 12 Nov 2026 02:00:34 +0600 Subject: [PATCH] Client purchases in the replica test; multipliers keep their small x Co-Authored-By: Claude Opus 5.5 --- Assets/Scripts/Core/DemoBot.Replica.cs | 37 ++++++++++++++++++++++++++ Assets/Scripts/UI/PieceScreen.cs | 3 ++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/Assets/Scripts/Core/DemoBot.Replica.cs b/Assets/Scripts/Core/DemoBot.Replica.cs index 0ec549f..0acc738 100644 --- a/Assets/Scripts/Core/DemoBot.Replica.cs +++ b/Assets/Scripts/Core/DemoBot.Replica.cs @@ -78,6 +78,43 @@ namespace GrassCutter Log($"host: the client's tractor {(theirs ? "is here" : "MISSING")}, mine {(Vehicle.Mine(VehicleKind.Tractor, Me.SaveId) ? "too" : "none (right)")}"); } + // every other kind of purchase, from the client: a matrix perk, a tool, gear, a belt slot, a building's upgrade + BuildPiece robot = null, garage = null; + if (host) + { + var rAt = Soil17(30f, -30f); + robot = Spawner.Instance.SpawnPiece(PieceId.RobotI, rAt, Face(rAt, Vector3.forward), Vector3.zero, true); + var gAt = Soil17(45f, 20f); + garage = Spawner.Instance.SpawnPiece(PieceId.Garage, gAt, Face(gAt, Vector3.forward), Vector3.zero, true); + } + yield return new WaitForSeconds(2f); + robot = BuildPiece.All.Find(x => x && x.piece == PieceId.RobotI); + garage = BuildPiece.All.Find(x => x && x.piece == PieceId.Garage); + if (!host) + { + PerkDef perk = null; + foreach (var d in GameDefs.Perks) if (Ts.Level(d.id) == 0 && Ts.PerkAvailable(d)) { perk = d; break; } + int slots = Me.BeltSlots.Value, tier = robot ? robot.Tier.Value : -1; + double cash = Ts.Money.Value; + if (perk != null) Ts.BuyPerkRpc((int)perk.id); + Ts.BuyToolRpc((byte)ToolId.Sickle); + Ts.BuyGearRpc((byte)GearId.Jetpack); + Ts.BuyBeltSlotRpc(); + if (robot) robot.UpgradeRpc(); + yield return new WaitForSeconds(2f); + Log($"client buys: perk {(perk != null ? perk.id + " " + Ts.Level(perk.id) : "none available")}, sickle {(Me.Owns(ToolId.Sickle) ? "yes" : "NO")}, jetpack {(Me.HasGear(GearId.Jetpack) ? "yes" : "NO")}, belt slots {slots} -> {Me.BeltSlots.Value}, robot {(robot ? "Mk " + (tier + 1) + " -> Mk " + (robot.Tier.Value + 1) : "MISSING")}, spent {cash - Ts.Money.Value:0}"); + + // and the screens, as the client sees them + BotCapture.From = null; + if (garage) { UIRoot.I.OpenGarage(garage.GetComponent(), VehicleKind.Tractor); yield return new WaitForSeconds(1.2f); yield return Shot("rep_client_garage"); UIRoot.I.CloseTopModal(); yield return new WaitForSeconds(0.4f); } + if (robot) { UIRoot.I.OpenPiece(robot); yield return new WaitForSeconds(1.2f); yield return Shot("rep_client_robot"); UIRoot.I.CloseTopModal(); yield return new WaitForSeconds(0.4f); } + UIRoot.I.OpenShop(); yield return new WaitForSeconds(1.2f); yield return Shot("rep_client_shop"); UIRoot.I.CloseTopModal(); yield return new WaitForSeconds(0.4f); + UIRoot.I.OpenSupply(); yield return new WaitForSeconds(1.2f); yield return Shot("rep_client_supply"); UIRoot.I.CloseTopModal(); yield return new WaitForSeconds(0.4f); + } + else yield return new WaitForSeconds(12f); + yield return new WaitForSeconds(1f); + if (host) Log($"host sees: robot Mk {(robot ? robot.Tier.Value + 1 : 0)}, the client owns a sickle {(other.Owns(ToolId.Sickle) ? "yes" : "NO")}, perks bought {Ts.Installs - 1}"); + // the client drives it and hops off; both watch how it stands var v = Vehicle.All.Find(x => x && x.kind == VehicleKind.Tractor); if (!host && v) diff --git a/Assets/Scripts/UI/PieceScreen.cs b/Assets/Scripts/UI/PieceScreen.cs index 97246f4..fb168dd 100644 --- a/Assets/Scripts/UI/PieceScreen.cs +++ b/Assets/Scripts/UI/PieceScreen.cs @@ -119,6 +119,7 @@ namespace GrassCutter } } - static string Cap(string s) => string.IsNullOrEmpty(s) ? s : char.ToUpper(s[0], Loc.Culture) + s.Substring(1); + /// A capital to start with, except on a multiplier ("x1.6 speed", not "X1.6"). + static string Cap(string s) => string.IsNullOrEmpty(s) || (s.Length > 1 && s[0] == 'x' && char.IsDigit(s[1])) ? s : char.ToUpper(s[0], Loc.Culture) + s.Substring(1); } }