Editorial Workflows

Monsters

public workflow

Install Workflow...

This workflow contains at least one Python script. Only use it if you trust the person who shared this with you, and if you know exactly what it does.

I understand, install the workflow!

This is a workflow for Editorial, a Markdown and plain text editor for iOS. To download it, you need to view this page on a device that has the app installed.

Description: Select a monster from Adventurer Conqueror King and pull their stats directly into your Editorial document. Requires the Monsters.txt data file installed in ACKS data directory to function.

Data files available in Dropbox folder: https://www.dropbox.com/sh/ghopk6jhloiqs5y/rV7ggkYpdr

Shared by: Chris Allison

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Get File Contents ?
File Name
ACKS data/Monsters.txt
In Dropbox
OFF
If File Does Not Exist
  • Empty Output
  • Stop Workflow
Set Variable ?
Variable Name
monster_dict
Value
Input
Run Python Script ?
Source Code
#coding: utf-8
import workflow, ast

monster_dict = {}
monster_dict = ast.literal_eval(workflow.get_variable('monster_dict'))

#TODO: Generate the output...

action_out = []
for key in monster_dict:
	action_out.append(key)

list_text = ''
list_text = '\n'.join(action_out)

workflow.set_output(list_text)
Sort Lines ?
Sort Order
  • Ascending (A → Z)
  • Descending (Z → A)
Select from List ?
Title
Monster Select
List (Lines)
Input
Multiple Selection
OFF
Show in Popover
OFF
Set Variable ?
Variable Name
monster
Value
Input
Run Python Script ?
Source Code
#coding: utf-8
import workflow, ast, random

monster = workflow.get_variable('monster')

monster_dict = {}
monster_dict = ast.literal_eval(workflow.get_variable('monster_dict'))

def roll_em(dice,pips,mods):
	total = 0
	for die in range(1,dice+1):
		total += random.randint(1,pips)
	total += mods
	if mods > 0:
		text = '>Rolled {}d{}+{}. Your result is **{}**.'.format(dice,pips,mods,total)
	elif mods < 0:
		text = '>Rolled {}d{}{}. Your result is **{}**.'.format(dice,pips,mods,total)
	else:
		text = '>Rolled {}d{}. Your result is **{}**.'.format(dice,pips,total)
	return total

# Basic encounter function called by the map.
def encounter(monster):
		mon_dict = monster_dict[monster]

		# Determining the number of creatures encountered, the distance (as per a wooded encounter) and surprise.
		tot_enc = 0
		if int(mon_dict['Enc Pips']) == 1:
			tot_enc = 1
			enc1 = "**Encounter: {} {}**.<br>".format(tot_enc,monster)
		else:
			tot_enc = roll_em(int(mon_dict['Enc Dice']),int(mon_dict['Enc Pips']),0)
			
			enc1 = "**Encounter: {} {}**.<br>".format(tot_enc,mon_dict['Natural Spelling Plural'])

		# Determining hit dice and hit points for creatures (NOTE: I screwed up some low hp creatures in the CSV file.  Will need to fix.)
		hd = 1
		hp = []
		x = 0
		
		try:
			int(mon_dict['HD'])
		except ValueError:
			raise
			mon_dict['HD'] = 1
			for i in range(1,100):
				print '********************'+mon_dict[""]+'**********************'
		
		num_beasties = 0
		if tot_enc > 26:
			num_beasties = 26
		else:
			num_beasties = tot_enc

		if int(mon_dict['Pips']) == 0:
			hd = str(mon_dict['HD'])
			for beast in range(1,num_beasties+1):
				x = roll_em(int(mon_dict['HD']),8,0)
				hp.append(x)

		elif mon_dict['HD'] in (0,'',""):
			hd = str(mon_dict['Pips'])+'hp'
			for beast in range(1,num_beasties+1):
				x = mon_dict['Pips']
				hp.append(x)
		else:
			hd = str(mon_dict['HD'])+'+'+str(mon_dict['Pips'])
			for beast in range(1,num_beasties+1):
				x = roll_em(int(mon_dict['HD']),8,int(mon_dict['Pips']))
				hp.append(x)

		if mon_dict['2nd Move Type'] == '':
			two_move = 'None'
		else:
			two_move = mon_dict['2nd Move Type']+" "+mon_dict['2nd Move Spd']

		# Final part of the stat block and returning the full script to the map.
		enc3 = '**Al**: {}, **Move**: {}, **Alt**: {}, **AC**: {}, **HD**: {}<br>**HP**: {}<br>**Atk**: {}, **Dam**: {}<br>**Save**: {}, **Morale**: {}, **Treasure**: {}, **XP**: {} (total {}xp)<br> **Special**: {}.'.format(mon_dict['Align'],mon_dict['Move'],two_move,str(mon_dict['AC']),str(hd),str(hp).strip('[]'),mon_dict['Attacks'],mon_dict['Damage'],mon_dict['Save'],str(mon_dict['Morale']),str(mon_dict['Treasure Type']),str(mon_dict['XP']),int(mon_dict['XP'])*num_beasties,mon_dict['Special Attack'])
		full_text = enc1+'\n'+enc3
		#print(full_text)
		#print('')
		return full_text

workflow.set_output(encounter(monster))
Replace Selected Text ?
Replacement Text
Input