(self, reloadOverride=None)
| 263 | if a.numShots == 0 and a.cycleTime > 0} |
| 264 | |
| 265 | def getCycleParametersPerEffect(self, reloadOverride=None): |
| 266 | factorReload = reloadOverride if reloadOverride is not None else self.owner.factorReload |
| 267 | # Assume it can cycle infinitely |
| 268 | if not factorReload: |
| 269 | return {a.effectID: CycleInfo(a.cycleTime, 0, math.inf, False) for a in self.abilities if a.cycleTime > 0} |
| 270 | limitedAbilities = [a for a in self.abilities if a.numShots > 0 and a.cycleTime > 0] |
| 271 | if len(limitedAbilities) == 0: |
| 272 | return {a.effectID: CycleInfo(a.cycleTime, 0, math.inf, False) for a in self.abilities if a.cycleTime > 0} |
| 273 | validAbilities = [a for a in self.abilities if a.cycleTime > 0] |
| 274 | if len(validAbilities) == 0: |
| 275 | return {} |
| 276 | mostLimitedAbility = min(limitedAbilities, key=lambda a: a.cycleTime * a.numShots) |
| 277 | durationToRefuel = mostLimitedAbility.cycleTime * mostLimitedAbility.numShots |
| 278 | # find out how many shots various abilities will do until reload, and how much time |
| 279 | # "extra" cycle will last (None for no extra cycle) |
| 280 | cyclesUntilRefuel = {mostLimitedAbility.effectID: (mostLimitedAbility.numShots, None)} |
| 281 | for ability in (a for a in validAbilities if a is not mostLimitedAbility): |
| 282 | fullCycles = int(floatUnerr(durationToRefuel / ability.cycleTime)) |
| 283 | extraShotTime = floatUnerr(durationToRefuel - (fullCycles * ability.cycleTime)) |
| 284 | if extraShotTime == 0: |
| 285 | extraShotTime = None |
| 286 | cyclesUntilRefuel[ability.effectID] = (fullCycles, extraShotTime) |
| 287 | refuelTimes = {} |
| 288 | for ability in validAbilities: |
| 289 | spentShots, extraShotTime = cyclesUntilRefuel[ability.effectID] |
| 290 | if extraShotTime is not None: |
| 291 | spentShots += 1 |
| 292 | refuelTimes[ability.effectID] = ability.getReloadTime(spentShots) |
| 293 | refuelTime = max(refuelTimes.values()) |
| 294 | cycleParams = {} |
| 295 | for ability in validAbilities: |
| 296 | regularShots, extraShotTime = cyclesUntilRefuel[ability.effectID] |
| 297 | sequence = [] |
| 298 | if extraShotTime is not None: |
| 299 | if regularShots > 0: |
| 300 | sequence.append(CycleInfo(ability.cycleTime, 0, regularShots, False)) |
| 301 | sequence.append(CycleInfo(extraShotTime, refuelTime, 1, True)) |
| 302 | else: |
| 303 | regularShotsNonReload = regularShots - 1 |
| 304 | if regularShotsNonReload > 0: |
| 305 | sequence.append(CycleInfo(ability.cycleTime, 0, regularShotsNonReload, False)) |
| 306 | sequence.append(CycleInfo(ability.cycleTime, refuelTime, 1, True)) |
| 307 | cycleParams[ability.effectID] = CycleSequence(sequence, math.inf) |
| 308 | return cycleParams |
| 309 | |
| 310 | @property |
| 311 | def maxRange(self): |
no test coverage detected