Skip to content

Commit

Permalink
Updates July 16 (#25)
Browse files Browse the repository at this point in the history
* Improved ReadMe
* Updated to resolve #22
  • Loading branch information
axxroytovu authored Jul 16, 2023
1 parent fd014ed commit 8b58b98
Show file tree
Hide file tree
Showing 6 changed files with 245 additions and 45 deletions.
256 changes: 229 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,63 @@ Repository that collects all sealed MTG products and maps their contents

## Product contents

Product sealed contents use the following types:
Product sealed contents use the following types: `card`, `pack`, `deck`, `sealed`, `variable`, and `other`.

### `card`

A `card` object refers to a single card, usually a promotional card.

`card` objects have the following properties:

```
name: [str] Full card name
set: [str] Set code
number: [str or int] Collector number
foil: [bool, optional] True if card is traditional or etched foil
uuid: [str, calculated] The card's MTGJson UUID. This is calculated by the compiler and you should not enter this in the YAML.
```

Example card YAML input:

```yaml
Phyrexia All Will Be One Compleat Bundle:
card:
- set: one
name: Phyrexian Arena
number: 283
foil: true
...
```

JSON result:

```json
"contents": {
"card": [
{
"foil": true,
"name": "Phyrexian Arena",
"number": "283",
"set": "one",
"uuid": "dab29a67-28a9-5847-a77e-1f0771b55be1"
}
],
"...": []
}
```

### `pack`

A `pack` object refers to an existing object in MTGJson `{set}.booster`. Example pack:
A `pack` object refers to an existing object in MTGJson `{set}.booster`. When `pack` is included in the product contents, the `card_count` parameter is required.

`pack` objects have the following properties:

```
set: [str] Set code
code: [str] Internal reference code targeting {set}.booster. 'default' refers to the draft booster for a given set.
```

Example pack YAML input:

```yaml
Unlimited Edition Booster Pack:
Expand All @@ -16,9 +68,31 @@ A `pack` object refers to an existing object in MTGJson `{set}.booster`. Example
code: default
```
JSON result:
```json
"contents": {
"pack": [
{
"code": "default",
"set": "2ed"
}
]
}
```

### `deck`

A `deck` object refers to a precompiled deck object. Example deck:
A `deck` object refers to a precompiled deck object. When `deck` is included in the product contents, the `card_count` parameter is required.

`deck` objects have the following properties:

```
set: [str] Set code
name: [str] The deck's name matching its MTGJson object.
```

Example deck YAML input:

```yaml
7th Edition Theme Deck Armada:
Expand All @@ -27,9 +101,33 @@ A `deck` object refers to a precompiled deck object. Example deck:
name: Armada
```
JSON result:
```json
"contents": {
"deck": [
{
"name": "Armada",
"set": "7ed"
}
]
}
```

### `sealed`

A `sealed` object refers to another sealed object. Sealed objects have a `count` associated with them. Example sealed:
A `sealed` object refers to another sealed object.

`sealed` objects have the following properties:

```
set: [str] Set code
name: [str] The product name
count: [int] Count of included products
uuid: [str, calculated] The MTGJson UUID of the linked product. This is calculated by the compiler and should not be added in the YAML.
```

Example sealed YAML input:

```yaml
Unlimited Edition Booster Box:
Expand All @@ -39,43 +137,129 @@ A `sealed` object refers to another sealed object. Sealed objects have a `count`
set: 2ed
```
JSON result:
```json
"contents": {
"sealed": [
{
"count": 36,
"name": "Unlimited Booster Pack",
"set": "2ed",
"uuid": "3f7ddeba-52f5-5f8f-a013-309403c8a870"
}
]
}
```

### `variable`

A `variable` object contains a list of sub-contents. Example variable:
A `variable` object contains a list of possible contents for the product.

`variable` products are defined in two sections: the main `variable` key and the `variable_mode` key.

The `variable` key defines all the possible sub-components to be chosen from randomly.

The `variable_mode` key defines how the components will be randomized.

`variable` objects have the following properties:

```
configs: [list[object]] A list of the possible configuration objects
```

`variable_mode` objects have the following properties:

```
count: [int] The number of components to pull
replacement: [bool] Whether duplicates are allowed in the randomization
```

Example variable YAML input:

```yaml
Phyrexia All Will Be One Jumpstart Booster Pack:
Amonkhet Booster Battle Pack:
card_count: 60
sealed:
- count: 2
name: Amonkhet Booster Pack
set: akh
variable:
- deck:
- set: one
name: Mite-y 1
- name: Amonkhet Welcome Deck - White
set: w17
- deck:
- set: one
name: Mite-y 2
...
- name: Amonkhet Welcome Deck - Blue
set: w17
- deck:
- name: Amonkhet Welcome Deck - Black
set: w17
- deck:
- name: Amonkhet Welcome Deck - Red
set: w17
- deck:
- name: Amonkhet Welcome Deck - Green
set: w17
variable_mode:
count: 2
replacement: false
```
### `card`
JSON result:
A `card` object refers to a single card (usually a promo). Example card:

```yaml
Phyrexia All Will Be One Compleat Bundle
sealed:
- set: one
name: Phyrexia All Will Be One Set Booster Pack
count: 12
card:
- set: one
name: Phyrexian Arena
number: 283
foil: true
...
```json
"contents": {
"sealed": [
{
"count": 2,
"name": "Amonkhet Booster Pack",
"set": "akh",
"uuid": "bdfaa43d-9ebd-502f-856b-11eadc97b026"
}
],
"variable": [
{
"configs": [
{
"deck": [
{
"name": "Amonkhet Welcome Deck - White",
"set": "w17"
},
{
"name": "Amonkhet Welcome Deck - Blue",
"set": "w17"
}
]
},
{
"deck": [
{
"name": "Amonkhet Welcome Deck - White",
"set": "w17"
},
{
"name": "Amonkhet Welcome Deck - Black",
"set": "w17"
}
]
},
{"...": ""}
]
}
]
}
```

### `other`

An `other` object refers to things not included in MTGJson. Example other:
An `other` object refers to things not included in MTGJson.

`other` objects have the following property:

`name: [str] A string describing the object`

Example other YAML input:

```yaml
Unlimited Edition Starter Deck:
Expand All @@ -85,3 +269,21 @@ An `other` object refers to things not included in MTGJson. Example other:
other:
- name: Unlimited Edition Starter Deck Rulebook
```
JSON result:
```json
"contents": {
"other": [
{
"name": "Unlimited Edition Starter Deck Rulebook"
}
],
"pack": [
{
"code": "starter",
"set": "2ed"
}
]
}
```
6 changes: 5 additions & 1 deletion data/contents/2XM.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ products:
- count: 3
name: Double Masters Draft Booster Pack
set: 2xm
Double Masters Box Topper Pack: []
Double Masters Box Topper Pack:
card_count: 1
pack:
- set: 2xm
code: box-topper
Double Masters Draft Booster Box:
sealed:
- count: 24
Expand Down
16 changes: 6 additions & 10 deletions data/contents/AKH.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
code: akh
products:
Amonkhet Booster Battle Pack:
card_count: 60
sealed:
- count: 2
name: Amonkhet Booster Pack
set: akh
variable:
- card_count: 30
deck:
- deck:
- name: Amonkhet Welcome Deck - White
set: w17
- card_count: 30
deck:
- deck:
- name: Amonkhet Welcome Deck - Blue
set: w17
- card_count: 30
deck:
- deck:
- name: Amonkhet Welcome Deck - Black
set: w17
- card_count: 30
deck:
- deck:
- name: Amonkhet Welcome Deck - Red
set: w17
- card_count: 30
deck:
- deck:
- name: Amonkhet Welcome Deck - Green
set: w17
variable_mode:
Expand Down
8 changes: 3 additions & 5 deletions outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,8 @@ def validate_contents(contents, route, logger, uuid_map, cc=True):
elif key == "variable":
check = True
try:
for configuration in value:
if "card_count" in contents:
check *= validate_contents(dict({"card_count": contents["card_count"]}, **configuration), route+"-variable", logger, uuid_map, cc=False)
else:
for product in value:
for configuration in product["configs"]:
check *= validate_contents(configuration, route+"-variable", logger, uuid_map, cc=False)
except:
logger.error("%s variable formatted incorrectly", route)
Expand Down Expand Up @@ -234,7 +232,7 @@ def parse_variable(contents, logger=None):
else:
for combo in itr.combinations(contents["variable"], options.get("count", 1)):
temp_variable.append(iterative_sum(combo, logger))
contents["variable"] = temp_variable
contents["variable"] = [{"configs": temp_variable}]
return contents

def deck_links(contents, uuid, logger=None):
Expand Down
2 changes: 1 addition & 1 deletion outputs/contents.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion outputs/deck_map.json

Large diffs are not rendered by default.

0 comments on commit 8b58b98

Please sign in to comment.