Split (judge) area definition from judges list.

This commit is contained in:
2023-06-02 11:08:43 +08:00
parent 52adef8e9b
commit 910e3ce277
2 changed files with 11 additions and 16 deletions

View File

@@ -47,14 +47,14 @@ namespace Cryville.Crtr {
_etor = new PdtEvaluator();
_etor.ContextJudge = this;
_rs = rs;
_areaFuncs = rs.judges.Areas;
_areaFuncs = rs.areas;
_numsrc1 = new PropSrc.Float(() => _numbuf1);
_numsrc2 = new PropSrc.Float(() => _numbuf2);
_numsrc3 = new PropSrc.Float(() => _numbuf3);
_numsrc4 = new PropSrc.Float(() => _numbuf4);
_identop = new PropOp.Identifier(v => _identbuf = new Identifier(v));
_clipop = new PropOp.Clip(v => _clipbuf = v);
_rs.judges.Judges.TryGetValue(new Identifier(_var_pause), out _judgePause);
_rs.judges.TryGetValue(new Identifier(_var_pause), out _judgePause);
foreach (var i in rs.inputs) {
var id = i.Key;
var l = new List<JudgeEvent>();
@@ -79,7 +79,7 @@ namespace Cryville.Crtr {
}
void InsertEvent(Chart.Judge ev, Clip clip, Identifier id, NoteHandler handler) {
if (id.Key == _var_pause) throw new InvalidOperationException("Cannot assign the special judge \"pause\" to notes");
var def = _rs.judges.Judges[id];
var def = _rs.judges[id];
_etor.Evaluate(_identop, def.input);
_etor.Evaluate(_clipop, def.clip);
var list = evs[_identbuf];
@@ -100,7 +100,7 @@ namespace Cryville.Crtr {
#region Judge
internal readonly IntKeyedDictionary<int> judgeMap = new IntKeyedDictionary<int>();
void InitJudges() {
foreach (var i in _rs.judges.Judges) {
foreach (var i in _rs.judges) {
var id = i.Key;
judgeMap.Add(id.Key, IdentifierManager.Shared.Request("judge_" + id.Name));
}
@@ -249,7 +249,7 @@ namespace Cryville.Crtr {
bool IJudge.Pass(JudgeEvent ev, float time, Identifier[] ids, int depth) {
if (depth >= 16) throw new JudgePropagationException();
foreach (var i in ids) {
var def = _rs.judges.Judges[i];
var def = _rs.judges[i];
if (def.hit != null) _etor.Evaluate(_flagop, def.hit);
else _flag = true;
if (_flag) {

View File

@@ -33,7 +33,8 @@ namespace Cryville.Crtr {
[Binder(typeof(PdtBinder))]
public class PdtRuleset {
public Dictionary<Identifier, InputDefinition> inputs;
public JudgeDefinitionCollection judges;
public Dictionary<Identifier, PdtExpression> areas;
public Dictionary<Identifier, JudgeDefinition> judges;
public Dictionary<Identifier, ScoreDefinition> scores;
public Constraint constraints;
public void Optimize(PdtEvaluatorBase etor) {
@@ -43,15 +44,15 @@ namespace Cryville.Crtr {
etor.Optimize(e.Value);
}
}
foreach (var j in judges.Judges) {
foreach (var a in areas) {
etor.Optimize(a.Value);
}
foreach (var j in judges) {
var judge = j.Value;
if (judge.hit != null) etor.Optimize(judge.hit);
if (judge.on_hit != null) OptimizeJudgeActions(judge.on_hit, etor);
if (judge.on_miss != null) OptimizeJudgeActions(judge.on_miss, etor);
}
foreach (var a in judges.Areas) {
etor.Optimize(a.Value);
}
foreach (var s in scores) {
var score = s.Value;
if (score.value != null) etor.Optimize(score.value);
@@ -71,12 +72,6 @@ namespace Cryville.Crtr {
public bool notnull;
public PairList<Identifier, PdtExpression> pass;
}
public class JudgeDefinitionCollection {
[ElementList]
public Dictionary<Identifier, JudgeDefinition> Judges = new Dictionary<Identifier, JudgeDefinition>();
[PropertyList]
public Dictionary<Identifier, PdtExpression> Areas = new Dictionary<Identifier, PdtExpression>();
}
public class JudgeDefinition {
public int stack;
public int prop;