Compare commits

..

12 Commits

3 changed files with 354 additions and 8 deletions

View File

@ -0,0 +1,273 @@
Set Name | Prerelease Kit EV
------------------------------------------------------------
Alpha Edition | #25,189.80
Beta Edition | #11,896.68
From the Vault: Relics | #5,010.96
Unlimited Edition | #3,808.92
Arabian Nights | #3,718.44
From the Vault: Exiled | #1,551.30
From the Vault: Realms | #1,445.22
Vampiric Bloodlust | #1,205.88
Open Hostility | #812.94
Stalwart Unity | #790.98
Legends | #737.58
From the Vault: Legends | #642.36
Draconic Domination | #638.52
Draconic Rage | #598.92
Entropic Uprising | #582.18
From the Vault: Transform | #560.34
From the Vault: Twenty | #542.46
Feline Ferocity | #519.90
From the Vault: Dragons | #518.64
Mystic Intellect | #474.00
Guided by Nature | #460.32
Party Time | #456.96
Lorehold Legacies | #433.08
Aura of Courage | #424.02
Breed Lethality | #423.36
Planar Portal | #408.54
From the Vault: Angels | #407.82
Antiquities | #405.66
Built from Scratch | #397.86
Peer Through Time | #384.84
Heavenly Inferno | #376.38
From the Vault: Lore | #363.00
Political Puppets | #360.24
Plunder the Graves | #348.54
Devour for Power | #347.58
Sworn to Darkness | #347.22
Exit from Exile | #344.40
Witherbloom Witchcraft | #342.60
Counterpunch | #329.34
Mind Flayarrrs | #324.24
Silverquill Statement | #318.72
Forged in Stone | #317.10
Timeless Wisdom | #314.52
Mirror Mastery | #309.54
Wade into Battle | #302.64
Dungeons of Death | #299.88
Invent Superiority | #294.12
Draconic Dissent | #284.76
Swell the Host | #282.84
Arcane Maelstrom | #281.58
Call the Spirits | #281.04
Prismari Performance | #278.28
Eternal Bargain | #267.42
Adaptive Enchantment | #264.84
Evasive Maneuvers | #263.64
Enhanced Evolution | #263.64
Quantum Quandrix | #255.96
Riveteers Rampage | #252.36
Power Hungry | #249.24
Exquisite Invention | #249.06
Bedecked Brokers | #245.16
Revised Edition | #238.86
Cabaretti Cacophony | #237.48
Faceless Menace | #230.40
Primal Genesis | #230.40
Ruthless Regiment | #229.62
Divine vs. Demonic | #228.30
Dimir Control | #228.12
From the Vault: Annihilation | #217.56
Faerie Schemes | #209.94
Mind Seize | #206.70
Buckle Up | #204.36
Savage Hunger | #193.68
Seize Control | #188.22
Undead Unleashed | #186.12
Gruul Stompy | #178.92
Nature of the Beast | #176.52
Knights vs. Dragons | #173.04
Maestros Massacre | #168.90
Upgrades Unleashed | #167.22
Symbiotic Swarm | #164.28
Obscura Operation | #158.16
Allied Fires | #155.40
Deadly Discovery | #153.90
Merciless Rage | #153.60
Mind vs. Might | #153.06
Arcane Wizardry | #151.20
Final Adventure | #146.64
Izzet vs. Golgari | #143.16
Wild Bounty | #140.28
Stronghold | #140.16
Nature's Vengeance | #138.66
Mono-Green Stompy | #135.90
Subjective Reality | #132.18
Vampiric Bloodline | #132.06
Mono-Red Aggro | #131.46
Elves vs. Goblins | #129.48
Garruk vs. Liliana | #127.32
Counter Surge | #126.54
Coven Counters | #125.40
Elves vs. Inventors | #124.56
Rakdos Vampires | #119.76
Phyrexia vs. the Coalition | #119.10
Exodus | #118.62
Urza's Saga | #117.00
Flash of Ferocity | #113.16
Cavalcade Charge | #105.96
Knights' Charge | #105.24
Portal Second Age | #96.72
Signature Spellbook: Jace | #87.72
Signature Spellbook: Chandra | #87.00
Second Sun Control | #86.64
Signature Spellbook: Gideon | #81.12
Tempest | #80.52
Double Masters | #78.78
The Dark | #77.22
Spirit Squadron | #76.74
Merfolk vs. Goblins | #74.10
Urza's Destiny | #72.54
Urza's Legacy | #70.32
Azorius Control | #69.48
Venser vs. Koth | #66.30
Alliances | #65.28
Zendikar vs. Eldrazi | #64.98
Vehicle Rush | #63.66
Ajani vs. Nicol Bolas | #63.66
Ultimate Masters w/ Box Toppers | #61.92
Arcane Tempo | #60.90
Jace vs. Chandra | #58.14
Mirage | #54.36
United Assault | #54.24
Ultimate Masters w/o Box Toppers | #53.10
Eternal Masters | #52.74
Dimir Rogue | #47.52
Blessed vs. Cursed | #46.44
Prophecy | #46.08
Portal | #45.96
Fifth Dawn | #44.88
Weatherlight | #43.08
Hazoret Aggro | #42.96
Lightning Aggro | #39.72
Modern Masters | #39.42
Speed vs. Cunning | #39.06
Coldsnap | #38.70
Elspeth vs. Tezzeret | #38.52
Mirrodin | #37.80
New Phyrexia | #36.84
Scourge | #36.72
Onslaught | #36.30
Visions | #35.70
Judgment | #35.64
Modern Horizons | #35.64
Time Spiral: Remastered | #35.16
Morningtide | #35.04
Shadowmoor | #34.86
Torment | #32.94
Zendikar | #32.76
Darksteel | #32.40
Future Sight | #32.40
Lorwyn | #31.86
Iconic Masters | #31.38
Champions of Kamigawa | #30.60
Masters 25 | #29.28
Modern Masters 2015 | #28.32
Mercadian Masques | #28.20
Ice Age | #27.24
Modern Horizons 2 | #26.04
Elspeth vs. Kiora | #25.92
Jumpstart 2022 | #25.80
Mono White Aggro | #25.50
Battlebond | #24.78
Worldwake | #24.54
Modern Masters 2017 | #24.48
Jumpstart | #24.42
Time Spiral | #23.94
Jace vs. Vraska | #23.88
Odyssey | #23.52
Saviors of Kamigawa | #22.26
Scars of Mirrodin | #21.66
Classic Sixth Edition | #21.12
Betrayers of Kamigawa | #20.94
Eventide | #20.88
Nissa vs. Ob Nixilis | #20.58
Ravnica: City of Guilds | #20.22
Heroes vs. Monsters | #19.74
Rise of the Eldrazi | #19.38
Fifth Edition | #18.90
Conspiracy | #18.78
Conspiracy: Take the Crown | #18.60
Nemesis | #18.54
Magic 2010 (M10) | #18.42
Invasion | #18.36
Avacyn Restored | #17.34
Planar Chaos | #17.04
Ikoria: Lair of Behemoths | #16.50
Alara Reborn | #16.44
Theros Beyond Death | #16.44
Magic 2011 (M11) | #16.32
Dissension | #16.20
Mirrodin Besieged | #16.08
Fourth Edition | #16.02
Kamigawa: Neon Dynasty | #15.84
10th Edition | #15.78
Apocalypse | #15.42
9th Edition | #15.24
Kaladesh w/ Inventions | #15.24
Legions | #15.18
Core Set 2020 | #14.94
March of the Machine | #14.88
Planeshift | #14.76
Khans of Tarkir | #14.76
Rivals of Ixalan | #14.16
Phyrexia: All Will Be One | #13.98
7th Edition | #13.74
Chronicles | #13.32
Kaldheim | #13.14
Journey Into Nyx | #12.84
The Brothers' War | #12.84
Gatecrash | #12.60
Conflux | #12.24
Return to Ravnica | #12.24
Throne of Eldraine | #12.24
Shards of Alara | #12.18
Wilds of Eldraine | #12.18
War of the Spark | #12.06
Amonkhet w/ Invocations | #11.94
Dominaria United | #11.88
Magic 2014 (M14) | #11.70
Ravnica Allegiance | #11.46
Aether Revolt w/ Inventions | #11.16
Zendikar Rising | #11.16
The Lost Caverns of Ixalan | #11.16
8th Edition | #11.10
Magic 2012 (M12) | #11.10
Adventures in the Forgotten Realms | #10.92
Strixhaven: School of Mages | #10.92
Streets of New Capenna | #10.44
Core Set 2021 | #10.32
Magic 2013 (M13) | #10.26
Innistrad | #10.14
Innistrad: Crimson Vow | #10.08
Amonkhet w/o Invocations | #9.96
Dominaria | #9.90
Core Set 2019 | #9.72
Eldritch Moon | #9.66
Theros | #9.48
Hour of Devastation w/ Invocations | #9.48
Guildpact | #9.30
Magic 2015 (M15) | #9.24
Innistrad: Midnight Hunt | #9.00
Guilds of Ravnica | #8.88
Kaladesh w/o Inventions | #8.76
Oath of the Gatewatch w/ Expeditions | #8.28
Ixalan | #8.22
Aether Revolt w/o Inventions | #8.04
Battle for Zendikar w/ Expeditions | #7.86
Fate Reforged w/ Fetches | #7.80
Hour of Devastation w/o Invocations | #7.62
Magic Origins | #7.26
Dragons of Tarkir | #7.08
Homelands | #6.96
Fate Reforged w/o Fetches | #6.24
Oath of the Gatewatch w/o Expeditions | #6.18
Shadows over Innistrad | #5.82
Born of the Gods | #5.28
Sorin vs. Tibalt | #4.80
Battle for Zendikar w/o Expeditions | #4.32
Fallen Empires | #3.60
Dark Ascension | #3.24
Dragon's Maze w/ Shocks | #2.58
Dragon's Maze w/o Shocks | #1.92

62
prereleasing/prereleasekit.py Executable file
View File

@ -0,0 +1,62 @@
#!/usr/bin/python
import re
import requests
from bs4 import BeautifulSoup
from dataclasses import dataclass, field
def get_price_in_gbp(price):
price_str = re.search(r'\d?,?\d+\.\d+', price).group()
price_str_no_comma = re.sub(",", "", price_str)
price_usd = float(price_str_no_comma)
price_gbp = usd_to_gbp(price_usd)
return price_gbp
def usd_to_gbp(dollars):
return round(dollars * 0.8, 2)
def get_dawnglare_html():
response = requests.get("https://mtg.dawnglare.com/?p=sets&pack=1")
if response.status_code != 200:
print("Request to Dawnglare failed with status code: " + response.status_code)
os.exit(1)
return response.text
@dataclass(order=True)
class ExpectedValue():
setName: str = field(compare=False)
boosterPackEV: float = field(compare=True)
@property
def prereleasePackEV(self):
return self.boosterPackEV * 6
def get_expected_values(soup):
prices = soup.find_all(class_="cP")
names = soup.find_all(class_="cN")
evs = []
for i in range(0, len(prices)):
setName = names[i].text
boosterPackEV = get_price_in_gbp(prices[i].text)
ev = ExpectedValue(setName, boosterPackEV)
evs.append(ev)
return evs
def main():
html = get_dawnglare_html()
soup = BeautifulSoup(html, features="lxml")
evs = get_expected_values(soup)
sorted_by_ev = sorted(evs, reverse=True)
print(f"{'Set Name':<40} | Prerelease Kit EV")
print("-" * 60)
for setEV in sorted_by_ev:
print(f'{setEV.setName:<40} | #{setEV.prereleasePackEV:,.2f}')
if __name__ == "__main__":
main()

View File

@ -68,10 +68,23 @@ func createProductTable(db *sql.DB) {
}
}
func insertProduct(db *sql.DB, product Product) {
query := "INSERT INTO Product (Name, Price, Available) VALUES ($1, $2, $3);"
func insertProduct(db *sql.DB, product Product) int64 {
query := "INSERT INTO Product (Name, Price, Available) VALUES (?, ?, ?);"
db.QueryRow(query, product.Name, product.Price, product.Available)
insert, err := db.Prepare(query)
defer insert.Close()
if err != nil {
log.Fatal(err)
}
result, err := insert.Exec(product.Name, product.Price, product.Available)
rowsAffected, _ := result.RowsAffected()
if err != nil || rowsAffected != 1 {
log.Fatal(err)
}
insertedRowId, _ := result.LastInsertId()
return insertedRowId
}
func getAllProducts(db *sql.DB) []Product {
@ -83,16 +96,14 @@ func getAllProducts(db *sql.DB) []Product {
}
defer rows.Close()
var name string
var price float64
var available bool
var product Product
for rows.Next() {
err := rows.Scan(&name, &price, &available)
err := rows.Scan(&product.Name, &product.Price, &product.Available)
if err != nil {
log.Fatal(err)
}
products = append(products, Product{name, price, available})
products = append(products, product)
}
return products