-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathOfferDealAction.cs
More file actions
45 lines (38 loc) · 1.59 KB
/
OfferDealAction.cs
File metadata and controls
45 lines (38 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System;
using System.Collections.Generic;
using System.Text;
using DevChatter.Bot.Core.Games.DealNoDeal;
using DevChatter.Bot.Core.Systems.Chat;
using DevChatter.Bot.Core.Util;
namespace DevChatter.Bot.Core.Automation
{
public class OfferDealAction : IIntervalAction
{
private readonly IClock _clock;
private DateTime _nextRunTime;
private IChatClient _chatClient;
private DealNoDealGame _dealNoDealGame;
public OfferDealAction(DealNoDealGame dealNoDealGame, IChatClient chatClient)
{
_dealNoDealGame = dealNoDealGame;
_chatClient = chatClient;
_clock = new SystemClock();
_dealNoDealGame.PrintBoxesRemaining();
_chatClient.SendMessage($"***DEAL OFFER: {dealNoDealGame.DealOffer} TOKENS!");
_chatClient.SendMessage(" type \"!dnd accept\" or \"!dnd decline\" to accept or decline offer ");
_chatClient.SendMessage($"You have {DealNoDealGame.SECONDS_TO_CHOOSE_BOXES} seconds or the deal will be automatically accepted");
SetNextRunTime();
}
public string Name { get; } = nameof(OfferDealAction);
public bool IsTimeToRun() => _clock.Now >= _nextRunTime;
public void Invoke()
{
_chatClient.SendMessage($"Automatically accepting deal! {DealNoDealGame.SECONDS_TO_CHOOSE_BOXES} seconds passed");
_dealNoDealGame.AcceptDeal(_chatClient);
}
private void SetNextRunTime()
{
_nextRunTime = _clock.Now.AddSeconds(DealNoDealGame.SECONDS_TO_CHOOSE_BOXES);
}
}
}