public T SelectFrom <T>(string tableName) { var table = percentileMapper.Map(tableName); var roll = dice.Roll().Percentile().AsSum(); if (!table.ContainsKey(roll)) { throw new ArgumentException($"{roll} is not a valid entry in the table {tableName}"); } return(GetValue <T>(table[roll])); }
public void EpicItemsPercentile(int level) { var epicLower = Math.Max(1, 100 - level); var majorLower = Math.Max(1, 17 - level + 30); var tableName = string.Format(TableNameConstants.Percentiles.Formattable.LevelXItems, level); var levelTable = PercentileMapper.Map(tableName); var mediumEntry = table[1]; var majorEntry = table[50]; var epicEntry = table[100]; Assert.That(levelTable.Keys, Is.EquivalentTo(Enumerable.Range(1, 100))); for (var i = 1; i < majorLower; i++) { Assert.That(levelTable[i], Is.EqualTo(mediumEntry)); } for (var i = majorLower; i < epicLower; i++) { Assert.That(levelTable[i], Is.EqualTo(majorEntry)); } for (var i = epicLower; i <= 100; i++) { Assert.That(levelTable[i], Is.EqualTo(epicEntry)); } }
public void LevelCoinsExistForAllLevels() { for (var level = LevelLimits.Minimum; level <= LevelLimits.Maximum; level++) { var levelTableName = string.Format(TableNameConstants.Percentiles.Formattable.LevelXCoins, level); var table = percentileMapper.Map(levelTableName); Assert.That(table, Is.Not.Null); Assert.That(table.Keys, Is.EqualTo(Enumerable.Range(1, 100))); } }
public Dictionary <int, string> Map(string tableName) { var assembly = assemblyLoader.GetRunningAssembly(); var key = assembly.FullName + tableName; lock (myLock) { if (!cachedTables.ContainsKey(key)) { var mappedTable = innerMapper.Map(tableName); cachedTables.Add(key, mappedTable); } } return(cachedTables[key]); }
public void EpicGoodsPercentile(int level) { var tableName = string.Format(TableNameConstants.Percentiles.Formattable.LevelXGoods, level); var levelTable = PercentileMapper.Map(tableName); Assert.That(levelTable.Keys, Is.EquivalentTo(Enumerable.Range(1, 100))); var gemEntry = table[10]; var artEntry = table[100]; for (var i = 1; i <= 38; i++) { Assert.That(levelTable[i], Is.EqualTo(gemEntry), $"Table {tableName}, Roll {i}"); } for (var i = 39; i <= 100; i++) { Assert.That(levelTable[i], Is.EqualTo(artEntry), $"Table {tableName}, Roll {i}"); } }
public void EpicCoinsPercentile(int level) { var tableName = string.Format(TableNameConstants.Percentiles.Formattable.LevelXCoins, level); var levelTable = PercentileMapper.Map(tableName); Assert.That(levelTable.Keys, Is.EquivalentTo(Enumerable.Range(1, 100))); var goldEntry = table[50]; var platinumEntry = table[100]; for (var i = 1; i <= 65; i++) { Assert.That(levelTable[i], Is.EqualTo(goldEntry)); } for (var i = 66; i <= 100; i++) { Assert.That(levelTable[i], Is.EqualTo(platinumEntry)); } }
public void AppendXmlFileExtensionToTableName() { mapper.Map(tableName); mockStreamLoader.Verify(l => l.LoadFor(filename), Times.Once); }
public void PercentileSetup() { PercentileMapper = GetNewInstanceOf <PercentileMapper>(); table = PercentileMapper.Map(tableName); }
public void ReturnTableFromInnerMapper() { var result = proxy.Map("table name"); Assert.That(result, Is.EqualTo(table)); }