Add judge feed and cleanup stub.
This commit is contained in:
@@ -5,6 +5,7 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace Cryville.Crtr {
|
namespace Cryville.Crtr {
|
||||||
public class Judge {
|
public class Judge {
|
||||||
|
readonly PdtEvaluator _etor;
|
||||||
readonly PdtRuleset _rs;
|
readonly PdtRuleset _rs;
|
||||||
readonly Dictionary<Identifier, float> ct
|
readonly Dictionary<Identifier, float> ct
|
||||||
= new Dictionary<Identifier, float>();
|
= new Dictionary<Identifier, float>();
|
||||||
@@ -24,7 +25,14 @@ namespace Cryville.Crtr {
|
|||||||
return x.StartTime.CompareTo(y.StartTime);
|
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) {
|
public Judge(PdtRuleset rs) {
|
||||||
|
_etor = ChartPlayer.etor;
|
||||||
_rs = rs;
|
_rs = rs;
|
||||||
foreach (var s in rs.scores) {
|
foreach (var s in rs.scores) {
|
||||||
var name = s.Key.Key;
|
var name = s.Key.Key;
|
||||||
@@ -49,11 +57,37 @@ namespace Cryville.Crtr {
|
|||||||
if (index < 0) index = ~index;
|
if (index < 0) index = ~index;
|
||||||
list.Insert(index, ev);
|
list.Insert(index, ev);
|
||||||
}
|
}
|
||||||
public void Feed(string target, float ft, float tt) {
|
public void Feed(Identifier target, float ft, float tt) {
|
||||||
Logger.Log("main", 0, "Judge", "Feed {0}: {1}->{2}", target, ft, tt);
|
Forward(target, tt);
|
||||||
|
var actlist = activeEvs[target];
|
||||||
|
foreach (var ev in actlist) {
|
||||||
|
// TODO judge ev
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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 void Cleanup(string target, float ft, float tt) {
|
|
||||||
Logger.Log("main", 0, "Judge", "Cleanup {0}: {1}->{2}", target, ft, tt);
|
|
||||||
}
|
}
|
||||||
public readonly Dictionary<int, ScoreDefinition> scoreDefs = new Dictionary<int, ScoreDefinition>();
|
public readonly Dictionary<int, ScoreDefinition> scoreDefs = new Dictionary<int, ScoreDefinition>();
|
||||||
public readonly Dictionary<int, float> scores = new Dictionary<int, float>();
|
public readonly Dictionary<int, float> scores = new Dictionary<int, float>();
|
||||||
|
Reference in New Issue
Block a user