forked from vantablack/vantaMOO
parent
839b4431a2
commit
b10cd6e786
|
@ -0,0 +1,47 @@
|
|||
"""
|
||||
Tracery Object
|
||||
|
||||
This is a joke object that changes its description every time you look at it.
|
||||
Requires installing pytracery as a pip dependency.
|
||||
|
||||
As Kate Compton puts it: "I can easily generate 10,000 bowls of plain oatmeal, with each oat being in a different position and different orientation, and mathematically speaking they will all be completely unique. But the user will likely just see a lot of oatmeal."
|
||||
|
||||
This relies on default Tracery and does not have a model memory (i.e. you cannot procgen object attributs based on its description and vice versa).
|
||||
"""
|
||||
from typeclasses.objects import Object
|
||||
import tracery
|
||||
from tracery.modifiers import base_english
|
||||
|
||||
"""
|
||||
An oatmeal object has an "origin" attribute.
|
||||
You make a table of rules with attributes, like:
|
||||
|
||||
set movie/origin:rules = ['This is #genre.a# #movie# about #subject.s#.', '#subject.s.capitalize# #sequel#: The #family.capitalize# Of All #movie.s.capitalize#!']
|
||||
|
||||
The table has to have category "rules" and the main entry point is called "origin". The rest is up to you:
|
||||
|
||||
set movie/sequel:rules = ['from hell #number#','#number#','the Resurrection','Origins','Rebooted','Reimagined','Again']
|
||||
set movie/family:rules = ['mother','father','aunt','xyther','grunkle','grandpa','grandma']
|
||||
set movie/number:rules = ['2','3','4','5','6','II','III','IV','V','VI','XXIII','MCMXCIII']
|
||||
set movie/movie:rules = ['movie', 'flick', 'animation', 'anime', 'moving picture', 'picture']
|
||||
'genre': ['action', 'romance', 'thriller', 'horror', 'abstract', 'slice-of-life', 'comedy', 'documentary'],
|
||||
'subject': ['wombat', 'stoner', '#pair# love #polycule#', 'smartphone', 'astronaut', 'explosion'],
|
||||
'pair': ['gay','aromantic','nonbinary','clueless','crazy'],
|
||||
'polycule': ['triange', 'pair', '3D icosahedron', 'polycule']
|
||||
"""
|
||||
class OatmealObject(Object):
|
||||
"""
|
||||
Can't be a self.db.desc because we *need* a function here.
|
||||
"""
|
||||
def get_display_desc(self, looker, **kwargs):
|
||||
rules = {}
|
||||
attrs = self.attributes.get(category='rules', return_obj=True)
|
||||
for attr in attrs:
|
||||
try
|
||||
rules[attr.key] = attr.value
|
||||
except Error:
|
||||
# do nothing if attr has no key or value
|
||||
grammar = tracery.Grammar(rules)
|
||||
grammar.add_modifiers(base_english)
|
||||
return grammar.flatten("#origin#")
|
||||
pass
|
|
@ -1,31 +0,0 @@
|
|||
"""
|
||||
Movie Screen
|
||||
|
||||
This is a joke object that changes its description every time you look at it.
|
||||
Requires installing pytracery as a pip dependency.
|
||||
"""
|
||||
from typeclasses.objects import Object
|
||||
import tracery
|
||||
from tracery.modifiers import base_english
|
||||
|
||||
class MovieScreen(Object):
|
||||
rules = {
|
||||
'origin': ['This is #genre.a# #movie# about #subject.s#.', '#subject.s.capitalize# #sequel#: The #family.capitalize# Of All #movie.s.capitalize#!'],
|
||||
'sequel': ['from hell #number#','#number#','the Resurrection','Origins','Rebooted','Reimagined','Again'],
|
||||
'family': ['mother','father','aunt','xyther','grunkle','grandpa','grandma'],
|
||||
'number': ['2','3','4','5','6','II','III','IV','V','VI','XXIII','MCMXCIII'],
|
||||
'movie': ['movie', 'flick', 'animation', 'anime', 'moving picture', 'picture'],
|
||||
'genre': ['action', 'romance', 'thriller', 'horror', 'abstract', 'slice-of-life', 'comedy', 'documentary'],
|
||||
'subject': ['wombat', 'stoner', '#pair# love #polycule#', 'smartphone', 'astronaut', 'explosion'],
|
||||
'pair': ['gay','aromantic','nonbinary','clueless','crazy'],
|
||||
'polycule': ['triange', 'pair', '3D icosahedron', 'polycule']
|
||||
}
|
||||
|
||||
"""
|
||||
Can't be a self.db.desc because we *need* a function here.
|
||||
"""
|
||||
def get_display_desc(self, looker, **kwargs):
|
||||
grammar = tracery.Grammar(self.rules)
|
||||
grammar.add_modifiers(base_english)
|
||||
return grammar.flatten("#origin#")
|
||||
pass
|
Loading…
Reference in New Issue