Fix pirates. Whoops. (#8623)

* Fix pirates. Whoops.

* Remove debug logs.
This commit is contained in:
Moony
2022-06-03 12:14:36 -05:00
committed by GitHub
parent 43f0d87252
commit 6b49933edd
3 changed files with 289 additions and 282 deletions

View File

@@ -34,8 +34,13 @@ public sealed class PiratesRuleSystem : GameRuleSystem
[Dependency] private readonly RoundEndSystem _roundEndSystem = default!;
[Dependency] private readonly PricingSystem _pricingSystem = default!;
[ViewVariables]
private List<Mind.Mind> _pirates = new();
[ViewVariables]
private EntityUid _pirateShip = EntityUid.Invalid;
[ViewVariables]
private HashSet<EntityUid> _initialItems = new();
[ViewVariables]
private double _initialShipValue;
public override string Prototype => "Pirates";
@@ -43,6 +48,8 @@ public sealed class PiratesRuleSystem : GameRuleSystem
/// <inheritdoc/>
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<RulePlayerSpawningEvent>(OnPlayerSpawningEvent);
SubscribeLocalEvent<RoundEndTextAppendEvent>(OnRoundEndTextEvent);
}
@@ -72,6 +79,9 @@ public sealed class PiratesRuleSystem : GameRuleSystem
return true;
}, (uid, price) =>
{
if (_initialItems.Contains(uid))
return;
mostValuableThefts.Add((price, uid));
mostValuableThefts.Sort((i1, i2) => i2.Item1.CompareTo(i1.Item1));
if (mostValuableThefts.Count > 5)
@@ -86,14 +96,26 @@ public sealed class PiratesRuleSystem : GameRuleSystem
var score = finalValue - _initialShipValue;
ev.AddLine(Loc.GetString("pirates-final-score", ("finalPrice", $"{finalValue:F2}"),
("score", $"{score:F2}")));
ev.AddLine(Loc.GetString("pirates-final-score", ("score", $"{score:F2}")));
ev.AddLine(Loc.GetString("pirates-final-score-2", ("finalPrice", $"{finalValue:F2}")));
ev.AddLine("");
ev.AddLine(Loc.GetString("pirates-most-valuable"));
foreach (var (price, obj) in mostValuableThefts)
{
ev.AddLine(Loc.GetString("pirates-stolen-item-entry", ("entity", obj), ("credits", $"{price:F2}")));
}
if (mostValuableThefts.Count == 0)
ev.AddLine(Loc.GetString("pirates-stole-nothing"));
}
ev.AddLine("");
ev.AddLine(Loc.GetString("pirates-list-start"));
foreach (var pirates in _pirates)
{
ev.AddLine($"- {pirates.CharacterName} ({pirates.Session?.Name}");
ev.AddLine($"- {pirates.CharacterName} ({pirates.Session?.Name})");
}
}
@@ -105,9 +127,12 @@ public sealed class PiratesRuleSystem : GameRuleSystem
{
// Forgive me for copy-pasting nukies.
if (!Enabled)
{
return;
}
_pirates.Clear();
_initialItems.Clear();
// Between 1 and <max pirate count>: needs at least n players per op.
var numOps = Math.Max(1,
@@ -190,7 +215,11 @@ public sealed class PiratesRuleSystem : GameRuleSystem
GameTicker.PlayerJoinGame(session);
}
_initialShipValue = _pricingSystem.AppraiseGrid(_pirateShip); // Include the players in the appraisal.
_initialShipValue = _pricingSystem.AppraiseGrid(_pirateShip, uid =>
{
_initialItems.Add(uid);
return true;
}); // Include the players in the appraisal.
}
private void OnStartAttempt(RoundStartAttemptEvent ev)

View File

@@ -2,6 +2,9 @@
pirates-description = A group of privateers has approached your lowly station. Hostile or not, their sole goal is to end the round with as many knicknacks on their ship as they can get.
pirates-no-ship = Through unknown circumstances, the privateer's ship was completely and utterly destroyed. No score.
pirates-final-score = The privateers successfully obtained {$score} credits worth of knicknacks, with their vessel being worth {$finalPrice} by the end.
pirates-final-score = The privateers successfully obtained {$score} credits worth
pirates-final-score-2 = of knicknacks, with a total of {$finalPrice} credits.
pirates-list-start = The privateers were:
pirates-most-valuable = The most valuable stolen items were:
pirates-stolen-item-entry = {$entity} ({$credits} credits)
pirates-stole-nothing = - The pirates stole absolutely nothing at all. Point and laugh.

File diff suppressed because it is too large Load Diff