def testItemizedList(self): self.assertEquals(self.format(language.ItemizedList([])), u'') # XXX Does this make sense? self.assertEquals(self.format(language.ItemizedList([u'foo'])), u'foo') self.assertEquals(self.format(language.ItemizedList([u'foo', u'bar'])), u'foo and bar') self.assertEquals( self.format(language.ItemizedList([u'foo', u'bar', u'baz'])), u'foo, bar, and baz')
def vt102(self, observer): heshe = language.Noun(self.thing).heShe() L = _orderTopClothingByGlobalSlotList(self.garments) if L is None: return language.Sentence([heshe, u' is naked.']).vt102(observer) return language.Sentence([ heshe, u' is wearing ', language.ItemizedList( [language.Noun(g.thing).nounPhrase() for g in L]), u'.' ]).vt102(observer)
def testCapitalization(self): self.assertEquals( self.format(language.ExpressString(u"foo").capitalizeConcept()), u"Foo") self.assertEquals( self.format( language.ExpressList([[[[u"hi"]]]]).capitalizeConcept()), u"Hi") self.assertEquals( self.format( language.ItemizedList([u"foo", u"bar", u"baz"]).capitalizeConcept()), u"Foo, bar, and baz")
def _expand(self, template, observer, concepts): """ Expand the given template using the wrapped container's L{Thing} as the subject. C{u"contents"} is also available for substitution with the contents of the container. @return: An iterator of concepts derived from the given template. """ return language.ConceptTemplate(template).expand(dict( subject=self.original.thing, contents=language.ItemizedList(concepts)))
def do(self, player, line): from imaginary import garments equipment = list( player.store.query( objects.Thing, AND(garments.Garment.thing == objects.Thing.storeID, garments.Garment.wearer == player), sort=objects.Thing.name.ascending)) if equipment: evt = events.Success(actor=player.thing, actorMessage=[ u"You are wearing ", language.ItemizedList(equipment), u"." ]) else: evt = events.Success(actor=player.thing, actorMessage=language.ExpressString( u"You aren't wearing any equipment.")) evt.broadcast()