Client purchases in the replica test; multipliers keep their small x

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
NiemandKG
2026-11-12 02:00:34 +06:00
parent d61167e22b
commit ae2bc83c24
2 changed files with 39 additions and 1 deletions

View File

@ -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<Garage>(), 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)

View File

@ -119,6 +119,7 @@ namespace GrassCutter
}
}
static string Cap(string s) => string.IsNullOrEmpty(s) ? s : char.ToUpper(s[0], Loc.Culture) + s.Substring(1);
/// <summary>A capital to start with, except on a multiplier ("x1.6 speed", not "X1.6").</summary>
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);
}
}