All pastes #209592 Raw Edit

Something

public python v1 · immutable
#209592 ·published 2006-10-19 07:31 UTC
rendered paste body
import randomdef rollForInitiative(s):    'return a hero guy'    guys = list(s.query(HeroGuy, sort=HeroGuy.DEX.descending, limit=2))    # leaving out 0 case for simplicity    if len(guys) == 1:        return guys[0]    elif len(guys) == 2:        winningDEX = guys[0].DEX        topGuy = s.findFirst(HeroGuy,                             HeroGuy.DEX == winningDEX,                             sort=HeroGuy.storeID.descending)        bottomGuy = s.findFirst(HeroGuy,                                HeroGuy.DEX == winningDEX,                                sort=HeroGuy.storeID.ascending)        spinTheWheel = random.randint(bottomGuy.storeID, topGuy.storeID)        return s.findFirst(HeroGuy,                           AND(HeroGuy.DEX == winningDEX,                               HeroGuy.storeID <= spinTheWheel))    assert 0, 'wtf'