wzrdbrain 0.1.3__py3-none-any.whl → 0.1.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
wzrdbrain/__init__.py CHANGED
@@ -1,10 +1,10 @@
1
- from .wzrdbrain import generate_combo, generate_trick
1
+ from .wzrdbrain import generate_combo
2
2
 
3
3
  """
4
4
  wzrdbrain: Basic APIs to generate tricks for wizard skating.
5
5
  """
6
6
 
7
7
 
8
- __all__ = ["generate_trick", "generate_combo"]
8
+ __all__ = ["generate_combo"]
9
9
 
10
10
  __version__ = "0.1.0"
wzrdbrain/wzrdbrain.py CHANGED
@@ -1,10 +1,11 @@
1
1
  import random
2
- from typing import Optional
2
+ from typing import Optional, Any
3
+ from dataclasses import dataclass, asdict
3
4
 
4
5
  # Trick data definitions
5
- direction = ("front", "back")
6
- stance = ("open", "closed")
7
- move = (
6
+ DIRECTIONS = ("front", "back")
7
+ STANCES = ("open", "closed")
8
+ MOVES = (
8
9
  "predator",
9
10
  "predator one",
10
11
  "parallel",
@@ -19,6 +20,7 @@ move = (
19
20
  "heel roll",
20
21
  "360",
21
22
  "180",
23
+ "540", # Added missing move
22
24
  "parallel slide",
23
25
  "soul slide",
24
26
  "acid slide",
@@ -27,6 +29,8 @@ move = (
27
29
  "fast slide",
28
30
  "back slide",
29
31
  )
32
+ # Moves that only occurs as the first trick for a combo
33
+ only_first = {"predator", "predator one", "parallel"}
30
34
 
31
35
  # Moves that use "fakie" instead of "back"
32
36
  use_fakie = {
@@ -36,6 +40,7 @@ use_fakie = {
36
40
  "heel roll",
37
41
  "360",
38
42
  "180",
43
+ "540",
39
44
  "parallel slide",
40
45
  "soul slide",
41
46
  "acid slide",
@@ -52,33 +57,103 @@ exclude_stance = {
52
57
  }.union(use_fakie)
53
58
 
54
59
 
55
- # Generate a trick
56
- def generate_trick() -> list[str]:
57
- selected_move = random.choice(move)
58
- trick = [random.choice(direction)]
60
+ @dataclass
61
+ class Trick:
62
+ direction: Optional[str] = None
63
+ stance: Optional[str] = None
64
+ move: Optional[str] = None
65
+ enter_into_trick: Optional[str] = None
66
+ exit_from_trick: Optional[str] = None
59
67
 
60
- if selected_move not in exclude_stance:
61
- trick.append(random.choice(stance))
68
+ def __post_init__(self) -> None:
69
+ """
70
+ Validate inputs and set random defaults for any attributes that were not provided.
71
+ """
72
+ # Input validation
73
+ if self.direction is not None and self.direction not in DIRECTIONS:
74
+ raise ValueError(f"Invalid direction: '{self.direction}'. Must be one of {DIRECTIONS}")
75
+ if self.stance is not None and self.stance not in STANCES:
76
+ raise ValueError(f"Invalid stance: '{self.stance}'. Must be one of {STANCES}")
77
+ if self.move is not None and self.move not in MOVES:
78
+ raise ValueError(f"Invalid move: '{self.move}'. Must be one of {MOVES}")
62
79
 
63
- trick.append(selected_move)
64
- return trick
80
+ # Generate default values
81
+ if self.direction is None:
82
+ self.direction = random.choice(DIRECTIONS)
65
83
 
84
+ if self.move is None:
85
+ self.move = random.choice(MOVES)
66
86
 
67
- # Generate a combination of tricks. Default setting is random, between 1-5 tricks.
68
- def generate_combo(num_of_tricks: Optional[int] = None) -> list[str]:
87
+ if self.enter_into_trick is None:
88
+ self.enter_into_trick = self.direction
89
+
90
+ if self.exit_from_trick is None:
91
+ self.exit_from_trick = self.direction
92
+
93
+ # Automatically determine stance if not provided
94
+ if self.stance is None and self.move not in exclude_stance:
95
+ self.stance = random.choice(STANCES)
96
+
97
+ # Update exit direction for moves that rotate the body
98
+ if self.move in ["gazelle", "lion", "180", "540"]:
99
+ if self.direction == "back":
100
+ self.exit_from_trick = "front"
101
+ elif self.direction == "front":
102
+ self.exit_from_trick = "back"
103
+
104
+ def __str__(self) -> str:
105
+ parts = []
106
+ display_direction = self.direction
107
+ # Handle fakie/forward display name
108
+ if self.move in use_fakie:
109
+ if self.direction == "back":
110
+ display_direction = "fakie"
111
+ elif self.direction == "front":
112
+ display_direction = "forward"
113
+
114
+ if display_direction:
115
+ parts.append(display_direction)
116
+ if self.stance:
117
+ parts.append(self.stance)
118
+ if self.move:
119
+ parts.append(self.move)
120
+
121
+ return " ".join(parts)
122
+
123
+ def to_dict(self) -> dict[str, Any]:
124
+ """Returns a dictionary representation of the trick, including its full name."""
125
+ data = asdict(self)
126
+ data["name"] = str(self)
127
+ return data
128
+
129
+
130
+ # Generate a combination of tricks. Default is a random number from 2 until 5.
131
+ def generate_combo(num_of_tricks: Optional[int] = None) -> list[dict[str, Any]]:
69
132
  if num_of_tricks is None:
70
- num_of_tricks = random.randint(1, 5)
71
-
72
- trick_line: list[str] = []
73
- for i in range(num_of_tricks):
74
- trick_parts = generate_trick()
75
- # If the move uses the fakie semantics, convert the direction "front"/"back" to "forward"/"fakie"
76
- if trick_parts:
77
- move_name = trick_parts[-1]
78
- if move_name in use_fakie:
79
- if trick_parts[0] == "back":
80
- trick_parts[0] = "fakie"
81
- elif trick_parts[0] == "front":
82
- trick_parts[0] = "forward"
83
- trick_line.append(" ".join(trick_parts))
84
- return trick_line
133
+ num_of_tricks = random.randint(2, 5)
134
+
135
+ if num_of_tricks <= 0:
136
+ return []
137
+
138
+ trick_objects: list[Trick] = []
139
+ previous_trick: Optional[Trick] = None
140
+
141
+ for _ in range(num_of_tricks):
142
+ if previous_trick is None:
143
+ # Generate the first trick without constraints
144
+ new_trick = Trick()
145
+ else:
146
+ # Generate subsequent tricks based on the previous one's exit
147
+ required_direction = previous_trick.exit_from_trick
148
+ # Loop until we generate a valid trick for this position
149
+ while True:
150
+ candidate_trick = Trick(direction=required_direction)
151
+ if candidate_trick.move not in only_first:
152
+ new_trick = candidate_trick
153
+ break
154
+
155
+ trick_objects.append(new_trick)
156
+ previous_trick = new_trick
157
+
158
+ # Convert all trick objects to dictionaries for the final output
159
+ return [trick.to_dict() for trick in trick_objects]
@@ -0,0 +1,107 @@
1
+ Metadata-Version: 2.4
2
+ Name: wzrdbrain
3
+ Version: 0.1.4
4
+ Summary: A simple library to generate trick combinations for wizard skating.
5
+ Author: nazroll
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/nazroll/wzrdbrain
8
+ Project-URL: Documentation, https://github.com/nazroll/wzrdbrain#readme
9
+ Project-URL: Repository, https://github.com/nazroll/wzrdbrain
10
+ Project-URL: Issues, https://github.com/nazroll/wzrdbrain/issues
11
+ Keywords: wizard skating,tricks,random,generator,inline skating
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Topic :: Games/Entertainment
14
+ Classifier: Topic :: Software Development :: Libraries
15
+ Requires-Python: >=3.9
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Provides-Extra: dev
19
+ Requires-Dist: pytest; extra == "dev"
20
+ Requires-Dist: ruff; extra == "dev"
21
+ Requires-Dist: black; extra == "dev"
22
+ Requires-Dist: mypy; extra == "dev"
23
+ Requires-Dist: build; extra == "dev"
24
+ Dynamic: license-file
25
+
26
+ # wzrdbrain
27
+
28
+ A library to generate random trick combinations for wizard skating.
29
+
30
+ ## Installation
31
+
32
+ ```bash
33
+ pip install wzrdbrain
34
+ ```
35
+
36
+ ## Usage
37
+
38
+ The primary function is `generate_combo`, which returns a list of trick dictionaries. You can also create `Trick` objects directly for more control.
39
+
40
+ ```python
41
+ from wzrdbrain import generate_combo, Trick
42
+
43
+ # Generate a combo of 3 tricks
44
+ combo = generate_combo(3)
45
+
46
+ # The output is a list of dictionaries, each representing a trick
47
+ # print(combo)
48
+ # Example output:
49
+ # [
50
+ # {
51
+ # 'direction': 'front', 'stance': 'open', 'move': 'gazelle',
52
+ # 'enter_into_trick': 'front', 'exit_from_trick': 'back',
53
+ # 'name': 'front open gazelle'
54
+ # },
55
+ # {
56
+ # 'direction': 'back', 'stance': None, 'move': '360',
57
+ # 'enter_into_trick': 'back', 'exit_from_trick': 'back',
58
+ # 'name': 'fakie 360'
59
+ # },
60
+ # # ... and so on
61
+ # ]
62
+
63
+ # To get just the names of the tricks in the combo:
64
+ trick_names = [trick['name'] for trick in combo]
65
+ print(trick_names)
66
+ # Example output: ['front open gazelle', 'fakie 360', 'back open lion']
67
+ ```
68
+
69
+ ### Creating a Trick Object
70
+
71
+ You can create a `Trick` object with specific attributes. Any attributes not provided will be randomly generated.
72
+
73
+ ```python
74
+ # Create a trick with a specific move
75
+ my_trick = Trick(move="lion s")
76
+
77
+ # Print the full trick object as a dictionary
78
+ print(my_trick.to_dict())
79
+ # Example output:
80
+ # {
81
+ # 'direction': 'back', 'stance': 'closed', 'move': 'lion s',
82
+ # 'enter_into_trick': 'back', 'exit_from_trick': 'back',
83
+ # 'name': 'back closed lion s'
84
+ # }
85
+ ```
86
+
87
+ ## Development
88
+
89
+ To contribute to this project, please see the [Contributing Guide](CONTRIBUTING.md).
90
+
91
+ First, clone the repository and install the project in editable mode with its development dependencies:
92
+
93
+ ```bash
94
+ git clone https://github.com/nazroll/wzrdbrain.git
95
+ cd wzrdbrain
96
+ pip install -e .[dev]
97
+ ```
98
+
99
+ You can run the test suite using `pytest`:
100
+
101
+ ```bash
102
+ pytest
103
+ ```
104
+
105
+ ## List of wizard skating tricks
106
+
107
+ The list of tricks in this library is not comprehensive. Please create an issue and give us your suggestions of new tricks
@@ -0,0 +1,7 @@
1
+ wzrdbrain/__init__.py,sha256=-b4GWOA6aZBzfRZTmxMCc8QyLTx5NQlBxL_g0-4hK98,162
2
+ wzrdbrain/wzrdbrain.py,sha256=I5j6jWg_P1RI6Pxm2PVsOxYtiwOg4okjziRGt6mbnVM,4779
3
+ wzrdbrain-0.1.4.dist-info/licenses/LICENSE,sha256=5cb0zgcuOCZO8R90wtzkxKYMTdgGLswLH9UHj9ATUoU,11351
4
+ wzrdbrain-0.1.4.dist-info/METADATA,sha256=S9h6hT7eaTky4N25BHJO9Jns2sG0oOeCytV47MVMHnw,3077
5
+ wzrdbrain-0.1.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
+ wzrdbrain-0.1.4.dist-info/top_level.txt,sha256=v5QVWmDcidVAN1NXyn-i9mFxfzSkvGqCRjHs2qyNmLk,10
7
+ wzrdbrain-0.1.4.dist-info/RECORD,,
@@ -1,4 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.27.0
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ wzrdbrain
@@ -1,66 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: wzrdbrain
3
- Version: 0.1.3
4
- Summary: A simple library to generate random trick combinations for wizard skating.
5
- Project-URL: Homepage, https://github.com/nazroll/wzrdbrain
6
- Project-URL: Documentation, https://github.com/nazroll/wzrdbrain#readme
7
- Project-URL: Repository, https://github.com/nazroll/wzrdbrain
8
- Project-URL: Issues, https://github.com/nazroll/wzrdbrain/issues
9
- Author: nazroll
10
- License-Expression: Apache-2.0
11
- License-File: LICENSE
12
- Keywords: generator,inline skating,random,tricks,wizard skating
13
- Classifier: Development Status :: 5 - Production/Stable
14
- Classifier: Intended Audience :: Developers
15
- Classifier: License :: OSI Approved :: Apache Software License
16
- Classifier: Programming Language :: Python
17
- Classifier: Programming Language :: Python :: 3
18
- Classifier: Programming Language :: Python :: 3 :: Only
19
- Classifier: Programming Language :: Python :: 3.9
20
- Classifier: Programming Language :: Python :: 3.10
21
- Classifier: Programming Language :: Python :: 3.11
22
- Classifier: Programming Language :: Python :: 3.12
23
- Classifier: Programming Language :: Python :: 3.13
24
- Classifier: Topic :: Games/Entertainment
25
- Classifier: Topic :: Software Development :: Libraries
26
- Classifier: Typing :: Typed
27
- Requires-Python: >=3.9
28
- Provides-Extra: dev
29
- Requires-Dist: black>=24.3; extra == 'dev'
30
- Requires-Dist: build>=1.2; extra == 'dev'
31
- Requires-Dist: mypy>=1.10; extra == 'dev'
32
- Requires-Dist: pytest>=8; extra == 'dev'
33
- Requires-Dist: ruff>=0.5; extra == 'dev'
34
- Description-Content-Type: text/markdown
35
-
36
- # wzrdbrain
37
-
38
- A simple library to generate random trick combinations for wizard skating.
39
-
40
- ## Installation
41
-
42
- ```bash
43
- pip install wzrdbrain
44
- ```
45
-
46
- ## Usage
47
-
48
- ```python
49
- from wzrdbrain import generate_trick, generate_combo
50
-
51
- # Generate a single trick as a list of its parts
52
- print(generate_trick())
53
- # Example output: ['front', 'open', 'lion']
54
-
55
- # Generate a line of multiple tricks as formatted strings
56
- print(generate_combo(3))
57
- # Example output: ['front parallel', 'fakie toe press', 'forward 360']
58
- ```
59
-
60
- ## List of wizard skating tricks
61
-
62
- The list of tricks in this library is not comprehensive. Please create an issue and give us your suggestions of new tricks to be added.
63
-
64
- ## Contributing
65
-
66
- Contributions are welcome! Please see the [Contributing Guide](CONTRIBUTING.md) for details on how to set up your development environment, run tests, and submit changes.
@@ -1,6 +0,0 @@
1
- wzrdbrain/__init__.py,sha256=trIv6PSyva-qbi3Qjyzu7PAvkZoFT33709p47wHFXFg,196
2
- wzrdbrain/wzrdbrain.py,sha256=jzo4gqiorLL_CSV2aFM3ep6aIcj9o8V6ym81D7FfvYY,1955
3
- wzrdbrain-0.1.3.dist-info/METADATA,sha256=48RG22JRhkAZTay0E4IFTBQYbRIKeU0sJxs6TRyaEl0,2360
4
- wzrdbrain-0.1.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
5
- wzrdbrain-0.1.3.dist-info/licenses/LICENSE,sha256=5cb0zgcuOCZO8R90wtzkxKYMTdgGLswLH9UHj9ATUoU,11351
6
- wzrdbrain-0.1.3.dist-info/RECORD,,