Skip to content

Commit

Permalink
Updating Unkie data (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
r0levrai committed Jun 14, 2024
1 parent b177b49 commit 171effc
Show file tree
Hide file tree
Showing 15 changed files with 12,498 additions and 0 deletions.
71 changes: 71 additions & 0 deletions data/convert_unkie_names_to_ids.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import csv
import json
from functools import cache
from pprint import pprint

@cache
def read_json(path):
with open(path, encoding='utf-8') as f:
return json.load(f)

path_in = "unkie_manually_typed/update 5 manually typed by burger/without_ids.csv"
path_out = "unkie_manually_typed/update 5 manually typed by burger/with_ids.csv"
with open(path_in, encoding='utf-8') as file_in, open(path_out, 'w', encoding='utf-8') as file_out:
for i_row, row in enumerate(csv.reader(file_in)):
if i_row == 0: # ignore header
continue
tab, subtab, name, price, rarity = row
tab = ' '.join(tab.split(' ')[1:])
subtab = ' '.join(subtab.split(' ')[1:])
price = int(price)
rarity = int(rarity.split(' ')[0])
rarity = {
0: None,
1: 'Cool',
2: 'Awesome',
3: 'SuperAwesome'
}[rarity]
store_data_for_subtab = {
'Street': 'vehicles_by_id.json',
'Off-Road': 'vehicles_by_id.json',
'Water': 'vehicles_by_id.json',
'Drivers': None,
'Flair': 'flairs_by_id.json',
'Stickers': 'stickers_by_id.json',
'Brick Packs': 'brickpacks_by_id.json',
'Engines': None,
'Horns': None,
}
id_for_name = {
'Tall Flag (Blue)': 'Flagpole_31079_Blue', # could be 'Flagpole_31079_Blue' or 'Flagpole_31079'
'Sunset Track Racer': 'TrackRacer_31089', # could be 'SportsCar_31089' (offroad) or 'TrackRacer_31089' (street)
'School Bus': 'SchoolBus_60329', # could be 'SchoolBus_VC70423' (garage_valid: 'CostExceeded') or 'SchoolBus_60329' (license: "City")
}
if tab == 'Store':
data_path = store_data_for_subtab[subtab]
if data_path is None:
continue
item_data = read_json(data_path)
elif tab == 'Official':
item_data = read_json('vehicles_by_id.json')
else:
raise NotImplemented(tab)
if item_data is not None:
items = [item for item in item_data.values() if name.lower() == item['name'].replace(' (new!)', '').lower().strip()]
if len(items) == 1:
id = items[0]['id']
elif not items:
print(' | could not find item name', name)
id = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
else: # several matching items
if name in id_for_name:
id = id_for_name[name]
elif len([item for item in items if rarity == item['rarity']]) == 1:
items = [item for item in items if rarity == item['rarity']]
id = items[0]['id']
else:
print(' | ambiguous id for item name', name, ': can be')
print(*items, sep='\n')
id = 'WWWWWWWWWWWWWWWWWWWWWWWWWWWWWW'
print(tab, subtab, name, price, rarity, id, sep=', ')
print(id, tab, subtab, price, sep=', ', file=file_out)
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
[
{
"storeId": "d57a26ba69134a759ff28fb9edb116d0",
"offerId": "dda91d68eaa54990aad581672f993ee8",
"name": "Chip Off The Old Brick",
"tags": [
"awesome",
"bundle"
],
"type": 0,
"offerData": "{\r\n \"OfferImageURL\": \"https://promotions-ew-assets.2kcoretech.online/assets/0fecde9d7aef896f7cca498fb2f085910dd218bce7d113a58704d9ef8ae7cf07-game.png\"\r\n}",
"validUntilInMs": 1699459199000,
"pricings": [
{
"priceValues": [
{
"currency": "BBX",
"amount": 19200,
"originalAmount": 19200
}
]
}
],
"sku": {
"id": "48634dd94492472da2a0be8b1d3b5c75",
"name": "Chip Off The Old Brick",
"includedItems": [
{
"id": "c15f65c18b2342c2a9f73d260fbd7042",
"quantity": 1,
"type": 0,
"customData": "Flair:Flair_HotSeat_Yellow"
},
{
"id": "ab87c6a6b3f4404b8bfdde6553986ac2",
"quantity": 1,
"type": 0,
"customData": "Vehicle:P59PlaneBoat_VC000"
},
{
"id": "35de138692904c91862a106630a74d0d",
"quantity": 1,
"type": 0,
"customData": "Minifig:Desert_male_15"
}
],
"sid": 0,
"allowRepurchaseUnique": false
},
"isValid": true,
"partialPurchasePolicy": "applySmartPricing"
},
{
"storeId": "d57a26ba69134a759ff28fb9edb116d0",
"offerId": "61bc7dbe4bf04a0b9b720e9b47551cc9",
"name": "Robo-Buggy",
"tags": [
"superawesome",
"bundle"
],
"type": 0,
"offerData": "{\r\n \"OfferImageURL\": \"https://promotions-ew-assets.2kcoretech.online/assets/000feaa31b6559dc6850fdf1b1fbeb3c5c77b1bc4f1ab558d5906a5a55eae77f-game.png\"\r\n}",
"validUntilInMs": 1699459199000,
"pricings": [
{
"priceValues": [
{
"currency": "BBX",
"amount": 16000,
"originalAmount": 16000
}
]
}
],
"sku": {
"id": "b4f534577e8f4f04bcd876d100eb4230",
"name": "Robo-Buggy",
"includedItems": [
{
"id": "bdb62dedd3534726a62911494bf21300",
"quantity": 1,
"type": 0,
"customData": "Minifig:Bandit_Ra"
},
{
"id": "5c2b28eaeb0f46b0ae1e5e2073807d7d",
"quantity": 1,
"type": 0,
"customData": "Vehicle:Traffic_HV_02Street"
}
],
"sid": 0,
"allowRepurchaseUnique": false
},
"isValid": true,
"partialPurchasePolicy": "applySmartPricing"
},
{
"storeId": "d57a26ba69134a759ff28fb9edb116d0",
"offerId": "0595d0b6eaf14a29baa125d864ecfeda",
"name": "Up in the Air",
"tags": [
"Bundle",
"Cool"
],
"type": 0,
"offerData": "{\r\n \"OfferImageURL\": \"https://promotions-ew-assets.2kcoretech.online/assets/40cc03dbf9f35ee45f6b565c2fd202d491670cf0a8701bcd2180a1b322b4aefa-game.png\"\r\n}",
"validUntilInMs": 1699459199535,
"pricings": [
{
"priceValues": [
{
"currency": "BBX",
"amount": 9600,
"originalAmount": 9600
}
]
}
],
"sku": {
"id": "38c4b82235514431ad2966c934c1a783",
"name": "Up in the Air",
"includedItems": [
{
"id": "48655e995bdc4bf88d46cbeb7fd1538f",
"quantity": 1,
"type": 0,
"customData": "Flair:Flair_Wingit_Green"
},
{
"id": "76197fe117d4444eb0bfa9366da1ec7f",
"quantity": 1,
"type": 0,
"customData": "Flair:Flair_Wingit_Blue"
},
{
"id": "651feeb893f74d3594926ed906c3ad11",
"quantity": 1,
"type": 0,
"customData": "Minifig:Pilot_FA"
}
],
"sid": 0,
"allowRepurchaseUnique": false
},
"isValid": true,
"partialPurchasePolicy": "applySmartPricing"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
[
{
"storeId": "3d48d3edead944cbaa257915d6631054",
"offerId": "4be8d50ad5fd40fa8028de353ff77caa",
"name": "Fishing Boat",
"type": 0,
"validUntilInMs": 1851404399000,
"pricings": [
{
"priceValues": [
{
"currency": "BBX",
"amount": 0,
"originalAmount": 0
}
]
}
],
"sku": {
"id": "f3de66946e3c44f29e3ca6a553d928bb",
"name": "Fishing Boat",
"includedItems": [
{
"id": "98e5024db9264d6da847763bdbc453ff",
"quantity": 1,
"type": 0,
"customData": "Vehicle:FishingBoat_VC70442"
}
],
"sid": 0,
"allowRepurchaseUnique": false
},
"isValid": true,
"partialPurchasePolicy": "notAllowed"
},
{
"storeId": "3d48d3edead944cbaa257915d6631054",
"offerId": "e48dff84e63c47e6bc130955a1930710",
"name": "Jack Custardly",
"type": 0,
"validUntilInMs": 1699459199000,
"pricings": [
{
"priceValues": [
{
"currency": "BBX",
"amount": 6000,
"originalAmount": 6000
}
]
}
],
"sku": {
"id": "c5ef3a9f8bc2422782ff06fc8bb9e45d",
"name": "Jack Custardly",
"includedItems": [
{
"id": "a826e5fcab2a472e8a560d2ee218719a",
"quantity": 1,
"type": 0,
"customData": "Minifig:Desert_male_13"
}
],
"sid": 0,
"allowRepurchaseUnique": false
},
"isValid": true,
"partialPurchasePolicy": "notAllowed"
},
{
"storeId": "3d48d3edead944cbaa257915d6631054",
"offerId": "6aa09cb41a1c4bb593a0cab47dba6f05",
"name": "Micro Jet (Blue)",
"type": 0,
"validUntilInMs": 1699459199000,
"pricings": [
{
"priceValues": [
{
"currency": "BBX",
"amount": 10000,
"originalAmount": 10000
}
]
}
],
"sku": {
"id": "edc9c267f98e46eda70d631352d34537",
"name": "Micro Jet (Blue)",
"includedItems": [
{
"id": "3d36471c9c72468f99847f71d3472878",
"quantity": 1,
"type": 0,
"customData": "Flair:Flair_RocketJet_Blue"
}
],
"sid": 0,
"allowRepurchaseUnique": false
},
"isValid": true,
"partialPurchasePolicy": "notAllowed"
},
{
"storeId": "3d48d3edead944cbaa257915d6631054",
"offerId": "48c2cb2d1be94a2b9dda32fcbf10ce91",
"name": "Pepperoni Express Off-roader",
"type": 0,
"validUntilInMs": 1699459199798,
"pricings": [
{
"priceValues": [
{
"currency": "BBX",
"amount": 14000,
"originalAmount": 14000
}
]
}
],
"sku": {
"id": "06bcc31800214019b14ad55ad5491222",
"name": "Pepperoni Express Off-roader",
"includedItems": [
{
"id": "a3efd00a0ee04943ae0d14ca12224855",
"quantity": 1,
"type": 0,
"customData": "Vehicle:PizzaCar_VC001"
}
],
"sid": 0,
"allowRepurchaseUnique": false
},
"isValid": true,
"partialPurchasePolicy": "notAllowed"
},
{
"storeId": "3d48d3edead944cbaa257915d6631054",
"offerId": "26954af332fe41cba8ac4881b3714f09",
"name": "Surf Chopper",
"type": 0,
"validUntilInMs": 1699459199000,
"pricings": [
{
"priceValues": [
{
"currency": "BBX",
"amount": 20000,
"originalAmount": 20000
}
]
}
],
"sku": {
"id": "1fa73306060941fda53173bd954f3d90",
"name": "Surf Chopper",
"includedItems": [
{
"id": "44156989b43044dcb1f50feb358b272d",
"quantity": 1,
"type": 0,
"customData": "Vehicle:SurfChopper_VC000"
}
],
"sid": 0,
"allowRepurchaseUnique": false
},
"isValid": true,
"partialPurchasePolicy": "notAllowed"
}
]
Loading

0 comments on commit 171effc

Please sign in to comment.