Skip to content

Commit

Permalink
Merge pull request #3 from darknightghost/v0.0.4
Browse files Browse the repository at this point in the history
V0.0.4
  • Loading branch information
darknightghost committed Mar 18, 2019
2 parents ffe1cda + 3c21ced commit 6025af3
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 34 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v0.0.4
Fixed a bug that the amount of resource are not influenced by workforce now.

v0.0.3
Fixed a bug that the amount of module cannot bigger than 100.
Fixed a mistake in the data of Wheat Production module.
Expand Down
2 changes: 1 addition & 1 deletion Common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import functools
from distutils.version import StrictVersion

VERSION = StrictVersion("0.0.3")
VERSION = StrictVersion("0.0.4")
RECORD_VERSION = StrictVersion("0.0.2")

import Common
Expand Down
13 changes: 3 additions & 10 deletions WorkSpaceWidget/SummaryItem.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ def __init__(self, group, parent=None):
#Resources
#{Product : amount}
self.__resources = {}
self.__maxResources = {}
self.__resourcesItem = QTreeWidgetItem(
self, [StringTable.getString("STR_RESOURCES")])
self.__resourcesItem.setFlags(Qt.ItemIsEnabled)
Expand Down Expand Up @@ -199,7 +198,7 @@ def resources(self):
'''
Get resources.
'''
return self.__resources, self.__maxResources
return self.__resources

def update(self):
'''
Expand All @@ -212,7 +211,6 @@ def update(self):
self.__products = {}
self.__maxProducts = {}
self.__resources = {}
self.__maxResources = {}
self.__foods = {}
self.__workforce = 0

Expand Down Expand Up @@ -280,13 +278,9 @@ def update(self):
try:
self.__resources[
r.product()] += r.amount() * m.amount()
self.__maxResources[r.product()] += r.amount(
) * m.amount() * m.stationModule().maxEfficiency()

except KeyError:
self.__resources[r.product()] = r.amount() * m.amount()
self.__maxResources[r.product()] = r.amount(
) * m.amount() * m.stationModule().maxEfficiency()

except AttributeError:
pass
Expand All @@ -312,7 +306,7 @@ def update(self):
if p in self.__resources:
#p is an intermediate
amount = self.__products[p] - self.__resources[p]
maxAmount = self.__maxProducts[p] - self.__maxResources[p]
maxAmount = self.__maxProducts[p] - self.__resources[p]
if p in self.__foods:
amount -= self.__foods[p]
maxAmount -= self.__foods[p]
Expand All @@ -336,8 +330,7 @@ def update(self):
continue

amount = self.__resources[p]
maxAmount = self.__maxResources[p]
SummaryProductItem(p, "%d/h - >%d/h" % (amount, maxAmount),
SummaryProductItem(p, "%d/h" % (amount),
self.__resourcesItem)

for p in self.__foods:
Expand Down
12 changes: 4 additions & 8 deletions WorkSpaceWidget/SummarysItem.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ def __initTotal(self):
#Resources
#{Product : amount}
self.__resources = {}
self.__maxResources = {}
self.__resourcesItem = QTreeWidgetItem(
self.__totalSummaryItem, [StringTable.getString("STR_RESOURCES")])
self.__resourcesItem.setFlags(Qt.ItemIsEnabled)
Expand Down Expand Up @@ -168,7 +167,6 @@ def __onUpdateTotal(self):
allProducts = {}
allMaxProducts = {}
allResources = {}
allMaxResources = {}
workforce = 0

def merge(dest, src):
Expand All @@ -191,8 +189,7 @@ def merge(dest, src):
merge(allFoods, g.foods())
merge(allProducts, g.products()[0])
merge(allMaxProducts, g.products()[1])
merge(allResources, g.resources()[0])
merge(allMaxResources, g.resources()[1])
merge(allResources, g.resources())

self.__workforceItem.setText(1, "%+d" % (workforce))

Expand All @@ -201,13 +198,13 @@ def merge(dest, src):
if p in allResources:
#p is an intermediate
amount = allProducts[p] - allResources[p]
maxAmount = allMaxProducts[p] - allMaxResources[p]
maxAmount = allMaxProducts[p] - allResources[p]

if p in allFoods:
amount -= allFoods[p]
maxAmount -= allFoods[p]

SummaryProductItem(p, "%+d/h -> %+d/h" % (amount, maxAmount),
SummaryProductItem(p, "%+d/h" % (amount),
self.__intermediatesItem)

else:
Expand All @@ -227,8 +224,7 @@ def merge(dest, src):
continue

amount = allResources[p]
maxAmount = allMaxResources[p]
SummaryProductItem(p, "%d/h -> %d/h" % (amount, maxAmount),
SummaryProductItem(p, "%d/h" % (amount),
self.__resourcesItem)

for p in allFoods:
Expand Down
34 changes: 19 additions & 15 deletions winpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
SCRIPT_DIR = pathlib.Path(__file__).parent
MAIN_FILE = SCRIPT_DIR / "main.pyw"

def copy(src, dest):
print("Copying \"%s\" to \"%s\"..." % (str(src), str(dest)))
if src.is_dir():
shutil.copytree(str(src), str(dest))

else:
shutil.copyfile(str(src), str(dest))

def scanDir(beginDir):
ret = []
Expand Down Expand Up @@ -78,21 +85,18 @@ def main():
return ret

#Copy data
shutil.copytree(
str(SCRIPT_DIR / "factions"), str(distpath / "main" / "factions"))
shutil.copytree(
str(SCRIPT_DIR / "products"), str(distpath / "main" / "products"))
shutil.copytree(
str(SCRIPT_DIR / "icons"), str(distpath / "main" / "icons"))
shutil.copytree(
str(SCRIPT_DIR / "station_modules"),
str(distpath / "main" / "station_modules"))
shutil.copyfile(
str(SCRIPT_DIR / "LICENSE"), str(distpath / "main" / "LICENSE"))
shutil.copyfile(
str(SCRIPT_DIR / "README.md"), str(distpath / "main" / "README.md"))
shutil.copyfile(
str(SCRIPT_DIR / "CHANGELOG"), str(distpath / "main" / "CHANGELOG"))
sources = [
"factions",
"products",
"icons",
"station_modules",
"LICENSE",
"README.md",
"CHANGELOG",
]

for s in sources:
copy(SCRIPT_DIR / s, distpath / "main" / s)

print("The output directory is \"%s\"." % str(distpath / "main"))
return 0
Expand Down

0 comments on commit 6025af3

Please sign in to comment.