private static Expression Prefix(Lexemes lexemes, IUnitRegistry unitRegistry) { IUnit unit; Prefix prefix; if (lexemes.AcceptTokenFrom(unitRegistry, out prefix)) { if (lexemes.AcceptTokenFrom(unitRegistry, out unit)) { return(Unit(prefix, unit)); } lexemes.MoveToPrevious(); } if (lexemes.AcceptTokenFrom(unitRegistry, out unit)) { return(Unit(null, unit)); } string variable; if (lexemes.AcceptTokenFrom(VariableRegex, out variable)) { return(new VariableExpression(variable)); } throw CreateParseException(UnitError.PrefixUnitOrUnitOrVariableNotFound, lexemes.Current); }
private static Expression Prefix(Lexemes lexemes, IUnitRegistry unitRegistry) { IUnit unit; Prefix prefix; if (lexemes.AcceptTokenFrom(unitRegistry, out prefix)) { if (lexemes.AcceptTokenFrom(unitRegistry, out unit)) { return Unit(prefix, unit); } lexemes.MoveToPrevious(); } if (lexemes.AcceptTokenFrom(unitRegistry, out unit)) { return Unit(null, unit); } string variable; if (lexemes.AcceptTokenFrom(VariableRegex, out variable)) { return new VariableExpression(variable); } throw CreateParseException(UnitError.PrefixUnitOrUnitOrVariableNotFound, lexemes.Current); }
public MoveUnitCommand(MoveUnitData data, IGridUnitManager gridUnitManager, IUnitRegistry unitRegistry, ILogger logger) { _data = data; _gridUnitManager = gridUnitManager; _unitRegistry = unitRegistry; _logger = logger; }
public IExpressionParser CreateParser(IUnitRegistry unitRegistry) { var tokenMatcherBuilder = new TokenMatcherBuilder(); var prefixTokenMatchers = tokenMatcherBuilder.Build(unitRegistry.GetPrefixNotations(), true); var unitTokenMatchers = tokenMatcherBuilder.Build(unitRegistry.GetUnitNotations(), false); var unitExpressionParser = new UnitExpressionParser( unitRegistry, new LexicalAnalyzer(new[] { prefixTokenMatchers, unitTokenMatchers })); return new ExpressionParser(unitExpressionParser); }
/// <summary> /// Creates the parser. /// </summary> /// <param name="unitRegistry">The unit registry.</param> /// <returns> /// A new <see cref="IExpressionParser" />. /// </returns> public IExpressionParser CreateParser(IUnitRegistry unitRegistry) { var tokenMatcherBuilder = new TokenMatcherBuilder(); var prefixTokenMatchers = tokenMatcherBuilder.Build(unitRegistry.GetPrefixNotations(), true); var unitTokenMatchers = tokenMatcherBuilder.Build(unitRegistry.GetUnitNotations(), false); var unitExpressionParser = new UnitExpressionParser( unitRegistry, new LexicalAnalyzer(new[] { prefixTokenMatchers, unitTokenMatchers })); return(new ExpressionParser(unitExpressionParser)); }
public MoveUnitSectionCommand(MoveUnitSectionCommandData data, ICommandFactory commandFactory, IUnitRegistry unitRegistry, IMapSectionEntryTileFinder entryTileFinder, IUnitDataIndexResolver unitDataIndexResolver, ILogger logger, MapStoreId mapStoreId) { _data = data; _commandFactory = commandFactory; _unitRegistry = unitRegistry; _entryTileFinder = entryTileFinder; _unitDataIndexResolver = unitDataIndexResolver; _logger = logger; _mapStoreId = mapStoreId; }
public IUnit[] GetAllUnits(UnitType unitType, IUnitRegistry unitRegistry) { List <IUnit> units = new List <IUnit>(); foreach (var keyValuePair in _unitMap) { UnitId unitId = keyValuePair.Key; IUnit unit = unitRegistry.GetUnit(unitId); if (unit.UnitData.UnitType == unitType) { units.Add(unit); } } return(units.ToArray()); }
public XmlScenario(string xml, IUnitRegistry unitRegistry) { if (xml == null) { throw new System.ArgumentNullException(nameof(xml)); } if (unitRegistry == null) { throw new System.ArgumentNullException(nameof(unitRegistry)); } var doc = XDocument.Parse(xml); foreach (var factionElement in doc.Root.Element("Factions").Elements()) { var faction = new Faction(factionElement.Element("Name").Value, new PositiveInt(int.Parse(factionElement.Element("Gold").Value))); _Factions.Add(faction); var occupations = factionElement.Element("Occupations"); if (occupations != null) { foreach (var occupation in occupations.Elements()) { _Occupations.Add(new Occupation(ExtractPosition(occupation), faction)); } } var units = factionElement.Element("Units"); if (units != null) { foreach (var unit in units.Elements()) { _Units.Add(new Model.Scenario.Unit(ExtractPosition(unit), unitRegistry[unit.Element("Name").Value], faction, unit.Element("Critical") != null)); } } } }
/// <summary> /// Initializes a new instance of the <see cref="UnitExpressionParser" /> class. /// </summary> /// <param name="unitRegistry">The unit registry.</param> /// <param name="lexicalAnalyzer">The lexical analyzer.</param> public UnitExpressionParser(IUnitRegistry unitRegistry, ILexicalAnalyzer lexicalAnalyzer) { this.unitRegistry = unitRegistry; this.lexicalAnalyzer = lexicalAnalyzer; }
/// <summary> /// Initializes a new instance of the <see cref="UnitExpressionParser" /> class. /// </summary> /// <param name="unitRegistry">The unit registry.</param> /// <param name="lexicalAnalyzer">The lexical analyzer.</param> public UnitExpressionParser(IUnitRegistry unitRegistry, ILexicalAnalyzer lexicalAnalyzer) { this.unitRegistry = unitRegistry; this.lexicalAnalyzer = lexicalAnalyzer; }
public UnitSelectionHighlighter(IUnitTransformRegistry unitTransformRegistry, IUnitRegistry unitRegistry) { _unitTransformRegistry = unitTransformRegistry; _unitRegistry = unitRegistry; }