Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update v0.15.0 #43

Merged
merged 6 commits into from
Oct 8, 2023
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
44 changes: 23 additions & 21 deletions llm_config.yaml

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions stories/prancingllama/story.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ def create_account_dialog(self, playerconnection: PlayerConnection, playernaming
Ask questions using the yield "input", "question?" mechanism.
Return True to declare all is well, and False to abort the player creation process.
"""
age = yield "input", "Custom creation question: What is your age?"
playernaming.story_data["age"] = int(age) # will be stored in the database (mud)
occupation = yield "input", "Custom creation question: What is your trade?"
playernaming.story_data["occupation"] = str(occupation) # will be stored in the database (mud)
return True
Expand Down
7 changes: 7 additions & 0 deletions stories/teaparty/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""
Package containing a demo room and some stuff, to easily check out
a running Tale framework (python -m tale.demo.story)

'Tale' mud driver, mudlib and interactive fiction framework
Copyright by Irmen de Jong ([email protected])
"""
35 changes: 35 additions & 0 deletions stories/teaparty/npcs/guests.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[
{
"name":"Mad Hatter",
"gender":"m",
"race":"human",
"type":"LivingExt",
"title":"Mad Hatter",
"personality":"The Mad Hatter from Lewis Carrol's Alice in Wonderland. He is a bit crazy and has a strange sense of humor.",
"descr":"Wearing a big hat and a colorful costume.",
"short_descr":"A man with a big hat and colorful costume.",
"location":"Mad Hatters House.Living Room"
},
{
"name":"Duchess",
"gender":"f",
"race":"human",
"type":"LivingExt",
"title":"Duchess",
"personality":"The Duchess from Lewis Carrol's Alice in Wonderland. Volatile and aggressive personality.",
"descr":"Very big head. Tall enough to rest her chin upon Alice’s shoulder, uncomfortably sharp chin.",
"short_descr": "Short woman with a very large head.",
"location":"Mad Hatters House.Living Room"
},
{
"name":"Ace of Spades",
"gender":"m",
"race":"human",
"type":"LivingExt",
"title":"Ace of Spades",
"personality":"A drunken ex-rock star. Like a talkative Ozzy Osbourne if he were in Alice in Wonderland.",
"descr":"Thin man with eyeliner and a vacant expression. Wearing a black leather jacket and a black top hat.",
"short_descr": "A man with leather jacket and a black top hat.",
"location":"Mad Hatters House.Living Room"
}
]
30 changes: 30 additions & 0 deletions stories/teaparty/story.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

import pathlib
import sys
from tale import parse_utils
from tale.driver import Driver
from tale.driver_if import IFDriver
from tale.json_story import JsonStory
from tale.main import run_from_cmdline
from tale.zone import Zone


class Story(JsonStory):

driver = None

def __init__(self) -> None:
super(Story, self).__init__('', parse_utils.load_story_config(parse_utils.load_json('story_config.json')))

def init(self, driver: Driver) -> None:
super(Story, self).init(driver)


if __name__ == "__main__":
# story is invoked as a script, start it in the Tale Driver.
gamedir = pathlib.Path(__file__).parent
if gamedir.is_dir() or gamedir.is_file():
cmdline_args = sys.argv[1:]
cmdline_args.insert(0, "--game")
cmdline_args.insert(1, str(gamedir))
run_from_cmdline(cmdline_args)
35 changes: 35 additions & 0 deletions stories/teaparty/story_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name":"The Tea Party",
"type":"StoryConfig",
"author":"test author",
"author_address":"" ,
"version":"1.00" ,
"requires_tale":"4.0" ,
"supported_modes":["IF"] ,
"player_name":"alice" ,
"player_gender":"f" ,
"player_race":"human" ,
"player_money":0.0 ,
"playable_races":[] ,
"money_type":"NOTHING" ,
"server_tick_method":"TIMER" ,
"server_tick_time":5.0 ,
"gametime_to_realtime":1 ,
"max_wait_hours":2 ,
"display_gametime":false ,
"display_race":false ,
"epoch":null ,
"startlocation_player":"Mad Hatters House.Living Room" ,
"startlocation_wizard":"Mad Hatters House.Living Room" ,
"savegames_enabled":true ,
"show_exits_in_look":true ,
"license_file":"",
"mud_host":"",
"mud_port":0,
"zones":["mad_hatters_house"],
"npcs":"guests",
"items":"",
"server_mode":"IF",
"story_type":"A whimsical and humoristic tale of tea and madness. Guests are so busy with their own problems that it's difficult to make yourself heard.",
"context":"The player is having tea in the Mad Hatter's house, as Alice. The guests are all mad in their own way, and making sense of anything is difficult."
}
13 changes: 13 additions & 0 deletions stories/teaparty/zones/mad_hatters_house.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name":"Mad Hatters House",
"description": "The Mad Hatter's house. It's a bit of a mess.",
"locations":[
{
"name": "Living Room",
"descr": "The Mad Hatter's cluttered living room. It's set up for a tea party.",
"exits": []
}
],
"races": [],
"items": []
}
7 changes: 7 additions & 0 deletions stories/test_story/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""
Package containing a demo room and some stuff, to easily check out
a running Tale framework (python -m tale.demo.story)

'Tale' mud driver, mudlib and interactive fiction framework
Copyright by Irmen de Jong ([email protected])
"""
30 changes: 30 additions & 0 deletions stories/test_story/story.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

import pathlib
import sys
from tale import parse_utils
from tale.driver import Driver
from tale.driver_if import IFDriver
from tale.json_story import JsonStory
from tale.main import run_from_cmdline
from tale.zone import Zone


class Story(JsonStory):

driver = None

def __init__(self) -> None:
super(Story, self).__init__('', parse_utils.load_story_config(parse_utils.load_json('test_story_config.json')))

def init(self, driver: Driver) -> None:
super(Story, self).init(driver)


if __name__ == "__main__":
# story is invoked as a script, start it in the Tale Driver.
gamedir = pathlib.Path(__file__).parent
if gamedir.is_dir() or gamedir.is_file():
cmdline_args = sys.argv[1:]
cmdline_args.insert(0, "--game")
cmdline_args.insert(1, str(gamedir))
run_from_cmdline(cmdline_args)
15 changes: 0 additions & 15 deletions stories/test_story/test_locations.json

This file was deleted.

7 changes: 5 additions & 2 deletions stories/test_story/zones/test_locations.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name":"Cave",
"rooms":[
"description": "This is a cave. It's dark and damp.",
"locations":[
{
"name": "Cave entrance",
"descr": "This cave entrance gives shelter from the wind and rain.",
Expand All @@ -11,5 +12,7 @@
"descr": "This is Kobbo the Kings throne room. It's a dark, damp place with a log in one end",
"exits": [{"name" : "Cave entrance", "short_desc":"exit to Cave entrance", "long_desc":"", "enter_msg":""}]
}
]
],
"races": [],
"items": []
}
8 changes: 7 additions & 1 deletion tale/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,11 @@ def lookup_location(self, location_name: str) -> base.Location:
module = importlib.import_module(modulename)
location = module
except ImportError:
raise errors.TaleError("Location not found: " + location_name)
if isinstance(self.story, DynamicStory):
dynamic_story = typing.cast(DynamicStory, self.story)
location = dynamic_story.find_location(location_name.split('.')[-1])
if not location:
raise errors.TaleError("Location not found: " + location_name)
return location # type: ignore

def _load_zones(self, zone_names: Sequence[str]) -> ModuleType:
Expand All @@ -679,6 +683,8 @@ def _load_zones(self, zone_names: Sequence[str]) -> ModuleType:
try:
module = importlib.import_module("zones." + zone)
except ImportError:
if isinstance(self.story, DynamicStory):
return []
raise errors.TaleError("zone not found: " + zone)
if hasattr(module, "init"):
# call the zone module initialization function
Expand Down
10 changes: 6 additions & 4 deletions tale/json_story.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ def __init__(self, path: str, config: StoryConfig):
super(JsonStory, self).__init__()
self.config = config
self.path = path


def init(self, driver) -> None:
self.driver = driver
locs = {}
zones = []
for zone in self.config.zones:
Expand All @@ -24,15 +28,13 @@ def __init__(self, path: str, config: StoryConfig):
zone = zones[name]
for loc in zone.locations.values():
locs[loc.name] = loc
self.add_zone(zone)
self._locations = locs
self._zones = zones # type: dict(str, dict)

if self.config.npcs:
self._world["creatures"] = parse_utils.load_npcs(parse_utils.load_json(self.path +'npcs/'+self.config.npcs + '.json'), self._zones)
if self.config.items:
self._world["items"] = parse_utils.load_items(parse_utils.load_json(self.path + self.config.items + '.json'), self._zones)

def init(self, driver) -> None:
pass


def welcome(self, player: Player) -> str:
Expand Down
Loading