Skip to content
This repository has been archived by the owner on Sep 5, 2019. It is now read-only.

Commit

Permalink
Added !redeem^ (redeem no-forwarding) and !ownsall
Browse files Browse the repository at this point in the history
  • Loading branch information
alvr committed Sep 25, 2016
1 parent de68ce5 commit 04a2c96
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 29 deletions.
75 changes: 54 additions & 21 deletions ASFui/ASFui.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 72 additions & 8 deletions ASFui/ASFui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ private void ASFui_FormClosing(object sender, FormClosingEventArgs e)
Logging.Info(@"Closing ASFui.");
}

private void GetBotList()
public void GetBotList()
{
cbBotList.Invoke(new MethodInvoker(delegate { cbBotList.Items.Clear(); }));

var status = Util.SendCommand("statusall");
var matches = Regex.Matches(status, @"Bot (.*) is");
cbBotList.Invoke(new MethodInvoker(delegate
cbBotList.Invoke(new MethodInvoker(delegate
{
foreach (Match m in matches)
{
Expand All @@ -133,7 +133,7 @@ private void BtnStart_Click(object sender, EventArgs e)
rtbOutput.AppendText(@"Starting ASF..." + Environment.NewLine);
if (Properties.Settings.Default.IsLocal)
{
_asf = new ASFProcess(rtbOutput);
_asf = new ASFProcess(this, rtbOutput);
_asf.Start();
}
btnStop.Enabled = true;
Expand All @@ -143,7 +143,6 @@ private void BtnStart_Click(object sender, EventArgs e)
btnReloadBots.Enabled = true;
_asfRunning = true;
btnASFuiSettings.Enabled = false;
Task.Delay(2500).ContinueWith(b => GetBotList());
tsslCommandOutput.Text = @"Started ASF server.";
Logging.Info("Server started successfully.");
}
Expand Down Expand Up @@ -257,7 +256,37 @@ private void btnRedeem_Click(object sender, EventArgs e)
}
else
{
Logging.Error(@"Input required (!owns)");
Logging.Error(@"Input required (!redeem)");
MessageBox.Show(@"An input is required.", @"Input required", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
});
}

private void btnRedeemNF_Click(object sender, EventArgs e)
{
Task.Run(() =>
{
if (!tbInput.Text.Equals(""))
{
var result =
Util.SendCommand(Util.GenerateCommand("redeem^", cbBotList.SelectedItem.ToString(),
Util.MultiToOne(tbInput.Lines)));
if (_isLocal)
{
tsslCommandOutput.Text = @"!redeem^ <" + cbBotList.SelectedItem + @">: " + result;
}
else
{
rtbOutput.AppendText(@"!redeem^ <" + cbBotList.SelectedItem + @">: " + result +
Environment.NewLine);
rtbOutput.SelectionStart = rtbOutput.Text.Length;
rtbOutput.ScrollToCaret();
}
}
else
{
Logging.Error(@"Input required (!redeem^)");
MessageBox.Show(@"An input is required.", @"Input required", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
Expand Down Expand Up @@ -287,7 +316,7 @@ private void btnAddLicense_Click(object sender, EventArgs e)
}
else
{
Logging.Error(@"Input required (!owns)");
Logging.Error(@"Input required (!addlicense)");
MessageBox.Show(@"An input is required.", @"Input required", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
Expand All @@ -309,11 +338,11 @@ private void btnOwns_Click(object sender, EventArgs e)
Util.MultiToOne(tbInput.Lines)));
if (_isLocal)
{
tsslCommandOutput.Text = @"!own <" + cbBotList.SelectedItem + @">: " + result;
tsslCommandOutput.Text = @"!owns <" + cbBotList.SelectedItem + @">: " + result;
}
else
{
rtbOutput.AppendText(@"!own <" + cbBotList.SelectedItem + @">: " + result +
rtbOutput.AppendText(@"!owns <" + cbBotList.SelectedItem + @">: " + result +
Environment.NewLine);
rtbOutput.SelectionStart = rtbOutput.Text.Length;
rtbOutput.ScrollToCaret();
Expand All @@ -328,6 +357,36 @@ private void btnOwns_Click(object sender, EventArgs e)
});
}

private void btnOwnAll_Click(object sender, EventArgs e)
{
Task.Run(() =>
{
if (!tbInput.Text.Equals(""))
{
var result =
Util.SendCommand(Util.GenerateCommand("ownsall", cbBotList.SelectedItem.ToString(),
Util.MultiToOne(tbInput.Lines)));
if (_isLocal)
{
tsslCommandOutput.Text = @"!ownsall <" + cbBotList.SelectedItem + @">: " + result;
}
else
{
rtbOutput.AppendText(@"!ownsall <" + cbBotList.SelectedItem + @">: " + result +
Environment.NewLine);
rtbOutput.SelectionStart = rtbOutput.Text.Length;
rtbOutput.ScrollToCaret();
}
}
else
{
Logging.Error(@"Input required (!ownsall)");
MessageBox.Show(@"An input is required.", @"Input required", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
});
}

private void btnPlay_Click(object sender, EventArgs e)
{
Task.Run(() =>
Expand Down Expand Up @@ -622,8 +681,10 @@ private void EnableElements()
btnLoot.Enabled = true;
btnLootAll.Enabled = true;
btnRedeem.Enabled = true;
btnRedeemNF.Enabled = true;
btnAddLicense.Enabled = true;
btnOwns.Enabled = true;
btnOwnAll.Enabled = true;
btnPlay.Enabled = true;
btnLeave.Enabled = true;
btnRejoin.Enabled = true;
Expand All @@ -646,12 +707,15 @@ private void EnableElements()
private void DisableElements()
{
tbInput.Enabled = false;
tbInput.Clear();
btnFarm.Enabled = false;
btnLoot.Enabled = false;
btnLootAll.Enabled = false;
btnRedeem.Enabled = false;
btnRedeemNF.Enabled = false;
btnAddLicense.Enabled = false;
btnOwns.Enabled = false;
btnOwnAll.Enabled = false;
btnPlay.Enabled = false;
btnLeave.Enabled = false;
btnRejoin.Enabled = false;
Expand Down

0 comments on commit 04a2c96

Please sign in to comment.