def holy_lance(actor, target, context): import actions x, y = context['origin'] ui.render_explosion(x, y, context['burst'], libtcod.violet, libtcod.light_yellow) spell_context = { 'stamina_cost': context['stamina_cost'], 'charges': context['charges'], 'caster': actor, 'team': actor.fighter.team, } lance = main.GameObject( x, y, chr(23), 'Holy Lance', libtcod.light_azure, on_tick=lambda o: actions.invoke_ability( 'ability_holy_lance_tick', o, spell_context=spell_context), summon_time=10) main.current_map.add_object(lance) for obj in main.get_fighters_in_burst(x, y, context['burst'], lance, actor.fighter.team): combat.attack_magical(actor.fighter, obj, 'ability_holy_lance') return 'success'
def __init__(self, screen, KeysP1, KeysP2, position = Point(0,0)): Menu.__init__(self, position, screen) charlist = getCharList() self.keysP1 = KeysP1 self.keysP2 = KeysP2 self.cursor_sprites = game.GameObject('../res/charcursor.png', 36, 44, Point(0,0)).sprite_list self.charmenuP1 = CharMenu(charlist, self.cursor_sprites, True) self.charmenuP2 = CharMenu(charlist, self.cursor_sprites, False)
def draw_path(path): oldpaths = [] for obj in main.current_map.objects: if obj.name == 'path': oldpaths.append(obj) for obj in oldpaths: obj.destroy() if path != 'failure': for t in path: main.current_map.add_object( main.GameObject(t[0], t[1], '*', 'path', libtcod.yellow, always_visible=True, description=''))
def _spawn_warning(actor, tiles): warning_particles = [] if isinstance(tiles, tuple): tiles = [tiles] for tile in tiles: go = main.GameObject(tile[0], tile[1], 'X', 'Warning', libtcod.red, description="Spell Warning. Source: {}".format( actor.name.capitalize())) main.current_map.add_object(go) warning_particles.append(go) return warning_particles
def snowstorm_tick(actor, target, context): caster = context['caster'] dc = context['save_dc'] + caster.fighter.spell_power(elements=['radiance']) for t in target: if main.roll_dice('1d10') > 7: combat.attack_magical(caster.fighter, t, 'ability_snowstorm') if t.fighter is not None: t.fighter.apply_status_effect(effects.slowed(), dc, caster) t.fighter.apply_status_effect(effects.blinded(), dc, caster) fx = main.GameObject(t.x, t.y, '*', 'cloud of snow', libtcod.lightest_azure, summon_time=2) main.current_map.objects.append(fx)
def timebomb(actor, target, context): (x, y) = target[0], target[1] rune = main.GameObject( x, y, chr(21), 'time bomb', spells.essence_colors['arcane'], description='"I prepared explosive runes this morning"') main.current_map.add_object(rune) rune_ticker = main.Ticker(context['delay'], _timebomb_ticker) rune_ticker.rune = rune rune_ticker.actor = actor main.current_map.tickers.append(rune_ticker) if actor is player.instance or fov.player_can_see(x, y): ui.message('A glowing rune forms...', spells.essence_colors['arcane'])
def create_teleportal(actor, target, context): x, y = target portal = main.GameObject(x, y, 9, 'teleportal', spells.essence_colors['arcane'], on_tick=teleportal_on_tick) portal.timer = 4 main.current_map.add_object(portal) main.changed_tiles.append((x, y)) if fov.player_can_see(x, y): ui.message( 'A volatile portal opens. In a few moments it will teleport creatures standing near it.', spells.essence_colors['arcane']) return 'success'
def bramble(actor, target, context): ui.message( 'Thorny brambles spring from %s fingertips!' % syntax.name(actor, possesive=True), spells.essence_colors['life']) for tile in target: _bramble = main.GameObject( tile[0], tile[1], 'x', 'bramble', libtcod.dark_lime, on_step=bramble_on_step, summon_time=context['duration_base'] + main.roll_dice(context['duration_variance'])) _bramble.summoner = actor _bramble.spell_power = actor.fighter.spell_power(['life']) main.current_map.add_object(_bramble) return 'success'
def snowstorm(actor, target, context): import actions (x, y) = target storm = main.GameObject(x, y, '@', 'Snowstorm', libtcod.lightest_azure, summon_time=10) storm.on_tick_specified = lambda o: actions.invoke_ability( 'ability_snowstorm_tick', storm, spell_context={ 'caster': actor, 'team': actor.fighter.team }) storm.creator = actor main.current_map.add_object(storm)
def threaded(connection_socket): global boss, boss_default, player try: item = game.GameObject(boss.to_string(), 'Unit') while True: # At first send boss health to client # After that send else information to client sending_data = pickle.dumps(item) connection_socket.send(sending_data) # If item turn to be 'END' end this thread if item.item == 'END': connection_socket.close() break # Receive input from client data = connection_socket.recv(2048).decode() # If boss is not died, client can attack if boss.status != 'died': if data == 'A': player.attack(boss) item = game.GameObject(boss.to_string(), 'Unit') elif data == 'Q': item = game.GameObject('END', 'Action') else: item = game.GameObject(boss.to_string(), 'Unit') # If boss already died, from attack above, ask client to play again if boss.status == 'died': item = game.GameObject('Boss has already died\nTry Again? Y: Yes, N: No', 'String') if data == 'Y': boss = boss_default.copy() item = game.GameObject(boss.to_string(), 'Unit') elif data == 'N': item = game.GameObject('END', 'Action') except: print('closed') connection_socket.close()
def summon_dragonweed(actor, target, context): x, y = target tile = main.current_map.tiles[x][y] if tile.tile_type != 'grass floor': if actor is player.instance: ui.message('The dragonseed must be planted on grass.', libtcod.gray) return 'cancelled' seed = main.GameObject( x, y, 'w', 'dragonweed sapling', libtcod.dark_chartreuse, description= 'A small, scaly blulb surrounded by sharp, thin leaves. In a few turns, ' 'it will grow into a full-sized Dragonweed.') main.current_map.add_object(seed) seed_ticker = main.Ticker(4, _dragonseed_ticker) seed_ticker.seed = seed main.current_map.tickers.append(seed_ticker) if actor is player.instance or fov.player_can_see(x, y): ui.message('A dragonseed is planted...', libtcod.dark_chartreuse) return 'success'
def setUp(self): self.game = game.Game('Python Game Project - Chai Grindean', 800, 800) self.player = game.Player('./Assets/player.png', 375, 700, 60, 60) self.enemy1 = game.Enemy('./Assets/monster4.png', 375, 700, 75, 50, 7) self.chest = game.GameObject('./Assets/chest.png', 375, 25, 50, 50)