Ejemplo n.º 1
0
    def getDescriptionForLookAt(self, keyword):
	if keyword in ['products', 'display']:
	    text = "In the products display you see:"
	    i = 0

	    curr = self.getRoom()._zone._currency
	    for id, price, qty in self._products:
		i = i+1

                if i % 2 == 1:
		    text = text + "\r\n"

		obj = self._world.getObject(id)
		descr = obj.getTheName()

		p = utils.convertCurrency(price, CUR_DOLLAR, curr)
		money = utils.getMoneyText(p, curr)
		if self._quantities[i-1] > 0:
		    text = text+'  ['+`i`+'] '+string.ljust(string.ljust(descr, 22)+money, 32)
		else:
		    text = text+'  ['+`i`+'] '+string.ljust(string.ljust(descr, 22)+'sold out', 36)


	    return text

	else:
	    return Object.getDescriptionForLookAt(self, keyword)
Ejemplo n.º 2
0
    def performList(self, ch):
	currency = self.getLocation()._zone._currency

	ch.writeToSelf(string.capitalize(
			utils.substNames(self._shopMessages["showList"],
					self, ch, None))+"\r\n")
	ch.writeToSelf(string.center("#", 4)
			+string.ljust("Description",46)
			+string.rjust("Stock",5)
			+string.rjust("Price",15)
			+"\r\n"+"-"*70+"\r\n")

	idx = 0
	for id, qty in self._products:
	    p = self._world.getObject(id)
	    if not p:
		self.warning("shopkeeper with invalid product "+id)
		continue

	    price = utils.convertCurrency(p._value, CUR_DOLLAR, currency)
	    price = utils.getMoneyText(price, currency)

	    if qty == 0:
		qty = "-"
	    else:
		qty = str(qty)
	    idx = idx + 1
	    
	    ch.writeToSelf(string.ljust('#'+`idx`, 4)
			    +string.ljust(p.getName(),46)
			    +string.rjust(qty, 5)
			    +string.rjust(price, 15)+"\r\n")
Ejemplo n.º 3
0
    def getMoneyText(self, complete=0):

	return utils.getMoneyText(self._amount, self._currency, complete)