예제 #1
0
파일: Main.py 프로젝트: Braastos/DWCM
def itemPlusFive():
    model = ui_inventory.inventoryView.model()
    selected = []
    data = tojson.loadfromsave()
    indexes = ui_inventory.inventoryView.selectionModel().selectedRows()
    for i in sorted(indexes):
        row = i.row()
        print(row)
        index = model.index(row, 0)
        # We suppose data are strings
        selected.append(model.data(index))
        strselected = "".join(selected)
        print(selected)
        for element in data["Inventory"]:
            if element == strselected:
                menge = data["Inventory"][strselected]["menge"]
                newMenge = int(menge) + 5
                data["Inventory"][strselected].update({"menge": newMenge})
                gewicht = data["Inventory"][strselected]["gewicht"]
                newGewicht = math.ceil(gewicht / menge * newMenge)
                if newMenge <= 0:
                    del data["Inventory"][strselected]
                else:
                    data["Inventory"][strselected].update({"menge": newMenge})
                    data["Inventory"][strselected].update(
                        {"gewicht": newGewicht})
                tojson.savetojson(data)
                updateListView()
                inv = Inventory()
                inv.update(ui)
                data = inv.save(data, ui)
                updateinv(inv, data)
                break
예제 #2
0
파일: Main.py 프로젝트: Braastos/DWCM
def saveItem():
    x = Item()
    data = tojson.loadfromsave()
    global ui_editor
    x.create(ui_editor)
    data = x.save(data)
    tojson.savetojson(data)
    closeEditor()
    updateListView()
예제 #3
0
파일: Main.py 프로젝트: Braastos/DWCM
def save():
    data = tojson.loadfromsave()
    stats = Stats()
    inv = Inventory()
    stats.update(ui)
    data = stats.save(data, ui)
    updateui(stats)
    inv.update(ui)
    data = inv.save(data, ui)
    updateinv(inv, data)
    tojson.savetojson(data)