introduction of items
This commit is contained in:
parent
68ef7c1591
commit
eb9e9476ef
@ -9,7 +9,7 @@ import webview
|
|||||||
|
|
||||||
import flask
|
import flask
|
||||||
|
|
||||||
from pylocal import core, desktop, dev, tick
|
from pylocal import core, desktop, dev, items, tick
|
||||||
|
|
||||||
core.desktop_mode = True
|
core.desktop_mode = True
|
||||||
sig_exit = threading.Event()
|
sig_exit = threading.Event()
|
||||||
@ -34,7 +34,7 @@ if __name__ == "__main__":
|
|||||||
storage_dir = pathlib.Path(os.environ["HOME"]) / "Library/Application Support/seagull"
|
storage_dir = pathlib.Path(os.environ["HOME"]) / "Library/Application Support/seagull"
|
||||||
else:
|
else:
|
||||||
storage_dir = pathlib.Path(os.environ["HOME"]) / ".local/share/seagull"
|
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:
|
if argo.debug:
|
||||||
desktop.api.debug_mode = True
|
desktop.api.debug_mode = True
|
||||||
|
@ -10,7 +10,7 @@ import threading
|
|||||||
import flask
|
import flask
|
||||||
from gevent.pywsgi import WSGIServer
|
from gevent.pywsgi import WSGIServer
|
||||||
|
|
||||||
from pylocal import core, dev, tick
|
from pylocal import core, dev, items, tick
|
||||||
|
|
||||||
sig_exit = threading.Event()
|
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
|
import flask
|
||||||
|
|
||||||
from . import core
|
from . import core, items
|
||||||
|
|
||||||
def generate_flavor_text():
|
def generate_flavor_text():
|
||||||
if core.desktop_mode:
|
if core.desktop_mode:
|
||||||
@ -45,7 +45,11 @@ def tick():
|
|||||||
case 1: # FLAVOR
|
case 1: # FLAVOR
|
||||||
result["log"] = generate_flavor_text()
|
result["log"] = generate_flavor_text()
|
||||||
case 10: # ENCHUMAN
|
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 _:
|
case _:
|
||||||
core.log.warning("undefined tick: {0}".format(result["event_type"]))
|
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>
|
@ -1,3 +1,5 @@
|
|||||||
function structuredClone(val) {
|
function structuredClone(val) {
|
||||||
return JSON.parse(JSON.stringify(val));
|
var output = JSON.parse(JSON.stringify(val));
|
||||||
|
if (window.pywebview.api.debug_mode) { console.log(("structuredClone:" + val) + " => " + outval); }
|
||||||
|
return output;
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
var desktop_mode = true;
|
var desktop_mode = true;
|
||||||
|
var tick_meter_running = false;
|
||||||
|
|
||||||
async function prepare_gamestate() {
|
async function prepare_gamestate() {
|
||||||
var gamestate_loaded = null;
|
var gamestate_loaded = null;
|
||||||
@ -18,6 +19,8 @@ async function prepare_gamestate() {
|
|||||||
gamestate = JSON.parse(gamestate_loaded);
|
gamestate = JSON.parse(gamestate_loaded);
|
||||||
record_log("Welcome back! Game loaded.")
|
record_log("Welcome back! Game loaded.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tick_meter_running = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function save_game() {
|
function save_game() {
|
||||||
@ -25,8 +28,6 @@ function save_game() {
|
|||||||
record_log("Game saved.");
|
record_log("Game saved.");
|
||||||
}
|
}
|
||||||
|
|
||||||
var tick_meter_running = true;
|
|
||||||
|
|
||||||
function reset_game() {
|
function reset_game() {
|
||||||
tick_meter_running = false;
|
tick_meter_running = false;
|
||||||
window.pywebview.api.delete_data("gamestate");
|
window.pywebview.api.delete_data("gamestate");
|
||||||
|
@ -12,6 +12,7 @@ const gamestate_default = {
|
|||||||
"statever": "1",
|
"statever": "1",
|
||||||
"tick": 1,
|
"tick": 1,
|
||||||
"name": "Nameless",
|
"name": "Nameless",
|
||||||
|
"class": "Seaglet",
|
||||||
"level": 1,
|
"level": 1,
|
||||||
"shinies": 0,
|
"shinies": 0,
|
||||||
"colony": 1,
|
"colony": 1,
|
||||||
@ -19,7 +20,9 @@ const gamestate_default = {
|
|||||||
"autosave": 35,
|
"autosave": 35,
|
||||||
"story_beat": 0,
|
"story_beat": 0,
|
||||||
"xp": 0,
|
"xp": 0,
|
||||||
"xp_next": 50
|
"xp_next": 50,
|
||||||
|
"enc_human": "pause",
|
||||||
|
"enc_seagull": "pause"
|
||||||
};
|
};
|
||||||
|
|
||||||
var bool_log_alt = false
|
var bool_log_alt = false
|
||||||
@ -48,6 +51,8 @@ function update_ui() {
|
|||||||
page_elements["lbl_colony"].innerHTML = gamestate["colony"];
|
page_elements["lbl_colony"].innerHTML = gamestate["colony"];
|
||||||
page_elements["lbl_shinies"].innerHTML = gamestate["shinies"];
|
page_elements["lbl_shinies"].innerHTML = gamestate["shinies"];
|
||||||
page_elements["lbl_food"].innerHTML = gamestate["food"];
|
page_elements["lbl_food"].innerHTML = gamestate["food"];
|
||||||
|
page_elements["lbl_xp"].innerHTML = gamestate["xp"];
|
||||||
|
page_elements["lbl_xp_next"].innerHTML = gamestate["xp_next"];
|
||||||
}
|
}
|
||||||
|
|
||||||
var dev_toolbox_open = false;
|
var dev_toolbox_open = false;
|
||||||
@ -96,9 +101,8 @@ async function game_tick() {
|
|||||||
} else if (tickdata["event_type"] == 1) {
|
} else if (tickdata["event_type"] == 1) {
|
||||||
// Flavor event - no gameplay effect, but occasionally says something fun.
|
// Flavor event - no gameplay effect, but occasionally says something fun.
|
||||||
record_log(tickdata["log"]);
|
record_log(tickdata["log"]);
|
||||||
} else if (tickdata["event_type"] == 10) {
|
} else if (tickdata["event_type"] == 10) { // ENCHUMAN
|
||||||
// Human encounter. This is a stub.
|
|
||||||
record_log("You have encountered a human.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// sanity check
|
// sanity check
|
||||||
@ -134,6 +138,7 @@ target.addEventListener(start_event, function (ev) {
|
|||||||
page_elements["div_name"] = document.querySelector("#side-seagull-name");
|
page_elements["div_name"] = document.querySelector("#side-seagull-name");
|
||||||
page_elements["div_name_editor"] = document.querySelector("#side-seagull-name-editor");
|
page_elements["div_name_editor"] = document.querySelector("#side-seagull-name-editor");
|
||||||
page_elements["lbl_name"] = document.querySelector("#lbl-seagull-name");
|
page_elements["lbl_name"] = document.querySelector("#lbl-seagull-name");
|
||||||
|
page_elements["lbl_class"] = document.querySelector("#lbl-seagull-class");
|
||||||
page_elements["lbl_colony"] = document.querySelector("#lbl-seagull-colony");
|
page_elements["lbl_colony"] = document.querySelector("#lbl-seagull-colony");
|
||||||
page_elements["lbl_shinies"] = document.querySelector("#lbl-seagull-shinies");
|
page_elements["lbl_shinies"] = document.querySelector("#lbl-seagull-shinies");
|
||||||
page_elements["lbl_food"] = document.querySelector("#lbl-seagull-food");
|
page_elements["lbl_food"] = document.querySelector("#lbl-seagull-food");
|
||||||
@ -141,6 +146,8 @@ target.addEventListener(start_event, function (ev) {
|
|||||||
page_elements["lbl_tick"] = document.querySelector("#main-day-counter");
|
page_elements["lbl_tick"] = document.querySelector("#main-day-counter");
|
||||||
page_elements["lbl_xp"] = document.querySelector("#lbl-seagull-xp-current");
|
page_elements["lbl_xp"] = document.querySelector("#lbl-seagull-xp-current");
|
||||||
page_elements["lbl_xp_next"] = document.querySelector("#lbl-seagull-xp-next");
|
page_elements["lbl_xp_next"] = document.querySelector("#lbl-seagull-xp-next");
|
||||||
|
page_elements["menu_enc_human"] = document.querySelector("#menu-enc-human");
|
||||||
|
page_elements["menu_enc_seagull"] = document.querySelector("#menu-enc-seagull");
|
||||||
|
|
||||||
prepare_gamestate().then(update_ui());
|
prepare_gamestate().then(update_ui());
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user