|
1 | 1 | """# Transformation |
2 | 2 |
|
3 | | -The building blocks of every crafting environment. |
4 | | -Each crafting environment is defined by a list of transformations. |
5 | | -They becomes the available actions of the environment. |
6 | | -
|
7 | | -Each transformation defines changes of: |
8 | | -
|
9 | | -* the player inventory |
10 | | -* the player position |
11 | | -* the current zone inventory |
12 | | -* the destination zone inventory (if the player postition changes). |
13 | | -* any specific zones inventories |
14 | | -
|
15 | | -Each inventory change is a list of removed and added ItemStack. |
16 | | -They may be available only in a subset of zones, or in every zone. |
17 | | -
|
18 | 3 | ## Examples |
19 | 4 |
|
20 | 5 | ```python |
|
129 | 114 |
|
130 | 115 |
|
131 | 116 | class Transformation: |
| 117 | + """The building blocks of every crafting environment. |
| 118 | +
|
| 119 | + A list of transformations is what defines each crafting environement. |
| 120 | + Transformation becomes the available actions and all available transitions of the environment. |
| 121 | +
|
| 122 | + Each transformation defines changes of: |
| 123 | +
|
| 124 | + * the player inventory |
| 125 | + * the player position to a given destination |
| 126 | + * the current zone inventory |
| 127 | + * the destination zone inventory (if a destination is specified). |
| 128 | + * all specific zones inventories |
| 129 | +
|
| 130 | + Each inventory change is a list of removed (-) and added (+) ItemStack. |
| 131 | +
|
| 132 | + If specified, they may be restricted to only a subset of valid zones, |
| 133 | + all zones are valid by default. |
| 134 | +
|
| 135 | + A Transformation can only be applied if valid in the given state. |
| 136 | + A transformation is only valid if the player in a valid zone |
| 137 | + and all relevant inventories have enough items to be removed *before* adding new items. |
| 138 | +
|
| 139 | + The picture bellow illustrates the impact of |
| 140 | + an example transformation on a given `crafting.CraftingState`: |
| 141 | +  |
| 142 | +
|
| 143 | + In this example, when applied, the transformation will: |
| 144 | +
|
| 145 | + * <span style="color:red">(-)</span> |
| 146 | + Remove 1 item "0", then <span style="color:red">(+)</span> |
| 147 | + Add 4 item "3" in the <span style="color:red">player inventory</span>. |
| 148 | + * Update the <span style="color:gray">player position</span> |
| 149 | + from the <span style="color:green">current zone</span> "1". |
| 150 | + to the <span style="color:orange">destination zone</span> "3". |
| 151 | + * <span style="color:green">(-)</span> |
| 152 | + Remove 2 zone item "0" and 1 zone item "1", then <span style="color:green">(+)</span> |
| 153 | + Add 1 item "1" in the <span style="color:green">current zone</span> inventory. |
| 154 | + * <span style="color:orange">(-)</span> |
| 155 | + Remove 1 zone item "2", then <span style="color:orange">(+)</span> |
| 156 | + Add 1 item "0" in the <span style="color:orange">destination zone</span> inventory. |
| 157 | + * <span style="color:blue">(-)</span> |
| 158 | + Remove 1 zone item "0" in the zone "1" inventory |
| 159 | + and 2 zone item "2" in the zone "2" inventory, |
| 160 | + then <span style="color:blue">(+)</span> |
| 161 | + Add 1 zone item "1" in the zone "0" inventory |
| 162 | + and 1 zone item "2" in the zone "1" inventory. |
| 163 | +
|
| 164 | + """ |
| 165 | + |
132 | 166 | OPERATIONS = [ |
133 | 167 | "destination", |
134 | 168 | "zones", |
@@ -159,6 +193,30 @@ def __init__( |
159 | 193 | Dict[Zone, List[Union["ItemStack", "Item"]]] |
160 | 194 | ] = None, |
161 | 195 | ) -> None: |
| 196 | + """The building blocks of every crafting environment. |
| 197 | +
|
| 198 | + Args: |
| 199 | + destination: Destination zone. |
| 200 | + Defaults to None. |
| 201 | + zones: List of valid zones, if None all zones are valid. |
| 202 | + Defaults to None. |
| 203 | + removed_player_items: List of removed ItemStacks from the player inventory. |
| 204 | + Defaults to None. |
| 205 | + added_player_items: List of added ItemStacks to the player inventory. |
| 206 | + Defaults to None. |
| 207 | + removed_destination_items: List of removed ItemStacks from the destination inventory. |
| 208 | + Defaults to None. |
| 209 | + added_destination_items : List of added ItemStacks to the destination inventory. |
| 210 | + Defaults to None. |
| 211 | + removed_zone_items: List of removed ItemStacks from the current zone inventory. |
| 212 | + Defaults to None. |
| 213 | + added_zone_items: List of added ItemStacks to the current zone inventory. |
| 214 | + Defaults to None. |
| 215 | + removed_zones_items: Dictionary of Lists of removed ItemStacks for each zone. |
| 216 | + Defaults to None. |
| 217 | + added_zones_items: Dictionary of Lists of added ItemStacks for each zone. |
| 218 | + Defaults to None. |
| 219 | + """ |
162 | 220 | self.destination = destination |
163 | 221 | self._destination = None |
164 | 222 |
|
|
0 commit comments