public FormulaeViewModel(IEnumerable <Formula> formulae, FormulaeBitmask knownFormulae) { Formulae = from f in formulae group f by f.Type into g orderby g.Key select new FormulaModel(g.ToArray(), knownFormulae); }
public void TestGetKnownFormulaeIds() { var bitmask = new byte[] { 0x00, 0x00, 0x05, 0x00, 0x05, 0x04, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x02, 0x00, 0x00 }; var formulae = FormulaeBitmask.FromBytes(bitmask).FormulaeIds; Assert.AreEqual(9, formulae.Count()); Assert.IsTrue(formulae.Contains(0x06)); Assert.IsTrue(formulae.Contains(0x08)); Assert.IsTrue(formulae.Contains(0x0c)); Assert.IsTrue(formulae.Contains(0x0e)); Assert.IsTrue(formulae.Contains(0x11)); Assert.IsTrue(formulae.Contains(0x13)); Assert.IsTrue(formulae.Contains(0x14)); Assert.IsTrue(formulae.Contains(0x38)); Assert.IsTrue(formulae.Contains(0x3a)); }
public FormulaModel(Formula[] formulae, FormulaeBitmask knownFormulae) { if (formulae.Length != 3) { throw new ArgumentException("Model requires three formulas"); } // order by ql just in case _formulae = (from f in formulae orderby f.Quality select f).ToArray(); _knownFormulae = knownFormulae; Type = _formulae[0].Type; // all should have same type Description = _formulae[0].Description; Quality25Tip = CreateTooltip(_formulae[0]); Quality35Tip = CreateTooltip(_formulae[1]); Quality45Tip = CreateTooltip(_formulae[2]); }
public static IEnumerable <FormulaeBitmask> ReadKnownFormulae() { if (_baseAddress == 0) { throw new InvalidOperationException("Connect to Darkland process first!"); } var formulae = new List <FormulaeBitmask>(NumberofCharacters); using (var accessor = new MemoryAccessor("dosbox")) { for (var i = 0; i < NumberofCharacters; i++) { var bytes = new byte[FormulaeBitmask.FormulaeBitmaskSize]; if (accessor.ReadMemory( _baseAddress + KnownFormulaeOffset + i * FormulaeBitmask.FormulaeBitmaskSize, bytes)) { formulae.Add(FormulaeBitmask.FromBytes(bytes)); } } } return(formulae); }