forked from s_ranjbar/city_retrofit
added new functions to access chapter and item by name in costs catalog
This commit is contained in:
parent
150614441e
commit
2dfe8254d1
|
@ -38,3 +38,13 @@ class CapitalCost:
|
||||||
:return: float
|
:return: float
|
||||||
"""
|
"""
|
||||||
return self._overhead_and_profit
|
return self._overhead_and_profit
|
||||||
|
|
||||||
|
def chapter(self, name) -> Chapter:
|
||||||
|
"""
|
||||||
|
Get specific chapter by name
|
||||||
|
:return: Chapter
|
||||||
|
"""
|
||||||
|
for chapter in self.general_chapters:
|
||||||
|
if chapter.chapter_type == name:
|
||||||
|
return chapter
|
||||||
|
raise KeyError(f'Chapter name {name} not found')
|
||||||
|
|
|
@ -30,3 +30,13 @@ class Chapter:
|
||||||
:return: [str]
|
:return: [str]
|
||||||
"""
|
"""
|
||||||
return self._items
|
return self._items
|
||||||
|
|
||||||
|
def item(self, name) -> ItemDescription:
|
||||||
|
"""
|
||||||
|
Get specific item by name
|
||||||
|
:return: ItemDescription
|
||||||
|
"""
|
||||||
|
for item in self.items:
|
||||||
|
if item.type == name:
|
||||||
|
return item
|
||||||
|
raise KeyError(f'Item name {name} not found')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user