Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discord Relay Re-Write #54

Merged
merged 1 commit into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Content.Server/_NF/Bank/StationATMSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private void OnWithdraw(EntityUid uid, StationBankATMComponent component, Statio
}

// check for sufficient funds
if (stationBank.Balance < args.Amount)
if (stationBank.Balance < args.Amount || args.Amount < 0)
{
ConsolePopup(args.Session, Loc.GetString("bank-insufficient-funds"));
PlayDenySound(uid, component);
Expand Down
31 changes: 29 additions & 2 deletions Content.Server/_NF/GameRule/NfAdventureRuleSystem.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Text.Json;
Expand Down Expand Up @@ -55,17 +56,43 @@ public override void Initialize()
private void OnRoundEndTextEvent(RoundEndTextAppendEvent ev)
{
var profitText = Loc.GetString($"adventure-mode-profit-text");
var lossText = Loc.GetString($"adventure-mode-loss-text");
ev.AddLine(Loc.GetString("adventure-list-start"));
var allScore = new List<Tuple<string, int>>();

foreach (var player in _players)
{
if (!TryComp<BankAccountComponent>(player.Item1, out var bank) || !TryComp<MetaDataComponent>(player.Item1, out var meta))
continue;

var profit = bank.Balance - player.Item2;
ev.AddLine($"- {meta.EntityName} {profitText} {profit} Spesos");
allScore.Add(new Tuple<string, int>(meta.EntityName, profit));
}

ReportRound(ev.Text);
if (!(allScore.Count >= 1))
return;

var relayText = Loc.GetString("adventure-list-high");
relayText += '\n';
var highScore = allScore.OrderByDescending(h => h.Item2).ToList();

for (var i = 0; i < 10 && i < highScore.Count; i++)
{
relayText += $"{highScore.First().Item1} {profitText} {highScore.First().Item2.ToString()} Spesos";
relayText += '\n';
highScore.Remove(highScore.First());
}
relayText += Loc.GetString("adventure-list-low");
relayText += '\n';
highScore.Reverse();
for (var i = 0; i < 10 && i < highScore.Count; i++)
{
relayText += $"{highScore.First().Item1} {lossText} {highScore.First().Item2.ToString()} Spesos";
relayText += '\n';
highScore.Remove(highScore.First());
}
ReportRound(relayText);
}

private void OnPlayerSpawningEvent(PlayerSpawnCompleteEvent ev)
Expand Down Expand Up @@ -98,7 +125,7 @@ private void OnStartup(RoundStartingEvent ev)
;
if (_map.TryLoad(mapId, tinnia, out var depotUid2s, new MapLoadOptions
{
Offset = -depotOffset
Offset = _random.NextVector2(975f, 1375f)
}))
{
var meta = EnsureComp<MetaDataComponent>(depotUid2s[0]);
Expand Down
9 changes: 6 additions & 3 deletions Resources/Locale/en-US/_NF/adventure/adventure.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
playtime-deny-reason-not-whitelisted = You need to be whitelisted.
adventure-list-start = NT Galactic Bank
adventure-mode-profit-text = made a total profit of: {" "}
adventure-mode-loss-text = lost a total of: {" "}
adventure-list-high = Today's Top Earners:
adventure-list-low = Today's Biggest Spenders:
adventure-title = New Frontier Adventure Mode
adventure-description = Join a ship crew or buy your own and explore, research, salvage, or haul your way to riches!
currency = Spesos
Expand All @@ -13,11 +16,11 @@ guide-entry-adventure = New Frontiers Program
guide-entry-bank = NT Galactic Bank
guide-entry-shipyard = Frontier Shipyards

shipyard-rules-default1 =
shipyard-rules-default1 =
Thank you for your interest in Nanotrasen Security Forces.
By purchasing a Security vessel, you agree to enforce Space Law
as found at https://wiki.nyanotrasen.moe/view/Space_Law.
shipyard-rules-default2 =
Any actions performed by you or you crew that violate Space Law
Any actions performed by you or you crew that violate Space Law
can and will result in administrative action.
Thank you for choosing Nanotrasen Security Forces.
Thank you for choosing Nanotrasen Security Forces.