From ff41f8856e15a538780eb573dd659ee6ec3bff7e Mon Sep 17 00:00:00 2001 From: Nostrademous Date: Thu, 27 Jan 2022 11:50:42 -0500 Subject: [PATCH 1/3] base implemenation of some classes following code_structures.md --- docs/code_structure.md | 2 +- src/classes/Build.py | 33 ++++++++++++++++++++++++ src/classes/Player.py | 57 +++++++++++++++++++++++++++++++++++++++++ src/classes/Tree.py | 30 ++++++++++++++++++++++ src/classes/__init__.py | 0 5 files changed, 121 insertions(+), 1 deletion(-) create mode 100755 src/classes/Build.py create mode 100755 src/classes/Player.py create mode 100755 src/classes/Tree.py create mode 100644 src/classes/__init__.py diff --git a/docs/code_structure.md b/docs/code_structure.md index b790061..1d66174 100644 --- a/docs/code_structure.md +++ b/docs/code_structure.md @@ -17,7 +17,7 @@ [class] Tree [str] version [dict] All Nodes (addressable by Node ID) - [dict] Selected Nodes (addressable by Node ID) + [dict] Allocated Nodes (addressable by Node ID) [class] Player [enum] Class Selection diff --git a/src/classes/Build.py b/src/classes/Build.py new file mode 100755 index 0000000..85978a4 --- /dev/null +++ b/src/classes/Build.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 + +# Build Class +# +# Contains: +# [class] Build +# [ref] Tree +# [ref] Player + +import Tree +import Player + + +class Build: + def __init__(self, name: str = "temp") -> None: + self.name = name + self.tree_ref = Tree.Tree() + self.player_ref = Player.Player() + + def __repr__(self) -> str: + ret_str = f"[BUILD]: '{self.name}'\n" + ret_str += f"{self.tree_ref}" + ret_str += f"{self.player_ref}" + return ret_str + + +def test() -> None: + build = Build() + print(build) + + +if __name__ == "__main__": + test() diff --git a/src/classes/Player.py b/src/classes/Player.py new file mode 100755 index 0000000..23fa186 --- /dev/null +++ b/src/classes/Player.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python3 + +# Player Class +# +# [class] Player +# [enum] Class Selection +# [enum] Ascendancy Selection +# [dict] Stats (e.g. Str/Dex/Int, Hit/Crit, Life/Mana, +# Block/Spell Block/Evade/Dodge, etc.) +# [dict] Item Slots +# [per slot ref] Item +# [optional list] Minions + +from enum import Enum + + +class PlayerClasses(Enum): + SCION = 0 + MARAUDER = 1 + RANGER = 2 + WITCH = 3 + DUELIST = 4 + TEMPLAR = 5 + SHADOW = 6 + + +class PlayerAscendancy(Enum): + NONE = None + + +class Player: + def __init__( + self, + player_class: PlayerClasses = PlayerClasses.SCION, + ascendancy: PlayerAscendancy = PlayerAscendancy.NONE, + level: int = 1, + ) -> None: + self.player_class = player_class + self.ascendancy = ascendancy + self.level = level + self.stats = dict() + self.item_slots = dict() + self.minions = dict() + + def __repr__(self) -> str: + ret_str = f"Level {self.level} {self.player_class.name}" + ret_str += f" {self.ascendancy.value}\n" if self.ascendancy.value else "\n" + return ret_str + + +def test() -> None: + player = Player() + print(player) + + +if __name__ == "__main__": + test() diff --git a/src/classes/Tree.py b/src/classes/Tree.py new file mode 100755 index 0000000..26b01f9 --- /dev/null +++ b/src/classes/Tree.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 + +# Tree Class +# +# [class] Tree +# [str] version +# [dict] All Nodes (addressable by Node ID) +# [dict] Allocated Nodes (addressable by Node ID) + +_VERSION_ = "3.17" + + +class Tree: + def __init__(self, version: str = _VERSION_) -> None: + self.version = version + self.tree_nodes = dict() + self.allocated_nodes = dict() + + def __repr__(self) -> str: + ret_str = f"[TREE]: version '{self.version}'\n" + return ret_str + + +def test() -> None: + tree = Tree() + print(tree) + + +if __name__ == "__main__": + test() diff --git a/src/classes/__init__.py b/src/classes/__init__.py new file mode 100644 index 0000000..e69de29 From 3b78689d99657bc697901e0683cd6300a4361eff Mon Sep 17 00:00:00 2001 From: Nostrademous Date: Thu, 27 Jan 2022 12:18:07 -0500 Subject: [PATCH 2/3] fix: moved 'classes' directly under src dir --- docs/code_structure.md | 22 ++++++++------ src/{classes => }/Build.py | 13 ++++---- src/Enumerations.py | 17 +++++++++++ src/Player.py | 45 +++++++++++++++++++++++++++ src/{classes => }/Tree.py | 18 ++++++----- src/{classes => }/__init__.py | 0 src/classes/Player.py | 57 ----------------------------------- 7 files changed, 91 insertions(+), 81 deletions(-) rename src/{classes => }/Build.py (86%) create mode 100644 src/Enumerations.py create mode 100755 src/Player.py rename src/{classes => }/Tree.py (61%) rename src/{classes => }/__init__.py (100%) delete mode 100755 src/classes/Player.py diff --git a/docs/code_structure.md b/docs/code_structure.md index 1d66174..4440f74 100644 --- a/docs/code_structure.md +++ b/docs/code_structure.md @@ -8,7 +8,7 @@ -- can return applicable list based on item type [class] Environment - [dict] Environment Configuration + [set] Environment Configuration [class] Build [ref] Tree @@ -16,16 +16,16 @@ [class] Tree [str] version - [dict] All Nodes (addressable by Node ID) - [dict] Allocated Nodes (addressable by Node ID) + [set] All Nodes (addressable by Node ID) + [set] Allocated Nodes (addressable by Node ID) [class] Player [enum] Class Selection [enum] Ascendancy Selection - [dict] Stats (e.g. Str/Dex/Int, Hit/Crit, Life/Mana, Block/Spell Block/Evade/Dodge, etc.) - [dict] Item Slots + [set] Stats (e.g. Str/Dex/Int, Hit/Crit, Life/Mana, Block/Spell Block/Evade/Dodge, etc.) + [set] Item Sets [per slot ref] Item - [optional list] Minions + [optional set] Minions [class] Item [dict] Attribute requirements @@ -43,24 +43,26 @@ [class] Minion [ref] Player - [dict] Stats + [set] Stats [ref list] Items [ref list] Skills [int] Quantity [class] EnemyModel (e.g. Shaper, Maven) - [dict] Stats (e.g. Str/Dex/Int, Hit/Crit, Life/Mana, Block/Spell Block/Evade/Dodge, etc.) + [str] Name + [set] Stats (e.g. Str/Dex/Int, Hit/Crit, Life/Mana, Block/Spell Block/Evade/Dodge, etc.) [class] Simulator [ref] Environment(s) [ref list] Build(s) [ref] Enemy Model(s) -[class] Analytics Module +[module] Analytics Module [func] Node Comparison [func] Item Comparison [func] Gem Comparison + [func] Minion Comparison -[list] Saved Builds +[set] Saved Builds [dict] UI API imports/exports diff --git a/src/classes/Build.py b/src/Build.py similarity index 86% rename from src/classes/Build.py rename to src/Build.py index 85978a4..1992573 100755 --- a/src/classes/Build.py +++ b/src/Build.py @@ -1,11 +1,12 @@ #!/usr/bin/env python3 -# Build Class -# -# Contains: -# [class] Build -# [ref] Tree -# [ref] Player +""" +Build Class + +[class] Build + [ref] Tree + [ref] Player +""" import Tree import Player diff --git a/src/Enumerations.py b/src/Enumerations.py new file mode 100644 index 0000000..9670ec5 --- /dev/null +++ b/src/Enumerations.py @@ -0,0 +1,17 @@ +# Enumeration Data for Path of Exile constants + +from enum import Enum + + +class PlayerClasses(Enum): + SCION = 0 + MARAUDER = 1 + RANGER = 2 + WITCH = 3 + DUELIST = 4 + TEMPLAR = 5 + SHADOW = 6 + + +class PlayerAscendancies(Enum): + NONE = None diff --git a/src/Player.py b/src/Player.py new file mode 100755 index 0000000..161b51e --- /dev/null +++ b/src/Player.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 + +""" +Player Class + +[class] Player + [enum] Class Selection + [enum] Ascendancy Selection + [set] Stats (e.g. Str/Dex/Int, Hit/Crit, Life/Mana, + Block/Spell Block/Evade/Dodge, etc.) + [set] Item Sets + [per slot ref] Item + [optional set] Minions +""" + +from Enumerations import PlayerClasses, PlayerAscendancies + + +class Player: + def __init__( + self, + player_class: PlayerClasses = PlayerClasses.SCION, + ascendancy: PlayerAscendancies = PlayerAscendancies.NONE, + level: int = 1, + ) -> None: + self.player_class = player_class + self.ascendancy = ascendancy + self.level = level + self.stats = set() + self.item_sets = set() + self.minions = set() + + def __repr__(self) -> str: + ret_str = f"Level {self.level} {self.player_class.name}" + ret_str += f" {self.ascendancy.value}\n" if self.ascendancy.value else "\n" + return ret_str + + +def test() -> None: + player = Player() + print(player) + + +if __name__ == "__main__": + test() diff --git a/src/classes/Tree.py b/src/Tree.py similarity index 61% rename from src/classes/Tree.py rename to src/Tree.py index 26b01f9..910884c 100755 --- a/src/classes/Tree.py +++ b/src/Tree.py @@ -1,11 +1,13 @@ #!/usr/bin/env python3 -# Tree Class -# -# [class] Tree -# [str] version -# [dict] All Nodes (addressable by Node ID) -# [dict] Allocated Nodes (addressable by Node ID) +""" +Tree Class + +[class] Tree + [str] version + [set] All Nodes (addressable by Node ID) + [set] Allocated Nodes (addressable by Node ID) +""" _VERSION_ = "3.17" @@ -13,8 +15,8 @@ class Tree: def __init__(self, version: str = _VERSION_) -> None: self.version = version - self.tree_nodes = dict() - self.allocated_nodes = dict() + self.tree_nodes = set() + self.allocated_nodes = set() def __repr__(self) -> str: ret_str = f"[TREE]: version '{self.version}'\n" diff --git a/src/classes/__init__.py b/src/__init__.py similarity index 100% rename from src/classes/__init__.py rename to src/__init__.py diff --git a/src/classes/Player.py b/src/classes/Player.py deleted file mode 100755 index 23fa186..0000000 --- a/src/classes/Player.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env python3 - -# Player Class -# -# [class] Player -# [enum] Class Selection -# [enum] Ascendancy Selection -# [dict] Stats (e.g. Str/Dex/Int, Hit/Crit, Life/Mana, -# Block/Spell Block/Evade/Dodge, etc.) -# [dict] Item Slots -# [per slot ref] Item -# [optional list] Minions - -from enum import Enum - - -class PlayerClasses(Enum): - SCION = 0 - MARAUDER = 1 - RANGER = 2 - WITCH = 3 - DUELIST = 4 - TEMPLAR = 5 - SHADOW = 6 - - -class PlayerAscendancy(Enum): - NONE = None - - -class Player: - def __init__( - self, - player_class: PlayerClasses = PlayerClasses.SCION, - ascendancy: PlayerAscendancy = PlayerAscendancy.NONE, - level: int = 1, - ) -> None: - self.player_class = player_class - self.ascendancy = ascendancy - self.level = level - self.stats = dict() - self.item_slots = dict() - self.minions = dict() - - def __repr__(self) -> str: - ret_str = f"Level {self.level} {self.player_class.name}" - ret_str += f" {self.ascendancy.value}\n" if self.ascendancy.value else "\n" - return ret_str - - -def test() -> None: - player = Player() - print(player) - - -if __name__ == "__main__": - test() From 32081d01d74307dfddd30cfca2f51dbd81cbaae3 Mon Sep 17 00:00:00 2001 From: Nostrademous Date: Tue, 1 Feb 2022 12:43:45 -0500 Subject: [PATCH 3/3] fix: minor fixups and documentation changes --- docs/code_structure.md | 1 + src/Build.py | 20 +++++++++++--------- src/Player.py | 16 ++++++---------- src/Tree.py | 13 +++++++------ 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/docs/code_structure.md b/docs/code_structure.md index 4440f74..5616e7f 100644 --- a/docs/code_structure.md +++ b/docs/code_structure.md @@ -23,6 +23,7 @@ [enum] Class Selection [enum] Ascendancy Selection [set] Stats (e.g. Str/Dex/Int, Hit/Crit, Life/Mana, Block/Spell Block/Evade/Dodge, etc.) + [list] Skills [set] Item Sets [per slot ref] Item [optional set] Minions diff --git a/src/Build.py b/src/Build.py index 1992573..71e07a1 100755 --- a/src/Build.py +++ b/src/Build.py @@ -1,11 +1,13 @@ -#!/usr/bin/env python3 - """ Build Class -[class] Build - [ref] Tree - [ref] Player +The build class is the top-level class encompassing all attributes and +parameters defining a build. It is defined by a specific Tree and Player +instance at time of evaluation. + +The intent is that there is only one Build for a character. There might be +numerous Passive Trees (at various Player Levels, or various Cluster Jewels) +associated with a Player. """ import Tree @@ -15,13 +17,13 @@ class Build: def __init__(self, name: str = "temp") -> None: self.name = name - self.tree_ref = Tree.Tree() - self.player_ref = Player.Player() + self.tree = Tree.Tree() + self.player = Player.Player() def __repr__(self) -> str: ret_str = f"[BUILD]: '{self.name}'\n" - ret_str += f"{self.tree_ref}" - ret_str += f"{self.player_ref}" + ret_str += f"{self.tree}" + ret_str += f"{self.player}" return ret_str diff --git a/src/Player.py b/src/Player.py index 161b51e..b4816b4 100755 --- a/src/Player.py +++ b/src/Player.py @@ -1,16 +1,11 @@ -#!/usr/bin/env python3 - """ Player Class -[class] Player - [enum] Class Selection - [enum] Ascendancy Selection - [set] Stats (e.g. Str/Dex/Int, Hit/Crit, Life/Mana, - Block/Spell Block/Evade/Dodge, etc.) - [set] Item Sets - [per slot ref] Item - [optional set] Minions +The Player represents an in-game character at a specific point in their +leveling progress. + +A unique Player is defined by: level, class selection, ascendancy selection, +skill selection, and itemization across the item sets. """ from Enumerations import PlayerClasses, PlayerAscendancies @@ -27,6 +22,7 @@ def __init__( self.ascendancy = ascendancy self.level = level self.stats = set() + self.skills = list() self.item_sets = set() self.minions = set() diff --git a/src/Tree.py b/src/Tree.py index 910884c..8ab8f73 100755 --- a/src/Tree.py +++ b/src/Tree.py @@ -1,12 +1,13 @@ -#!/usr/bin/env python3 - """ Tree Class -[class] Tree - [str] version - [set] All Nodes (addressable by Node ID) - [set] Allocated Nodes (addressable by Node ID) +This class represents an instance of the Passive Tree for a given Build. +Multiple Trees can exist in a single Build (at various progress levels; +at different Jewel/Cluster itemizations, etc.) + +A Tree is tied to a Version of the Tree as released by GGG and thus older Trees +need to be supported for backwards compatibility reason. + """ _VERSION_ = "3.17"