Esempio n. 1
0
def setup():
    global SETTINGS

    # editor selection
    SETTINGS.update({"editor": select_editor()})
    redraw("text editor set to: "+SETTINGS["editor"])

    # publishing selection
    SETTINGS.update({"publishing":select_publishing()})
    redraw("blog publishing: "+str(publishing()))

    if publishing():
        oldDir = SETTINGS.get("publish dir")
        newDir = select_publish_dir()
        SETTINGS.update({"publish dir": newDir})
        subprocess.call(["rm", "-rf", os.path.join(PUBLIC, oldDir)])
        make_publish_dir(newDir)
        core.load_files()
        core.write("index.html")
    else:
        unpublish()

    # save settings
    ttbprc = open(TTBPRC, "w")
    ttbprc.write(json.dumps(SETTINGS, sort_keys=True, indent=2, separators=(',',':')))
    ttbprc.close()

    return SETTINGS
Esempio n. 2
0
def write_entry(entry=os.path.join(DATA, "test.txt")):

    entered = raw_input("""
"""+util.hilight("new feature!")+""" you can now use standard markdown in your entry text!
raw html is still valid, and you can mix them together.

feels will be recorded for today, """+time.strftime("%d %B %Y")+""".

if you've already started recording feels for this day, you
can pick up where you left off.

press <enter> to begin recording your feels.

""")

    if entered:
        entryFile = open(entry, "a")
        entryFile.write("\n"+entered+"\n")
        entryFile.close()
    subprocess.call([SETTINGS["editor"], entry])

    left = ""

    if publishing():
        core.load_files()
        core.write("index.html")
        left = "posted to "+LIVE+USER+"/"+SETTINGS["publish dir"]+"/index.html"
    redraw(left + " thanks for sharing your feels!")

    return
Esempio n. 3
0
File: events.py Progetto: AKJ/sage
def writhe_event(now):
	if queues.writhe_queue.is_empty() == False:
		if player.afflictions['sleep'] or \
		player.stunned or \
		player.afflictions['amnesia']:
			return

		# have to be on balance to writhe from impale
		if player.afflictions['impale'] and player.balance is False:
			return

		if player.writhe_balance == 1:
			core.enable_trigger('failure_writhe', 'failures')
			enable = (
				'impale',
				'webbed_roped',
				'transfixed',
				#'bound'
			)

			#if player.combat_class.lower() == 'bard':
			#	enable.append('dwinnu')

			for trigger in enable:
				core.enable_trigger('cure_enablers_' + trigger, 'cure_enablers')
			core.write(queues.writhe_queue.fire())
			player.writhe_balance = .5
			player.writhe_lastfire = now
		elif player.writhe_balance == .5:
			if now - player.writhe_lastfire > 2:
				player.writhe_balance = 1 # just a catchall
		elif player.writhe_balance == 0:
			if now - player.writhe_lastfire > 8:
				player.writhe_balance = 1
Esempio n. 4
0
File: events.py Progetto: AKJ/sage
def smoke_event(now):
	'''
	Thoughts...
	Wouldn't it be cool if pipes were completely independent of eachother?
	That each pipe had its own tracking, handling, firing, and reloading?
	A pipe class with each pipe being an instance of? It would...
	'''

	if queues.smoke_queue.is_empty() == False:
		if now - queues.smoke_queue.lastfire > player.latency:
			if player.afflictions['asthma'] is False and \
				player.afflictions['sleep'] is False and \
				player.stunned is False and \
				player.afflictions['amnesia'] is False:
					pipe = queues.smoke_queue.fire()
					smoke = False
					player.puffs.append(pipe)
					if pipe == 'elm' \
					and (player.elm_lit or player.arty_elm):
						smoke = player.elm_pipe
					elif pipe == 'valerian' \
					and (player.valerian_lit or player.arty_valerian):
						smoke = player.valerian_pipe
					elif pipe == 'skullcap' \
					and (player.skullcap_lit or player.arty_skullcap):
						if player.skullcap_puffs <= 0:
							return
						smoke = player.skullcap_pipe
					if smoke:
						core.enable_trigger('smoke_puff', 'balances')
						core.enable_trigger('failure_smoking', 'failures')
						core.enable_trigger('failure_asthma_smoking', 'failures')
						core.enable_trigger('failure_pipe_out', 'failures')
						core.write('smoke ' + smoke)
Esempio n. 5
0
def handleInput():
    downloadQueue = []

    #data.txt is the file where the front end leaves the data for us
    inputText = core.read('/opt/lampp/htdocs/data.txt')
    print(inputText)
    core.write('/opt/lampp/htdocs/data.txt', '')
    #inputText is split into an array so that we can interact with each line
    #individually (Different URLs are put on different lines by the frontend).
    inputArray = core.split(inputText)
    print(inputArray)

    i = 0
    #This loop allows us to perform the same function
    #on each line of the array. In this case it goes through each line and sorts
    #it into a video url, a playlist url, or random text. And then the
    #appropriate response is carried out
    while i < len(inputArray):
        inputData = inputArray[i]
        print(inputData)

        if 'list=' in inputData:  #'list=' is unique to playlist urls
            core.log('playlists', inputData)
        if 'v=' in inputData:  #v= is unique to video urls
            downloadQueue.append(inputData)

        i = i + 1

    return downloadQueue
Esempio n. 6
0
File: stun.py Progetto: AKJ/sage
def stun(line, time, backrefs):
	if core.is_paused():
		return

	if player.stunned is False:
		player.stun_ticks = 0
	core.enable_trigger('cures_stun', 'cures')
	core.enable_trigger('cures_unconciousness', 'cures')
	core.enable_trigger('ai_stun_check', 'anti-illusion')
	player.stunned = True
	player.stun_ticks += 1
	player.stun_time = time
	if player.stun_ticks < 3:
		if core.aeon_mode == False:
			core.write('touch stun')
	core.debug("stunned")
	# should probably add more balance resets here
	if player.focus_balance == .5:
		player.focus_balance = 1
	if player.herb_balance == .5:
		player.herb_balance = 1
	if player.salve_balance == .5:
		player.salve_balance = 1
	if player.hmsip_balance == .5:
		player.hmsip_balance = 1
	player.waiting_for_aeon = 0
Esempio n. 7
0
def write_entry(entry=os.path.join(DATA, "test.txt")):
    '''
    main feels-recording handler
    '''

    entered = raw_input("""
feels will be recorded for today, """+time.strftime("%d %B %Y")+""".

if you've already started recording feels for this day, you
can pick up where you left off.

you can write your feels in plaintext, markdown, html, or a mixture of
these.

press <enter> to begin recording your feels in your chosen text
editor.

""")

    if entered:
        entryFile = open(entry, "a")
        entryFile.write("\n"+entered+"\n")
        entryFile.close()
    subprocess.call([SETTINGS.get("editor"), entry])

    left = ""

    if core.publishing():
        core.load_files()
        core.write("index.html")
        left = "posted to "+LIVE+USER+"/"+str(SETTINGS.get("publish dir"))+"/index.html\n\n>"
    redraw(left + " thanks for sharing your feels!")

    return
Esempio n. 8
0
File: events.py Progetto: AKJ/sage
def focus_event(now):
	if player.ableto_focus is False \
	or player.allow_focus is False:
		return

	if now - player.focus_lastfire > 3:
		player.focus_balance = 1

	if player.focus_balance == 1:
		if player.fire_focus:
			if player.afflictions['sleep'] \
			or player.stunned \
			or (player.afflictions['impatience'] == True and player.focus_on_impatience == False) \
			or player.afflictions['amnesia']:
				return

			core.enable_trigger('survival_focusing', 'survival')
			player.focus_balance = .5
			player.focus_lastfire = now
			core.write('focus')
	elif player.focus_balance == .5:
		if now - player.focus_lastfire > .5:
			player.focus_balance = 1
	elif player.focus_balance == 0:
		if now - player.focus_lastfire > 3:
			player.focus_balance = 1
	core.enable_trigger('failure_focus_offbal', 'failures')
Esempio n. 9
0
File: events.py Progetto: AKJ/sage
def sileris_event(now):
	player.sileris_event_last = now
	if player.keepup['sileris']:
		if player.afflictions['slickness'] \
		or player.afflictions['sleep'] \
		or player.stunned \
		or player.afflictions['amnesia']:
			return

		if player.defences['sileris'] != 1 \
		and player.waiting_for_sileris == 1:
			if now - player.sileris_last > 5.6 + player.latency:
				if player.multi_flay:
					player.waiting_for_sileris = 0
					player.defences['sileris'] = 1
					player.multi_flay = False
				else:
					player.waiting_for_sileris = 0
					player.defences['sileris'] = 0

		if player.defences['sileris'] == 0 \
		and player.waiting_for_sileris == 0:
			if herbs.herbs['sileris'].inv <= 0:
				if player.is_hindered() is False and player.can_outr():
					if now - player.sileris_lastoutr > 1:
						player.sileris_lastoutr = now
						herbs.herbs['sileris'].outr()
			else:
				core.enable_trigger('sileris_balance', 'balances')
				core.enable_trigger('failure_sileris_slickness', 'failures')
				player.waiting_for_sileris = .5
				core.write('apply sileris')
Esempio n. 10
0
def write_entry(entry=os.path.join(DATA, "test.txt")):
    '''
    main feels-recording handler
    '''

    entered = raw_input("""
feels will be recorded for today, """+time.strftime("%d %B %Y")+""".

if you've already started recording feels for this day, you
can pick up where you left off.

you can write your feels in plaintext, markdown, html, or a mixture of
these.

press <enter> to begin recording your feels in your chosen text
editor.

""")

    if entered:
        entryFile = open(entry, "a")
        entryFile.write("\n"+entered+"\n")
        entryFile.close()
    subprocess.call([SETTINGS.get("editor"), entry])

    left = ""

    if core.publishing():
        core.load_files()
        core.write("index.html")
        left = "posted to "+LIVE+USER+"/"+str(SETTINGS.get("publish dir"))+"/index.html\n\n>"
    redraw(left + " thanks for sharing your feels!")

    return
Esempio n. 11
0
File: clotting.py Progetto: AKJ/sage
def bleed(line, time, backrefs):
	if core.is_paused() \
	or core.aeon_mode:
		return

	bleed = int(backrefs[0])

	if bleed >= player.max_health:
		return

	global clotting, clot_num
	if player.afflictions['haemophilia'] or \
	player.afflictions['aeon'] or \
	player.afflictions['sleep'] or \
	player.stunned:
		return


	clots = (bleed - 61) / 20
	mana_cost = clots * 60

	h = player.health_percentage / 100.0
	m = (player.mana - mana_cost) / float(player.max_mana)
	d = (bleed / float(player.max_health)) * 5

	clot_factor = 1 / (1 + exp((-(m * 2.5) + (h / 2.0) + 1) * (5 - d)))

	num_clots = round(clot_factor * clots)

	if num_clots > 0:
		clotting = True
		clot_num = num_clots - 1
		core.enable_trigger('clot_tick', 'general_afflictions')
		core.enable_trigger('no_clot', 'general_afflictions')
		core.write('clot', int(num_clots))
Esempio n. 12
0
    def _make_wav(carrier: List[float], sr: int, hz: float, wav_type: str, 
                modulator: List[float]=None, ac: float=None, ka: float=None):

        """
        Dynamically generates tone as wav file
        --------------------------------------
        Recieves:
            - Starting Hz
            - Carrier array
            - Sample Rate
            - Wav Form Type
            - Modulator Carrier Hz
            - AC
            - KA
        Return:
            - Returns nothing as a function but saves a wav file
            based on the dictating data
        """
        # currently there is the option to overlay
        # a modulation envelope over the tone 
        if modulator:
            # construct the envelope pattern
            envelope = ac * (1.0 + ka * modulator)
            # develop the modulated data, passing it through the envelope
            modulated = envelope * carrier
            modulated *= 0.3 # the severity of the modualtion
            # generate the tone
            modulated_data = np.int16(modulated * 32767)
            write(f"modulated_{hz}_{wav_type}.wav", rate=sr, data=modulated_data)
        # if no modulation desired, a consistent tone is generated
        carrier *= 0.3 # the amplitude of the wav
        data = np.int16(carrier * 32767)
        write(f"sample_packages/simple_{hz}_{wav_type}.wav", rate=sr, data=data)
Esempio n. 13
0
File: libserp.py Progetto: AKJ/sage
def snipe_target(backrefs):
	if offense_module.wielding['left'] != offense_module.weapons['bow'] and offense_module.wielding['right'] != offense_module.weapons['bow']:
		offense_module.wield_bow()
	direction = backrefs[1].lstrip()
	if not offense_module.aiming:
		core.write('aim ' + player.target + ' ' + direction)
	core.write('snipe ' + player.target + ' ' + direction)
	
Esempio n. 14
0
def amnesia(line, time, backrefs):
	if core.aeon_mode:
		if core.last_output == '' or core.last_output == ' ':
			core.write('touch amnesia')
		else:
			core.write(core.last_output)
	else:
		cures.affliction('amnesia')
Esempio n. 15
0
def write_entry(entry=os.path.join(DATA, "test.txt")):

    raw_input("\nfeelings will be recorded for today, "+time.strftime("%d %B %Y")+".\n\nif you've already started recording feelings for this day, you \ncan pick up where you left off.\n\npress <enter> to begin recording your feelings.\n\n")
    subprocess.call([SETTINGS["editor"], entry])
    core.load_files()
    core.write("index.html")
    redraw("posted to "+LIVE+USER+"/"+SETTINGS["publish dir"]+"/index.html\n\nthanks for sharing your feelings!")
    return
Esempio n. 16
0
def focus(line, time, backrefs):
	player.fire_focus = True
	if player.focus_balance == 1:
		core.write('focus')
		core.enable_trigger('survival_focusing', 'survival')
		core.enable_trigger('failure_focus_offbal', 'failures')
		player.focus_balance = 0.5
		player.focus_lastfire = time
Esempio n. 17
0
def tumble(line, time, backrefs):
	if player.defences['riding'] == 1:
		core.write('kneel')

	if "tumble" in line:
		return line
	else:
		core.write('tumble ' + backrefs[0])
Esempio n. 18
0
File: smoking.py Progetto: AKJ/sage
def pipe_full(line, time, backrefs):
	# Assume 10??
	player.elm_puffs = 10
	player.skullcap_puffs = 10
	player.valerian_puffs = 10
	player.waiting_for_aeon = 0
	core.disable_trigger('pipe_full', 'pipes')
	core.disable_trigger('pipes_paralysis_nofill', 'pipes')
	core.enable_trigger_group('plist')
	core.write('plist')
Esempio n. 19
0
File: events.py Progetto: AKJ/sage
def hmsip_event(now):
	if player.afflictions['sleep'] or player.afflictions['anorexia'] or player.afflictions['amnesia'] or player.stunned:
		return

	if now - player.hmsip_lastfire > (6 + player.latency):
		player.hmsip_balance = 1

	# flush queues
	queues.hmsip_queue.empty()

	health = player.health_percentage
	mana = player.mana_percentage

	# Determine which sip gets priority over the other
	priority = sip_priority(health, mana)

	if health <= core.config['health_sip_percentage']:
		if priority is 'health':
			queues.hmsip_queue.add('sip_health', 'sip health', 10)
		else:
			queues.hmsip_queue.add('sip_health', 'sip health', 5)

	if mana <= core.config['mana_sip_percentage']:
		if priority is 'mana':
			queues.hmsip_queue.add('sip_mana', 'sip mana', 10)
		else:
			queues.hmsip_queue.add('sip_mana', 'sip mana', 5)


	if player.hmsip_balance == 1 and queues.hmsip_queue.is_empty() is False:
		core.enable_trigger('cure_enablers_health', 'cure_enablers')
		core.enable_trigger('cure_enablers_mana', 'cure_enablers')
		core.write(queues.hmsip_queue.fire())
		player.hmsip_balance = .5
		player.hmsip_lastfire = now
	elif player.hmsip_balance == .5:
		if now - player.hmsip_lastfire > 2:
			player.hmsip_balance = 1

	# Lestagii healing
	if core.config['eat_lestagii']:
		if player.lestagii_balance == 1 and core.is_paused() is False:
			if health <= player.lestagii_health_percentage:
				core.enable_trigger('cure_enablers_lestagii', 'cure_enablers')
				herbs.lestagii.eat()
				player.lestagii_balance = .5
				player.lestagii_lastfire = now
			elif mana <= player.lestagii_mana_percentage:
				core.enable_trigger('cure_enablers_lestagii', 'cure_enablers')
				herbs.lestagii.eat()
				player.lestagii_balance = .5
				player.lestagii_lastfire = now
		else:
			if now - player.lestagii_lastfire > 7:
				player.lestagii_balance = 1
Esempio n. 20
0
def playlistCheck():
    playlists = core.split(core.read('playlists'))

    i = 0
    while i < len(playlists):
        if len(playlists[0]) > 2:
            core.write(playlists[i].split('list=')[1], '')
            playlist(playlists[i])
        i = i + 1

    return
Esempio n. 21
0
File: clotting.py Progetto: AKJ/sage
def preempt_clot(line, time, backrefs):
	global auto_clotting
	if core.is_paused() \
	or core.aeon_mode:
		return

	if player.mana_percentage > 55 and player.afflictions['haemophilia'] is False and player.afflictions['aeon'] is False:
		core.enable_trigger('clot_tick', 'general_afflictions')
		core.enable_trigger('no_clot', 'general_afflictions')
		auto_clotting = True
		core.write('clot')
Esempio n. 22
0
File: events.py Progetto: AKJ/sage
def immediate_event():
	if queues.immediate_queue.is_empty() == False:
		if player.afflictions['sleep'] or \
		player.stunned:
			return

		action = queues.immediate_queue.pop()
		if ";" in action:
			action = action.split(";")
			for act in action:
				core.write(act)
		else:
			core.write(action)
Esempio n. 23
0
def ping(line, time, backrefs):
	IAC  = chr(255)
	DONT = chr(254)
	DO   = chr(253)
	WONT = chr(252)
	WILL = chr(251)
	SB   = chr(250)
	SE   = chr(240)
	GA   = chr(249)
	EOR	 = chr(25)
	CR 	 = chr(13)
	NL   = chr(10)
	ECHO = chr(1)
	ATCP = chr(200)

	core.write(IAC + SB + "ping" + IAC + SE)
Esempio n. 24
0
File: clotting.py Progetto: AKJ/sage
def clot_tick(line, time, backrefs):
	global clot_num, clotting
	if core.is_paused() \
	or core.aeon_mode:
		return

	if auto_clotting:
		if player.mana_percentage > 55 and player.afflictions['haemophilia'] is False and player.afflictions['aeon'] is False:
			core.write('clot')
	elif clotting:
		if clot_num > 0:
			core.write('clot')
			clot_num -= 1
		else:
			clotting = False
			clot_num = 0
Esempio n. 25
0
File: events.py Progetto: AKJ/sage
def herb_event(now):
	# It's been too long.. should have gotten herb bal back now
	if now - player.herb_lastfire > 3.5 \
	and (player.herb_balance == 0 or player.herb_balance == .5):
		player.herb_balance = 1

	if now - player.herb_lastfire <= player.latency:
		return

	if queues.herb_queue.is_empty() == False:
		if player.afflictions['anorexia'] or \
		player.afflictions['sleep'] or \
		player.stunned or \
		player.afflictions['amnesia']:
			return

		if player.herb_balance == 1:
			herb = queues.herb_queue.fire()
			if player.is_hindered() and herbs.herbs[herb].inv == 0:
				return
			core.enable_trigger('cure_enablers_' + herb, 'cure_enablers')
			core.enable_trigger('failure_eating', 'failures')
			core.enable_trigger('failure_eating_anorexia', 'failures')
			core.enable_trigger('failure_eating_mickey', 'failures')
			herbs.herbs[herb].eat()
			player.herb_lastfire = now
			if player.afflictions['blackout']:
				player.blackout_ate[herb] = True
			if herb == 'goldenseal':
				core.enable_trigger('failure_goldenseal_insomnia', 'failures')
				core.write('insomnia')
			player.herb_balance = .5
		elif player.herb_balance == .5 \
		and now - player.herb_lastfire > (player.latency * 4):
			herb = queues.herb_queue.fire()
			core.enable_trigger('cure_enablers_' + herb, 'cure_enablers')
			core.enable_trigger('failure_eating', 'failures')
			core.enable_trigger('failure_eating_anorexia', 'failures')
			core.enable_trigger('failure_eating_mickey', 'failures')
			core.enable_trigger('failure_eat_offbal', 'failures')
			herbs.herbs[herb].eat()
			player.herb_lastfire = now
			if player.afflictions['blackout']:
				player.blackout_ate[herb] = True
			if herb == 'goldenseal':
				core.write('insomnia')
Esempio n. 26
0
    def commit_with_msg(self, msg, tmpfile, amend=False):
        """Creates a git commit."""

        if not msg.endswith('\n'):
            msg += '\n'

        # Create the commit message file
        fh = open(tmpfile, 'w')
        core.write(fh, msg)
        fh.close()

        # Run 'git commit'
        status, out = self.git.commit(F=tmpfile, v=True, amend=amend,
                                      with_status=True,
                                      with_stderr=True)
        os.unlink(tmpfile)
        return (status, out)
Esempio n. 27
0
File: events.py Progetto: AKJ/sage
def action_event():
	if queues.action_queue.is_empty() == False:
		if player.ready() \
		and player.is_hindered() is False \
		and player.afflictions['sleep'] is False \
		and player.afflictions['amnesia'] is False:
			action = queues.action_queue.fire()
			if 'reject' in action:
				core.enable_trigger('cures_lust', 'cures')
				core.enable_trigger('failure_reject', 'failures')
			elif 'lose' in action:
				core.enable_trigger('cures_emperor', 'cures')
				core.enable_trigger('failure_lose', 'failures')
				core.enable_trigger('failure_lose_follower', 'failures')
			core.write(action)
			if player.afflictions['blackout']:
				player.balance = False
				player.equilibrium = False
Esempio n. 28
0
File: events.py Progetto: AKJ/sage
def sleep_event(now):
	if player.afflictions['sleep']:
		if player.wake_balance == 1:
			player.wake_balance = .5
			sleep_cures = ('cures_sleep_waking', 'cures_sleep_1', 'cures_sleep_2', 'cures_sleep_3', 'cures_sleep_metawake')
			for cure in sleep_cures:
				core.enable_trigger(cure, 'cures')
			core.write('wake')
			player.wake_lastfire = now
		elif player.wake_balance == .5:
			if now - player.wake_lastfire > .2:
				sleep_cures = ('cures_sleep_waking', 'cures_sleep_1', 'cures_sleep_2', 'cures_sleep_3', 'cures_sleep_metawake')
				for cure in sleep_cures:
					core.enable_trigger(cure, 'cures')
				core.write('wake')
				player.wake_lastfire = now
	else:
		player.wake_balance = 1
Esempio n. 29
0
def update_publishing():
    '''
    updates publishing directory if user is publishing. otherwise, wipe it.
    '''

    global SETTINGS

    if core.publishing():
        oldDir = SETTINGS.get("publish dir")
        newDir = select_publish_dir()
        SETTINGS.update({"publish dir": newDir})
        if oldDir:
            subprocess.call(["rm", os.path.join(PUBLIC, oldDir)])
        make_publish_dir(newDir)
        core.load_files()
        core.write("index.html")
    else:
        unpublish()
        SETTINGS.update({"publish dir": None})

    core.load(SETTINGS)
Esempio n. 30
0
def update_publishing():
    '''
    updates publishing directory if user is publishing. otherwise, wipe it.
    '''

    global SETTINGS

    if core.publishing():
        oldDir = SETTINGS.get("publish dir")
        newDir = select_publish_dir()
        SETTINGS.update({"publish dir": newDir})
        if oldDir:
            subprocess.call(["rm", os.path.join(PUBLIC, oldDir)])
        make_publish_dir(newDir)
        core.load_files()
        core.write("index.html")
    else:
        unpublish()
        SETTINGS.update({"publish dir": None})

    core.load(SETTINGS)
Esempio n. 31
0
File: herbs.py Progetto: AKJ/sage
	def eat(self):
		if self.inv > 0:
			core.write('eat ' + self.name)
		else:
			core.enable_trigger('herbs_outp', 'herbs')
			core.write('outp ' + self.name)
			core.write('eat ' + self.name)
Esempio n. 32
0
File: events.py Progetto: AKJ/sage
def free_event(now):
	if queues.free_queue.is_empty() == False:
		if player.ready() \
		and player.free_balance == 1 \
		and player.afflictions['amnesia'] is False \
		and player.afflictions['sleep'] is False:
			# Flush the entire queue, we're not waiting for any balances here
			while queues.free_queue.length() > 0:
				action = queues.free_queue.pop()
				if action == 'stand':
					if player.can_stand() is False:
						continue
					core.enable_trigger('cures_prone', 'cures')
					core.enable_trigger('cures_prone_redundant', 'cures')
				elif action == 'hold breath':
					core.enable_trigger('asthma_hold_breath', 'symptoms')
				if ";" in action:
					action = action.split(";")
					for act in action:
						core.write(act)
				else:
					core.write(action)
Esempio n. 33
0
def main(instance):
    R, C, F, N, B, T, rides = read(instance + ".in")
    rides = deque(sorted(rides, key=comp_ti))

    #t_rides = [[] for i in range(T)]    # Rides beginning at time id
    #for ride in t_rides:
    #    t_rides[ride.ti].append(ride)

    # available_cars = [[Car2(idx) for idx in range(N)]]  # Cars availble at time id
    # available_cars.extend([[] for i in range(T-1)])
    available_cars = deque([Car(idx) for idx in range(F)])

    def score(car, ride):
        pass

    car = available_cars.popleft()
    again = True
    while car.time < T:
        waiting_zone = []
        print("Car :", car)
        while rides:
            ride = rides.popleft()
            #print(len(rides), len(available_cars))
            #print("- Ride :", ride)
            di = distance(ride.x0, ride.y0, car.x, car.y)
            if di + ride.d + car.time < ride.tf:
                car.path.append(ride.idx)
                car.time = max(ride.ti, car.time + di)
                available_cars.append(car)
                rides.extendleft(waiting_zone[max(0, len(waiting_zone) - MU):])
                break
            waiting_zone.append(ride)
        else:
            available_cars.append(car)
            break
        car = available_cars.popleft()

    write(instance + ".out", [car.path for car in available_cars])
Esempio n. 34
0
File: events.py Progetto: AKJ/sage
def asip_event(now):
	if now - queues.asip_queue.lastfire > 3:
		player.asip_balance = 1

	if queues.asip_queue.is_empty() == False:
		if player.afflictions['sleep'] or \
		player.stunned or \
		player.afflictions['anorexia'] or \
		player.afflictions['amnesia']:
			return

		elixir = queues.asip_queue.fire()
		if elixir in ('immunity', 'speed', 'frost'):
			core.enable_trigger('cure_enablers_free_asip', 'cure_enablers')
			elixir = queues.asip_queue.pop()
			core.write('sip ' + elixir)
		elif player.asip_balance == 1:
			core.enable_trigger('cure_enablers_elixirs', 'cure_enablers')
			player.asip_balance = .5
			core.write('sip ' + elixir)
		if player.asip_balance == .5:
			if now - queues.asip_queue.lastfire > 3:
				player.asip_balance = 1
Esempio n. 35
0
File: events.py Progetto: 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')
Esempio n. 36
0
File: libserp.py Progetto: AKJ/sage
def hypnosis_afflictions(line):
	affs = {
		#h(im|co|di|an|ma|ha|de|ag|ep|dea|pa|cl|am|st|hy|stu|re|ve|le)
		'him': 'impatience',
		'hco': 'confusion',
		'hdi': 'disrupt',
		'han': 'anorexia',
		'hma': 'masochism',
		'hha': 'hallucinations',
		'hde': 'dementia',
		'hag': 'agoraphobia',
		'hep': 'epilepsy',
		'hdea': 'deadening',
		'hpa': 'paranoia',
		'hcl': 'clumsiness',
		'ham': 'amnesia',
		'hst': 'stupidity',
		'hstu': 'stuttering',
		'hre': 'recklessness',
		'hve': 'vertigo',
		'hle': 'lethargy',
		'hypo': 'hypochondria'
	}
	core.write('suggest ' + player.target + ' ' + affs[line])
Esempio n. 37
0
#!/usr/bin/python

import core

core.load()
print("\n blog updated at " + core.write("index.html") + "\n")
Esempio n. 38
0
def main_menu():
    '''
    main navigation menu
    '''

    menuOptions = [
            "record your feels",
            "review your feels",
            "check out your neighbors",
            "browse global feels",
            "scribble some graffiti\t(new!)",
            "change your settings",
            "send some feedback",
            "see credits",
            "read documentation"]

    print("you're at ttbp home. remember, you can always press <ctrl-c> to come back here.\n")
    util.print_menu(menuOptions, RAINBOW)

    try:
        choice = raw_input("\ntell me about your feels (or 'quit' to exit): ")
    except KeyboardInterrupt:
        redraw(EJECT)
        return main_menu()

    if choice == '0':
        redraw()
        today = time.strftime("%Y%m%d")
        write_entry(os.path.join(DATA, today+".txt"))
        core.www_neighbors()
    elif choice == '1':
        if core.publishing():
            intro = "here are some options for reviewing your feels:"
            redraw(intro)
            review_menu(intro)
            core.load_files()
            core.write("index.html")
        else:
            redraw("your recorded feels, listed by date:")
            view_feels(USER)
    elif choice == '2':
        users = core.find_ttbps()
        redraw("the following "+p.no("user", len(users))+" "+p.plural("is", len(users))+" recording feels on ttbp:")
        view_neighbors(users)
    elif choice == '3':
        redraw("most recent global entries")
        view_feed()
    elif choice == '4':
        graffiti_handler()
    elif choice == '5':
        redraw("now changing your settings. press <ctrl-c> if you didn't mean to do this.")
        try:
            core.load(setup()) # reload settings to core
        except KeyboardInterrupt():
            redraw(EJECT)
        redraw()
    elif choice == '6':
        redraw("you're about to send mail to ~endorphant about ttbp")
        feedback_menu()
    elif choice == '7':
        redraw()
        show_credits()
    elif choice == '8':
        subprocess.call(["lynx", os.path.join(SOURCE, "..", "README.html")])
        redraw()
    elif choice in QUITS:
        return stop()
    else:
        redraw(INVALID)

    return main_menu()
Esempio n. 39
0
def update_version():
    '''
    updates user to current version
    '''

    global SETTINGS

    versionFile = os.path.join(PATH, "version")

    print("ttbp had some updates!")

    print("\ngive me a second to update you to version "+__version__+"...\n")

    time.sleep(1)
    print("...")
    time.sleep(2)

    userVersion = ""

    if not os.path.isfile(versionFile):
        # from 0.8.5 to 0.8.6:

        # change style.css location
        if os.path.isfile(os.path.join(WWW, "style.css")):
            subprocess.call(["mv", os.path.join(WWW, "style.css"), CONFIG])

        # change www symlink
        if os.path.exists(WWW):
            subprocess.call(["rm", WWW])
        
        subprocess.call(["mkdir", WWW])

        subprocess.call(["ln", "-s", os.path.join(CONFIG, "style.css"), os.path.join(WWW, "style.css")])

        publishDir = os.path.join(PUBLIC, SETTINGS.get("publish dir"))
        if os.path.exists(publishDir):
            subprocess.call(["rm", "-rf", publishDir])

        subprocess.call(["ln", "-s", WWW, os.path.join(PUBLIC, SETTINGS.get("publish dir"))])

        # repopulate html files
        core.load_files()
        core.write("index.html")

        # add publishing setting
        print("\nnew feature!\n")
        SETTINGS.update({"publishing":select_publishing()})
        update_publishing()
        ttbprc = open(TTBPRC, "w")
        ttbprc.write(json.dumps(SETTINGS, sort_keys=True, indent=2, separators=(',',':')))
        ttbprc.close()

    else: # version at least 0.8.6
        userVersion = open(versionFile, "r").read().rstrip()

        # from 0.8.6
        if userVersion == "0.8.6":
            print("\nresetting your publishing settings...\n")
            SETTINGS.update({"publishing":select_publishing()})
            update_publishing()
            ttbprc = open(TTBPRC, "w")
            ttbprc.write(json.dumps(SETTINGS, sort_keys=True, indent=2, separators=(',',':')))
            ttbprc.close()

    # increment user versionfile
    open(versionFile, "w").write(__version__)
    print("""
you're all good to go, """+chatter.say("friend")+"""! please contact ~endorphant if
somehing strange happened to you during this update.
""")

    # show patch notes
    #if userVersion != "0.9.0" and userVersion != "0.9.0b":
    if userVersion[0:5] < "0.9.0":
        # version 0.9.0 patch notes:
        print("""
ver. 0.9.0 features:
    * browsing other people's feels from neighbor view
    * documentation browser
        """)

    if userVersion[0:5] < "0.9.1":
        # version 0.9.1 patch notes
        print("""
ver 0.9.1 features:
    * graffiti wall
        """)