64 lines
1.8 KiB
C#
64 lines
1.8 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 = IdentifierManager.SharedInstance.Request(s.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>();
|
|
public Dictionary<int, string> GetFormattedScoreStrings() {
|
|
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<string, PdtExpression> pass;
|
|
}
|
|
public class JudgeDefinition {
|
|
public PdtExpression clip;
|
|
public PdtExpression hit;
|
|
public string[] pass;
|
|
public string miss;
|
|
public Dictionary<string, PdtExpression> scores;
|
|
}
|
|
public class ScoreOperation {
|
|
public int name;
|
|
public PdtOperator op;
|
|
}
|
|
public class ScoreDefinition {
|
|
public PdtExpression value;
|
|
public float init = 0;
|
|
public string format = "";
|
|
}
|
|
}
|