Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

More backend and event fixes pre-launch #208

Merged
merged 5 commits into from
Apr 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions deploy/web/configs/prod/config
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ main_act/model
/home/ubuntu/data/models/acting/model
--disable-builder
True
--is-logging
True
1 change: 1 addition & 0 deletions deploy/web/gameapp/src/GameRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const GameRouter = () => {
<HashRouter>
<Switch>
<Route path="/" component={GamePage} exact />
<Route path="/_=_" component={GamePage} exact />
<Route path="/profile" component={ProfilePage} exact />
</Switch>
</HashRouter>
Expand Down
2 changes: 1 addition & 1 deletion deploy/web/landingapp/src/pages/LandingPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const LandingPage = (props) => {
</div>
<div className="menu-container__section">
<div className="menu-container">
<a style={{ textDecoration: "none" }} href="/play">
<a style={{ textDecoration: "none" }} href="/play/">
<div className="menu-item ">
<h1>Play Now</h1>
</div>
Expand Down
2 changes: 1 addition & 1 deletion deploy/web/server/html/landing.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ <h3>Usage terms</h3>
playing the game.
</p>

<a href="/play"><h1>Play Now</h1></a>
<a href="/play/"><h1>Play Now</h1></a>
</body>
</html>
16 changes: 16 additions & 0 deletions deploy/web/server/run_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,16 @@ def main():
DEFAULT_PORT = 35494
DEFAULT_HOSTNAME = "localhost"

def str2bool(v):
if isinstance(v, bool):
return v
if v.lower() in ("yes", "true", "t", "y", "1"):
return True
elif v.lower() in ("no", "false", "f", "n", "0"):
return False
else:
raise argparse.ArgumentTypeError("Boolean value expected.")

parser = argparse.ArgumentParser(
description="Start the game server.", fromfile_prefix_chars="@"
)
Expand Down Expand Up @@ -245,6 +255,12 @@ def main():
type=str,
default="",
)
parser.add_argument(
"--is-logging",
type=str2bool,
default=False,
help="flag to enable storing logs of interactions",
)
FLAGS, _unknown = parser.parse_known_args()

print(FLAGS)
Expand Down
2 changes: 1 addition & 1 deletion deploy/web/server/tests/test_tornado_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ def test_landing_page_redirect(self, mocked_auth):
headers = {"Content-Type": "application/json"}
with self.assertRaises(httpclient.HTTPClientError) as cm:
response = yield self.client.fetch(
f"{URL}/play",
f"{URL}/play/",
method="GET",
headers=headers,
follow_redirects=False,
Expand Down
5 changes: 3 additions & 2 deletions deploy/web/server/tornado_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ def get_handlers(self, database, hostname=DEFAULT_HOSTNAME, password="LetsPlay")
(r"/#/error", NotFoundHandler, {"database": database}),
(r"/play", GameHandler, {"database": database}),
(r"/play/?id=.*", GameHandler, {"database": database}),
(r"/play/*", GameHandler, {"database": database}),
(r"/build", BuildHandler, {"database": database}),
(
r"/login",
Expand Down Expand Up @@ -501,7 +502,7 @@ async def get(self):
code=self.get_argument("code"),
)
self.set_current_user(fb_user["id"])
self.redirect("/play")
self.redirect("/play/")
return
self.authorize_redirect(
redirect_uri=redirect,
Expand Down Expand Up @@ -542,7 +543,7 @@ def post(self):
_ = ldb.create_user(name)
self.set_current_user(name)
# self.redirect(self.get_argument("next", "/"))
self.redirect("/play")
self.redirect("/play/")
else:
error_msg = "?error=" + tornado.escape.url_escape("incorrect")
self.redirect("/#/login" + error_msg)
Expand Down
1 change: 1 addition & 0 deletions light/graph/builders/map_json_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def get_graph(self):
data = f.read()
f.close()
g = OOGraph.from_json(data)
g._opt = self.opt
self.original_agents = {
agent.name: (agent.get_room(), agent.get_props())
for agent in g.agents.values()
Expand Down
19 changes: 18 additions & 1 deletion light/graph/events/graph_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,23 @@ def view_as(self, viewer: GraphAgent) -> Optional[str]:
class SpeechEvent(GraphEvent):
"""Base speaking class mostly to handle dialogue safety."""

def __init__(
self,
actor: GraphAgent,
target_nodes: Optional[List[GraphNode]] = None,
text_content: Optional[str] = None,
event_id: Optional[str] = None,
):
super().__init__(
actor,
target_nodes=target_nodes,
text_content=text_content,
event_id=event_id,
)
# Give opportunity to skip the safety after initialization
# for debug reasons
self.skip_safety = False

def is_dialogue_safe(self, text):
if safety_classifier is None:
self.safe = True
Expand All @@ -109,7 +126,7 @@ def execute(self, world: "World") -> List[GraphEvent]:
"""On execution, store the expected views, then broadcast"""
assert not self.executed
actor_name = self.actor.get_prefix_view()
if self.is_dialogue_safe(self.text_content):
if self.skip_safety or self.is_dialogue_safe(self.text_content):
self.__in_room_view = f'{actor_name} said "{self.text_content}"'
self.__self_view = None
else:
Expand Down
Loading