public static EnhancementSession Start(Item item) { var s = new EnhancementSession(); var r = new HistoryRecord() { Item = item, PositionsAfter = new List <Range>() { new Range() { from = chances[item.Type][item.enhLevel + 1] * 2, to = chances[item.Type][item.enhLevel + 1] + 1 } }, PositionsBefore = new List <Range>() { new Range() { from = 0, to = 1 } } }; s.History.Add(r); return(s); }
public void FailEnhance(Item item) { var r = new HistoryRecord() { Item = item, PositionsBefore = CurrentPositions, }; var enhChance = chances[item.Type][item.enhLevel + 1]; r.PositionsAfter = CurrentPositions.SelectMany(p => CalculatePosition(p, enhChance)).ToList(); NormalizeRecord(ref r); History.Add(r); }
private void NormalizeRecord(ref HistoryRecord r) { //var l = r.PositionsAfter.Select(p => p.from < 1).ToList(); if (r.PositionsAfter.Any(p => p.from >= 1 && p.to >= 1)) { for (int i = 0; i < r.PositionsAfter.Count; i++) { if (r.PositionsAfter[i].from >= 1 && r.PositionsAfter[i].to >= 1) { r.PositionsAfter[i] = new Range() { from = r.PositionsAfter[i].from - 1, to = r.PositionsAfter[i].to - 1 } } } } ; }