Exemplo n.º 1
0
 def setUp(self):
     self.shopkeeper = Shopkeeper("lucy", "f")
     shop = ShopBehavior()
     shop.open_hours = [(9, 17), (22, 3)]    # from 9 to 17 and in the night from 22 to 03
     self.shopkeeper.set_shop(shop)
Exemplo n.º 2
0
class TestShopping(unittest.TestCase):
    def setUp(self):
        self.shopkeeper = Shopkeeper("lucy", "f")
        shop = ShopBehavior()
        shop.open_hours = [(9, 17), (22, 3)]    # from 9 to 17 and in the night from 22 to 03
        self.shopkeeper.set_shop(shop)

    def test_open_hours(self):
        self.shopkeeper.validate_open_hours(current_time=datetime.time(9, 0))
        self.shopkeeper.validate_open_hours(current_time=datetime.time(9, 1))
        self.shopkeeper.validate_open_hours(current_time=datetime.time(13, 0))
        self.shopkeeper.validate_open_hours(current_time=datetime.time(16, 59))
        self.shopkeeper.validate_open_hours(current_time=datetime.time(22, 0))
        self.shopkeeper.validate_open_hours(current_time=datetime.time(23, 59))
        self.shopkeeper.validate_open_hours(current_time=datetime.time(0, 0))
        self.shopkeeper.validate_open_hours(current_time=datetime.time(0, 1))
        self.shopkeeper.validate_open_hours(current_time=datetime.time(2, 59))
        wiz = NPC("wizard", "m")
        wiz.privileges.add("wizard")
        self.shopkeeper.validate_open_hours(wiz, current_time=datetime.time(2, 59))

    def test_closed_hours(self):
        with self.assertRaises(ActionRefused):
            self.shopkeeper.validate_open_hours(current_time=datetime.time(6, 30))
        with self.assertRaises(ActionRefused):
            self.shopkeeper.validate_open_hours(current_time=datetime.time(8, 59))
        with self.assertRaises(ActionRefused):
            self.shopkeeper.validate_open_hours(current_time=datetime.time(17, 0))
        with self.assertRaises(ActionRefused):
            self.shopkeeper.validate_open_hours(current_time=datetime.time(21, 59))
        with self.assertRaises(ActionRefused):
            self.shopkeeper.validate_open_hours(current_time=datetime.time(3, 0))
        wiz = NPC("wizard", "m")
        wiz.privileges.add("wizard")
        self.shopkeeper.validate_open_hours(wiz, current_time=datetime.time(21, 59))
Exemplo n.º 3
0
 def setUp(self):
     self.shopkeeper = Shopkeeper("lucy", "f")
     shop = ShopBehavior()
     shop.open_hours = [(9, 17), (22, 3)]    # from 9 to 17 and in the night from 22 to 03
     self.shopkeeper.set_shop(shop)
Exemplo n.º 4
0
class TestShopping(unittest.TestCase):
    def setUp(self):
        self.shopkeeper = Shopkeeper("lucy", "f")
        shop = ShopBehavior()
        shop.open_hours = [(9, 17), (22, 3)]    # from 9 to 17 and in the night from 22 to 03
        self.shopkeeper.set_shop(shop)

    def test_open_hours(self):
        self.shopkeeper.validate_open_hours(current_time=datetime.time(9, 0))
        self.shopkeeper.validate_open_hours(current_time=datetime.time(9, 1))
        self.shopkeeper.validate_open_hours(current_time=datetime.time(13, 0))
        self.shopkeeper.validate_open_hours(current_time=datetime.time(16, 59))
        self.shopkeeper.validate_open_hours(current_time=datetime.time(22, 0))
        self.shopkeeper.validate_open_hours(current_time=datetime.time(23, 59))
        self.shopkeeper.validate_open_hours(current_time=datetime.time(0, 0))
        self.shopkeeper.validate_open_hours(current_time=datetime.time(0, 1))
        self.shopkeeper.validate_open_hours(current_time=datetime.time(2, 59))
        wiz = Living("wizard", "m")
        wiz.privileges.add("wizard")
        self.shopkeeper.validate_open_hours(wiz, current_time=datetime.time(2, 59))

    def test_closed_hours(self):
        with self.assertRaises(ActionRefused):
            self.shopkeeper.validate_open_hours(current_time=datetime.time(6, 30))
        with self.assertRaises(ActionRefused):
            self.shopkeeper.validate_open_hours(current_time=datetime.time(8, 59))
        with self.assertRaises(ActionRefused):
            self.shopkeeper.validate_open_hours(current_time=datetime.time(17, 0))
        with self.assertRaises(ActionRefused):
            self.shopkeeper.validate_open_hours(current_time=datetime.time(21, 59))
        with self.assertRaises(ActionRefused):
            self.shopkeeper.validate_open_hours(current_time=datetime.time(3, 0))
        wiz = Living("wizard", "m")
        wiz.privileges.add("wizard")
        self.shopkeeper.validate_open_hours(wiz, current_time=datetime.time(21, 59))
Exemplo n.º 5
0

def init(driver):
    # called when zone is first loaded
    pass


# create the Olde Shoppe and its owner
shopinfo = ShopBehavior()
toothpick = Item("toothpick", "pointy wooden toothpick")
toothpick.value = 0.12
shopinfo.forsale.add(toothpick)
shopinfo.banks_money = True
shopkeeper = Shopkeeper(
    "Lucy",
    "f",
    short_description=
    "Lucy, the shop owner, is looking happily at her newly arrived customer.")
shopkeeper.money = 14000
shop = Location("Curiosity Shoppe", "A weird little shop. It sells odd stuff.")
shop.insert(shopkeeper, shop)
shop.add_exits([
    Exit(["door", "out"], "town.lane",
         "A fancy door provides access back to the lane outside.")
])

# provide some items in the shop
clock = clone(gameclock)
clock.value = 500
paper = clone(newspaper)
gem2 = clone(diamond)
Exemplo n.º 6
0
from tale.items.basic import gameclock, diamond, gem, newspaper
from tale import mud_context


def init(driver):
    # called when zone is first loaded
    pass


# create the Olde Shoppe and its owner
shopinfo = ShopBehavior()
toothpick = Item("toothpick", "pointy wooden toothpick")
toothpick.value = 0.12
shopinfo.forsale.add(toothpick)
shopinfo.banks_money = True
shopkeeper = Shopkeeper("Lucy", "f", short_description="Lucy, the shop owner, is looking happily at her newly arrived customer.")
shopkeeper.money = 14000
shop = Location("Curiosity Shoppe", "A weird little shop. It sells odd stuff.")
shop.insert(shopkeeper, shop)
shop.add_exits([Exit(["door", "out"], "town.lane", "A fancy door provides access back to the lane outside.")])


# provide some items in the shop
clock = clone(gameclock)
clock.value = 500
paper = clone(newspaper)
gem2 = clone(diamond)
gem2.value = 80000
gem3 = clone(gem)
gem3.value = 9055
shopkeeper.init_inventory([gem2, gem3, toothpick])