introduction of items
This commit is contained in:
@@ -9,7 +9,7 @@ import webview
|
||||
|
||||
import flask
|
||||
|
||||
from pylocal import core, desktop, dev, tick
|
||||
from pylocal import core, desktop, dev, items, tick
|
||||
|
||||
core.desktop_mode = True
|
||||
sig_exit = threading.Event()
|
||||
@@ -34,7 +34,7 @@ if __name__ == "__main__":
|
||||
storage_dir = pathlib.Path(os.environ["HOME"]) / "Library/Application Support/seagull"
|
||||
else:
|
||||
storage_dir = pathlib.Path(os.environ["HOME"]) / ".local/share/seagull"
|
||||
desktop.path_storagedir = pathlib.Path(storage_dir)
|
||||
desktop.path_storagedir = storage_dir
|
||||
|
||||
if argo.debug:
|
||||
desktop.api.debug_mode = True
|
||||
|
@@ -10,7 +10,7 @@ import threading
|
||||
import flask
|
||||
from gevent.pywsgi import WSGIServer
|
||||
|
||||
from pylocal import core, dev, tick
|
||||
from pylocal import core, dev, items, tick
|
||||
|
||||
sig_exit = threading.Event()
|
||||
|
||||
|
26
app/pylocal/items.py
Normal file
26
app/pylocal/items.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import subprocess
|
||||
import xml.etree.ElementTree as xmltree
|
||||
|
||||
from . import core
|
||||
|
||||
valid_resources = [
|
||||
"food", "shinies", "psi" # early game
|
||||
]
|
||||
|
||||
def generate_item(resource, target):
|
||||
if core.desktop_mode:
|
||||
rant_path = core.path_appdir / "opt/rant/bin/rant"
|
||||
else:
|
||||
rant_path = "rant" # rely on OS PATH
|
||||
proc_rant = subprocess.run([rant_path, (core.path_appdir / f"rant/{resource}/{target}.rant").as_posix()], capture_output=True)
|
||||
return proc_rant.stdout.decode()
|
||||
|
||||
class TickItem(object):
|
||||
def __init__(self, resource, amount, target):
|
||||
if resource not in valid_resources:
|
||||
raise TypeError
|
||||
|
||||
self.resource = resource
|
||||
self.amount = amount
|
||||
self.target = target
|
||||
self.desc = generate_item(resource, target)
|
@@ -4,7 +4,7 @@ import subprocess
|
||||
|
||||
import flask
|
||||
|
||||
from . import core
|
||||
from . import core, items
|
||||
|
||||
def generate_flavor_text():
|
||||
if core.desktop_mode:
|
||||
@@ -45,7 +45,11 @@ def tick():
|
||||
case 1: # FLAVOR
|
||||
result["log"] = generate_flavor_text()
|
||||
case 10: # ENCHUMAN
|
||||
result["items"] = {} # TODO: implement items
|
||||
result["items"] = {
|
||||
# TODO: read ranges from XML rule files
|
||||
"food": [items.TickItem("food", random.uniform(0.0, 20.0), "humans")],
|
||||
"shinies": [items.TickItem("food", random.uniform(0.0, 20.0), "humans")]
|
||||
}
|
||||
case _:
|
||||
core.log.warning("undefined tick: {0}".format(result["event_type"]))
|
||||
|
||||
|
53
app/rant/food/humans.rant
Normal file
53
app/rant/food/humans.rant
Normal file
@@ -0,0 +1,53 @@
|
||||
@require "../wordlist"
|
||||
[$desc_food] @text {
|
||||
{
|
||||
[pick: <wordlist/adjectives/food>] @weight 1.25 |
|
||||
[pick: <wordlist/adjectives/taste>] @weight 1.1 |
|
||||
[pick: <wordlist/names/cities/united_states>] @weight 1.1 |
|
||||
[pick: <wordlist/names/cities/canada>] @weight 0.9 |
|
||||
[pick: <wordlist/names/cities/spain>] @weight 0.75 |
|
||||
[pick: <wordlist/names/cities/alpha>] @weight 0.5 |
|
||||
{ # stuffed/filled/covered
|
||||
`{
|
||||
[pick: <wordlist/nouns/fruit>] @weight 1 |
|
||||
[pick: <wordlist/nouns/meat>] @weight 1 |
|
||||
[pick: <wordlist/nouns/food>] @weight 1 |
|
||||
[pick: <wordlist/nouns/cheese>] @weight 1 |
|
||||
[pick: <wordlist/nouns/condiments>] @weight 1 |
|
||||
[pick: <wordlist/nouns/music_theory>] @weight 0.5 |
|
||||
[pick: <wordlist/nouns/music_production>] @weight 0.5 |
|
||||
[pick: <wordlist/nouns/set_theory>] @weight 0.25 |
|
||||
[pick: <wordlist/nouns/ghosts>] @weight 0.33 |
|
||||
[pick: <wordlist/nouns/web_development>] @weight 0.25
|
||||
} `{stuffed|filled|covered|dipped|coated}
|
||||
} @weight 1 # stuffed/filled/covered
|
||||
}
|
||||
}
|
||||
|
||||
[$get_entree] @text {
|
||||
{
|
||||
[pick: <wordlist/nouns/food>] |
|
||||
[pick: <wordlist/nouns/fast_food>]
|
||||
}
|
||||
}
|
||||
|
||||
[$mod_order] @text {
|
||||
{
|
||||
add | no | sub | extra |
|
||||
half | left | right | side
|
||||
} `{
|
||||
[pick: <wordlist/nouns/condiments>] |
|
||||
[pick: <wordlist/nouns/cheese>] |
|
||||
[pick: <wordlist/nouns/food>] |
|
||||
[pick: <wordlist/nouns/seasonings>] |
|
||||
[pick: <wordlist/nouns/plants>]
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
a piece of `[pick: <wordlist/nouns/cheese>] |
|
||||
a `{
|
||||
[if: [%maybe]]{[desc_food]} [get_entree] |
|
||||
[pick: <wordlist/nouns/fruit>]
|
||||
}
|
||||
}
|
4
app/rant/shinies/humans.rant
Normal file
4
app/rant/shinies/humans.rant
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
a watch |
|
||||
a bracelet
|
||||
}
|
24
app/rules/items/humans.xml
Normal file
24
app/rules/items/humans.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0"?>
|
||||
<ItemRules>
|
||||
<Event>ENCHUMAN</Event>
|
||||
<Food>
|
||||
<Min>0</Min>
|
||||
<Max>10</Max>
|
||||
</Food>
|
||||
<Shinies>
|
||||
<Min>0</Min>
|
||||
<Max>20</Max>
|
||||
</Shinies>
|
||||
<Food StoryBeat=3>
|
||||
<Min>0</Min>
|
||||
<Max>20</Max>
|
||||
</Food>
|
||||
<Shinies StoryBeat=3>
|
||||
<Min>0</Min>
|
||||
<Max>50</Max>
|
||||
</Shinies>
|
||||
<Psi StoryBeat=3>
|
||||
<Min>0</Min>
|
||||
<Max>15</Max>
|
||||
</Psi>
|
||||
</ItemRules>
|
Reference in New Issue
Block a user