Add judge area definition.

This commit is contained in:
2023-05-11 16:15:57 +08:00
parent 3e273d67ba
commit fe4280aa2e
2 changed files with 15 additions and 4 deletions

View File

@@ -15,6 +15,7 @@ namespace Cryville.Crtr {
readonly ChartPlayer _sys;
internal readonly PdtEvaluator _etor;
readonly PdtRuleset _rs;
internal Dictionary<Identifier, PdtExpression> _areaFuncs;
readonly Dictionary<Identifier, List<JudgeEvent>> evs
= new Dictionary<Identifier, List<JudgeEvent>>();
readonly Dictionary<Identifier, List<JudgeEvent>> activeEvs
@@ -41,6 +42,7 @@ namespace Cryville.Crtr {
_etor = new PdtEvaluator();
_etor.ContextJudge = this;
_rs = rs;
_areaFuncs = rs.judges.Areas;
_numsrc1 = new PropSrc.Float(() => _numbuf1);
_numsrc2 = new PropSrc.Float(() => _numbuf2);
_numsrc3 = new PropSrc.Float(() => _numbuf3);
@@ -67,7 +69,7 @@ namespace Cryville.Crtr {
if (tev.Id.Key == _var_pause) throw new InvalidOperationException("Cannot assign the special judge \"pause\" to notes");
Identifier input = default(Identifier);
Clip clip = default(Clip);
var def = _rs.judges[tev.Id];
var def = _rs.judges.Judges[tev.Id];
_etor.Evaluate(new PropOp.Identifier(v => input = new Identifier(v)), def.input);
_etor.Evaluate(new PropOp.Clip(v => clip = v), def.clip);
double st = sev.Time, et = st + sev.Duration;
@@ -89,7 +91,7 @@ namespace Cryville.Crtr {
#region Judge
internal readonly IntKeyedDictionary<int> judgeMap = new IntKeyedDictionary<int>();
void InitJudges() {
foreach (var i in _rs.judges) {
foreach (var i in _rs.judges.Judges) {
var id = i.Key;
judgeMap.Add(id.Key, IdentifierManager.Shared.Request("judge_" + id.Name));
}
@@ -169,7 +171,7 @@ namespace Cryville.Crtr {
bool Pass(JudgeEvent ev, float time, Identifier[] ids, int depth = 0) {
if (depth >= 16) throw new JudgePropagationException();
foreach (var i in ids) {
var def = _rs.judges[i];
var def = _rs.judges.Judges[i];
if (def.hit != null) _etor.Evaluate(_flagop, def.hit);
else _flag = true;
if (_flag) {

View File

@@ -41,7 +41,7 @@ namespace Cryville.Crtr {
etor.Optimize(e.Value);
}
}
foreach (var j in judges) {
foreach (var j in judges.Judges) {
var judge = j.Value;
if (judge.hit != null) etor.Optimize(judge.hit);
if (judge.scores != null) {
@@ -52,6 +52,9 @@ namespace Cryville.Crtr {
}
}
}
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);
@@ -62,6 +65,12 @@ namespace Cryville.Crtr {
constraints.PrePatch(chart);
}
}
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 Constraint {
static readonly PropOp.Arbitrary _arbop = new PropOp.Arbitrary();
[ElementList]