Increase shiftletters payout (and shiftnet sub stuff)
This commit is contained in:
parent
ec61f5dfe9
commit
82a5ca296b
4 changed files with 48 additions and 5 deletions
|
@ -167,14 +167,33 @@ namespace ShiftOS.WinForms.Applications
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a Shiftnet download speed in bytes based on the user's subscription.
|
||||
/// </summary>
|
||||
/// <returns>Download speed in bytes.</returns>
|
||||
public static int GetDownloadSpeed()
|
||||
{
|
||||
switch (SaveSystem.CurrentSave.ShiftnetSubscription)
|
||||
{
|
||||
case 0:
|
||||
return 256/*B*/;
|
||||
case 1:
|
||||
return 1024 * 1024/*KB*/;
|
||||
case 2:
|
||||
return 1024 * 10240/*KB*/;
|
||||
case 3:
|
||||
return 1024 * 1024 * 1024/*MB*/;
|
||||
}
|
||||
return 256;
|
||||
}
|
||||
|
||||
public static void StartDownload(Download down)
|
||||
{
|
||||
var t = new Thread(() =>
|
||||
{
|
||||
int byteWrite = 256;
|
||||
_downloads.Add(down);
|
||||
DownloadStarted?.Invoke(down);
|
||||
for (int i = 0; i < down.Bytes.Length; i += byteWrite)
|
||||
for (int i = 0; i < down.Bytes.Length; i += GetDownloadSpeed())
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
_downloads[_downloads.IndexOf(down)].Progress = (int)((float)(i / down.Bytes.Length) * 100);
|
||||
|
@ -197,4 +216,25 @@ namespace ShiftOS.WinForms.Applications
|
|||
public byte[] Bytes { get; set; }
|
||||
public int Progress { get; set; }
|
||||
}
|
||||
|
||||
[Namespace("dev")]
|
||||
public static class DownloaderDebugCommands
|
||||
{
|
||||
[Command("setsubscription", description ="Use to set the current shiftnet subscription.", usage ="{value:int32}")]
|
||||
[RequiresArgument("value")]
|
||||
public static bool SetShiftnetSubscription(Dictionary<string, object> args)
|
||||
{
|
||||
int val = 0;
|
||||
if(int.TryParse(args["value"].ToString(), out val) == true)
|
||||
{
|
||||
SaveSystem.CurrentSave.ShiftnetSubscription = val;
|
||||
SaveSystem.SaveGame();
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Not a valid 32-bit integer.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -215,7 +215,7 @@ namespace ShiftOS.WinForms.Applications
|
|||
if (!lblword.Text.Contains("_"))
|
||||
{
|
||||
int oldlives = lives;
|
||||
int cp = word.Length * oldlives;
|
||||
int cp = (word.Length * oldlives) * 5;
|
||||
SaveSystem.TransferCodepointsFrom("shiftletters", cp);
|
||||
StartGame();
|
||||
}
|
||||
|
|
|
@ -104,7 +104,10 @@ namespace ShiftOS.WinForms.Applications
|
|||
</html>";
|
||||
|
||||
string body = CommonMark.CommonMarkConverter.Convert(markdown);
|
||||
|
||||
for(int i = 0; i <= Encoding.UTF8.GetBytes(body).Length; i += DownloadManager.GetDownloadSpeed())
|
||||
{
|
||||
//halt the page load until 'download' finishes.
|
||||
}
|
||||
html = html.Replace("<markdown/>", body);
|
||||
return html;
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace ShiftOS.WinForms
|
|||
bytesTransferred += 256;
|
||||
pgprogress.Value = bytesTransferred;
|
||||
lbshiftneturl.Text = $@"{d.ShiftnetUrl}
|
||||
{bytesTransferred} B out of {d.Bytes.Length} B transferred at 256 B per second.
|
||||
{bytesTransferred} B out of {d.Bytes.Length} B transferred at {DownloadManager.GetDownloadSpeed()} B per second.
|
||||
To {d.Destination}";
|
||||
pgprogress.Maximum = d.Bytes.Length;
|
||||
}
|
||||
|
|
Reference in a new issue