(self, src, maxTime)
| 94 | |
| 95 | # Private stuff |
| 96 | def _prepareDpsVolleyData(self, src, maxTime): |
| 97 | # Time is none means that time parameter has to be ignored, |
| 98 | # we do not need cache for that |
| 99 | if maxTime is None: |
| 100 | return True |
| 101 | self._generateInternalForm(src=src, maxTime=maxTime) |
| 102 | fitCache = self._data[src.item.ID] |
| 103 | # Final cache has been generated already, don't do anything |
| 104 | if 'finalDps' in fitCache and 'finalVolley' in fitCache: |
| 105 | return |
| 106 | # Convert cache from segments with assigned values into points |
| 107 | # which are located at times when dps/volley values change |
| 108 | pointCache = {} |
| 109 | for key, dmgList in fitCache['internalDpsVolley'].items(): |
| 110 | pointData = pointCache[key] = {} |
| 111 | prevDps = None |
| 112 | prevVolley = None |
| 113 | prevTimeEnd = None |
| 114 | for timeStart, timeEnd, dps, volley in dmgList: |
| 115 | # First item |
| 116 | if not pointData: |
| 117 | pointData[timeStart] = (dps, volley) |
| 118 | # Gap between items |
| 119 | elif floatUnerr(prevTimeEnd) < floatUnerr(timeStart): |
| 120 | pointData[prevTimeEnd] = (DmgTypes.default(), DmgTypes.default()) |
| 121 | pointData[timeStart] = (dps, volley) |
| 122 | # Changed value |
| 123 | elif dps != prevDps or volley != prevVolley: |
| 124 | pointData[timeStart] = (dps, volley) |
| 125 | prevDps = dps |
| 126 | prevVolley = volley |
| 127 | prevTimeEnd = timeEnd |
| 128 | # We have data in another form, do not need old one any longer |
| 129 | del fitCache['internalDpsVolley'] |
| 130 | changesByTime = {} |
| 131 | for key, dmgMap in pointCache.items(): |
| 132 | for time in dmgMap: |
| 133 | changesByTime.setdefault(time, []).append(key) |
| 134 | # Here we convert cache to following format: |
| 135 | # {time: {key: (dps, volley}} |
| 136 | finalDpsCache = fitCache['finalDps'] = {} |
| 137 | finalVolleyCache = fitCache['finalVolley'] = {} |
| 138 | timeDpsData = {} |
| 139 | timeVolleyData = {} |
| 140 | for time in sorted(changesByTime): |
| 141 | timeDpsData = copy(timeDpsData) |
| 142 | timeVolleyData = copy(timeVolleyData) |
| 143 | for key in changesByTime[time]: |
| 144 | dps, volley = pointCache[key][time] |
| 145 | timeDpsData[key] = dps |
| 146 | timeVolleyData[key] = volley |
| 147 | finalDpsCache[time] = timeDpsData |
| 148 | finalVolleyCache[time] = timeVolleyData |
| 149 | |
| 150 | def _generateInternalForm(self, src, maxTime): |
| 151 | if self._isTimeCacheValid(src=src, maxTime=maxTime): |
no test coverage detected