示例#1
0
文件: input.py 项目: AKJ/sage
def outgoing_line_reciever(line):
	global lock

	if len(line) == 0:
		return line

	# deprecated
	clean_line = line

	if lock:
		if clean_line.lower() == 'break':
			lock = False
			core.echo("Input resumed")
			return
		elif clean_line.lower() == 'pp':
			lock = False
			core.paused = True
			core.echo("Pausing, automatically breaking lock")
		else:
			return

	# Alias Parsing
	for group in core.alias_groups_active:
		for alias in core.aliases[group].values():
			result = alias.match(clean_line)
			if result != False:
				if result != None:
					return result
				else:
					return None

	return line
示例#2
0
文件: utils.py 项目: AKJ/sage
def load_playerstate():
	if os.path.isfile('playerstate'):
		file = open('playerstate', 'rb')
		try:
			player_dict = pickle.load(file)
		except EOFError:
			return player

		try:
			player.health = int(player_dict['health'])
			player.mana = int(player_dict['mana'])
			player.endurance = int(player_dict['endurance'])
			player.willpower = int(player_dict['willpower'])
			player.max_health = int(player_dict['max_health'])
			player.max_mana = int(player_dict['max_mana'])
			player.max_endurance = int(player_dict['max_endurance'])
			player.max_willpower = int(player_dict['max_willpower'])
			player.elm_puffs = int(player_dict['elm_puffs'])
			player.skullcap_puffs = int(player_dict['skullcap_puffs'])
			player.valerian_puffs = int(player_dict['valerian_puffs'])
			player.mount = player_dict['mount']
			player.tattoos = player_dict['tattoos']
			player.last_fashion = player_dict['last_fashion']
		except KeyError:
			# Means our playerstate file is out of date
			print "Warning: Playerstate file out of date"

		core.echo('Playerstate Loaded.')
		file.close()
		return player
	else:
		return player
示例#3
0
def toggle_focus(line, time, backrefs):
	if player.allow_focus:
		core.echo("Disabling focusing")
		player.allow_focus = False
	else:
		core.echo("Enabling focusing")
		player.allow_focus = True
示例#4
0
def toggle_breathing(line, time, backrefs):
	if player.keepup['breathing']:
		player.keepup['breathing'] = False
		core.echo("No longer keeping up breathing")
	else:
		player.keepup['breathing'] = True
		core.echo("Keeping up breathing")
		free_queue.add('breathing', 'hold breath', 400)
示例#5
0
def toggle_rebounding(line, time, backrefs):
	if player.keepup['rebounding']:
		player.keepup['rebounding'] = False
		core.echo("No longer keeping up rebounding")
	else:
		player.keepup['rebounding'] = True
		core.echo("Keeping up rebounding")
		return ""
示例#6
0
def toggle_pause(line, time, backrefs):
	if core.paused:
		core.paused = False
		core.echo("System Unpaused")
	else:
		core.paused = True
		core.echo("System Paused")
	return ""
示例#7
0
def retardation_autocure(line, time, backrefs):
	if aeon_cures.rr_auto == True:
		core.echo("Disabling RR Autocuring")
		aeon_cures.rr_auto = False
	else:
		core.echo("Enabling RR Autocuring")
		aeon_cures.rr_auto = True
		aeon_cures.aeon_event(time)
示例#8
0
def config(line, time, backrefs):
	arg = backrefs[1].strip()
	arg = arg.split(' ')
	try:
		command = arg[0]
		param = arg[1]
		core.set_config(command, param)
	except IndexError:
		core.echo("Invalid configuration option")
示例#9
0
def echo_afflictions(line, time, backrefs):
        short_affs = []
        for aff in player.afflictions:
            if player.afflictions[aff]:
                short_affs.append(aff)
        short_affs = ", ".join(short_affs)
        if len(short_affs) > 0:
            core.echo('Afflictions: ' + short_affs)
        else:
            core.echo('No recognized afflictions')
示例#10
0
def basic(line, time, backrefs):
	core.echo('Basic Defences Mode')
	player.mode = 'basic'
	player.moss_health_percentage = core.config['basic_moss_health_percentage']
	player.moss_mana_percentage = core.config['basic_moss_mana_percentage']
	player.keepup = player.keepup_basic
	for defence in player.basic:
		if player.basic[defence] is True and player.keepup[defence] is False:
			if player.defences[defence] == 0:
				defences.load_def(defence)
	input.run_events(time)
示例#11
0
def combat(line, time, backrefs):
	core.echo('Combat Defences Mode')
	player.mode = 'combat'
	player.moss_health_percentage = core.config['combat_moss_health_percentage']
	player.moss_mana_percentage = core.config['combat_moss_mana_percentage']
	player.keepup = player.keepup_combat
	for defence in player.combat:
		if player.basic[defence] is True and player.keepup[defence] is False:
			if player.defences[defence] == 0:
				defences.load_def(defence)
	input.run_events(time)
示例#12
0
def toggle_heartseed(line, time, backrefs):
	if player.allow_heartseed:
		core.echo("Disabling Heartseed Trigger for 5 Minutes")
		player.allow_heartseed = False
		core.disable_trigger('elementalism_heartseed', 'elementalism')
		player.heartseed_timer = Timer(300, reenable_heartseed)
		player.heartseed_timer.start()
	else:
		core.echo("Enabling Heartseed Trigger")
		player.allow_heartseed = True
		player.heartseed_timer.cancel()
		core.enable_trigger('elementalism_heartseed', 'elementalism')
示例#13
0
文件: failures.py 项目: AKJ/sage
def failure_mount(line, time, backrefs):
	if player.mount_failures >= 3:
		player.keepup['riding'] = False
		player.defences['riding'] = 0
		player.mount_failures = 0
		action_queue.remove_by_name('riding')
		core.disable_trigger('ondef_vaulted', 'ondef')
		core.disable_trigger('ondef_mounted', 'ondef')
		core.disable_trigger('failure_mount', 'failures')
		core.echo("Can't mount steed " + player.mount + ".")
	else:
		player.mount_failures += 1
示例#14
0
def toggle_retardation_mode(line, time, backrefs):
	if core.retardation_mode:
		core.disable_alias('retardation_cure', 'sage_internal_commands')
		core.disable_alias('retardation_autocure', 'sage_internal_commands')
		core.enable_trigger('symptoms_aeon', 'symptoms')
		core.echo("Disabling retardation mode")
		core.retardation_mode = False
		core.aeon_mode = False
	else:
		core.enable_alias('retardation_autocure', 'sage_internal_commands')
		core.enable_alias('retardation_cure', 'sage_internal_commands')
		core.disable_trigger('symptoms_aeon', 'symptoms')
		core.echo("Enabling retardation aeon mode")
		core.retardation_mode = True
		core.aeon_mode = True
示例#15
0
文件: events.py 项目: AKJ/sage
def tree_event(now):
	if now - player.tree_lastfire > 10 and player.tree_balance == 0 and now - player.last_tree_echo > 1:
		core.echo('Tree balance regained')
		player.last_tree_echo = now

	if now - player.tree_lastfire > 10 + player.latency:
		player.tree_balance = 1

	if player.tree_balance == 1:
		if player.fire_tree:
			if player.afflictions['sleep'] or \
			player.stunned or \
			player.afflictions['amnesia'] or \
			player.afflictions['paralysis'] or \
			player.is_hindered() or \
			player.can_outr() is False or \
			player.tattoos['tree'] <= 0:
				return

			player.tree_balance = .5
			player.tree_lastfire = now
			core.enable_trigger('cure_enablers_tree', 'cure_enablers')
			core.write('touch tree')
示例#16
0
def toggle_lyre(line, time, backrefs):
	if player.combat_class.lower() == 'sentinel' or player.combat_class.lower() == 'druid':
		if player.keepup['melody']:
			player.keepup['melody'] = False
			core.echo('No longer keeping up melody')
		else:
			player.keepup['melody'] = True
			core.echo('Keeping up melody')
			return ""
	else:
		if player.keepup['lyre']:
			player.keepup['lyre'] = False
			core.echo("No longer keeping up lyre")
		else:
			player.keepup['lyre'] = True
			core.echo("Keeping up lyre")
			return ""
示例#17
0
def keepup(line, time, backrefs):
	defence = backrefs[0]
	try:
		if player.keepup[defence]:
			player.keepup[defence] = False
			core.echo("No longer keeping up " + defence)
		else:
			player.keepup[defence] = True
			core.echo("Keeping up " + defence)
	except KeyError:
		core.echo("Invalid defence name")
示例#18
0
def ignore_affliction(line, time, backrefs):
	args = backrefs[1]

	if len(args) == 0:
		if len(player.ignored_afflictions) == 0:
			core.echo("You aren't ignoring any afflictions.")
		else:
			affs = utils.list_to_csv(player.ignored_afflictions)
			core.echo("Currently ignoring: " + affs + ".")
		return

	arg = args.strip()

	if arg not in player.afflictions.keys():
		core.echo("That's not a valid affliction.")
		return
	else:
		player.ignored_afflictions.append(arg)
		core.echo("Added " + arg + " to ignored afflictions.")
示例#19
0
def unignore_affliction(line, time, backrefs):
	args = backrefs[1]

	if len(args) == 0:
		return

	arg = args.strip()

	if arg not in player.afflictions.keys():
		core.echo("That's not a valid affliction.")
		return
	elif arg not in player.ignored_afflictions:
		core.echo("That affliction isn't currently being ignored.")
		return
	else:
		player.ignored_afflictions.remove(arg)
		core.echo("No longer ignoring " + arg + ".")
示例#20
0
def reenable_heartseed():
	core.enable_trigger('elementalism_heartseed', 'elementalism')
	core.echo("Heartseed Trigger Re-enabled")
	player.allow_heartseed = True
示例#21
0
文件: input.py 项目: AKJ/sage
def prompt_receiver(line):
	global buffer, pfunctions, pfunction_args, previous_stats, current_stats, gagnext

	if len(line) == 0:
		return line

	clean_line = ansi.filter_ansi(line)
	# Strip newlines
	if clean_line[0] == NL:
		clean_line = clean_line[1:]

	match = prompt.match(clean_line)
	if match:
	
		# pending triggers to be disabled
		if len(core.triggers_pending_disable) > 0:
			for trigger in core.triggers_pending_disable:
				core.disable_trigger(trigger[0], trigger[1])

			core.triggers_pending_disable = []

		if len(core.trigger_groups_pending_disable) > 0:
			for group in core.trigger_groups_pending_disable:
				core.disable_trigger_group(group)

			core.trigger_groups_pending_disable = []

		backrefs = match.groups()

		player.last_health = player.health
		player.health = int(backrefs[0])
		player.delta_health = player.health - player.last_health
		player.last_mana = player.mana
		player.mana	= int(backrefs[1])
		player.delta_mana = player.mana - player.last_mana

		player.health_percentage = percentage(player.health, player.max_health)
		player.mana_percentage = percentage(player.mana, player.max_mana)

		previous_stats = current_stats
		current_stats = backrefs[2]
		status = backrefs[2]
		ex = ''
		stats = ''
		if status is None:
			player.equilibrium = False
			player.balance = False
			player.defences['cloak'] = 0
			player.defences['blind'] = 0
			player.defences['deaf'] = 0
			player.defences['kelventari'] = 0
		else:
			if 'e' in status:
				player.equilibrium = True
				ex = ex + 'e'
			else:
				player.equilibrium = False
			if 'y' or 'z' in status:
				#balance stuff. Work on this
				if player.combat_class == 'monk':
					if player.leftarm_balance and player.rightarm_balance:
						player.balance = True
					else:
						player.balance = False
				else:
					player.balance = True
				ex = ex + 'x'
			else:
				player.balance = False
			if 'c' in status:
				player.defences['cloak'] = 1
				stats = stats + 'c'
				queues.action_queue.remove_by_name('cloak')
			else:
				player.defences['cloak'] = 0
			if 'b' in status:
				player.defences['blind'] = 1
				stats = stats + 'b'
				queues.herb_queue.remove_by_name('blind')
			else:
				player.defences['blind'] = 0
			if 'd' in status:
				player.defences['deaf'] = 1
				stats = stats + 'd'
				queues.herb_queue.remove_by_name('deaf')
			else:
				player.defences['deaf'] = 0
			if 'k' in status:
				player.defences['kelventari'] = 1
				stats = stats + 'k'
			else:
				if player.defences['kelventari'] != .5:
					player.defences['kelventari'] = 0

		# quick reckless check
		if player.health < player.max_health or player.mana < player.max_mana:
			player.afflictions['reckless'] = False

		# death handling
		if player.health == 0:
			player.dead = True
		else:
			player.dead = False

		# we -might- be dead
		if player.dead == False:
			dead = True
			if player.death_check:
				if player.equilibrium is False:
					dead = False
				elif player.balance is False:
					dead = False
				elif player.defences['cloak'] == 1:
					dead = False
				elif player.defences['blind'] == 1:
					dead = False
				elif player.defences['deaf'] == 1:
					dead = False
				elif player.defences['kola'] == 1:
					dead = False
				if dead:
					player.dead = True

				if player.dead and player.starburst_check:
					hooks.burst.run()
					player.mode = 'starburst'
					player.keepup = player.keepup_starburst
					for defence in player.starburst:
						if player.starburst[defence] is True and player.keepup[defence] is False:
							if player.defences[defence] == 0:
								defences.load_def(defence)
				player.death_check = False
				player.starburst_check = False
		else:
			dead = False

		if player.dead:
			if dead:
				core.echo("You're no daisy. You're no daisy at all!")
			if player.health == 0:
				core.paused = True

			for aff in player.afflictions:
				player.afflictions[aff] = False
			for defence in player.defences:
				player.defences[defence] = 0
			queues.flush_queues()
			player.stunned = False
			player.herb_balance = 1
			player.hmsip_balance = 1
			player.asip_balance = 1
			player.lestagii_balance = 1
			player.herb_balance = 1
			player.free_balance = 1
			player.waiting_for_kelventari = 0
			player.focus_balance = 1
			player.fire_focus = False
			player.ableto_focus = True
			player.tree_balance = 1
			player.writhe_balance = 1
			core.aeon_mode = False
			core.retardation_mode = False
			herbs.reset()
			hooks.death.run()

		now = time.time()

		if len(pfunctions) > 0:
			i = 0
			for function in pfunctions:
				function(pfunction_args[i][0], pfunction_args[i][1], pfunction_args[i][2])
				i += 1

		pfunctions = []
		pfunction_args = []

		# Cure and Affliction Events
		defences.defence_event(now)
		cures.cure_event()
		if core.aeon_mode is False:
			cures.affliction_event(now)
		else:
			aeon_cures.affliction_event()

		cures.lifevision = False # reset lifevision
		cures.temporary_priorities = {}

		# prompt events
		run_events(now)

		# restyle prompt
		new_prompt = format_prompt(ex, stats)

		buffer = []

		if gagging or gagnext:
			if gagnext:
				gagnext = False

			return None
		else:
			return new_prompt

	# Blackout prompt
	else:
		if clean_line[0] == '-':
			player.afflictions['blackout'] = True

			core.enable_trigger_group('blackout_cures')
			core.enable_trigger_group('venoms')

			now = time.time()

			if len(pfunctions) > 0:
				for function in pfunctions:
					pfunctions[function](pfunction_args[function][0], pfunction_args[function][1], pfunction_args[function][2])

			pfunctions = []
			pfunction_args = []

			defences.defence_event(now)
			cures.cure_event()

			if core.aeon_mode is False:
				cures.affliction_event(now)
			else:
				aeon_cures.affliction_event()

			cures.lifevision = False # reset lifevision
			cures.temporary_priorities = {}

			run_events(now)

			buffer = []
			return blackout_prompt()

	return line
示例#22
0
def pause_off(line, time, backrefs):
	if core.paused == True:
		core.paused = False
		core.echo("System Unpaused")
示例#23
0
def pause_on(line, time, backrefs):
	if core.paused == False:
		core.paused = True
		core.echo("System Paused")
示例#24
0
def reset_everything(line, time, backrefs):
	core.echo("Reseting the system...")
	core.echo("Reseting afflictions")
	for affliction in player.afflictions:
		player.afflictions[affliction] = False

	core.echo("Reseting defenses")
	for defence in player.defences:
		player.defences[defence] = 0

	core.echo("Reseting plants eaten")
	for plant in player.ate:
		player.ate[plant] = False

	for plant in player.blackout_ate:
		player.blackout_ate[plant] = False

	core.echo("Reseting actions")
	for action in player.actions:
		if action != 'applied_to':
			player.actions[action] = False
		else:
			player.actions[action] = ''

	core.echo("Flushing all queues")
	flush_queues()
	core.echo("Reseting action variables")
	player.ignored_afflictions = []

	player.delta_health = 0
	player.delta_mana = 0
	player.balance = True
	player.balance_lastfire = 0
	player.leftarm_balance = True
	player.rightarm_balance = True
	player.equilibrium = True
	player.equilibrium_lastfire = 0
	player.hmsip_balance = 1
	player.hmsip_lastfire = 0

	player.asip_balance = 1
	player.asip_lastfire = 0

	player.moss_balance = 1
	player.moss_lastfire = 0

	player.herb_balance = 1
	player.herb_lastate = 0
	player.herb_lastfire = 0
	player.ate_offbal = False

	player.free_balance = 1
	player.free_lastfire = 0

	player.voice_balance = 1
	player.voice_lastfire = 0

	player.salve_balance = 1
	player.salve_lastfire = 0
	player.last_salve = ''
	player.last_salve_where = ''
	player.salve_failure = False
	player.restro_cures = ()

	player.waiting_for_sileris = 0
	player.sileris_last = 0
	player.sileris_event_last = 0
	player.sileris_lastoutr = 0

	player.focus_balance = 1
	player.focus_lastfire = 0
	player.fire_focus = False
	player.ableto_focus = True
	player.allow_focus = True
	player.focus_on_impatience = False

	player.allow_heartseed = True

	player.tree_balance = 1
	player.tree_lastfire = 0
	player.fire_tree = False

	player.writhe_balance = 1
	player.writhe_lastfire = 0

	player.wake_balance = 1
	player.wake_lastfire = 0

	player.waitfor_deaf = False
	player.waitfor_deaf_last = 0

	player.stunned = False
	player.stun_ticks = 0
	player.stun_prompts = 0
	player.stun_time = 0

	player.dead = False
	player.death_check = False
	player.starburst_check = False
	player.smokeable = True
	player.pipe_light_queue = []

	player.last_dstab = 0
	player.dstab_check = False

	player.multi_flay = False
	player.unknown_affliction = 0

	player.puffs = []
	player.rebounding_pending = False

	player.waiting_for_aeon = 0
	player.waiting_for_aeon_last = 0
	player.mount_failures = 0

	player.grate = False

	player.last_purity = 0
	player.last_angel_care = 0
	player.last_healing_rite = 0
	player.last_hallelujah = 0
	player.last_amnesia = 0
	player.last_snap = 0

	player.last_fashion = {}

	player.tumbling = False
	core.echo("System reset")
示例#25
0
def reload_triggers(line, time, backrefs):
	core.triggers = {}
	core.trigger_groups = []
	core.trigger_groups_active = []
	loadXML.load_xml_triggers()
	core.echo("Triggers Reloaded")
示例#26
0
def alias_flush_queues(line, time, backrefs):
	flush_queues()
	core.echo("All queues flushed")
示例#27
0
def shutdown(line, time, backrefs):
	inra(None, None, None)
	utils.save_playerstate(player)
	core.echo("Playerstate Saved")
	hooks.qq.run()
	return "qq"
示例#28
0
running = True  # it do be running

prompt = ">"

# prompt loop and commands
while running:
    # prompt
    command = input(prompt + " ").lower()

    if command == "prompt":
        print("Input the new prompt.")
        prompt = input(">> ")

    # echo
    elif command == 'echo':
        core.echo()

    # exits masonCLI
    elif command == 'exit':
        running = False
        exit()

    # help
    elif command == 'help':
        core.assist()

    # syshelp
    elif command == 'help -sys':
        core.assist_sys()

    # geom help
示例#29
0
def save_playerstate(line, time, backrefs):
	utils.save_playerstate(player)
	core.echo("Playerstate Saved")
示例#30
0
def set_mount(line, time, backrefs):
	player.mount = backrefs[0]
	player.keepup['riding'] = True
	core.echo("Setting mount to " + player.mount)
	core.enable_trigger('ondef_riding', 'ondef')
	return line
示例#31
0
def lastoutbound(line, time, backrefs):
	if core.last_output == None:
		return

	core.echo("Last outbound was: \"" + core.last_output.strip(chr(13) + chr(10)) + "\"")