<s> """<STR_LIT>""" <EOL> from . animation import Animation <EOL> from . counters import DamageCounter <EOL> from random import Random <EOL> from PyQt4 . QtCore import ( QEasingCurve , QPropertyAnimation , <EOL> QSequentialAnimationGroup ) <EOL> from herculeum . ui . gui . layers import zorder_counter <EOL> from pyherc . events import e_target , e_damage <EOL> class AttackHitAnimation ( Animation ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , event ) : <EOL> """<STR_LIT>""" <EOL> super ( ) . __init__ ( event ) <EOL> self . location = e_target ( event ) . location <EOL> self . damage = - e_damage ( event ) [ <NUM_LIT:0> ] <EOL> self . colour = '<STR_LIT>' <EOL> self . offset = ( <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> def trigger ( self , ui ) : <EOL> """<STR_LIT>""" <EOL> damage_counter = DamageCounter ( damage = str ( self . damage ) , <EOL> colour = self . colour , <EOL> parent = ui ) <EOL> ui . view . scene ( ) . addItem ( damage_counter ) <EOL> damage_counter . setZValue ( zorder_counter ) <EOL> bounds = damage_counter . boundingRect ( ) <EOL> width = bounds . width ( ) <EOL> rand = Random ( ) <EOL> damage_counter . setPos ( ( self . location [ <NUM_LIT:0> ] * <NUM_LIT:32> <EOL> + <NUM_LIT:16> - ( width / <NUM_LIT:2> ) <EOL> + rand . randint ( - <NUM_LIT:16> , <NUM_LIT:16> ) ) + self . offset [ <NUM_LIT:0> ] , <EOL> self . location [ <NUM_LIT:1> ] * <NUM_LIT:32> + self . offset [ <NUM_LIT:1> ] ) <EOL> animation = QSequentialAnimationGroup ( ) <EOL> moving = QPropertyAnimation ( damage_counter . adapter , <EOL> '<STR_LIT>' ) <EOL> moving . setDuration ( <NUM_LIT> ) <EOL> moving . setStartValue ( self . location [ <NUM_LIT:1> ] * <NUM_LIT:32> + self . offset [ <NUM_LIT:1> ] ) <EOL> moving . setEndValue ( self . location [ <NUM_LIT:1> ] * <NUM_LIT:32> - <NUM_LIT:32> + self . offset [ <NUM_LIT:1> ] ) <EOL> curve = QEasingCurve ( QEasingCurve . OutElastic ) <EOL> moving . setEasingCurve ( curve ) <EOL> animation . addAnimation ( moving ) <EOL> fading = QPropertyAnimation ( damage_counter . adapter , <EOL> '<STR_LIT>' ) <EOL> fading . setDuration ( <NUM_LIT> ) <EOL> fading . setStartValue ( <NUM_LIT:1.0> ) <EOL> fading . setEndValue ( <NUM_LIT:0.0> ) <EOL> animation . addAnimation ( fading ) <EOL> def clean_up ( ) : <EOL> animation . stop ( ) <EOL> ui . animations . remove ( animation ) <EOL> ui . view . items ( ) . remove ( damage_counter ) <EOL> ui . remove_finished_animation ( ) <EOL> animation . finished . connect ( clean_up ) <EOL> ui . animations . append ( animation ) <EOL> animation . start ( ) </s>
