-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 20second delay before sending Loss to Warp.World to account for a…
…ccidental exits.
- Loading branch information
1 parent
a7a9f37
commit 59b7bf2
Showing
6 changed files
with
189 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using MarioMaker2OCR.Objects; | ||
using Newtonsoft.Json; | ||
|
||
namespace MarioMaker2OCR | ||
{ | ||
class StatsTracker | ||
{ | ||
private List<StatsEvent> history = new List<StatsEvent>(); | ||
|
||
public void addEvent(string eventType) | ||
{ | ||
addEvent(eventType, ""); | ||
} | ||
|
||
public void addEvent(string eventType, string data) | ||
{ | ||
var e = new StatsEvent | ||
{ | ||
type = eventType, | ||
time = DateTime.Now, | ||
data = data, | ||
}; | ||
history.Add(e); | ||
} | ||
|
||
public void clearHistory() | ||
{ | ||
history.Clear(); | ||
} | ||
|
||
public StatsEvent latest(string eventType) | ||
{ | ||
return history.FindLast((StatsEvent e) => | ||
{ | ||
return e.type == eventType; | ||
}); | ||
} | ||
|
||
public int count(string eventType) | ||
{ | ||
var results = history.FindAll((StatsEvent e) => | ||
{ | ||
return e.type == eventType; | ||
}); | ||
return results.Count; | ||
} | ||
public int count() | ||
{ | ||
return history.Count; | ||
} | ||
|
||
public string serialize() | ||
{ | ||
return JsonConvert.SerializeObject(history); | ||
} | ||
} | ||
|
||
class StatsEvent : DataEventWrapper | ||
{ | ||
public DateTime time; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace MarioMaker2OCR.Test | ||
{ | ||
[TestClass] | ||
public class StatsTrackerTests | ||
{ | ||
[TestMethod] | ||
public void CanAddEvents() | ||
{ | ||
var tracker = new StatsTracker(); | ||
|
||
Assert.AreEqual(tracker.count(), 0); | ||
|
||
tracker.addEvent("testEvent"); | ||
Assert.AreEqual(tracker.count(), 1); | ||
|
||
tracker.addEvent("testEventWithData", "[test data]"); | ||
Assert.AreEqual(tracker.count(), 2); | ||
|
||
for(int i=0;i<20;i++) | ||
{ | ||
if(i%2==0) | ||
{ | ||
tracker.addEvent("testEventWithData", String.Format("test{0}", i)); | ||
} else | ||
{ | ||
tracker.addEvent("testEvent"); | ||
} | ||
} | ||
|
||
Assert.AreEqual(tracker.count(), 22); | ||
Assert.AreEqual(tracker.count("testEvent"), 11); | ||
Assert.AreEqual(tracker.count("testEventWithData"), 11); | ||
|
||
var result = tracker.latest("testEventWithData"); | ||
Assert.IsNotNull(result); | ||
Assert.AreEqual(result.data, "test18"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters