flavor text, autosaves
This commit is contained in:
		@@ -1,8 +1,22 @@
 | 
			
		||||
 | 
			
		||||
import os
 | 
			
		||||
import sys
 | 
			
		||||
 | 
			
		||||
import flask
 | 
			
		||||
 | 
			
		||||
app = flask.Flask("seagull-game", root_path="/app")
 | 
			
		||||
orig_url_for = app.url_for
 | 
			
		||||
 | 
			
		||||
def url_for_override(endpoint, *posargs, _anchor=None, _method=None, _scheme=None, _external=None, self=app, **values):
 | 
			
		||||
    if endpoint == "static":
 | 
			
		||||
        # bandaid for #1
 | 
			
		||||
        if not os.path.exists("/app/static/" + values["filename"]):
 | 
			
		||||
            sys.stderr.write("WARN:: requested {0} from local file, but it doesn't exist in this container. Redirecting to CDN...\n".format(values["filename"]))
 | 
			
		||||
            sys.stderr.flush()
 | 
			
		||||
            return "https://cdn.otl-hga.net/seagull/" + values["filename"]
 | 
			
		||||
    
 | 
			
		||||
    return orig_url_for(endpoint, *posargs, _anchor=_anchor, _method=_method, _scheme=_scheme, _external=_external, **values)
 | 
			
		||||
 | 
			
		||||
app.url_for = url_for_override
 | 
			
		||||
 | 
			
		||||
base_context = {}
 | 
			
		||||
base_context_live = False
 | 
			
		||||
@@ -23,9 +37,9 @@ def render_base_context():
 | 
			
		||||
        base_context["seagull_pic"] = "https://cdn.otl-hga.net/seagull/image/seagull.jpg"
 | 
			
		||||
    else:                            # dev, serve files from here
 | 
			
		||||
        print(base_domain)
 | 
			
		||||
        base_context["styles"] = [flask.url_for("static", filename="css/seagull.css")]
 | 
			
		||||
        base_context["scripts"] = [flask.url_for("static", filename="js/seagull.js")]
 | 
			
		||||
        base_context["seagull_pic"] = flask.url_for("static", filename="image/seagull.jpg")
 | 
			
		||||
        base_context["styles"] = [app.url_for("static", filename="css/seagull.css")]
 | 
			
		||||
        base_context["scripts"] = [app.url_for("static", filename="js/seagull.js")]
 | 
			
		||||
        base_context["seagull_pic"] = app.url_for("static", filename="image/seagull.jpg")
 | 
			
		||||
 | 
			
		||||
    base_context_live = True
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,13 @@
 | 
			
		||||
import json
 | 
			
		||||
import random
 | 
			
		||||
import subprocess
 | 
			
		||||
 | 
			
		||||
from . import core
 | 
			
		||||
 | 
			
		||||
def generate_flavor_text():
 | 
			
		||||
    proc_rant = subprocess.run(["rant", "/app/rant/flavor.rant"], capture_output=True)
 | 
			
		||||
    return proc_rant.stdout.decode()
 | 
			
		||||
 | 
			
		||||
@core.app.route("/tick")
 | 
			
		||||
def tick():
 | 
			
		||||
    return random.choices([json.dumps({"code": 200, "event_type": 0}), json.dumps({"code": 200, "event_type": 1, "log": "The server chose a flavor text event, which hasn't been fully implemented yet."})], weights=[16, 1])[0]
 | 
			
		||||
    return random.choices([json.dumps({"code": 200, "event_type": 0}), json.dumps({"code": 200, "event_type": 1, "log": generate_flavor_text()})], weights=[16, 1])[0]
 | 
			
		||||
							
								
								
									
										26
									
								
								app/rant/flavor.rant
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								app/rant/flavor.rant
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
			
		||||
@require "wordlist"
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
    You meet {
 | 
			
		||||
        a `[pick: <wordlist/nouns/birds>] |
 | 
			
		||||
        `{
 | 
			
		||||
            [pick: <wordlist/names/people/butlers>] |
 | 
			
		||||
            [pick: <wordlist/names/people/computing>] |
 | 
			
		||||
            [pick: <wordlist/names/people/founders>] |
 | 
			
		||||
            [pick: <wordlist/names/streets/chicago>] |
 | 
			
		||||
            [pick: <wordlist/names/streets/newyork>] |
 | 
			
		||||
            [pick: <wordlist/names/surnames/english>] |
 | 
			
		||||
            [pick: <wordlist/names/surnames/irish>] |
 | 
			
		||||
            [pick: <wordlist/names/surnames/scottish>]
 | 
			
		||||
        } the `[pick: <wordlist/nouns/birds>]
 | 
			
		||||
    }. {
 | 
			
		||||
        It completely ignores you. |
 | 
			
		||||
        You have a polite conversation about birdly affairs. |
 | 
			
		||||
        It scoffs and flies away.
 | 
			
		||||
    }
 | 
			
		||||
    |
 | 
			
		||||
    You encounter a human and attempt to steal their `{
 | 
			
		||||
        [pick: <wordlist/nouns/food>] |
 | 
			
		||||
        [pick: <wordlist/nouns/fast_food>]
 | 
			
		||||
    }.
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										172
									
								
								app/rant/wordlist.rant
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										172
									
								
								app/rant/wordlist.rant
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@@ -24,7 +24,7 @@
 | 
			
		||||
    <div id="side-seagull-stats">
 | 
			
		||||
        <p id="side-seagull-lvl">Lv 1 LoadError</p>
 | 
			
		||||
        <p id="side-seagull-misc">
 | 
			
		||||
            Colony: 1337<br />
 | 
			
		||||
            Colony: <span id="lbl-seagull-colony">1337</span><br />
 | 
			
		||||
            Shinies: 420<br />
 | 
			
		||||
        </p>
 | 
			
		||||
    </div>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user