def __call__(self, args): """ resolves combat based on a physical attack calculate the terminal velocity of the attack (the speed at the point of the impact) calculate the kinetic energy of the weapon given the speed actor ability: target: """ if not args['actor'].target.alive: return False print 'attack %(target)s' % {'target': args['actor'].target} from dungeon.dungeonmaster import DungeonMaster dm = DungeonMaster(args['stage']) attack_time = 0.5 #for now, all attacks are heavy #calculate terminal velocity (speed) weapon travels from rest weapon_speed = args['actor'].strength * ( 1 / args['actor'].weapon.mass) * attack_time #calculate distance weapon travels given weapon_dist = (1.0 / 2.0) * weapon_speed * attack_time #calculate kinetic energy of weapon weapon_kenergy = (1.0 / 2.0) * pow(weapon_speed, 2) * args['actor'].weapon.mass print 'Weapon Speed: %(ws)s' % {'ws': weapon_speed} print 'Weapon Distance: %(wd)s' % {'wd': weapon_dist} print 'Weapon Kinetic Energy: %(ke)s' % {'ke': weapon_kenergy} #calculate target_dist = (1.0 / 2.0) * args['target'].agility * ( 1.0 / args['target']._mass) * attack_time * attack_time tweapon_speed = args['target'].strength * ( 1 / args['actor'].weapon.mass) * attack_time print 'Target Speed: %(ts)s' % {'ts': target_dist} #============================================================================================= #hit automatically, cause a wound args['target'].health -= weapon_kenergy if args['target'].health <= 0: print 'target death' print 'hit! target health: %(th)s' % {'th': args['target'].health} dm.foo(args['target'])
from dungeon.dungeongenerator import DungeonGenerator from dungeon.dungeonmaster import DungeonMaster #================================================================================================= from character.effect import Effect import os dg = DungeonGenerator(10,64) dungeon = dg.generate() decorator = DungeonDecorator() pc = decorator.decorate(dungeon) controller = Controller( pc ) selection = controller._selection dungeonmaster = DungeonMaster(dungeon) b = Character("Hardeep", "/home/lorin/projects/ge/art/planetcute/Character Boy.png", None, []) def drw(): pcloc= dungeon.loc( pc ) dungeonmaster.update() dungeon.draw( pcloc ) selection.draw() pos = actor.Vertex() def drwsel(): pcloc = dungeon.loc( pc ) dungeon.draw( pcloc, True )