73 lines
2.0 KiB
C#
73 lines
2.0 KiB
C#
using Cryville.Common;
|
|
using Cryville.Common.Pdt;
|
|
using Cryville.Common.Unity.Input;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Cryville.Crtr {
|
|
public class Judge {
|
|
readonly PdtRuleset _rs;
|
|
public Judge(PdtRuleset rs) {
|
|
_rs = rs;
|
|
foreach (var s in rs.scores) {
|
|
var name = s.Key.Key;
|
|
scoreDefs.Add(name, s.Value);
|
|
scores.Add(name, s.Value.init);
|
|
}
|
|
}
|
|
public void Feed(string target) {
|
|
}
|
|
public void Feed(InputEvent ev) {
|
|
|
|
}
|
|
public readonly Dictionary<int, ScoreDefinition> scoreDefs = new Dictionary<int, ScoreDefinition>();
|
|
public readonly Dictionary<int, float> scores = new Dictionary<int, float>();
|
|
readonly Dictionary<int, string> ScoreCache = new Dictionary<int, string>();
|
|
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));
|
|
}
|
|
return ScoreCache;
|
|
}
|
|
}
|
|
public string GetFullFormattedScoreString() {
|
|
bool flag = false;
|
|
string result = "";
|
|
foreach (var s in GetFormattedScoreStrings()) {
|
|
result += string.Format(flag ? "\n{0}: {1}" : "{0}: {1}", IdentifierManager.SharedInstance.Retrieve(s.Key), s.Value);
|
|
flag = true;
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
public class InputDefinition {
|
|
public int dim;
|
|
public bool notnull;
|
|
public Dictionary<Identifier, PdtExpression> pass;
|
|
}
|
|
public class JudgeDefinition {
|
|
public PdtExpression clip;
|
|
public PdtExpression input;
|
|
public Identifier InputName;
|
|
public PdtExpression hit;
|
|
public Identifier[] pass;
|
|
public Identifier miss;
|
|
public Dictionary<ScoreOperation, PdtExpression> scores;
|
|
}
|
|
public class ScoreOperation {
|
|
public Identifier name;
|
|
public Identifier op;
|
|
public override string ToString() {
|
|
if (op == default(Identifier)) return name.ToString();
|
|
else return string.Format("{0} {1}", name, op);
|
|
}
|
|
}
|
|
public class ScoreDefinition {
|
|
public PdtExpression value;
|
|
public float init = 0;
|
|
public string format = "";
|
|
}
|
|
}
|