Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
little tweaks here and there to refine the code
  • Loading branch information
N1Ran committed Jan 19, 2019
commit d42effce062549c39da4cd0aca051ffc8a6dce90
24 changes: 7 additions & 17 deletions Essentials/Commands/VotingModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ public void Vote(string name)
Context.Respond($"{name} is not set for voting.");
return;
}
if (_voteDuration.TotalSeconds == 0)
{
Context.Respond($"{name} has no duration for voting. That's a no go boss");
return;
}
voteInProgress = name;
_voteInProgress = true;
Task.Run(() =>
Expand Down Expand Up @@ -163,6 +158,7 @@ public void VoteYes()
[Permission(MyPromoteLevel.Admin)]
public void VoteCount()
{
Context.Respond($"{voteInProgress} is currently active with");
Context.Respond($"vote count: {_votecount} / Vote percent: {votePercent}");

}
Expand All @@ -178,21 +174,15 @@ private IEnumerable VoteCountdown(TimeSpan time)
{
_voteInProgress = false;
_cancelVote = false;
Context.Torch.CurrentSession.Managers.GetManager<IChatManagerClient>()
.SendMessageAsSelf($"Vote for {voteInProgress} cancelled");
voteInProgress = "";
_votecount = 0;
votePercent = 0;
_voteReg.Clear();
Context.Respond($"vote cancelled");
yield break;
}
votePercent = (_votecount / playerCount) * 100;
if (((_votecount / playerCount) * 100) >= command.Percentage && TimeSpan.Parse(command.VoteDuration).TotalSeconds == 0)
{
Context.Respond($"Vote for {voteInProgress} is successful");
command.RunNow();
_voteInProgress = false;
_cancelVote = false;
}

if (i >= 60 && i % 60 == 0)
{
Expand All @@ -212,7 +202,8 @@ private IEnumerable VoteCountdown(TimeSpan time)
{
if (((_votecount / playerCount) * 100) >= command.Percentage)
{
Context.Respond($"Vote for {voteInProgress} is successful");
Context.Torch.CurrentSession.Managers.GetManager<IChatManagerClient>()
.SendMessageAsSelf($"Vote for {voteInProgress} is successful");
command.RunNow();
_voteInProgress = false;
_cancelVote = false;
Expand All @@ -221,13 +212,12 @@ private IEnumerable VoteCountdown(TimeSpan time)
{
_voteInProgress = false;
_cancelVote = false;
Context.Torch.CurrentSession.Managers.GetManager<IChatManagerClient>()
.SendMessageAsSelf($"Vote for {voteInProgress} failed");
voteInProgress = "";
_votecount = 0;
votePercent = 0;
_voteReg.Clear();
Context.Respond($"vote cancelled");
Context.Respond($"Vote for {voteInProgress} failed");

}
yield break;
}
Expand Down