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

Support importing game data #45

Closed
24 tasks done
Tracked by #41 ...
oubiwann opened this issue Jul 23, 2022 · 3 comments
Closed
24 tasks done
Tracked by #41 ...

Support importing game data #45

oubiwann opened this issue Jul 23, 2022 · 3 comments
Labels
Milestone

Comments

@oubiwann
Copy link
Contributor

oubiwann commented Jul 23, 2022

This functionality will essentially only be used once: to upgrade game data to the in-memory graph db (see #46). Still useful, though ...

Tasks:

  • Use filestore to load data
  • Convert loaded data to maps
  • Add support for finding / getting all data of a given type
    • all rooms
    • all objects
    • all characters
  • Add utility functions for loading all data into memory
    • add function to get list of games
    • add function to get list of tables
    • use these to create additional arity functions for mg-import:from-fs
  • Add utility functions for loading rooms into graphdb
    • add vertices for all rooms
    • add edges based upon room name, exits entry in room, and direction
  • Add utility functions for loading objects
    • add vertices for all objects
    • add edges based upon room name, objects entry in room
  • Add utility functions for loading characters
    • add vertices for all characters
    • add edge for location
    • add edges for inventory
  • Add utility functions for loading games
    • add edges for characters in games
  • Add utility functions for loading users
    • add edges for games

Some notes: we did this in ticket #68 ...

Load data from files:

(set `#(ok ,rm1) (mudgraph-v1:load "rooms" "room1"))
(set `#(ok ,rm2) (mudgraph-v1:load "rooms" "room2"))
(set `#(ok ,obj1) (mudgraph-v1:load "objects" "sword"))
(set `#(ok ,obj2) (mudgraph-v1:load "objects" "painting"))
(set `#(ok ,per1) (mudgraph-v1:load "characters" "eve"))

We'll want to be more specific with this, though ... maybe indicating the source format?

Then we convert that data to maps for use as "labels" (arbitrary data storage) on the nodes:

(set rm1 (proplists:to_map rm1))
(set rm2 (proplists:to_map rm2))
(set obj1 (proplists:to_map obj1))
(set obj2 (proplists:to_map obj2))
(set per1 (proplists:to_map per1))

We'll probably just include this in the above functions ...

@oubiwann
Copy link
Contributor Author

Let's try this out ... Import filestore data:

(set rm1 (mg-import:from-fs "rooms" "room1"))
(set rm2 (mg-import:from-fs "rooms" "room2"))
(set obj1 (mg-import:from-fs "objects" "sword"))
(set obj2 (mg-import:from-fs "objects" "painting"))
(set per1 (mg-import:from-fs "characters" "eve"))

Now actually let's use the imported data in a graph:

(set v1 (mg:add-vertex rm1)) ; we'll store the vertex's ID in a variable so we can look it up latter
(mg:add-vertex rm2)
(set e1 (mg:add-edge rm1 rm2 #m(type transit direction east size normal))) ; again, for later look-up
(mg:add-edge rm2 rm1 #m(type transit direction west size normal))

(mg:add-vertex obj1)
(mg:add-vertex obj2)
(mg:add-vertex per1)
(mg:add-edge obj1 rm1 #m(type contains))
(mg:add-edge obj2 rm1 #m(type contains))
(mg:add-edge per1 rm1 #m(type contains))

(mg:in-edges rm1)
(mg:in-neighbours rm1)
(mg:out-neighbours rm1)

(mg:in-neighbours rm1 'contains) ; get all objects in the room
(mg:out-neighbours rm1 'transit) ; get all exits out of the room

(mg:vertex v1)
(mg:edge e1)

@oubiwann
Copy link
Contributor Author

Supporting games and users is all that's left ...

@oubiwann
Copy link
Contributor Author

Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant