Add judge feed and cleanup stub.
This commit is contained in:
@@ -5,6 +5,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Cryville.Crtr {
|
||||
public class Judge {
|
||||
readonly PdtEvaluator _etor;
|
||||
readonly PdtRuleset _rs;
|
||||
readonly Dictionary<Identifier, float> ct
|
||||
= new Dictionary<Identifier, float>();
|
||||
@@ -24,7 +25,14 @@ namespace Cryville.Crtr {
|
||||
return x.StartTime.CompareTo(y.StartTime);
|
||||
}
|
||||
}
|
||||
static IComparer<JudgeEvent> _etcmp = new JudgeEventEndTimeComparer();
|
||||
class JudgeEventEndTimeComparer : IComparer<JudgeEvent> {
|
||||
public int Compare(JudgeEvent x, JudgeEvent y) {
|
||||
return x.EndTime.CompareTo(y.EndTime);
|
||||
}
|
||||
}
|
||||
public Judge(PdtRuleset rs) {
|
||||
_etor = ChartPlayer.etor;
|
||||
_rs = rs;
|
||||
foreach (var s in rs.scores) {
|
||||
var name = s.Key.Key;
|
||||
@@ -49,11 +57,37 @@ namespace Cryville.Crtr {
|
||||
if (index < 0) index = ~index;
|
||||
list.Insert(index, ev);
|
||||
}
|
||||
public void Feed(string target, float ft, float tt) {
|
||||
Logger.Log("main", 0, "Judge", "Feed {0}: {1}->{2}", target, ft, tt);
|
||||
public void Feed(Identifier target, float ft, float tt) {
|
||||
Forward(target, tt);
|
||||
var actlist = activeEvs[target];
|
||||
foreach (var ev in actlist) {
|
||||
// TODO judge ev
|
||||
}
|
||||
}
|
||||
public void Cleanup(string target, float ft, float tt) {
|
||||
Logger.Log("main", 0, "Judge", "Cleanup {0}: {1}->{2}", target, ft, tt);
|
||||
public void Cleanup(Identifier target, float ft, float tt) {
|
||||
Forward(target, tt);
|
||||
var actlist = activeEvs[target];
|
||||
for (int i = actlist.Count - 1; i >= 0; i--) {
|
||||
JudgeEvent ev = actlist[i];
|
||||
if (tt > ev.EndTime) {
|
||||
actlist.RemoveAt(i);
|
||||
Logger.Log("main", 0, "Judge", "miss {0}", target);
|
||||
// TODO miss ev
|
||||
}
|
||||
}
|
||||
}
|
||||
void Forward(Identifier target, float tt) {
|
||||
var list = evs[target];
|
||||
var actlist = activeEvs[target];
|
||||
JudgeEvent ev;
|
||||
while (list.Count > 0 && (ev = list[0]).StartTime <= tt) {
|
||||
list.RemoveAt(0);
|
||||
var index = actlist.BinarySearch(ev, _etcmp);
|
||||
if (index < 0) index = ~index;
|
||||
actlist.Insert(index, ev);
|
||||
Logger.Log("main", 0, "Judge", "active {0}", target);
|
||||
// TODO priority?
|
||||
}
|
||||
}
|
||||
public readonly Dictionary<int, ScoreDefinition> scoreDefs = new Dictionary<int, ScoreDefinition>();
|
||||
public readonly Dictionary<int, float> scores = new Dictionary<int, float>();
|
||||
@@ -61,12 +95,12 @@ namespace Cryville.Crtr {
|
||||
readonly object _lock = new object();
|
||||
public Dictionary<int, string> GetFormattedScoreStrings() {
|
||||
lock (_lock) {
|
||||
if (ScoreCache.Count == 0) {
|
||||
foreach (var s in scores)
|
||||
ScoreCache.Add(s.Key, s.Value.ToString(scoreDefs[s.Key].format));
|
||||
if (ScoreCache.Count == 0) {
|
||||
foreach (var s in scores)
|
||||
ScoreCache.Add(s.Key, s.Value.ToString(scoreDefs[s.Key].format));
|
||||
}
|
||||
return ScoreCache;
|
||||
}
|
||||
return ScoreCache;
|
||||
}
|
||||
}
|
||||
public string GetFullFormattedScoreString() {
|
||||
bool flag = false;
|
||||
|
Reference in New Issue
Block a user