コード例 #1
0
ファイル: db.py プロジェクト: MikeF0007/Warehouse-Wizard
    def load(self):
        alpha = ['A', 'B', 'C', 'D']
        self.warehouseObjLoad = Warehouse(
            self.data["warehouse"][0]["filename"],
            (self.data["warehouse"][0]["height"],
             self.data["warehouse"][0]["width"]))

        self.warehouseObjLoad.itemCount = self.data["warehouse"][0][
            "itemCount"]
        self.warehouseObjLoad.storageCap = self.data["warehouse"][0][
            "storageCap"]

        for i in range(0, 4):
            for j in range(1, 5):
                index = alpha[i] + str(j)
                itemList = self.data["warehouse"][0]["storageLocation"][index][
                    "items"]

                for k in range(len(itemList)):
                    self.warehouseObjLoad.addItem(
                        (itemList[k]["dimensions"][0],
                         itemList[k]["dimensions"][1]), itemList[k]["name"],
                        itemList[k]["description"])

        return self.warehouseObjLoad
コード例 #2
0
    def setUp(self):
        # empty warehouse
        self.wh_1 = Warehouse("wh_1", (1000, 1000))

        # warehouse with 1 item
        self.item_1 = Item(0, (40000, 1), "Boombox", "loud", (0, 0))
        self.item_2 = Item(1, (100, 1), "Guitar", "6-string", (0, 1))
        self.wh_2 = Warehouse("wh_2", (1000, 1000), items=2, id=2)
        self.customMatrix = [[StorageSpace(self.wh_2.storageCap, {0: self.item_1}), StorageSpace(self.wh_2.storageCap, {1: self.item_2}),
                              StorageSpace(self.wh_2.storageCap, dict()), StorageSpace(self.wh_2.storageCap, dict())],
                             [StorageSpace(self.wh_2.storageCap, dict()), StorageSpace(self.wh_2.storageCap, dict()),
                              StorageSpace(self.wh_2.storageCap, dict()), StorageSpace(self.wh_2.storageCap, dict())],
                             [StorageSpace(self.wh_2.storageCap, dict()), StorageSpace(self.wh_2.storageCap, dict()),
                              StorageSpace(self.wh_2.storageCap, dict()), StorageSpace(self.wh_2.storageCap, dict())],
                             [StorageSpace(self.wh_2.storageCap, dict()), StorageSpace(self.wh_2.storageCap, dict()),
                              StorageSpace(self.wh_2.storageCap, dict()), StorageSpace(self.wh_2.storageCap, dict())]]
        self.customMatrix[0][0].remainingArea = 0
        self.customMatrix[0][0].spaceLeft = False
        self.customMatrix[0][1].category = "Instruments"
        self.wh_2.spaceMatrix = self.customMatrix
        pass