AdaCode / elist2.xml

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Monday, December 03, 2012, 12:00 PM -->
<!-- MuClient version 4.77 -->

<!-- Plugin "Elist2" generated by Plugin Wizard -->

<muclient>
<plugin
   name="Elist2"
   author="Ada"
   id="bfec5e22c152db0c56821f27"
   language="Python"
   purpose="Vial management"
   date_written="2013-01-04 12:00:00"
   requires="4.62"
   version="1.0"
   >
<description trim="y">
<![CDATA[
While ELIXLIST in Vision is of great utility in itself, a brief summary is often more useful than a raw list. This plugin rewrites the output from ELIXLIST and VENOMLIST and displays a short summary of vials in your inventory. Additionally it also automates the task of pouring old vials into new ones so you can safely feed empty vials to your favorite humgii with good conscience.

This plugin is written in Python, please see this page to setup Python on your computer: http://adayoung.bitbucket.org/pythonsqlite.html

The following aliases are available:

    Elist2 - Display a summary of all vials (except venoms) held in your inventory
    Vlist2 - Display a summary of all venoms held in your inventory
             (Do Elist2 first to let it collect empty vials if you intend to 'repour')

    Elist2:Repour - Pour contents of old and decaying vials into fresh empty vials
    Elist2:Reshift - Re-arrange vials in your inventory in order of decay time

The algorithm in the 'repour' alias makes sure that vials with the longest lifespan have the most amount of any fluid available in them. This ensures you don't lose much even if you do end up with vials decaying before you've had a chance to buy new ones.

The algorithm in the 'reshift' alias makes sure vials are arranged in the order of decay time in your inventory, if you 'repour'red your vials before hitting this alias, you'll have the added benefit of sipping from vials in a sensible order. Not to mention that'll also prevent you from sipping yucky salves due to stupidity since the first vial in your inventory is likely to be empty.
]]>
</description>

</plugin>

<!--  Get our standard constants -->

<include name="constants.pys"/>

<!--  Triggers  -->

<triggers>
  <trigger
   group="Elist2"
   enabled="n"
   keep_evaluating="y"
   match="^Vial\s+(Fluid|Venom)\s+(Sips|Doses)\s+Months Left$"
   name="ListPreamble"
   omit_from_output="y"
   regexp="y"
   send_to="12"
   sequence="900"
  >
  <send>
world.EnableTrigger("ListPreamble", False)
world.EnableTrigger("HorizontalLine", True)
world.EnableTrigger("VialInfo", True)
world.EnableTrigger("PromptCaptureElist2", True)
  </send>
  </trigger>
  <trigger
   group="Elist2"
   enabled="n"
   keep_evaluating="y"
   match="^\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-"
   name="HorizontalLine"
   omit_from_output="y"
   regexp="y"
   send_to="12"
   sequence="900"
  >
  <send>
world.EnableTrigger("HorizontalLine", False)
  </send>
  </trigger>
  <trigger
   group="Elist2"
   enabled="n"
   keep_evaluating="y"
   match="^Vial(\d+)\s+(.+?)\s+(\d+)\s+(\d+)$"
   name="VialInfo"
   omit_from_output="y"
   regexp="y"
   send_to="12"
   sequence="900"
  >
  <send>
ProcessVial("%1", "%2", int("%3"), int("%4"))
  </send>
  </trigger>
  <trigger
   group="Elist2"
   enabled="n"
   keep_evaluating="y"
   match="^\d+h(, \d+m)?(, \d+e)?(, \d+w)? [@cexkdb]*(?: Vote)?-"
   name="PromptCaptureElist2"
   regexp="y"
   send_to="12"
   sequence="900"
  >
  <send>
world.EnableTrigger("VialInfo", False)
world.EnableTrigger("PromptCaptureElist2", False)
DisplayVials()
  </send>
  </trigger>
</triggers>

<!--  Aliases  -->

<aliases>
  <alias
   match="^(E|V)list2$"
   enabled="y"
   group="Elist2"
   regexp="y"
   send_to="12"
   ignore_case="y"
   sequence="100"
  >
  <send>
vial_table = []
if "%1".lower() == "e":
  empty_vials = []
world.EnableTrigger("ListPreamble", True)
world.SendNoEcho("%sLIST2" % "%1")
  </send>
  </alias>
  <alias
   match="^(E|V)list2:repour$"
   enabled="y"
   group="Elist2"
   regexp="y"
   send_to="12"
   ignore_case="y"
   sequence="100"
  >
  <send>
RePourVials()
  </send>
  </alias>
  <alias
   match="^(E|V)list2:reshift$"
   enabled="y"
   group="Elist2"
   regexp="y"
   send_to="12"
   ignore_case="y"
   sequence="100"
  >
  <send>
ReShiftVials()
  </send>
  </alias>
  <alias
   match="^(?:E|V)list2:test (.*?)$"
   enabled="y"
   group="Elist2"
   regexp="y"
   send_to="12"
   ignore_case="y"
   sequence="100"
  >
  <send>exec("%1")</send>
  </alias>
</aliases>

<!--  Script  -->

<script>
<![CDATA[
def Note(message): # not writing world.Note everywhere ^_^
    world.Note(message)

elixir_map = [
    ("frost", "endothermia"),
    ("health", "vitality"),
    ("immunity", "antigen"),
    ("levitation", "hovering"),
    ("mana", "mentality"),
    ("speed", "haste"),
    ("venom", "toxin"),
]

salve_map = [
    ("caloric", "exothermic"),
    ("epidermal", "sensory"),
    ("mass", "density"),
    ("mending", "renewal"),
    ("restoration", "reconstructive"),
]

vial_table = []
empty_vials = []

def ProcessVial(vial_id, fluid, sips, lifespan):
    if fluid != 'empty':
        vial_table.append((vial_id, fluid, sips, lifespan))
    else:
        empty_vials.append((vial_id, fluid, sips, lifespan))

def DisplayVials():
    global vial_table
    vial_table_full = vial_table[:]
    vial_table_full.extend(empty_vials)
    vial_summary = {}
    vial_totals = {
        'total_sips' : 0,
        'total_vials' : 0,
    }
    for (vial_id, fluid, sips, lifespan) in vial_table_full:
        if not vial_summary.has_key(fluid):
            vial_summary[fluid] = {
                'total_sips' : 0,
                'lifespan_min' : 999,
                'lifespan_max' : 0,
                'total_vials' : 0,
            }
        vial_summary[fluid]['total_sips'] += sips
        vial_totals['total_sips'] += sips
        if vial_summary[fluid]['lifespan_min'] > lifespan:
            vial_summary[fluid]['lifespan_min'] = lifespan
        if vial_summary[fluid]['lifespan_max'] < lifespan:
            vial_summary[fluid]['lifespan_max'] = lifespan
        vial_summary[fluid]['total_vials'] += 1
        vial_totals['total_vials'] += 1
    fluids = vial_summary.keys()
    fluids.sort()
    Note("----------------------------------------------------------------------")
    Note("Fluid                            Life Span    # of vials    Total sips")
    Note("----------------------------------------------------------------------")
    for i in fluids:
        fluid = i
        lifespan = "%d-%d" % (vial_summary[i]['lifespan_min'], vial_summary[i]['lifespan_max'])
        total_vials = str(vial_summary[i]['total_vials'])
        total_sips = str(vial_summary[i]['total_sips'])

        if len(fluid) < 34:
            fluid += " "*(33 - len(fluid))
        else:
            fluid = fluid[:33] + " "

        if len(lifespan) < 15:
            lifespan += " "*(14 - len(lifespan))
        else:
            lifespan = lifespan[:14] + "   "

        if len(total_vials) < 12:
            total_vials += " "*(11 - len(total_vials))
        else:
            total_vials = total_vials[:11] + " "

        if len(total_sips) < 10:
            total_sips = " "*(9 - len(total_sips)) + total_sips
        else:
            total_sips = " " + total_sips[:9]

        Note("%s %s %s %s" % (fluid, lifespan, total_vials, total_sips))
    Note("----------------------------------------------------------------------")

    total_vials = str(vial_totals['total_vials'])
    total_sips = str(vial_totals['total_sips'])

    if len(total_vials) < 12:
        total_vials += " "*(11 - len(total_vials))
    else:
        total_vials = total_vials[11:] + " "

    if len(total_sips) < 10:
        total_sips = " "*(9 - len(total_sips)) + total_sips
    else:
        total_sips = " " + total_sips[:9]

    Note("Total                                            %s %s" % (total_vials, total_sips))
    Note("----------------------------------------------------------------------")

def RePourVials():
    global vial_table
    global empty_vials
    vial_table.extend(empty_vials)
    vials = sorted(vial_table, VialCompare)

    for i in range(len(vials)):
        vials[i] = list(vials[i])

    while len(vials) > 0:
        (f_vial, f_fluid, f_sips, f_lifespan) = vials.pop(0)
        for i in range(len(vials) - 1, -1, -1):
            (l_vial, l_fluid, l_sips, l_lifespan) = vials[i]
            if (l_fluid == f_fluid or l_fluid == 'empty') and l_sips < 200:

                if f_sips <= 0:
                    break

                world.SendNoEcho("POUR %s INTO %s" % (f_vial, l_vial))

                vials[i][1] = f_fluid # to update 'empty' vials
                vials[i][2] = l_sips + f_sips

                f_sips = l_sips + f_sips - 200

    vial_table = []
    empty_vials = []

def VialCompare(a, b):
    if a[3] < b[3]:
        return -1
    elif a[3] > b[3]:
        return 1
    else:
        return 0

def ReShiftVials():
    Note("Elist2: Oops, this isn't implemented yet.")
]]>
</script>

<!--  Plugin help  -->

<aliases>
  <alias
   script="OnHelp"
   match="(E|V)list2:help"
   ignore_case="y"
   regexp="y"
   enabled="y"
  >
  </alias>
</aliases>

<script>
<![CDATA[
def OnHelp (a, b, c):
    world.note (world.GetPluginInfo (world.GetPluginID, 3))
]]>
</script>

</muclient>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.