Module: GamesAndRpgParadise::MagicTheGathering
- Extended by:
- GamesAndRpgParadise
- Defined in:
- lib/games_and_rpg_paradise/games/magic_the_gathering/project/project.rb,
lib/games_and_rpg_paradise/games/magic_the_gathering/base/base.rb,
lib/games_and_rpg_paradise/games/magic_the_gathering/menu/menu.rb,
lib/games_and_rpg_paradise/games/magic_the_gathering/classes/sort_cards.rb,
lib/games_and_rpg_paradise/games/magic_the_gathering/constants/constants.rb,
lib/games_and_rpg_paradise/games/magic_the_gathering/classes/obtain_price_from.rb,
lib/games_and_rpg_paradise/games/magic_the_gathering/classes/parse_card_format.rb,
lib/games_and_rpg_paradise/games/magic_the_gathering/classes/download_single_card.rb,
lib/games_and_rpg_paradise/games/magic_the_gathering/classes/parse_multiple_cards.rb,
lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb,
lib/games_and_rpg_paradise/games/magic_the_gathering/classes/store_card_information.rb,
lib/games_and_rpg_paradise/games/magic_the_gathering/classes/download_from_spielraum.rb,
lib/games_and_rpg_paradise/games/magic_the_gathering/classes/search_for_this_magic_card.rb,
lib/games_and_rpg_paradise/games/magic_the_gathering/classes/add_n_lands_to_these_n_non_lands.rb,
lib/games_and_rpg_paradise/games/magic_the_gathering/classes/download_cards_from_gatherer_wizards_com.rb,
lib/games_and_rpg_paradise/games/magic_the_gathering/classes/show_price_information_from_magickartenmarkt.rb
Overview
GamesAndRpgParadise::MagicTheGathering
Defined Under Namespace
Classes: AddNLandsToTheseNNonLands, Base, DownloadCardsFromGathererWizardsCom, DownloadFromSpielraum, DownloadSingleCard, ObtainPriceFrom, ParseCardFormat, ParseMultipleCards, SearchForThisMagicCard, ShowPriceInformationFromMagickartenmarkt, SortCards, StoreCardInformation
Constant Summary collapse
- PROJECT_BASE_DIRECTORY =
#
PROJECT_BASE_DIRECTORY
#
File.absolute_path("#{__dir__}/..")+'/'
- PROJECT_DIR =
PROJECT_DIR
PROJECT_BASE_DIRECTORY
- PROJECT_YAML_DIRECTORY =
#
PROJECT_YAML_DIRECTORY
#
"#{PROJECT_BASE_DIRECTORY}yaml/"
- ISO_ENCODING =
#
ISO_ENCODING
#
'ISO-8859-1'
- UTF_ENCODING =
#
UTF_ENCODING
#
'UTF-8'
- FILE_KARTENLISTE_MIT_PREISEN_CSV =
#
FILE_KARTENLISTE_MIT_PREISEN_CSV
This entry is valid for my home system.
#
"#{HOME_DIRECTORY_OF_THE_USER_X}data/personal/magic_the_gathering/"\ "Kartenliste_mit_Preisen.csv"
- FILE_KARTENLISTE_CSV =
#
FILE_KARTENLISTE_CSV
This file here is assumed to also include the card-sets, that is, the name of the card sets.
#
"#{HOME_DIRECTORY_OF_THE_USER_X}data/GAMES/magic_the_gathering/Kartenliste.csv"
- TRY_TO_USE_JPEGOPTIM_TO_OPTIMIZE_JPG_FILES =
#
TRY_TO_USE_JPEGOPTIM_TO_OPTIMIZE_JPG_FILES
#
true
- LOG_DIR =
#
LOG_DIR
Store into:
/Depot/Temp/magic_the_gathering/
#
"#{TEMP_DIR}magic_the_gathering/"
- DEFAULT_SET_NAME =
#
DEFAULT_SET_NAME
#
'Eldritch Moon'
- FILE_TOTAL_CARDS =
#
FILE_TOTAL_CARDS
#
"#{yaml_dir?}total_cards.yml"
- FILE_MAIN_CARD_SET =
#
FILE_MAIN_CARD_SET
#
"#{GamesAndRpgParadise.yaml_dir?}games/magic_the_gathering/main_card_set.yml"
- ARRAY_COLOURS =
#
ARRAY_COLOURS
All the colours that are available in magic should be registered in this Array.
#
%w( colourless white blue black red green multicolour artefact land )
- REGEX_FOR_THE_CARD_NUMBER =
#
REGEX_FOR_THE_CARD_NUMBER
See the following URL for this regex in use:
https://rubular.com/r/YNxPwoJJHB
#
/Card Number:<\/div>\s+<div(a id="ctl00_ctl00_ctl00_MainContent_SubContent_SubContent_CardNumberValue")? class="value">\s+(\d{1,2}[abcdef]{0,1})/
- REGEX_FOR_RARITY_OF_A_CARD =
#
REGEX_FOR_RARITY_OF_A_CARD
#
/Rarity:<\/div>\s+<div class="value">\s+<span class='(.+)'>/
- REGEX_AVAILABLE_SINCE =
#
REGEX_AVAILABLE_SINCE
This is the regex that can be used to determine at which price the cards will be available.
#
/<td class="outerLeft col_Even col_0 cell_1_0">Verf.{1}gbar ab \(EX\+\)\:<\/td><td class="outerRight col_Odd col_1 cell_1_1"><span itemprop="lowPrice">(\d{1,2},\d{1,2})<\/span>/
- URL_MTGPRICE =
#
URL_MTGPRICE
#
'https://www.mtgprice.com/search'
- SPIELRAUM_URL =
#
SPIELRAUM_URL
#
'https://www.spielraum.co.at/'
- GATHERER_WIZARDS_COM =
#
MagicTheGathering::GATHERER_WIZARDS_COM
The base URL for gatherer.wizards.com/ - must have a trailing ‘/’ character.
#
'https://gatherer.wizards.com/'
- NAME_OF_THE_SET =
‘oath-of-the-gatewatch’
YAML.load_file(target_file)
- REMOTE_BASE_DIR =
"#{SPIELRAUM_URL}de/magic/#{NAME_OF_THE_SET.downcase.delete(':').tr(' ','-')}/"
- PREISTENDENZ_REGEX =
#
PREISTENDENZ_REGEX
The old regex was:
/Verf.gbar ab \(EX\+\):<\/td>.+<\/td><\/tr><tr class="row_Even row_2"><td class="outerLeft col_Even col_0 cell_2_0">Preistendenz:<\/td><td class="outerRight col_Odd col_1 cell_2_1">(\d+,?\d+) €<\/td><\/tr>/
#
/Preistendenz:<\/td><td class="outer.{1,8}\s+.*col_Odd col_1 cell_2_1">(\d+,?\d+)\s€<\/td><\/tr>/
- ALSO_SHOW_MAGICKARTEN_DE_URL =
#
ALSO_SHOW_MAGICKARTEN_DE_URL
If this constant is set to true then we will also show the URL that we would have for magickarten.de, for that card.
#
true
- SHALL_WE_CREATE_AND_UPLOAD_A_ZIP_FILE =
#
SHALL_WE_CREATE_AND_UPLOAD_A_ZIP_FILE
#
false
- ARRAY_CHECKED_CARD_TYPES =
#
GamesAndRpgParadise::MagicTheGathering::ARRAY_CHECKED_CARD_TYPES (main tag, main array tag)
This array, which is maintained manually, tells us which card-sets have been checked so far. This can then be fed into some methods for batch-processing of these cards.
Ideally, the listing should be date-sorted, that is, older entries will come at the end of the Array, and more recent entries will come at the beginning of the Array. In order to simplify this, the first entry is the name of the set, and the second entry is the month-year of when it was first released.
The time entry in the Array refers to the “Release date”.
A listing of the timeline for magic cards can be found here:
https://en.wikipedia.org/wiki/List_of_Magic:_The_Gathering_sets#Expansion_sets
#
[ # ======================================================================= # # === Innistrad: Crimson Vow (277) # # magic "--set Innistrad: Crimson Vow"; magic dl # # magic --ncards? "Innistrad: Crimson Vow" # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Innistrad: Crimson Vow] # # ======================================================================= # ['Innistrad: Crimson Vow','November 12, 2021',277], # 0 # ======================================================================= # # === Innistrad: Midnight Hunt (277) # # magic "--set Innistrad: Midnight Hunt"; magic dl # # magic --ncards? "Innistrad: Midnight Hunt" # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Innistrad: Midnight Hunt%22] # # ======================================================================= # ['Innistrad: Midnight Hunt','September 24, 2021',277], # 0 # ======================================================================= # # === Strixhaven: School of Mages (275) # # magic "--set Strixhaven: School of Mages"; magic dl # # magic --ncards? "Strixhaven: School of Mages" # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Strixhaven: School of Mages%22] # # ======================================================================= # ['Strixhaven: School of Mages','April 16, 2021',275], # 0 # ======================================================================= # # === Kaldheim (285) # # magic "--set Kaldheim"; magic dl # # magic --ncards? "Kaldheim" # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Kaldheim%22] # # ======================================================================= # ['Kaldheim','January 29, 2021',285], # 0 # ======================================================================= # # === Zendikar Rising (280) # # magic "--set Zendikar Rising"; magic dl # # magic --ncards? "Zendikar Rising" # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Zendikar Rising%22] # # ======================================================================= # ['Zendikar Rising','September 18, 2020',280], # 0 # ======================================================================= # # === Ikoria: Lair of Behemoths (274) # # magic "--set Ikoria: Lair of Behemoths"; magic dl # # magic --ncards? "Ikoria: Lair of Behemoths" # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Ikoria: Lair of Behemoths%22] # # ======================================================================= # ['Ikoria: Lair of Behemoths','April 17, 2020',274], # 0 # ======================================================================= # # === Theros Beyond Death (254) # # This one is a bit odd because the ":" is not part of the URL. # Well ... # # magic "--set Theros Beyond Death"; magic dl # # magic --ncards? "Theros Beyond Death" # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Theros Beyond Death%22] # # ======================================================================= # ['Theros Beyond Death','January 17, 2020',254], # 0 # ======================================================================= # # === Throne of Eldraine (269) # # magic "--set Throne of Eldraine"; magic dl # # magic --ncards? "Throne of Eldraine" # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Throne of Eldraine%22] # # ======================================================================= # ['Throne of Eldraine','September 28, 2019',269], # 0 # ======================================================================= # # === War of the Spark (264) # # magic "--set War of the Spark"; magic dl # # magic --ncards? "War of the Spark" # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22War of the Spark%22] # # ======================================================================= # ['War of the Spark','27 April 2019',264], # 0 # ======================================================================= # # === Ravnica Allegiance (259) # # magic "--set Ravnica Allegiance"; magic dl # # magic --ncards? "Ravnica Allegiance" # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Ravnica Allegiance%22] # # ======================================================================= # ['Ravnica Allegiance','19 January 2019',259], # 1 # ======================================================================= # # === Guilds of Ravnica (259) # # This one is called "Guilds of Ravnica". It is the 79th Magic # expansion, released on 05.10.2018. # # magic "--set Guilds of Ravnica"; magic dl # # magic --ncards? "Guilds of Ravnica" # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Guilds of Ravnica%22] # # ======================================================================= # ['Guilds of Ravnica','20 September 2018',259], # 2 # ======================================================================= # # === Dominaria (269) # # magic "--set Dominaria"; magic dl # # magic --ncards? "Dominaria" # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Dominaria%22] # # ======================================================================= # ['Dominaria','21 April 2018',269], # 3 # ======================================================================= # # === Rivals of Ixalan (212 or 196 cards) # # magic "--set Rivals of Ixalan"; magic dl # # magic --ncards? "Rivals of Ixalan" # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Rivals of Ixalan%22] # # ======================================================================= # ['Rivals of Ixalan','13 January 2018',212], # 4 # ======================================================================= # # === Ixalan (279 cards) # # magic "--set Ixalan"; magic dl # # magic --ncards? "Ixalan" # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Ixalan%22] # # ======================================================================= # ['Ixalan','September 2017',279], # 5 # ======================================================================= # # === Hour of Devastation (199 cards) # # magic "--set Hour of Devastation"; magic dl # # magic --ncards? "Hour of Devastation" # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Hour of Devastation%22] # # ======================================================================= # ['Hour of Devastation','July 2017',199], # 6 # ======================================================================= # # === Amonkhet (274 cards) # # Wikipedia says 269 but I found 271 instead. Spielraum says 274 but # without basic lands. https://shop.tcgplayer.com/price-guide/magic/amonkhet # says 287 cards, but 20 are lands, so 267. The Spielraum link for # Amonkhet is here: # # https://www.spielraum.co.at/de/magic/amonkhet/amonkhet-magic-the-gathering-einzelkarten.aspx # # magic "--set Amonkhet"; magic dl # # magic --ncards? "Amonkhet" # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Amonkhet%22] # # ======================================================================= # ['Amonkhet','April 2017',274], # 7 # ======================================================================= # # === Aether Revolt (184 cards says wikipedia, but gatherer says 194) # # magic "--set Aether Revolt"; magic dl # # magic --ncards? "Aether Revolt" # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Aether Revolt%22] # # ======================================================================= # ['Aether Revolt','January 2017',184], # 8 # ======================================================================= # # === Kaladesh (264 cards) # # magic "--set Kaladesh"; magic dl # # magic --ncards? Kaladesh # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Kaladesh%22] # # ======================================================================= # ['Kaladesh','September 2016',264], # 9 # ======================================================================= # # === Eldritch Moon (223 cards) # # magic "--set Eldritch Moon"; magic dl # # magic "--ncards? Eldritch Moon" # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Eldritch Moon%22] # # ======================================================================= # ['Eldritch Moon','July 2016',223], # 10 # ======================================================================= # # === Shadows over Innistrad (320 cards) # # magic "--set Shadows over Innistrad"; magic dl # # magic --ncards? "Shadows over Innistrad" # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Shadows over Innistrad%22] # # ======================================================================= # ['Shadows over Innistrad','April 2016',320], # 2 # ======================================================================= # # === Oath of the Gatewatch (183 cards) # # magic "--set Oath of the Gatewatch"; magic dl # # magic --ncards? "Oath of the Gatewatch" # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Oath of the Gatewatch%22] # # ======================================================================= # ['Oath of the Gatewatch','January 2016',183], # 3 # ======================================================================= # # === Battle for Zendikar (274 cards) # # magic "--set Battle for Zendikar"; magic dl # # magic --ncards? Battle for Zendikar # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Battle for Zendikar%22] # # ======================================================================= # ['Battle for Zendikar','October 2015',254], # 4 # ======================================================================= # # === Zendikar Expeditions (45 cards) # # This one only includes land cards which are printed in foil. # # magic "--set Zendikar Expeditions"; magic dl # # magic --ncards? Zendikar Expeditions # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?action=advanced&set=[%22Zendikar%20Expeditions%22] # # ======================================================================= # ['Zendikar Expeditions','October 2015',45], # 4 # ======================================================================= # # === Dragons of Tarkir (254 cards) # # magic "--set Dragons of Tarkir"; magic dl # # magic --ncards? Dragons of Tarkir # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Dragons of Tarkir%22] # # ======================================================================= # ['Dragons of Tarkir','March 2015',254], # 5 # ======================================================================= # # === Fate Reforged (180 cards) # # magic "--set Fate Reforged"; magic dl # # magic --ncards? Fate Reforged # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Fate Reforged%22] # # ======================================================================= # ['Fate Reforged','January 2015',180], # 6 # ======================================================================= # # === Khans of Tarkir (254 cards) # # magic "--set Khans of Tarkir"; magic dl # # magic --ncards? Khans of Tarkir # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Khans of Tarkir%22] # # ======================================================================= # ['Khans of Tarkir','September 2014',254], # 7 # ======================================================================= # # === Journey into Nyx (165 cards) # # magic "--set Journey into Nyx"; magic dl # # magic --ncards? Journey into Nyx # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Journey Into Nyx%22] # # ======================================================================= # ['Journey into Nyx','May 2014',165], # 8 # ======================================================================= # # === Born of the Gods (165 cards) # # magic "--set Born of the Gods"; magic dl # # magic --ncards? Born of the Gods # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Born of the Gods%22] # # ======================================================================= # ['Born of the Gods','February 2014',165], # 9 # ======================================================================= # # === Theros (234 cards) # # magic "--set Theros"; magic dl # # magic --ncards? Theros # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Theros%22] # # ======================================================================= # ['Theros','September 2013',234], # 10 # ======================================================================= # # === Modern Masters (229 cards) # # magic "--set Modern Masters"; magic dl # # magic --ncards? Modern Masters # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Modern Masters%22] # # ======================================================================= # ['Modern Masters','June 2013',229], # ======================================================================= # # === Dragon's Maze (171 cards) # # magic "--set Dragon's Maze"; magic dl # # magic --ncards? Dragon's Maze # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Dragon's Maze%22] # # ======================================================================= # ["Dragon's Maze",'03 May 2013',171], # 11 # ======================================================================= # # === Gatecrash (249 cards) # # magic "--set Gatecrash"; magic dl # # magic --ncards? Gatecrash # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Gatecrash%22] # # ======================================================================= # ['Gatecrash','February 2013',249], # 12 # ======================================================================= # # === Return to Ravnica (254 cards) # # magic "--set Return to Ravnica"; magic dl # # magic --ncards? Return to Ravnica # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Return to Ravnica%22] # # ======================================================================= # ['Return to Ravnica','October 2012',254], # 13 # ======================================================================= # # === Avacyn Restored (234 cards) # # magic "--set Avacyn Restored"; magic dl # # magic --ncards? Avacyn Restored # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Avacyn Restored%22] # # ======================================================================= # ['Avacyn Restored','May 2012',234], # 14 # ======================================================================= # # === Dark Ascension (171 cards) # # magic "--set Dark Ascension"; magic dl # # magic --ncards? Dark Ascension # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Dark Ascension%22] # # ======================================================================= # ['Dark Ascension','February 2012',171], # 15 # ======================================================================= # # === Innistrad (274 cards) # # magic "--set Innistrad"; magic dl # # magic --ncards? Innistrad # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Innistrad%22] # # ======================================================================= # ['Innistrad','September 2011',274], # 16 # ======================================================================= # # === New Phyrexia (170 cards) # # magic "--set New Phyrexia"; magic dl # # magic --ncards? New Phyrexia # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22New Phyrexia%22] # # ======================================================================= # ['New Phyrexia','May 2011',170], # 17 # ======================================================================= # # === Mirrodin Besieged (150 cards) # # magic "--set Mirrodin Besieged"; magic dl # # magic --ncards? Mirrodin Besieged # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Mirrodin Besieged%22] # # ======================================================================= # ['Mirrodin Besieged','February 2011',150], # 18 # ======================================================================= # # === Scars of Mirrodin (234 cards) # # magic "--set Scars of Mirrodin"; magic dl # # magic --ncards? Scars of Mirrodin # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Scars of Mirrodin%22] # # ======================================================================= # ['Scars of Mirrodin','October 2010',234], # 19 # ======================================================================= # # === Rise of the Eldrazi (233 cards) # # magic "--set Rise of the Eldrazi"; magic dl # # magic --ncards? Rise of the Eldrazi # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Rise of the Eldrazi%22] # # ======================================================================= # ['Rise of the Eldrazi','April 2010',233], # 20 # ======================================================================= # # === Worldwake (145 cards) # # magic "--set Worldwake"; magic dl # # magic --ncards? Worldwake # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Worldwake%22] # # ======================================================================= # ['Worldwake','February 2010',145], # 21 # ======================================================================= # # === Zendikar (234 cards) # # magic "--set Zendikar"; magic dl # # magic --ncards? Zendikar # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Zendikar%22] # # ======================================================================= # ['Zendikar','October 2009',234], # 22 # ======================================================================= # # === Planechase (189 cards) # # Planechase is a special format. # # magic "--set Planechase"; magic dl # # magic --ncards? Planechase # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Planechase%22] # # ======================================================================= # ['Planechase','September 2009',189], # ======================================================================= # # === Conflux (145 cards) # # magic "--set Conflux"; magic dl # # magic --ncards? Conflux # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Conflux%22] # # ======================================================================= # ['Conflux','February 2009',145], # 23 # ======================================================================= # # === Alara Reborn (145 cards) # # magic "--set Alara Reborn"; magic dl # # magic --ncards? Alara Reborn # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Alara Reborn%22] # # ======================================================================= # ['Alara Reborn','April 2009',145], # 24 # ======================================================================= # # === Shards of Alara (234 cards) # # magic "--set Shards of Alara"; magic dl # # magic --ncards? Shards of Alara # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Shards of Alara%22] # # ======================================================================= # ['Shards of Alara','October 2008',234], # 25 # ======================================================================= # # === Eventide (180 cards) # # magic "--set Eventide"; magic dl # # magic --ncards? Eventide # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Eventide%22] # # ======================================================================= # ['Eventide','July 2008',180], # 26 # ======================================================================= # # === Shadowmoor (286 cards) # # magic "--set Shadowmoor"; magic dl # # magic --ncards? Shadowmoor # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Shadowmoor%22] # # ======================================================================= # ['Shadowmoor','May 2008',286], # 27 # ======================================================================= # # === Morningtide (150 cards) # # magic "--set Morningtide"; magic dl # # magic --ncards? Morningtide # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Morningtide%22] # # ======================================================================= # ['Morningtide','February 2008',150], # 28 # ======================================================================= # # === Lorwyn (286 cards) # # magic "--set Lorwyn"; magic dl # # magic --ncards? Lorwyn # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Lorwyn%22] # # ======================================================================= # ['Lorwyn','October 2007',286], # 29 # ======================================================================= # # === Future Sight (180 cards) # # magic "--set Future Sight"; magic dl # # magic --ncards? Future Sight # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Future Sight%22] # # ======================================================================= # ['Future Sight','May 2007',180], # 30 # ======================================================================= # # === Planar Chaos (168 cards) # # magic "--set Planar Chaos"; magic dl # # magic --ncards? Planar Chaos # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Planar Chaos%22] # # ======================================================================= # ['Planar Chaos','February 2007',168], # 31 # ======================================================================= # # === Time Spiral (286 cards) # # magic "--set Time Spiral"; magic dl # # magic --ncards? Time Spiral # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Time Spiral%22] # # ======================================================================= # ['Time Spiral','October 2006',286], # 32 # ======================================================================= # # === Coldsnap (155 cards) # # magic "--set Coldsnap"; magic dl # # magic --ncards? Coldsnap # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Coldsnap%22] # # ======================================================================= # ['Coldsnap','July 2006',155], # 33 # ======================================================================= # # === Dissension (190 cards) # # magic "--set Dissension"; magic dl # # magic --ncards? Dissension # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?set=[%22Dissension%22] # # ======================================================================= # ['Dissension','May 2006',190], # 34 # ======================================================================= # # === Guildpact (165 cards) # # magic "--set Guildpact"; magic dl # # magic --ncards? Guildpact # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?set=[%22Guildpact%22] # # ======================================================================= # ['Guildpact','February 2006',165], # 35 # ======================================================================= # # === Ravnica: City of Guilds (291 cards) # # This is the variant that was released in 2005. It is also called # Ravnica. # # magic "--set Ravnica: City of Guilds"; magic dl # # magic --ncards? Ravnica: City of Guilds # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?set=[%22Ravnica: City of Guilds%22] # # ======================================================================= # ['Ravnica: City of Guilds','October 2005',291], # 36 # ======================================================================= # # === Ninth Edition (344 cards) # # magic "--set Ninth Edition"; magic dl # # magic --ncards? Ninth Edition # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?set=[%22Ninth Edition%22] # # ======================================================================= # ['Ninth Edition','July 2005',344], # 37 # ======================================================================= # # === Saviors of Kamigawa (170 cards) # # magic "--set Saviors of Kamigawa"; magic dl # # magic --ncards? Saviors of Kamigawa # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?set=[%22Saviors of Kamigawa%22] # # ======================================================================= # ['Saviors of Kamigawa','June 2005',170], # 37 # ======================================================================= # # === Betrayers of Kamigawa (168 cards) # # magic "--set Betrayers of Kamigawa"; magic dl # # magic --ncards? Betrayers of Kamigawa # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?set=[%22Betrayers of Kamigawa%22] # # ======================================================================= # ['Betrayers of Kamigawa','February 2005',168], # 38 # ======================================================================= # # === Champions of Kamigawa (168 cards) # # magic "--set Champions of Kamigawa"; magic dl # # magic --ncards? Champions of Kamigawa # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?set=[%22Betrayers of Kamigawa%22] # # ======================================================================= # ['Champions of Kamigawa','October 2004',168], # 39 # ======================================================================= # # === Fifth Dawn (165 cards) # # magic "--set Fifth Dawn"; magic dl # # magic --ncards? Fifth Dawn # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?set=[%22Fifth Dawn%22] # # ======================================================================= # ['Fifth Dawn','June 2004',165], # 40 # ======================================================================= # # === Darksteel (165 cards) # # magic "--set Darksteel"; magic dl # # magic --ncards? Darksteel # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?set=[%22Darksteel%22] # # ======================================================================= # ['Darksteel','February 2004',165], # 41 # ======================================================================= # # === Mirrodin (291 cards) # # magic "--set Mirrodin"; magic dl # # magic --ncards? Mirrodin # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?set=[%22Mirrodin%22] # # ======================================================================= # ['Mirrodin','October 2003',291], # 42 # ======================================================================= # # === Scourge (143 cards) # # Released in May 2003. # # magic "--set Scourge"; magic dl # # magic --ncards? Scourge # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?set=[%22Scourge%22] # # ======================================================================= # ['Scourge','May 2003',143], # 43 # ======================================================================= # # === Legions (145 cards) # # magic "--set Legions"; magic dl # # magic --ncards? Legions # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?set=[%22Legions%22] # # ======================================================================= # ['Legions','February 2003',145], # 44 # ======================================================================= # # === Onslaught (335 cards) # # magic "--set Onslaught"; magic dl # # magic --ncards? Onslaught # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?set=[%22Onslaught%22] # # ======================================================================= # ['Onslaught','October 2002',335], # 45 # ======================================================================= # # === Judgment (143 cards) # # magic "--set Judgment"; magic dl # # magic --ncards? Judgment # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?set=[%22Judgment%22] # # ======================================================================= # ['Judgment','May 2002',143], # 46 # ======================================================================= # # === Torment (143 cards) # # magic "--set Torment"; magic dl # # magic --ncards? Torment # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?set=[%22Torment%22] # # ======================================================================= # ['Torment','February 2002',143], # 47 # ======================================================================= # # === Odyssey (335 cards) # # magic "--set Odyssey"; magic dl # # magic --ncards? Odyssey # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?set=[%22Odyssey%22] # # ======================================================================= # ['Odyssey','October 2001',335], # 48 # ======================================================================= # # === Apocalypse (148 cards) # # magic "--set Apocalypse"; magic dl # # magic --ncards? Apocalypse # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?set=[%22Apocalypse%22] # # ======================================================================= # ['Apocalypse','June 2001',148], # 49 # ======================================================================= # # === Planeshift (143 cards) # # magic "--set Planeshift"; magic dl # # magic --ncards? Planeshift # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Planeshift%22] # # ======================================================================= # ['Planeshift','February 2001',143], # 50 # ======================================================================= # # === Invasion (340 cards) # # magic "--set Invasion"; magic dl # # magic --ncards? Invasion # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Invasion%22] # # ======================================================================= # ['Invasion','October 2000',340], # 51 # ======================================================================= # # === Prophecy (143 cards) # # magic "--set Prophecy"; magic dl # # magic --ncards? Prophecy # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Prophecy%22] # # ======================================================================= # ['Prophecy','June 2000',143], # 52 # ======================================================================= # # === Nemesis (143 cards) # # magic "--set Nemesis"; magic dl # # magic --ncards? Nemesis # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Nemesis%22] # # ======================================================================= # ['Nemesis','February 2000',143], # 53 # ======================================================================= # # === Mercadian Masques (335 cards) # # magic "--set Mercadian Masques"; magic dl # # magic --ncards? Mercadian Masques # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Mercadian Masques%22] # # ======================================================================= # ['Mercadian Masques','October 1999',335], # 54 # ======================================================================= # # === Urza's Destiny (143 cards) # # magic "--set Urza's Destiny"; magic dl # # magic --ncards? "Urza's Destiny" # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Urza%27s%20Destiny%22] # # ======================================================================= # ["Urza's Destiny",'June 1999',143], # 55 # ======================================================================= # # === Urza's Legacy (143 cards) # # magic "--set Urza's Legacy"; magic dl # # magic --ncards? "Urza's Legacy" # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Urza%27s%20Legacy%22] # # ======================================================================= # ["Urza's Legacy",'February 1999',143], # 56 # ======================================================================= # # === Urza's Saga (335 cards) # # magic "--set Urza's Saga"; magic dl # # magic --ncards? "Urza's Saga" # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Urza%27s%20Saga%22] # # ======================================================================= # ["Urza's Saga",'October 1998',335], # 57 # ======================================================================= # # === Exodus (143 cards) # # magic "--set Exodus"; magic dl # # magic --ncards? Exodus # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Exodus%22] # # ======================================================================= # ['Exodus','June 1998',143], # 58 # ======================================================================= # # === Stronghold (143 cards) # # magic "--set Stronghold"; magic dl # # magic --ncards? Stronghold # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Stronghold%22] # # ======================================================================= # ['Stronghold','March 1998',143], # 59 # ======================================================================= # # === Tempest (335 cards) # # magic "--set Tempest"; magic dl # # magic --ncards? Tempest # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Tempest%22] # # ======================================================================= # ['Tempest','October 1997',335], # 60 # ======================================================================= # # === Weatherlight (167 cards) # # magic "--set Weatherlight"; magic dl # # magic --ncards? Weatherlight # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Weatherlight%22] # # ======================================================================= # ['Weatherlight','June 1997',167], # 61 # ======================================================================= # # === Visions (167 cards) # # magic "--set Visions"; magic dl # # magic --ncards? Visions # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?page=1&output=standard&set=[%22Visions%22] # # ======================================================================= # ['Visions','February 1997',167], # 62 # ======================================================================= # # === Mirage (335 cards) # # magic "--set Mirage"; magic dl # # magic --ncards? Mirage # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?set=[%22Mirage%22] # # ======================================================================= # ['Mirage','October 1996',335], # 63 # ======================================================================= # # === Alliances (144 cards, Alliances tag) # # magic "--set Alliances"; magic dl # # magic --ncards? Alliances # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?set=[%22Alliances%22] # # ======================================================================= # ['Alliances','June 1996',144], # 64 # ======================================================================= # # === Ice Age (373 cards) # # magic "--set Ice Age"; magic dl # # magic --ncards? Ice Age # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?set=[%22Ice%20Age%22] # # ======================================================================= # ['Ice Age','June 1995',373], # 65 # ======================================================================= # # === Homelands (115 cards) # # magic "--set Homelands"; magic dl # # magic --ncards? Homelands # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?set=[%22Homelands%22] # # ======================================================================= # ['Homelands','October 1995',115], # 66 # ======================================================================= # # === Fallen Empires (102 cards) # # magic "--set Fallen Empires"; magic dl # # magic --ncards? Fallen Empires # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?set=[%22Fallen%20Empires%22] # https://en.wikipedia.org/wiki/Fallen_Empires # # ======================================================================= # ['Fallen Empires','November 1994',102], # 67 # ======================================================================= # # === The Dark (119 cards) # # magic "--set The Dark"; magic dl # # magic --ncards? The Dark # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?set=[%22The%20Dark%22] # # ======================================================================= # ['The Dark','August 1994',119], # 68 # ======================================================================= # # === Legends (310 cards) # # magic "--set Legends"; magic dl # # magic --ncards? Legends # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?set=[%22Legends%22] # # ======================================================================= # ['Legends','June 1994',310], # 69 # ======================================================================= # # === Revised Edition (296 cards) # # magic "--set Revised Edition"; magic dl # # magic --ncards? Revised Edition # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?set=[%22Revised Edition%22] # # ======================================================================= # ['Revised Edition','April 1994',296], # 70 # ======================================================================= # # === Antiquities (100 cards) # # magic "--set Antiquities"; magic dl # # magic --ncards? Antiquities # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?set=[%22Antiquities%22] # # ======================================================================= # ['Antiquities','March 1994',100], # 71 # ======================================================================= # # === Arabian Nights (92 cards) # # magic "--set Arabian Nights"; magic dl # # magic --ncards? Arabian Nights # # See also the following URL: # # https://gatherer.wizards.com/Pages/Search/Default.aspx?set=[%22Arabian%20Nights%22] # # ======================================================================= # ['Arabian Nights','December 1993',92], # 72 ]
- HASH_GERMAN_TO_ENGLISH =
#
HASH_GERMAN_TO_ENGLISH
#
{ 'farblos' => 'colourless', 'weiss' => 'white', 'blau' => 'blue', 'schwarz' => 'black', 'rot' => 'red', 'gruen' => 'green', 'multicolor' => 'multicolour', 'artefakt' => 'artefact', 'land' => 'land', }
- FILE_YAML_FILE_CONTAINING_ALL_CARDS =
#
FILE_YAML_FILE_CONTAINING_ALL_CARDS
#
"#{log_dir?}yaml_file_containing_all_cards.yml"
- YAML_FILE_CONTAINING_THE_LOCAL_CARD_COLLECTION_FOR_MAGIC_THE_GATHERING =
#
GamesAndRpgParadise::MagicTheGathering::YAML_FILE_CONTAINING_THE_LOCAL_CARD_COLLECTION_FOR_MAGIC_THE_GATHERING
This is the .yml file of the user. By default it does not exist for new users - they have to create it anew on their own.
#
"#{GamesAndRpgParadise::MagicTheGathering.log_directory?}"\ "card_collection/"+ # It is in a subdirectory since as of November 2021. "card_collection.yml"
- REGEX_TO_DETERMINE_HOW_MANY_CARDS_ARE_IN_THIS_SET =
#
REGEX_TO_DETERMINE_HOW_MANY_CARDS_ARE_IN_THIS_SET
#
/.*\((\d+)\)<\/span>.?<\/p>/
- REGEX_FOR_THE_CONVERTED_MANA_COST =
#
REGEX_FOR_THE_CONVERTED_MANA_COST
#
/Converted Mana Cost:<\/div>\s+<div class="value">\s+(\d+)<\/div>/
- REGEX_FOR_FINDING_A_CARD =
#
REGEX_FOR_FINDING_A_CARD
This regex will find two entries - the specific card id first, and then the name of the card itself.
#
/multiverseid=(\d+)&type=card" id=".+" alt="(.+)" .+ \/>/
- REGEX_MULTIVERSEID =
REGEX_FOR_FINDING_A_CARD
- FULL_SPIELRAUM_URL =
#
FULL_SPIELRAUM_URL
This is the aggregate URL.
#
REMOTE_BASE_DIR+ (NAME_OF_THE_SET.downcase.delete(':').tr(' ','-'))+'-magic-the-gathering-einzelkarten.aspx'
Constants included from GamesAndRpgParadise
COLOUR_SETTLEMENT, DATA_DIR, DEBUG, DIRECTORY_AM_RANDE_DER_NACHT, DIRECTORY_TO_THE_IMAGES_OF_THE_THEME_SYMBOLS, ERROR_LINE, FILE_DND_CHARACTERS, FILE_MAGICAL_ITEMS, FILE_TAI_NAMES, HOME_DIRECTORY_OF_THE_USER_X, HOME_X_DATA, IMG_DIR, LAST_UPDATE, MAGICAL_ITEMS, N, PROJECT_YAML_DIR, RPG_IMG_DIR, RUBY_HEADER, SARLEM, SARLEM_MAP, SARLEM_YAML, STD_FONT_SIZE, TAI_MAP, TEMP_DIR, UNHAPPY_SMILEY, USE_THIS_PORT, VERSION
Class Method Summary collapse
-
.all_cards_of_the_set? ⇒ Boolean
# === GamesAndRpgParadise::MagicTheGathering.all_cards_of_the_set? ========================================================================= #.
-
.available_cards? ⇒ Boolean
# === GamesAndRpgParadise::MagicTheGathering.available_cards?.
-
.available_items_in_this_URL(remote_URL = 'https://www.cardmarket.com/en/Magic/Products/Singles/Tempest/Eladamri-Lord-of-Leaves') ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.available_items_in_this_URL.
-
.available_sets? ⇒ Boolean
# === GamesAndRpgParadise::MagicTheGathering.available_sets?.
-
.available_themes? ⇒ Boolean
# === GamesAndRpgParadise::MagicTheGathering.available_themes? ========================================================================= #.
-
.bootstrap ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.bootstrap.
-
.check_preistendenz_and_verfügbar_ab_for_this_card(name_of_the_card) ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.check_preistendenz_and_verfügbar_ab_for_this_card.
-
.cleanse_this_md_file(which_md_file = :default) ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.cleanse_this_md_file.
-
.clear_all_cards_of_the_set ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.clear_all_cards_of_the_set ========================================================================= #.
-
.create_and_show_random_booster_set ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.create_and_show_random_booster_set.
-
.create_big_zip_file(this_dir = log_dir? ) ⇒ Object
# === MagicTheGathering.create_big_zip_file.
-
.create_big_zip_file_or_copy_existing_zip_file(i) ⇒ Object
# === MagicTheGathering.create_big_zip_file_or_copy_existing_zip_file.
-
.create_html_page(this_directory = '/home/Temp/magic_the_gathering/Scourge/') ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.create_html_page (html tag).
-
.create_personal_cards_webpage(i = my_cvs_dataset? ) ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.create_personal_cards_webpage.
-
.download_from_the_official_site(i) ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.download_from_the_official_site =========================================================================== #.
-
.e(i = '') ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.e ========================================================================= #.
-
.ecomment(i = '') ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.ecomment ========================================================================= #.
-
.generate_main_html_file(be_verbose = true) ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.generate_main_html_file.
-
.generate_yaml_stats ⇒ Object
# === MagicTheGathering.generate_yaml_stats.
-
.interactive_csv ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.interactive_csv.
-
.is_this_card_included?(this_card) ⇒ Boolean
# === GamesAndRpgParadise::MagicTheGathering.is_this_card_included?.
-
.local_cvs_prices_twenty_percent ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.local_cvs_prices_twenty_percent ========================================================================= #.
-
.log_dir? ⇒ Boolean
# === GamesAndRpgParadise::MagicTheGathering.log_dir?.
-
.main_card_set?(i = FILE_MAIN_CARD_SET) ⇒ Boolean
# === MagicTheGathering.main_card_set? ========================================================================= #.
-
.main_encoding? ⇒ Boolean
# === GamesAndRpgParadise::MagicTheGathering.main_encoding?.
-
.menu(i) ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.menu (menu tag) ========================================================================= #.
-
.merge_all_individual_md_files_into_one_big_yaml_file(be_verbose = true) ⇒ Object
# === MagicTheGathering.merge_all_individual_md_files_into_one_big_yaml_file.
-
.merge_in_these_cards_into_all_cards_of_the_set(i) ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.merge_in_these_cards_into_all_cards_of_the_set(i) ========================================================================= #.
-
.most_recent_magic_theme? ⇒ Boolean
# === GamesAndRpgParadise::MagicTheGathering.most_recent_magic_theme? ========================================================================= #.
-
.my_cvs_dataset?(filter_away_price_tag = true) ⇒ Boolean
# === GamesAndRpgParadise::MagicTheGathering.my_cvs_dataset?.
-
.n_cards_in_this_card_set(card_set = current_card_set? ) ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.n_cards_in_this_card_set.
-
.n_cards_registered_in_total ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.n_cards_registered_in_total.
-
.n_sets_in_total? ⇒ Boolean
# === GamesAndRpgParadise::MagicTheGathering.n_sets_in_total?.
-
.parse_big_csv_file(i = FILE_KARTENLISTE_MIT_PREISEN_CSV, output_result = true, be_verbose_or_be_quiet = :be_verbose) ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.parse_big_csv_file.
-
.parse_this_csv_file(i = FILE_KARTENLISTE_MIT_PREISEN_CSV, limit_at_n_entries = 50, output_result = true, be_verbose_or_be_quiet = :be_quiet) ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.parse_this_csv_file.
-
.price_trend_in_this_URL(remote_URL = 'https://www.cardmarket.com/en/Magic/Products/Singles/Tempest/Eladamri-Lord-of-Leaves', remote_dataset = :default) ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.price_trend_in_this_URL.
-
.project_base_dir? ⇒ Boolean
# === GamesAndRpgParadise::MagicTheGathering.project_base_dir? ========================================================================= #.
-
.project_yaml_dir? ⇒ Boolean
# === project_yaml_dir? ========================================================================= #.
-
.register_sigint ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.register_sigint ========================================================================= #.
-
.release_of_this_card_set(i = 'Guildpact') ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.release_of_this_card_set.
-
.remote_dataset? ⇒ Boolean
# === GamesAndRpgParadise::MagicTheGathering.remote_dataset? ========================================================================= #.
-
.report_how_many_cards_are_available_in_total ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.report_how_many_cards_are_available_in_total.
-
.report_total_amount_of_cards_in_this_set_or_overall(optional_name_of_the_set = '') ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.report_total_amount_of_cards_in_this_set_or_overall.
-
.report_which_local_entries_are_missing ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.report_which_local_entries_are_missing.
-
.return_card_set_from_this_card_name(i = 'Tarmogoyf', use_this_file = FILE_YAML_FILE_CONTAINING_ALL_CARDS) ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.return_card_set_from_this_card_name.
-
.return_common_cards_from_this_set(card_set = default_card_set) ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.return_common_cards_from_this_set.
-
.return_image_url_for_magickartenmarkt_for_this_card(this_card, name_of_the_set = nil) ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.return_image_url_for_magickartenmarkt_for_this_card.
-
.return_local_picture_for_this_card(name_of_the_card, from_this_set = self.current_card_set?) ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.return_local_picture_for_this_card.
-
.return_n_lands_necessary(n_cards_in_total = 60) ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.return_n_lands_necessary.
-
.return_only_image_files(i) ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.return_only_image_files.
-
.return_preistendenz_of_this_card_from_magickartenmarkt(this_card = 'Tarmogoyf', name_of_the_set = nil, be_verbose = true, use_this_regex = PREISTENDENZ_REGEX) ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.return_preistendenz_of_this_card_from_magickartenmarkt.
-
.return_random_booster(from_this_card_set = main_card_set? ) ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.return_random_booster.
-
.return_rare_cards_from_this_set(card_set = self.default_card_set) ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.return_rare_cards_from_this_set.
-
.return_remote_url_to_the_picture_from_this_card_set(this_card_set) ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.return_remote_url_to_the_picture_from_this_card_set.
-
.return_uncommon_cards_from_this_set(card_set = self.default_card_set) ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.return_uncommon_cards_from_this_set ========================================================================= #.
-
.return_url_for_magickarten_de_for_this_card(this_card, name_of_the_set = nil, be_verbose = false) ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.return_url_for_magickarten_de_for_this_card.
-
.return_verfügbar_ab_of_this_card_from_magickartenmarkt(this_card = 'Tarmogoyf', name_of_the_set = nil, be_verbose = true, use_this_regex = REGEX_AVAILABLE_SINCE) ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.return_verfügbar_ab_of_this_card_from_magickartenmarkt.
-
.rev ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.rev ========================================================================= #.
-
.set_all_cards_of_the_set(i) ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.set_all_cards_of_the_set ========================================================================= #.
-
.set_main_card_set(i = 'Alara Reborn') ⇒ Object
# === MagicTheGathering.set_main_card_set ========================================================================= #.
-
.sfancy(i = '') ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.sfancy ========================================================================= #.
-
.sfile(i = '') ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.sfile ========================================================================= #.
-
.show_available_cards ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.show_available_cards.
-
.show_content_of_the_main_constant_file(file = "#{PROJECT_DIR}constants/checked_card_types.rb") ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.show_content_of_the_main_constant_file.
-
.show_help ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.show_help (help tag).
-
.show_location_of_the_main_csv_file(i = FILE_KARTENLISTE_CSV) ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.show_location_of_the_main_csv_file.
-
.show_n_total_cards ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.show_n_total_cards.
-
.show_relevant_statistics ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.show_relevant_statistics.
-
.show_the_available_local_sets ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.show_the_available_local_sets.
-
.simp(i = '') ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.simp ========================================================================= #.
-
.slateblue(i = '') ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.slateblue ========================================================================= #.
-
.this_set_should_have_n_cards(this_card_set) ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.this_set_should_have_n_cards.
-
.total_value_of_all_cards(i = FILE_KARTENLISTE_MIT_PREISEN_CSV) ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.total_value_of_all_cards.
-
.turn_all_strings_in_this_hash_into_iso_encoding(hash) ⇒ Object
# === MagicTheGathering.turn_all_strings_in_this_hash_into_iso_encoding.
-
.turn_ruby_hash_into_yaml_file(ruby_hash = :use_default_ruby_hash_of_the_main_card_set, name_of_the_set = main_card_set? ) ⇒ Object
# === GamesAndRpgParadise::MagicTheGathering.turn_ruby_hash_into_yaml_file.
Methods included from GamesAndRpgParadise
available_gamebooks?, available_magic_themes?, bold_yellow, calculates, cat, cd, chdir, convert, copy_file, delete, disable_colours, embeddable_interface, enable_colours, ensure_that_the_log_directory_exists, esystem, file_good_dos_games, file_good_windows_games, gamebook_dataset_for, gamebooks_directory?, generate_name, image_directory?, is_on_roebe?, load_gamebook_dataset, load_npc, minfo, mkdir, mv, n_cards_are_registered_in_the_local_magic_collection?, pngopt, project_base_directory?, project_image_directory?, project_yaml_directory?, rds, return_array_available_magic_theme_icons, return_sarlem_name, rev, riddles, roll, run_app, run_gamebooks_app, show_dnd_xp_table, silently_roll_this_die, speak_to_group, speak_to_your_group, steelblue, string_draw_a_card_from_the_deck_of_many_things, temp_dir?, use_colours?, version?, word_wrap
Class Method Details
.all_cards_of_the_set? ⇒ Boolean
#
GamesAndRpgParadise::MagicTheGathering.all_cards_of_the_set?
#
1445 1446 1447 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1445 def self.all_cards_of_the_set? @all_cards_of_the_set # Return the above Hash. end |
.available_cards? ⇒ Boolean
#
GamesAndRpgParadise::MagicTheGathering.available_cards?
This method will return an Array with all the available cards.
You can then use this dataset to obtain subsets of cards from it.
Commandline invocation example:
magic --available-cards?
#
1738 1739 1740 1741 1742 1743 1744 1745 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1738 def self.available_cards? _ = FILE_YAML_FILE_CONTAINING_ALL_CARDS if File.exist? _ return YAML.load_file(_) else e 'No file could be found at `'+sfile(_)+'`.' end end |
.available_items_in_this_URL(remote_URL = 'https://www.cardmarket.com/en/Magic/Products/Singles/Tempest/Eladamri-Lord-of-Leaves') ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.available_items_in_this_URL
This method returns how many available items are found in the given URL.
A number (integer) will be returned if all goes well.
#
1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1859 def self.available_items_in_this_URL( remote_URL = 'https://www.cardmarket.com/en/Magic/Products/Singles/Tempest/Eladamri-Lord-of-Leaves' ) @remote_dataset = URI.open(remote_URL).read # ======================================================================= # # Sanitize that dataset a bit via Cyberweb, but do not use that # modified dataset - the original content is stored in # @remote_dataset. # ======================================================================= # dataset = Cyberweb.sanitizer(@remote_dataset) use_this_regex = # See: https://rubular.com/r/TyOC7Sw8S54dLS /Available items<\/dt>\n<dd class="col-6 col-xl-7">\n(\d+)<\/dd>/ dataset =~ use_this_regex result = $1 return result.to_s.to_i # Must return an Integer here, even if it is just 0. end |
.available_sets? ⇒ Boolean
#
GamesAndRpgParadise::MagicTheGathering.available_sets?
Return all available card sets.
#
1774 1775 1776 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1774 def self.available_sets? ARRAY_CHECKED_CARD_TYPES.map {|entry| entry.first } end |
.available_themes? ⇒ Boolean
#
GamesAndRpgParadise::MagicTheGathering.available_themes?
#
1481 1482 1483 1484 1485 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/constants/constants.rb', line 1481 def self.available_themes? ARRAY_CHECKED_CARD_TYPES.map {|inner_array| inner_array.first } end |
.bootstrap ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.bootstrap
This method will bootstrap from zero.
Invocation example:
magic --bootstrap
#
194 195 196 197 198 199 200 201 202 203 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 194 def self.bootstrap e 'We will bootstrap (download all card sets) from scratch next.' _ = available_sets? _.each {|this_set| e "Working on the set #{sfancy(this_set)} next." set_main_set(this_set) download_this_set(this_set) merge_all_individual_md_files_into_one_big_yaml_file(:be_verbose) } end |
.check_preistendenz_and_verfügbar_ab_for_this_card(name_of_the_card) ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.check_preistendenz_and_verfügbar_ab_for_this_card
This will, in a verbose way, display the Preistendenz and the Verfügbar ab, of a given card. The remote URL will be magickartenmarkt.de.
#
1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1785 def self.(name_of_the_card) e 'Card: '+simp(name_of_the_card)+':' sanitized_name_of_the_card = name_of_the_card.tr('(','|').delete(')') preistendenz = return_preistendenz_of_this_card_from_magickartenmarkt( sanitized_name_of_the_card, nil, :be_quiet ) e 'Preistendenz: '+sfancy(preistendenz.to_s.rjust(5),)+' Euro' = ( sanitized_name_of_the_card, nil, :be_quiet ) e 'Verfügbar ab: '+sfancy(.to_s.rjust(5),)+' Euro' return [preistendenz, ] # Also return the Array here. end |
.cleanse_this_md_file(which_md_file = :default) ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.cleanse_this_md_file
To invoke this method, try:
#
1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1712 def self.cleanse_this_md_file(which_md_file = :default) case which_md_file when :default # Use the default .md file from the given set in this case. _ = which_set?.tr(' ','_') which_md_file = log_dir?+_+'/'+_+'.md' end if File.exist? which_md_file e 'Removing the file '+sfile(which_md_file)+' next.' delete(which_md_file) else e 'No file exists at '+sfile(which_md_file)+'.' end end |
.clear_all_cards_of_the_set ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.clear_all_cards_of_the_set
#
1470 1471 1472 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1470 def self.clear_all_cards_of_the_set @all_cards_of_the_set = {} end |
.create_and_show_random_booster_set ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.create_and_show_random_booster_set
To invoke this method from the commandline, try:
magic --booster
#
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 99 def self.create_and_show_random_booster_set from_this_set = current_card_set? e "We will create a booster of the card set called `"\ "#{simp(from_this_set)}`." available_cards = return_random_booster e e 'The cards in this booster are:' e what = '<html><head><title>Booster for '+ from_this_set+'</title></head></body>'.dup available_cards.each_with_index {|name_of_the_card, index| name_of_the_card = name_of_the_card.dup if name_of_the_card.frozen? index += 1 index = royalblue((index.to_s+')').rjust(3)) e ' '+index+' '+slateblue(name_of_the_card) # =================================================================== # # Next, show the picture URL: # =================================================================== # local_url_to_the_card_picture = return_local_picture_for_this_card( name_of_the_card, from_this_set ) e ' '+slategray(local_url_to_the_card_picture) unless name_of_the_card.encoding.to_s.include? MAIN_ENCODING name_of_the_card = name_of_the_card.force_encoding(MAIN_ENCODING) end what << '<h4 style="display: inline; padding: 5px;">'+name_of_the_card+'</h4>'+N unless local_url_to_the_card_picture.encoding.to_s.include? MAIN_ENCODING local_url_to_the_card_picture = local_url_to_the_card_picture.force_encoding(MAIN_ENCODING) end what << '<img src="'+local_url_to_the_card_picture.tr(' ','_')+'">'+N } what << '</body></html>'+N into = self.log_dir?+'random_booster.html' e # ======================================================================= # # Notify where we will store this new file next: # ======================================================================= # e 'Also creating .html file at `'+sfile(into)+'`.' SaveFile.write_what_into(what, into) do_open_in_browser = true if do_open_in_browser begin require 'open' Open.in_browser(into) rescue LoadError; end end end |
.create_big_zip_file(this_dir = log_dir? ) ⇒ Object
#
MagicTheGathering.create_big_zip_file
To invoke, try this:
magic --create-zip-file
#
1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1149 def self.create_big_zip_file( this_dir = log_dir? ) original_start_directory = Dir.pwd GamesAndRpgParadise.cd(File.dirname(this_dir)) # Go back to the start directory. simple_filename = 'magic_the_gathering.zip' e rev+'Next creating a .zip archive.' _ = 'zip '+simple_filename+' -r magic_the_gathering/' GamesAndRpgParadise.esystem(_) target = "#{File.dirname(this_dir)}/#{simple_filename}" e rev+ 'The file should now be available at: '+ sfile(target) e rev+'The filesize is: '+ ::Colours.royalblue( (File.size(target).to_f / 1024.0 / 1024.0).round(1).to_s+' MB' ) if original_start_directory.start_with?('/Depot') e 'As the current working directory is somewhere within the' e '/Depot/ hierarchy, we will also copy that .zip file to' e 'the current working directory.' new_target = original_start_directory+'/'+ File.basename(target) ::GamesAndRpgParadise.copy_file(target, new_target) e 'The file should now be available at: '+ sfile(new_target) end end |
.create_big_zip_file_or_copy_existing_zip_file(i) ⇒ Object
#
MagicTheGathering.create_big_zip_file_or_copy_existing_zip_file
To tap into this entry point, try something like:
magic /Depot/jjj/magic_the_gathering.zip
#
1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1121 def self.create_big_zip_file_or_copy_existing_zip_file(i) if i and i.start_with?('--') and !File.exist?(i) # In this case we will try to find a local .zip file. possible_local_zip_files = Dir['*.zip'] unless possible_local_zip_files.empty? i = possible_local_zip_files.first.to_s end end if File.exist? i e "Extracting the file #{i} next." target_directory = GamesAndRpgParadise::MagicTheGathering.log_dir? cmd = "unzip #{i} -d #{File.dirname(target_directory)}/" e GamesAndRpgParadise.esystem cmd e else create_big_zip_file end end |
.create_html_page(this_directory = '/home/Temp/magic_the_gathering/Scourge/') ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.create_html_page (html tag)
This can be used to create a .html page. This page will reside inside of the specific sub-set directory.
The argument that is passed to this method should be the full path of where it will be stored.
#
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 214 def self.create_html_page( this_directory = '/home/Temp/magic_the_gathering/Scourge/' ) begin require 'html_tags' rescue LoadError; end # ======================================================================= # # Handle Array-as-input first # ======================================================================= # this_directory = this_directory.first if this_directory.is_a? Array this_directory = this_directory.dup if this_directory.include? '"' this_directory.tr!('"') end # ======================================================================= # # Handle semi-complete input next. # ======================================================================= # unless this_directory.include? '/' # Simplified way to call it. this_directory.prepend(log_dir?) this_directory << '/' unless this_directory.end_with? '/' this_directory = this_directory.dup end # ======================================================================= # # Next we load up the specific file that contains all the cards of # this given set. In the old days, this used to be a .yml file, but # since November 2016, we will use a custom .md file for this. # # We are only interested in the .jpg files anyway. # ======================================================================= # md_file = this_directory.tr(' ','_')+ File.basename(this_directory).tr(' ','_')+'.md' dataset = ParseMultipleCards.new(md_file) jpg_files = Dir[this_directory.tr(' ','_')+'*.jpg'].sort _ = "<html><title>#{this_directory}</title><body style=\"font-size: 1.25em\">".dup # ======================================================================= # # Show how many cards are in that particular card-set. # ======================================================================= # _ << '<p>This card set has <b>'+jpg_files.size.to_s+'</b> cards.</p>' jpg_files.each_with_index {|file, index| file = file.force_encoding(USE_THIS_ENCODING) _ << HtmlTags.h5( File.basename(file).gsub(/#{File.extname(file)}/,'').tr('_',' ') ) # ===================================================================== # # The key must be something like "Canopy Gorger" rather # than "Canopy Gorger.jpg". # ===================================================================== # key = File.basename( file.tr('_',' ') ).gsub(/#{File.extname(file)}/,'') if dataset.has_key? key # =================================================================== # # === Add the rarity # =================================================================== # rarity = dataset.return_rarity_of(key).to_s _ << HtmlTags.h5('Rarity: '+rarity, css_style: 'margin-left:1em; margin-top: 2px; margin-bottom: 4px; display: flex;') end _ << '<img style="margin-left:1em" src="'+file+'">' case (index % 3) when 0 _ << '<br>' end } _ << '</body></html>' what = _ into = this_directory.tr(' ','_')+'index.html' opn; e 'Saving a '+slateblue('.html page')+' into `'+sfile(into)+'`.' SaveFile.write_what_into(what, into) end |
.create_personal_cards_webpage(i = my_cvs_dataset? ) ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.create_personal_cards_webpage
This method can be used to generate a standalone page with all my cards. All the images should be under the subdirectory called images/.
To invoke this metho, do:
magic --create-personal-cards-webpage
#
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 298 def self.create_personal_cards_webpage( i = my_cvs_dataset? ) use_this_temp_dir = '/home/Temp/' e 'We will work through this dataset, which has '+simp(i.size.to_s)+' entries.' base_dir_to_use_for_images = use_this_temp_dir+'magic_cards_images/' GamesAndRpgParadise.cd(use_this_temp_dir) unless File.directory? base_dir_to_use_for_images GamesAndRpgParadise.mkdir(base_dir_to_use_for_images) end string = '<html> <style> img { border: 0px solid black; } </style> <body style="padding: 0.5em; margin:2px; margin-left:8px; border: 0px solid black"> <table cellspacing=5> <tr><td><b style="text-decoration:underline">Name of the card</b></td> <td><b style="text-decoration:underline">Name of the set</b></td> <td><b style="text-decoration:underline">Picture</b></td> <td><b style="text-decoration:underline">Price on magickarten.de</b></td></tr> '.dup # ======================================================================= # # For now, take only the first 150. # ======================================================================= # if i.size > 150 i = i[0...150] end # ======================================================================= # # Next, batch-add all these entries. # ======================================================================= # i.each_with_index {|name_of_the_card, index| index += 1 index = simp( (index.to_s+')').rjust(3) ) e index+' Now working on the card `'+simp(name_of_the_card)+'`.' # ===================================================================== # # We must also copy the image-file. # ===================================================================== # name_of_the_set = GamesAndRpgParadise::MagicTheGathering.return_card_set_from_this_card_name(name_of_the_card) _ = ::GamesAndRpgParadise.log_dir?+name_of_the_set.tr(' ','_')+ '/'+name_of_the_card.tr(' ','_') _ = Dir[_+'*'].first unless File.exist?(base_dir_to_use_for_images+'/'+File.basename(_)) copy_file(_, base_dir_to_use_for_images) end img_tag_to_use = '<img src="magic_cards_images/'+name_of_the_card.tr(' ','_')+ '.jpg" style="width: 60%; height: 60%"/>' # Here, we must also add the amount of cards that we have. # ^^^ TODO # ===================================================================== # # Next, add in the price. # ===================================================================== # price = return_magickarten_de_price_for(name_of_the_card).to_s.dup string << '<tr><td>'+name_of_the_card.ljust(35)+'</td>'+N+ ' <td>'+name_of_the_set.to_s+'</td>'+N+ ' <td>'+img_tag_to_use+'</td>'+N+ ' <td><b>'+price+Cyberweb::EURO_SYMBOL+'</b></td>'+N+ N } string << ' </table> <p> .cvs Datei findet sich im folgenden Link:<br> <a href="Kartenliste_mit_Preisen_28.09.2016.csv" style="margin-left:2em"> <b> Kartenliste_mit_Preisen_28.09.2016.csv </b> </a> <br> <br> https://www.magickartenmarkt.de/<br> <a href="https://www.magickartenmarkt.de/" style="margin-left:2em"> <b> https://www.magickartenmarkt.de/ </b> </a> </p>'.dup what = string into = File.dirname(base_dir_to_use_for_images)+'/Magic_Karten.html' # e string # We could feed back the string here, but it appears # to be not too overly useful to do so. e 'Storing into `'+sfile(into)+'`.' SaveFile.write_what_into(what, into) end |
.download_from_the_official_site(i) ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.download_from_the_official_site
#
518 519 520 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/classes/download_cards_from_gatherer_wizards_com.rb', line 518 def self.download_from_the_official_site(i) ::GamesAndRpgParadise::MagicTheGathering::DownloadCardsFromGathererWizardsCom.new(i) end |
.e(i = '') ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.e
#
659 660 661 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 659 def self.e(i = '') puts i end |
.ecomment(i = '') ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.ecomment
#
1181 1182 1183 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1181 def self.ecomment(i = '') puts ::Colours.comment(i) end |
.generate_main_html_file(be_verbose = true) ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.generate_main_html_file
This method will generate the main .html file that links in to all the other html files.
We will also show a red text in case that the number that we obtained here, does not correspond to the amount listed in the yaml “registry”.
To invoke this method, do:
#
1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1198 def self.generate_main_html_file(be_verbose = true) require 'html_tags' require 'save_file' case be_verbose when :be_verbose be_verbose = true when :be_quiet, :be_silent be_verbose = false end log_dir = log_dir? # ======================================================================= # # Grab all index.html files next # ======================================================================= # all_index_html_files = Dir["#{log_dir}**/**"].select {|entry| File.basename(entry) == 'index.html' } _ = ''.dup _ << '<html><title>All Magic The Gathering Cards</title><body>'+N _ << HtmlTags.h4('The following entries have been found:') n_cards_in_total = 0 # ======================================================================= # # Next, we sort these entries alphabetically. In theory we could also # sort by date, but I think alphabetical sorting makes more sense as # the default, for now. # ======================================================================= # sorted = all_index_html_files.sort sorted.each_with_index {|entry, index| index += 1 # ===================================================================== # # We also have to determine how many cards there are in this # subdirectory. # ===================================================================== # dirname = (File.dirname(entry)+'/').squeeze '/' jpg_image_files = Dir["#{dirname}**/**.jpg"] # ===================================================================== # # Determine how many cards we actually have. # ===================================================================== # n_cards = jpg_image_files.size.to_s use_this_regex = /\/home\/Temp\/magic_the_gathering\/(.+)\/index.html/ entry =~ use_this_regex card_set = $1.to_s.dup # ===================================================================== # # Determine how many cards it should have: # ===================================================================== # should_have_n_cards = this_set_should_have_n_cards(card_set) optional_error_string = '' unless n_cards.to_i == should_have_n_cards optional_error_string = optional_error_string.dup if optional_error_string.frozen? optional_error_string << ' <b style="color: red">This is not correct. It should have '+should_have_n_cards.to_s+' instead.</b>' end n_cards_in_total += n_cards.to_i _ << '<b style="color: saddlebrown">('+index.to_s+ ')</b>'+ HtmlTags.a(entry, css_style: 'margin-left:1.5em')+ '(<b style="color: darkblue">'+n_cards+' cards</b>)'+ optional_error_string # === magic --html _ << HtmlTags.br } _ << '<p>This collection has a total of <b>'+n_cards_in_total.to_s+ '</b> cards.</p>'+N _ << '</body></html>'+N what = _ into = log_dir+'all_subpages.html' e 'Saving into `'+sfile(into)+'`.' if be_verbose SaveFile.write_what_into(what, into) end |
.generate_yaml_stats ⇒ Object
#
MagicTheGathering.generate_yaml_stats
This method will generate some statistics stored in yaml format.
To invoke this method, do:
magic --yaml-stats
#
1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1757 def self.generate_yaml_stats hash = {} available_card_sets?.each {|this_card_set| should_have_n_cards = this_set_should_have_n_cards(this_card_set) hash[this_card_set] = should_have_n_cards } what = YAML.dump(hash) into = log_dir?+'statistics.yml' e 'Now storing into `'+sfile(into)+'`.' SaveFile.write_what_into(what, into) end |
.interactive_csv ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.interactive_csv
Read in an simulate some .csv dataset.
#
524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 524 def self.interactive_csv delimiter_to_use = '__' e e 'This method allows you to "read in" a .csv file manually, that is' e 'you simply input name and value in euro.' e 'End this input by typing '+simp(delimiter_to_use)+' on a new line.' e 'Start to input your cards now:' e user_input = $stdin.gets('__') dataset = user_input.split(N).map(&:strip).select {|line| !line.strip.empty? } dataset.reject! {|entry| entry.strip == delimiter_to_use } # Get rid of the delimiter. dataset.map! {|line| if line.include? '$' line = line[0 .. (line.index('$')-1)] line.strip! end line } sum = 0 n_entries = dataset.size.to_s e 'The given dataset has '+simp(n_entries)+' entries.' dataset.each {|this_card| sum += return_price_of(this_card, :be_verbose).to_s.tr(',','.').to_f } sum = sum.round(3) e 'Total sum worth for these '+simp(dataset.size.to_s)+ ' cards: '+sfancy(sum)+' Euro' end |
.is_this_card_included?(this_card) ⇒ Boolean
#
GamesAndRpgParadise::MagicTheGathering.is_this_card_included?
Simple query method to determine whether any given card is included in the whole collection.
#
1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1579 def self.is_this_card_included?(this_card) _ = available_cards? if _ _.include? this_card else e "The cardset does not seem to be available. Queried "\ "card was #{sfancy(this_card)}." false end end |
.local_cvs_prices_twenty_percent ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.local_cvs_prices_twenty_percent
#
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 558 def self.local_cvs_prices_twenty_percent dataset = <<-EOF Plateau Revised Edition 42,52 EURO Crucible of Worlds Fifth Dawn 30,52 EURO Ancestral Vision Time Spiral 31,27 EURO Glimpse of Nature Champions of Kamigawa 11,85 EURO Demonic Tutor Revised Edition 12,10 EURO Sylvan Library Legends 41,55 EURO Kiki-Jiki, Mirror Breaker Modern Masters 9,30 EURO Land Tax Legends 11,27 EURO Life from the Loam Modern Masters 11,81 EURO Pendelhaven Legends 10,59 EURO Privileged Position Ravnica: City of Guilds 5,21 EURO Anvil of Bogardan Visions 7,32 EURO Mana Vault Revised Edition 4,83 EURO Sliver Overlord Scourge 5,11 EURO Mycosynth Golem Fifth Dawn 6,33 EURO Cloudstone Curio Ravnica: City of Guilds 5,16 EURO Eladamri, Lord of Leaves Tempest 7,30 EURO Enlightened Tutor Mirage 5,69 EURO Maze of Ith The Dark 13,90 EURO Grave Pact Stronghold 5,98 EURO Weathered Wayfarer Onslaught 3,85 EURO Temple Garden Ravnica: City of Guilds 9,04 EURO Disrupting Shoal Betrayers of Kamigawa 5,80 EURO Ghostly Prison Champions of Kamigawa 2,50 EURO Lotus Vale Weatherlight 4,23 EURO Might of Old Krosa Time Spiral 4,36 EURO Slaughter Pact Modern Masters 7,42 EURO Threads of Disloyalty Betrayers of Kamigawa 2,68 EURO Urborg, Tomb of Yawgmoth Planar Chaos 8,47 EURO Sedge Sliver Time Spiral 3,77 EURO Necropotence Ice Age 4,57 EURO Forbidden Orchard Champions of Kamigawa 2,69 EURO Merrow Reejerey Lorwyn 1,79 EURO Rune-Tail, Kitsune Ascendant Saviors of Kamigawa 2,13 EURO Winter Orb Revised Edition 4,08 EURO EOF dataset = dataset.split("\n") # ======================================================================= # # Must sanitize it now. # ======================================================================= # dataset.map! {|line| line = line.gsub!(/\t\t/,"\t") splitted = line.split("\t").map(&:strip) new_array = [] new_array << (splitted[0]+':').ljust(30) cheaper_cost = ( splitted[-1].tr(',','.').sub(/ EURO/,'').strip.to_f ) * 0.2 cheaper_cost = cheaper_cost.round(2) new_array << cheaper_cost.to_s } dataset.sort_by! {|array| # Highest price first. array[-1].to_f } dataset = dataset.reverse.map {|entry| entry[-1] = entry[-1].ljust(4,'0') entry.join(' ') } e dataset.join("\n") end |
.log_dir? ⇒ Boolean
#
GamesAndRpgParadise::MagicTheGathering.log_dir?
This method will return the value of the LOG_DIR constant. This constant denotes our base directory - that is, where we will download our cards to.
#
1515 1516 1517 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/constants/constants.rb', line 1515 def self.log_dir? LOG_DIR end |
.main_card_set?(i = FILE_MAIN_CARD_SET) ⇒ Boolean
#
MagicTheGathering.main_card_set?
#
1314 1315 1316 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1314 def self.main_card_set?(i = FILE_MAIN_CARD_SET) YAML.load_file(i).strip end |
.main_encoding? ⇒ Boolean
#
GamesAndRpgParadise::MagicTheGathering.main_encoding?
The old constants MAIN_ENCODING = MAIN_ENCODING_TO_USE = USE_THIS_ENCODING = UTF_ENCODING were removed in March 2023. Use this method here instead.
#
105 106 107 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/constants/constants.rb', line 105 def self.main_encoding? UTF_ENCODING end |
.menu(i) ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.menu (menu tag)
#
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/menu/menu.rb', line 24 def self.(i) if i.is_a? Array i.each {|entry| (entry) } else case i # case tag # ===================================================================== # # === magic --log_dir? # ===================================================================== # when /log(_|-)?dir\??/, /^-?-?base-?dir\??/, /^-?-?dir\??/ # magic --dir? e GamesAndRpgParadise::MagicTheGathering.log_dir? # ===================================================================== # # === magic --"159 cards" # # Alternatively, use: # # magic --ncards=167 # # ===================================================================== # when /^-?-?(\d+)(-|_| )?cards$/i, # === $1 /^-?-?ncards=(.+)$/i # === $1 e GamesAndRpgParadise::MagicTheGathering.return_n_lands_necessary($1.to_s.dup).to_s+ ' lands are necessary.' # ===================================================================== # # === magic --create-html-page # # This entry point can be used to generate a new .html page. # # Invocation example: # # magic "--create-html-page Journey_into_Nyx/" # magic "--create-html-page Tempest" # # ===================================================================== # when /-?-?create(-|_| )?html(-|_| )?page ?(.*)/ # Must come before the second html clause. _ = GamesAndRpgParadise::MagicTheGathering.main_card_set? # See: https://rubular.com/r/romrZqKXXq _ = $1.to_s.dup if $1 _ = $3.to_s.dup if $3 _.chop! if _.end_with? '/' GamesAndRpgParadise::MagicTheGathering.create_html_page(_) # magic "--create-html-page Journey_into_Nyx/" # ===================================================================== # # === magic --html? # # This entry point will generate a new "all_subpages.html" file. # ===================================================================== # when 'main_html_file', /-?-?generate(-|_| )?all(-|_| )?subpages$/, # === magic --generate-all-subpages /-?-?html\??/, /^-?-?subpage/ # Allow html-generation here. require 'games_and_rpg_paradise/games/magic_the_gathering/module_methods/generate_main_html_file.rb' generate_main_html_file # magic main_html_file # ===================================================================== # # === magic --missing? # # This entry point can be used to query which card-sets are # missing yet. # ===================================================================== # when /^-?-?missing\??$/i report_which_local_entries_are_missing exit # ===================================================================== # # === magic --open # # This entry point will simply open some of the files that I # wish to modify. # ===================================================================== # when /^-?-?open$/i GamesAndRpgParadise.esystem 'bluefish /home/x/DATA/PROGRAMMING_LANGUAGES/RUBY/src/rpg_paradise/lib/rpg_paradise/magic_the_gathering/menu/menu.rb' GamesAndRpgParadise.esystem 'bluefish /home/x/DATA/PROGRAMMING_LANGUAGES/RUBY/src/rpg_paradise/lib/rpg_paradise/magic_the_gathering/constants/checked_card_types.rb' exit # ===================================================================== # # === magic create_zip_file # # This entry point will either create a .zip file (one big .zip file), # or it will extract an existing .zip file. # # Invocation example: # # magic --zip # # ===================================================================== # when /zip$/, /^-?-?unzip/ require 'games_and_rpg_paradise/games/magic_the_gathering/module_methods/zip.rb' create_big_zip_file_or_copy_existing_zip_file(i) # ===================================================================== # # === magic --booster # ===================================================================== # when /^-?-?boost?e?r?/, /^-?-?boster/ create_and_show_random_booster_set # ===================================================================== # # === magic --ncards? # # See this regex: http://rubular.com/r/ruXew3opjv # # To invoke it, try this: # # magic "--n_cards? Kaladesh" # # ===================================================================== # when /-?-?n_?cards\??\s?(.+)?$/ # magic --n_cards? # =================================================================== # # Either report the total amount of cards - or only those cards # of a given set. # =================================================================== # report_total_amount_of_cards_in_this_set_or_overall($1.to_s.dup) # bl module_methods/n_cards_registered_in_total.rb # ===================================================================== # # === magic --report-n-cards # # This entry point will check how many registered cards are # available locally. # ===================================================================== # when /^-?-?report(-|_)?n(-|_)?cards$/, /^-?-?n(-|_)?cards$/ report_total_amount_of_cards # ===================================================================== # # === magic --cardset? # # This entry point can be used to query the main card set in # use for the MagicTheGathering submodule. # ===================================================================== # when /^-?-?cardset\??/, 'main_set?' # magic main_set? e GamesAndRpgParadise::MagicTheGathering.main_card_set? # ===================================================================== # # === magic --n_sets? # ===================================================================== # when /-?-?n_?sets\??/ e GamesAndRpgParadise::MagicTheGathering.n_sets_in_total?.to_s+ ' sets are available/registered in total.' # ===================================================================== # # === magic --localset # ===================================================================== # when /^-?-?local(-|_)?sets?\??/, /^-?-?all(-|_)?sets/, '--all-sets' show_the_available_local_sets # ===================================================================== # # === magic --stats? # ===================================================================== # when /-?-?stats\??/ show_relevant_statistics # This method is in misc.rb # ===================================================================== # # === magic --all-cards # ===================================================================== # when /^-?-?all(-|_)?cards/, /(-|_)?(-|_)?show(-|_)?cards/ show_all_cards # In the file misc.rb # ===================================================================== # # === magic --merge # ===================================================================== # when /^-?-?merge in all yaml files/, /^-?-?merge$/, /^-?-?yaml/ # magic --merge merge_all_individual_md_files_into_one_big_yaml_file # ===================================================================== # # === magic --yaml-stats # ===================================================================== # when /-?-?yaml(-|_)?stats$/, /^-?-?generate_?yaml_?stats/ generate_yaml_stats # ===================================================================== # # === magic --show-available-cards # ===================================================================== # when /^-?-?show(_|-)?available(_|-)?cards/, /^-?-?show$/i # === magic --show show_available_cards # ===================================================================== # # === magic available_cards? # ===================================================================== # when 'available_cards?' p available_cards? # ===================================================================== # # === magic "release_of? Kaladesh" # # This entry point can be used to quickly determine the release # of a particular set. # # Invocation example: # # magic "release_of? War of the Spark" # # ===================================================================== # when /release_?of\?? (.+)/ # See: https://rubular.com/r/0z8NbNVQxC _ = $1.to_s.dup e GamesAndRpgParadise::MagicTheGathering.release_of_this_card_set(_) # ===================================================================== # # === magic --n_sets_in_total? # # This entry point allows us to query how many sets exist in total. # ===================================================================== # when /^-?-?n_?sets(_|-)?in(_|-)?total\??$/ e GamesAndRpgParadise::MagicTheGathering.n_sets_in_total? # ===================================================================== # # === magic --n_cards_in_this_card_set # ===================================================================== # when /^-?-?n_cards_in_this_card_set$/ n_cards_in_this_card_set # ===================================================================== # # === magic --bootstrap # # This entry point can be used to bootstrap (batchdownload) the # card to the local computer. # ===================================================================== # when /^-?-?bootstrap$/ bootstrap # ===================================================================== # # === magic --pricelist # ===================================================================== # when /pricelist/ e 'This is just for demo purposes, to test functionality.' sum = 0 array = [ 'Tarmogoyf', 'Lhurgoyf', 'Crucible of Worlds', "Umezawa's Jitte", 'Sylvan Library' ] array.each {|line| sum += return_price_of(line).to_f e 'The average price ("Preistendenz") for the card '+simp(line)+ ' is '+sfancy(sum.to_s)+'.' } e 'Total sum worth for these '+simp(array.size.to_s)+ ' cards: '+sfancy(sum)+' Euro' # ===================================================================== # # === magic --show-constant # ===================================================================== # when /^-?-?show(_|-)?constant$/ show_content_of_the_main_constant_file # ===================================================================== # # === magic --cvs? # ===================================================================== # when /^-?-?cvs\??$/, /^-?-?csv\??$/ show_location_of_the_main_csv_file exit # ===================================================================== # # === show_price_information # # Use this to create a .html page with all your cards. # ===================================================================== # when /show_?price_?information/, /price(_|-)?info\??$/, # magic --priceinfo /-?-?show(_|-)?price(_|-)?information$/ GamesAndRpgParadise::MagicTheGathering::ShowPriceInformationFromMagickartenmarkt.new # ===================================================================== # # === magic --price-info-file # ===================================================================== # when /price(_|-)?info(_|-)?file\??$/ GamesAndRpgParadise::MagicTheGathering::ShowPriceInformationFromMagickartenmarkt.show_path_to_main_file exit # ===================================================================== # # === magic "--cost_of? Plateau" # ===================================================================== # when /cost(_|-)?of\??(.+)/ name_of_the_card = $2.to_s.strip.dup cost_of?(name_of_the_card) # ===================================================================== # # === magic --batch_process_current_csv # ===================================================================== # when /batch_process_current_csv/ this_file = "#{HOME_DIRECTORY_OF_THE_USER_X}DATA/GAMES/magic_the_gathering/Aktuelle_Kartenliste_19.11.2016.csv" data = File.readlines(this_file) preistendenz = 0 = 0 data.each {|line| result = (line.strip.squeeze(' ')) preistendenz += result.first.to_f += result.last.to_f } e "Sum of Preistendenz: #{preistendenz.to_s} Euro" e "Sum of Verfügbar ab: #{.to_s} Euro" # ===================================================================== # # === magic "Temple Garden | Ravnica: City of Guilds" # ===================================================================== # when /(.+\s*\|\s*.+)/ # See: http://rubular.com/r/7K89HClvpw name_of_the_card = $1.to_s.dup.strip (name_of_the_card) # ===================================================================== # # === magic "Tarmogoyf (Future Sight)" # ===================================================================== # when /(.+\(.+\))/ # See: http://rubular.com/r/hoOyE9FzyC name_of_the_card = $1.to_s.dup.strip (name_of_the_card) # ===================================================================== # # === magic --cleanse-md-file # ===================================================================== # when /-?-?cleanse-?md-?file/ cleanse_this_md_file(:default) # ===================================================================== # # === magic --download # ===================================================================== # when /-?-?download/,'dl' use_this_set = GamesAndRpgParadise::MagicTheGathering.main_card_set? n_pages_to_download = ( GamesAndRpgParadise::MagicTheGathering.return_n_cards_in_this_set(use_this_set) / 100.0 ).ceil # Specify here how many pages to download. I think we may # have to add +1 here but I am not entirely sure - just in case, # we do it anyway. e rev+'We assume that '+sfancy(n_pages_to_download.to_s)+' different '\ 'remote (web)pages have to be queried for the card set ' e simp(use_this_set)+'. (n cards registered: '+ sfancy( GamesAndRpgParadise::MagicTheGathering.this_set_should_have_n_cards(use_this_set).to_s )+' cards)' GamesAndRpgParadise::MagicTheGathering.download_from_the_official_site( # Download the specified variant. name_of_the_set: use_this_set, # magic "--set Odyssey" n_pages: n_pages_to_download ) # =================================================================== # # In the old code, we used to convert the .rb file into # a .yaml file next. This is no longer necessary. # =================================================================== # # MagicTheGathering.turn_ruby_hash_into_yaml_file() # ===================================================================== # # === magic download_single_card # ===================================================================== # when 'download_single_card' GamesAndRpgParadise::MagicTheGathering::DownloadSingleCard.new # Just to download the single file. # ===================================================================== # # === magic --test # ===================================================================== # when /test/, /update_?set/ # magic --updateset name_of_the_set = "Journey into Nyx" should_have_n_cards = GamesAndRpgParadise::MagicTheGathering.this_set_should_have_n_cards(name_of_the_set) should_have_n_pages = (should_have_n_cards / 100.0).ceil e rev+'We assume that the set '+sfancy(name_of_the_set)+ ' has '+simp(should_have_n_pages.to_s)+' pages ('+ sfancy(should_have_n_cards.to_s)+' cards).' GamesAndRpgParadise::MagicTheGathering.obtain_all_pages( name_of_the_set, should_have_n_pages ) path = GamesAndRpgParadise::MagicTheGathering.log_dir?+ name_of_the_set.tr(' ','_')+'/'+name_of_the_set.tr(' ','_')+'.rb' require path GamesAndRpgParadise::MagicTheGathering.turn_ruby_hash_into_yaml_file( GamesAndRpgParadise::MagicTheGathering::HASH_CARD_SETS[name_of_the_set], name_of_the_set ) n_cards = GamesAndRpgParadise::MagicTheGathering.report_n_cards_in_this_set(name_of_the_set).to_i n_cards_for_real = GamesAndRpgParadise::MagicTheGathering.this_set_should_have_n_cards(name_of_the_set).to_i if n_cards == n_cards_for_real # Pass through - all is fine here. else e 'This is not correct - it should have `'+ sfancy(n_cards_for_real.to_s)+'` instead.' end # ===================================================================== # # === magic show-n-total-cards # ===================================================================== # when /show(_|-)?n(_|-)?total(_|-)?cards/ show_n_total_cards # ===================================================================== # # === magic --interactive-csv # ===================================================================== # when /interactive/ interactive_csv # ===================================================================== # # == magic --create-personal-cards-webpage # ===================================================================== # when /(-|_)?(-|_)?create(-|_)?personal(-|_)?cards(-|_)?webpage/ create_personal_cards_webpage # ===================================================================== # # === magic simple_download # ===================================================================== # when 'simple_download' # Just a simple-download. GamesAndRpgParadise::MagicTheGathering::DownloadCardsFromGathererWizardsCom.new # ===================================================================== # # === magic "--set Kaladesh" # ===================================================================== # when /-?-?set (.+)/,/set_theme (.+)/,/-?-?card-?set (.+)/ GamesAndRpgParadise::MagicTheGathering.set_main_card_set($1.to_s.dup) # in toplevel_methods/main_card_set.rb # ===================================================================== # # === magic "magickarten_url Kird Ape | Eternal Masters" # ===================================================================== # when /magickarten_?url (.+ \| .+)/ # See: http://rubular.com/r/DqpffCQCKK _ = $1.to_s.dup # =================================================================== # # Pass the '|`-splitted entry into the following API: # =================================================================== # e GamesAndRpgParadise::MagicTheGathering.return_url_for_magickarten_de_for_this_card(*_.split('|')) # ===================================================================== # # === magic --help # ===================================================================== # when /-?-?help\??/ show_help else # =================================================================== # # Next, check if the card is included. To test this, try: # # magic Tarmogoyf # # =================================================================== # if GamesAndRpgParadise::MagicTheGathering.is_this_card_included? i name_of_the_set = GamesAndRpgParadise::MagicTheGathering.return_card_set_from_this_card_name(i).to_s e 'The card `'+simp(i)+'` is included. '\ 'It belongs to the '\ 'set '+sfancy(name_of_the_set)+'.' # magic Plateau e 'It can be found at this location:' location = GamesAndRpgParadise::MagicTheGathering.log_dir?+ name_of_the_set.tr(' ','_')+'/'+i.tr(' ','_')+'.jpg' e ' '+sfile(location) if ALSO_SHOW_MAGICKARTEN_DE_URL magickarten_de_url = GamesAndRpgParadise::MagicTheGathering.return_url_for_magickarten_de_for_this_card(i) e 'This would correspond to the following URL at magickarten.de:' e e " #{simp(magickarten_de_url)}" e end # =================================================================== # # Next, check if the user passed in a .csv file. # =================================================================== # elsif File.exist?(i) # Ok, it is an existing file. case File.extname(i).delete('.') when 'csv' e 'Found an existing .csv file - will try to calculate '\ 'the total "Preistendenz" for this file.' # MagicTheGathering.parse_this_csv_file(i) # With limitation. GamesAndRpgParadise::MagicTheGathering.parse_big_csv_file(i) # Without limitation. end # magic $USERS/x/DATA/GAMES/magic_the_gathering/Kartenliste_mit_Preisen_28.09.2016.csv # =================================================================== # # Else we have no idea what to do with the instruction, # hence report this to the user. # =================================================================== # else # else tag e "The card `#{simp(i)}` is NOT included." end end end end |
.merge_all_individual_md_files_into_one_big_yaml_file(be_verbose = true) ⇒ Object
#
MagicTheGathering.merge_all_individual_md_files_into_one_big_yaml_file
This method will gather all individual .md files, then generate one giant yaml file in the base directory.
To trigger this from the commandline, try:
magic --merge
#
1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1367 def self.merge_all_individual_md_files_into_one_big_yaml_file( be_verbose = true ) case be_verbose when :be_verbose be_verbose = true when :be_silent be_verbose = false end log_dir = log_dir? # ======================================================================= # # We will store this file into the base log-directory. # ======================================================================= # into = "#{log_dir}yaml_file_containing_all_cards.yml" _ = Dir[log_dir+'**/**.md'] # Obtain all .md files. hash = {} # ======================================================================= # # Iterate over all the .md files next. What information do we want # to store in the big yaml file? # ======================================================================= # _.each {|file| name_of_the_set = File.basename(file).gsub(/\.md$/,'') # ===================================================================== # # Next, keep the set only with all ' ' replaced via '_'. # ===================================================================== # name_of_the_set.tr!(' ','_') parsed_cards = ParseMultipleCards.new(file) hash[name_of_the_set] = parsed_cards.to_hash } begin # Must be protected. what = YAML.dump(hash) e 'Writing into `'+sfile(into)+'`.' if be_verbose # Otherwise we will be silent. By default we will be verbose. SaveFile.write_what_into(what, into) rescue ArgumentError => error e 'An error happened when trying to do: what = YAML.dump(hash)' pp error pp error.class end end |
.merge_in_these_cards_into_all_cards_of_the_set(i) ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.merge_in_these_cards_into_all_cards_of_the_set(i)
#
1477 1478 1479 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1477 def self.merge_in_these_cards_into_all_cards_of_the_set(i) @all_cards_of_the_set.update(i) end |
.most_recent_magic_theme? ⇒ Boolean
#
GamesAndRpgParadise::MagicTheGathering.most_recent_magic_theme?
#
1490 1491 1492 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/constants/constants.rb', line 1490 def self.most_recent_magic_theme? ARRAY_CHECKED_CARD_TYPES.first.first end |
.my_cvs_dataset?(filter_away_price_tag = true) ⇒ Boolean
#
GamesAndRpgParadise::MagicTheGathering.my_cvs_dataset?
Simply return my .csv dataset. By default, we will do some basic modifications such as chopping away all newlines.
Usage example:
x = GamesAndRpgParadise::MagicTheGathering.my_cvs_dataset?
#
419 420 421 422 423 424 425 426 427 428 429 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 419 def self.my_cvs_dataset?( filter_away_price_tag = true ) _ = File.readlines(FILE_KARTENLISTE_MIT_PREISEN_CSV).map(&:chomp).select {|entry| entry.include? '$' } _.map! {|entry| entry.split('$').first.strip } if filter_away_price_tag # Filter away the price tag here. return _ end |
.n_cards_in_this_card_set(card_set = current_card_set? ) ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.n_cards_in_this_card_set
This will return how many cards are in any given set.
It will use the corresponding yaml file in order to determine this. So if that yaml file is wrong, we will also give a wrong result.
There exists another method called “MagicTheGathering.this_set_should_have_n_cards()”. This method will be more accurate as it has hardcoded numbers right from the official homepage.
Usage example:
GamesAndRpgParadise::MagicTheGathering.n_cards_in_this_card_set('Shadowmoor')
GamesAndRpgParadise::MagicTheGathering.n_cards_in_this_card_set('Hour of Devastation')
#
683 684 685 686 687 688 689 690 691 692 693 694 695 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 683 def self.n_cards_in_this_card_set( card_set = current_card_set? ) directory = log_dir?+card_set+'/' md_file = directory+card_set+'.md' if File.exist? md_file _ = ParseMultipleCards.new(md_file) n_cards = _.n_cards? return n_cards else e 'No .md file at `'+sfile(md_file)+'` exists.' end end |
.n_cards_registered_in_total ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.n_cards_registered_in_total
This method will give us back a number, telling us how many cards are registered in total.
#
717 718 719 720 721 722 723 724 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 717 def self.n_cards_registered_in_total dataset = YAML.load_file(FILE_YAML_FILE_CONTAINING_ALL_CARDS) n_cards = 0 dataset.keys.each {|entry| n_cards += dataset[entry].keys.size } return n_cards end |
.n_sets_in_total? ⇒ Boolean
#
GamesAndRpgParadise::MagicTheGathering.n_sets_in_total?
Feedback how many sets are available in total. This ought to be feedbacked from the main array constant, so this array should be correct at all times.
#
1463 1464 1465 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1463 def self.n_sets_in_total? ARRAY_CHECKED_CARD_TYPES.size end |
.parse_big_csv_file(i = FILE_KARTENLISTE_MIT_PREISEN_CSV, output_result = true, be_verbose_or_be_quiet = :be_verbose) ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.parse_big_csv_file
This method is similar to MagicTheGathering.parse_this_csv_file() but without entry-limitation. That is, we can parse big .csv files with this method just fine. It has a threshold value though, which presently is 200.
#
507 508 509 510 511 512 513 514 515 516 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 507 def self.parse_big_csv_file( i = FILE_KARTENLISTE_MIT_PREISEN_CSV, output_result = true, be_verbose_or_be_quiet = :be_verbose ) limit_at_n_entries = 200 parse_this_csv_file( i, limit_at_n_entries, output_result, be_verbose_or_be_quiet ) end |
.parse_this_csv_file(i = FILE_KARTENLISTE_MIT_PREISEN_CSV, limit_at_n_entries = 50, output_result = true, be_verbose_or_be_quiet = :be_quiet) ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.parse_this_csv_file
The first argument should be an existing .csv file.
The second argument will tell us how many entries we will process.
To invoke this from the commandline, do something like this:
magic /home/x/DATA/games/magic_the_gathering/Kartenliste_mit_Preisen_28.09.2016.csv
#
443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 443 def self.parse_this_csv_file( i = FILE_KARTENLISTE_MIT_PREISEN_CSV, limit_at_n_entries = 50, output_result = true, be_verbose_or_be_quiet = :be_quiet # Whether to report something or not. ) case be_verbose_or_be_quiet # case tag when :be_verbose be_verbose_or_be_quiet = true when :be_quiet be_verbose_or_be_quiet = false end if i.is_a? Array if i.empty? parse_this_csv_file( # Recursive call here. FILE_KARTENLISTE_MIT_PREISEN_CSV, limit_at_n_entries, output_result ) return end i.each {|file| parse_this_csv_file(file, limit_at_n_entries, output_result) } else # ===================================================================== # # If the file exists, continue here. # ===================================================================== # if File.exist? i register_sigint dataset = File.readlines(i, encoding: USE_THIS_ENCODING).select {|entry| entry.include? '$' }.map {|inner_entry| inner_entry.split('$').first.strip } if limit_at_n_entries # Must check whether we have set any limitation at all. if dataset.size > limit_at_n_entries dataset = dataset[0, limit_at_n_entries] end end sum = 0 n_entries = dataset.size.to_s if output_result e 'The given dataset has `'+simp(n_entries)+'` entries.' end dataset.each {|this_card| sum += return_price_of(this_card, be_verbose_or_be_quiet).to_s.tr(',','.').to_f } sum = sum.round(3).to_s e 'Total sum worth for these '+simp(dataset.size.to_s)+ ' cards: '+sfancy(sum)+' Euro' if output_result return sum # Must always return the sum here. else e "No file called #{sfile(i)} exists." if output_result end end end |
.price_trend_in_this_URL(remote_URL = 'https://www.cardmarket.com/en/Magic/Products/Singles/Tempest/Eladamri-Lord-of-Leaves', remote_dataset = :default) ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.price_trend_in_this_URL
This method can be used to query the price trend from a remote URL.
#
1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1883 def self.price_trend_in_this_URL( remote_URL = 'https://www.cardmarket.com/en/Magic/Products/Singles/Tempest/Eladamri-Lord-of-Leaves', remote_dataset = :default ) case remote_dataset # ======================================================================= # # === :default # ======================================================================= # when :default remote_dataset = @remote_dataset end if remote_dataset and !remote_dataset.is_a?(Symbol) # In this case we will just pass through. else remote_dataset = URI.open(remote_URL).read end if remote_dataset # Assign anew as well. @remote_dataset = remote_dataset unless @remote_dataset == remote_dataset end # ======================================================================= # # Sanitize that dataset a bit via Cyberweb: # ======================================================================= # dataset = Cyberweb.sanitizer(remote_dataset) use_this_regex = # See: https://rubular.com/r/0uyCp9WEZ2JYea /Price Trend<\/dt>\n<dd class="col-6 col-xl-7">\n<span>\n(\d+,?\d+) €<\/span>/ dataset =~ use_this_regex result = $1.to_s.dup.tr(',','.') return result.to_f # Must return a float here. end |
.project_base_dir? ⇒ Boolean
#
GamesAndRpgParadise::MagicTheGathering.project_base_dir?
#
22 23 24 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/project/project.rb', line 22 def self.project_base_dir? PROJECT_BASE_DIRECTORY end |
.project_yaml_dir? ⇒ Boolean
#
project_yaml_dir?
#
34 35 36 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/project/project.rb', line 34 def self.project_yaml_dir? PROJECT_YAML_DIRECTORY end |
.register_sigint ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.register_sigint
#
1630 1631 1632 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1630 def self.register_sigint Signal.trap('SIGINT') { exit } end |
.release_of_this_card_set(i = 'Guildpact') ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.release_of_this_card_set
This method can be used to determine when a given card set was released. It will return the given month and year, as a String.
Usage example:
GamesAndRpgParadise::MagicTheGathering.release_of_this_card_set('Guildpact') # => "February 2006"
Commandline usage example:
magic "release_of? Kaladesh"
#
1662 1663 1664 1665 1666 1667 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1662 def self.release_of_this_card_set(i = 'Guildpact') selection = ARRAY_CHECKED_CARD_TYPES.select {|entry| entry.first.include? i } return selection.first[1].to_s # The second entry contains the date. end |
.remote_dataset? ⇒ Boolean
#
GamesAndRpgParadise::MagicTheGathering.remote_dataset?
#
1847 1848 1849 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1847 def self.remote_dataset? @remote_dataset end |
.report_how_many_cards_are_available_in_total ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.report_how_many_cards_are_available_in_total
This method will simply report how many cards are available in total, across all Magic The Gathering sets, onto the commandline.
Usage example:
magic --report-n-cards
#
771 772 773 774 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 771 def self.report_how_many_cards_are_available_in_total n_cards = n_cards_registered_in_total e "#{rev}There are a total of #{simp(n_cards.to_s)} registered cards." end |
.report_total_amount_of_cards_in_this_set_or_overall(optional_name_of_the_set = '') ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.report_total_amount_of_cards_in_this_set_or_overall
To trigger this method, try:
magic --report-n-cards
#
734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 734 def self.report_total_amount_of_cards_in_this_set_or_overall( optional_name_of_the_set = '' # This defaults to "all cards". ) _ = optional_name_of_the_set.to_s.dup case _ when '','total','all_cards','all cards' report_how_many_cards_are_available_in_total else # Else assume that the user wants to find a specific set. Trigger this like so: magic --n_cards? The Dark # ===================================================================== # # === magic --n_cards? The Dark # ===================================================================== # directory_name = _.tr(' ','_') target_dir = log_dir?+directory_name+'/' target_file = target_dir+directory_name+'.md' if File.exist? target_file # Load up the dataset. dataset = ParseMultipleCards.new(target_file) n_keys = dataset.n_cards?.to_s e 'There are a total of `'+simp(n_keys)+'` registered cards '\ 'in the set '+simp(_)+'.' return n_keys # Also return the amount of keys here. else e 'No file called '+sfile(target_file)+' was found.' end end end |
.report_which_local_entries_are_missing ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.report_which_local_entries_are_missing
This method will report which entries are missing locally, aka, which ones have not yet been downloaded.
That way the user can find out what still has to be downloaded.
Invocation example:
magic --missing?
#
1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1812 def self.report_which_local_entries_are_missing these_directories_should_exist = ARRAY_CHECKED_CARD_TYPES.map {|inner_array| first = inner_array.first first = first.tr(' ','_').delete("'") } local_directories = Dir[log_dir?+'*'].select {|entry| File.directory? entry # Select all local directories. }.map {|entry| # And shorten it for now. File.basename(entry) } missing_entries = these_directories_should_exist.reject {|entry| local_directories.include? entry } e ::Colours.rev+ 'The following '+steelblue(missing_entries.size.to_s)+ ' entries are missing:' e missing_entries.sort.each {|entry| e " - #{entry}" } e end |
.return_card_set_from_this_card_name(i = 'Tarmogoyf', use_this_file = FILE_YAML_FILE_CONTAINING_ALL_CARDS) ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.return_card_set_from_this_card_name
Pass the name of an (existing) card to this method. This method will then return the corresponding card set, e. g. “Ice Age” and similar.
Currently this is limited in that it will only return ONE entry - some card names belong to multiple sets though. In a future revision, this limitation will probably be removed.
Usage example:
GamesAndRpgParadise::MagicTheGathering.return_card_set_from_this_card_name('Tarmogoyf') # => "Future Sight"
#
795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 795 def self.return_card_set_from_this_card_name( i = 'Tarmogoyf', use_this_file = FILE_YAML_FILE_CONTAINING_ALL_CARDS ) i = i.first if i.is_a? Array i = 'Tarmogoyf' if i.nil? # Restore to a default state in this case. if File.exist? use_this_file dataset = YAML.load_file(use_this_file) if dataset.has_key? i return dataset[i][3] # Entry number 3 is the name of the set. end else nil # Else return nil. end end |
.return_common_cards_from_this_set(card_set = default_card_set) ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.return_common_cards_from_this_set
The first argument is the specific card set in use.
The hash will have a structure such as this one here:
"Underworld Dreams"=>[3, "uncommon", 0],
#
79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 79 def self.return_common_cards_from_this_set( card_set = default_card_set ) possibilities = available_cards?[card_set.tr(' ','_')] possibilities.select! {|name_of_the_card, inner_array| if inner_array[1] == 'common' name_of_the_card end } return possibilities.keys end |
.return_image_url_for_magickartenmarkt_for_this_card(this_card, name_of_the_set = nil) ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.return_image_url_for_magickartenmarkt_for_this_card
This method will return the image url of a specific card. It is not verbose.
This method does not work perfectly well though.
Usage example:
GamesAndRpgParadise::MagicTheGathering.return_image_url_for_magickartenmarkt_for_this_card('Tarmogoyf','Future Sight')
#
959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 959 def self.return_image_url_for_magickartenmarkt_for_this_card( this_card, name_of_the_set = nil ) sanitized_name_of_the_card = this_card.dup sanitized_name_of_the_card.tr!(' ','+') if sanitized_name_of_the_card.include? ' ' use_this_regex = /class="slideshow-img"><img src="(\/img.+?\.jpg)"/ # See: http://rubular.com/r/jFkvELxHqK name_of_the_set.tr!(' ','+') remote_url = 'https://www.magickartenmarkt.de/Products/Singles/'+name_of_the_set+ '/'+sanitized_name_of_the_card dataset = open(remote_url).read dataset =~ use_this_regex match = $1.to_s.dup match.prepend('https://www.magickartenmarkt.de/') return match end |
.return_local_picture_for_this_card(name_of_the_card, from_this_set = self.current_card_set?) ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.return_local_picture_for_this_card
This will return the “URL” towards the local picture of any given card. We will make use of existing files for this.
Usage example:
GamesAndRpgParadise::MagicTheGathering.return_local_picture_for_this_card('Veteran Motorist','Kaladesh')
#
825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 825 def self.return_local_picture_for_this_card( name_of_the_card, from_this_set = self.current_card_set? ) from_this_set[0,1] = from_this_set[0,1].upcase from_this_set.tr(' ','_') unless name_of_the_card.encoding.to_s.include? MAIN_ENCODING name_of_the_card = name_of_the_card.dup if name_of_the_card.frozen? name_of_the_card = name_of_the_card.force_encoding(MAIN_ENCODING) end # ======================================================================= # # Build up the local URL. # ======================================================================= # local_url = log_dir?+ from_this_set+'/'+ name_of_the_card.tr(' ','_')+ '.jpg' return local_url end |
.return_n_lands_necessary(n_cards_in_total = 60) ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.return_n_lands_necessary
This method will return how many lands are necessary in a given deck, without being too mana constrained.
#
1839 1840 1841 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1839 def self.return_n_lands_necessary(n_cards_in_total = 60) ( n_cards_in_total.to_f * 0.4 ).ceil.to_i end |
.return_only_image_files(i) ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.return_only_image_files
This method will act as a filter.
#
1639 1640 1641 1642 1643 1644 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1639 def self.return_only_image_files(i) i.select {|entry| extname = File.extname(entry).delete('.') entry if extname == 'jpg' or extname == 'png' } end |
.return_preistendenz_of_this_card_from_magickartenmarkt(this_card = 'Tarmogoyf', name_of_the_set = nil, be_verbose = true, use_this_regex = PREISTENDENZ_REGEX) ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.return_preistendenz_of_this_card_from_magickartenmarkt
This is a simplified method that will return, in Euro, the “Preistendenz” price for the given card.
The API is somewhat flexible. Have a look at the following usage examples for this.
Usage examples:
GamesAndRpgParadise::MagicTheGathering.return_preistendenz_of_this_card_from_magickartenmarkt('Tarmogoyf')
GamesAndRpgParadise::MagicTheGathering.return_preistendenz_of_this_card_from_magickartenmarkt('Tarmogoyf','Future Sight')
GamesAndRpgParadise::MagicTheGathering.return_preistendenz_of_this_card_from_magickartenmarkt('Tarmogoyf | Future Sight')
GamesAndRpgParadise::MagicTheGathering.return_preistendenz_of_this_card_from_magickartenmarkt('Sylvan Library') # => "41,55"
GamesAndRpgParadise::MagicTheGathering.return_preistendenz_of_this_card_from_magickartenmarkt('Sylvan Library | Legends') # => "48,64"
GamesAndRpgParadise::MagicTheGathering.return_preistendenz_of_this_card_from_magickartenmarkt("Sensei's Divining Top | Champions of Kamigawa")
#
864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 864 def self.return_preistendenz_of_this_card_from_magickartenmarkt( this_card = 'Tarmogoyf', name_of_the_set = nil, # If nil then we will try to decude it. be_verbose = true, # We are verbose by default. use_this_regex = PREISTENDENZ_REGEX ) case be_verbose when :be_quiet, :be_silent be_verbose = false end if this_card.is_a?(String) and this_card.include?('|') and name_of_the_set.nil? # If the second variant is nil splitted = this_card.split('|') this_card, name_of_the_set = splitted end if this_card.is_a? Array this_card.each {|card| return_preistendenz_of_this_card_from_magickartenmarkt(card) } else # ===================================================================== # # The URL must look like this: # # https://www.magickartenmarkt.de/Products/Singles/Future+Sight/Tarmogoyf # # So in order to reach such an URL, we need to return the name of the # card set. Note that the word "Preistendenz" may appear several times # on that webpage. # ===================================================================== # unless name_of_the_set name_of_the_set = return_card_set_from_this_card_name(this_card) end if name_of_the_set remote_url = return_url_for_magickarten_de_for_this_card( this_card, name_of_the_set, be_verbose ) begin remote_page = URI.open(remote_url).read # unless remote_page.encoding.to_s == MAIN_ENCODING # remote_page = remote_page.encode(MAIN_ENCODING) # end remote_page =~ use_this_regex n_euro = $1.to_s.dup if be_verbose e 'The value of this card is: '+sfancy(n_euro.to_s)+' Euro' end n_euro # Return value. rescue URI::InvalidURIError 0 end else if be_verbose e 'The card does not appear to be registered in the current dataset.' e 'The card name was `'+simp(this_card)+'`.' end nil end end end |
.return_random_booster(from_this_card_set = main_card_set? ) ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.return_random_booster
This method can be used to create a random “booster” card, that is, if you were to buy a booster. So we will return an Array with the cards, the rare one being listed last.
A typical booster in magic has 15 cards.
Each pack contains 10 commons, 3 Uncommons, 1 Rare, and 1 Land.
Extra-rare replacements take place as follows:
- a Mythic rare takes the place of the rare.
- a Foil card of any rarity takes the place of a Common.
- a "Hidden Treasure" repackaged older card takes the place of the land.
Token/Tips & Tricks card may also be in a booster but they are not playable cards.
#
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 167 def self.return_random_booster( from_this_card_set = main_card_set? ) # n_cards_in_this_booster = 15 # 15 cards are in this booster. all_common_cards = return_common_cards_from_this_set(from_this_card_set).shuffle all_uncommon_cards = return_uncommon_cards_from_this_set(from_this_card_set).shuffle all_rare_cards = return_rare_cards_from_this_set(from_this_card_set).shuffle booster_package = [] 10.times { booster_package << all_common_cards.shift } 3.times { booster_package << all_uncommon_cards.shift } 1.times { booster_package << all_rare_cards.shift } return booster_package end |
.return_rare_cards_from_this_set(card_set = self.default_card_set) ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.return_rare_cards_from_this_set
Return all rare cards from a given set.
#
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 41 def self.return_rare_cards_from_this_set( card_set = self.default_card_set ) _ = available_cards? possibilities = _[card_set.tr(' ','_')] possibilities.select! {|name_of_the_card, inner_array| if inner_array[1] == 'rare' name_of_the_card end } return possibilities.keys end |
.return_remote_url_to_the_picture_from_this_card_set(this_card_set) ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.return_remote_url_to_the_picture_from_this_card_set
This method will return the remote URL to the picture of the particular card set.
#
1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1615 def self.return_remote_url_to_the_picture_from_this_card_set( this_card_set ) case this_card_set # ======================================================================= # # === 'Kaladesh' # ======================================================================= # when 'Kaladesh' 'https://gatherer.wizards.com/Handlers/Image.ashx?type=symbol&set=KLD&size=small&rarity=R' end end |
.return_uncommon_cards_from_this_set(card_set = self.default_card_set) ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.return_uncommon_cards_from_this_set
#
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 57 def self.return_uncommon_cards_from_this_set( card_set = self.default_card_set ) possibilities = available_cards?[card_set.tr(' ','_')] possibilities.select! {|name_of_the_card, inner_array| if inner_array[1] == 'uncommon' name_of_the_card end } return possibilities.keys end |
.return_url_for_magickarten_de_for_this_card(this_card, name_of_the_set = nil, be_verbose = false) ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.return_url_for_magickarten_de_for_this_card
This method will return the proper URL for magickarten.de for any given card passed to it.
The first argument is the name of the card.
The second argument is the card set itself. It is optional. If you omit it, then we will attempt to deduce which card set it may be, which can lead to random results. So if you DO know the name of the set, then you should pass it into this method in order to be sure.
Usage example:
GamesAndRpgParadise::MagicTheGathering.return_url_for_magickarten_de_for_this_card('Tarmogoyf')
GamesAndRpgParadise::MagicTheGathering.return_url_for_magickarten_de_for_this_card('Tarmogoyf','Future Sight')
#
996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 996 def self.return_url_for_magickarten_de_for_this_card( this_card, name_of_the_set = nil, be_verbose = false ) # ======================================================================= # # The URL must look like this: # # https://www.magickartenmarkt.de/Products/Singles/Future+Sight/Tarmogoyf # # So in order to build such an URL, we need to return the name of # the card set. Note that the word "Preistendenz" may appear # several times on that webpage. # ======================================================================= # unless name_of_the_set name_of_the_set = MagicTheGathering.return_card_set_from_this_card_name(this_card) end this_card.strip! if name_of_the_set name_of_the_set.strip! # ===================================================================== # # For some strange reason, magickartenmarkt.de filters away the # word "Edition" in card-set names. This leads to somewhat # awkward results. # # For instance, consider the card "Plateau" which you can see here: # # http://gatherer.wizards.com/Pages/Card/Details.aspx?multiverseid=1378 # # You can clearly see that the name of the set is "Revised Edition". # # You can click on it here: # # http://gatherer.wizards.com/Pages/Search/Default.aspx?action=advanced&set=[%22Revised%20Edition%22] # # Yet, the corresponding entry at magickartenmarkt.de is # # https://www.magickartenmarkt.de/Products/Singles/Revised/Plateau # # when it really should be this instead: # # https://www.magickartenmarkt.de/Products/Singles/Revised+Edition/Plateau # # However had, and here the madness begins to kick in, Tenth Edition does # not have anything removed. # # This is the URL that works: # # https://www.magickartenmarkt.de/Products/Singles/Tenth+Edition/Crucible+of+Worlds # ===================================================================== # if name_of_the_set.end_with? 'Edition' # See the above ^^^ explanation. unless name_of_the_set.include? 'Fourth' or name_of_the_set.include? 'Fifth' or name_of_the_set.include? 'Sixth' or name_of_the_set.include? 'Seventh' or name_of_the_set.include? 'Ninth' or name_of_the_set.include? 'Tenth' name_of_the_set.sub!(/Edition$/,'') end name_of_the_set.strip! end name_of_the_set.tr!(' ','+') if name_of_the_set.include? ' ' sanitized_name_of_the_card = this_card.dup sanitized_name_of_the_card.tr!(' ','+') if sanitized_name_of_the_card.include? ' ' remote_url = 'https://www.magickartenmarkt.de/Products/Singles/'+name_of_the_set+ '/'+sanitized_name_of_the_card if be_verbose e 'Trying this URL next: '+sfancy(remote_url) end return remote_url # Return this URL here. end end |
.return_verfügbar_ab_of_this_card_from_magickartenmarkt(this_card = 'Tarmogoyf', name_of_the_set = nil, be_verbose = true, use_this_regex = REGEX_AVAILABLE_SINCE) ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.return_verfügbar_ab_of_this_card_from_magickartenmarkt
Usage examples:
GamesAndRpgParadise::MagicTheGathering.('Tarmogoyf','Future Sight')
#
935 936 937 938 939 940 941 942 943 944 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 935 def self.( this_card = 'Tarmogoyf', name_of_the_set = nil, # If nil then we will try to decude it. be_verbose = true, # We are verbose by default. use_this_regex = REGEX_AVAILABLE_SINCE ) return return_preistendenz_of_this_card_from_magickartenmarkt( this_card, name_of_the_set, be_verbose, use_this_regex ) # Delegate to the method above. end |
.rev ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.rev
#
624 625 626 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 624 def self.rev ::Colours.rev end |
.set_all_cards_of_the_set(i) ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.set_all_cards_of_the_set
#
1452 1453 1454 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1452 def self.set_all_cards_of_the_set(i) @all_cards_of_the_set = i end |
.set_main_card_set(i = 'Alara Reborn') ⇒ Object
#
MagicTheGathering.set_main_card_set
#
1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1327 def self.set_main_card_set( i = 'Alara Reborn' ) if available_sets?.include? i what = YAML.dump(i) into = FILE_MAIN_CARD_SET e rev+ 'Now writing '+simp(what.chomp.delete('-').strip)+ ' into `'+sfile(into)+'`.' SaveFile.write_what_into(what, into) # ======================================================================= # # Also store it on my home system. # ======================================================================= # if ENV['IS_ROEBE'].to_s == '1' into = ENV['RSRC'].to_s+'/rpg_paradise/lib/rpg_paradise/yaml/magic_the_gathering/'+ File.basename(into) e 'Now writing '+simp(what.chomp.delete('-').strip)+ ' into `'+sfile(into)+'`.' SaveFile.write_what_into(what, into) end else e ::Colours.tomato('Can not store ')+ sfancy(i)+ ::Colours.tomato(' because it is not registered '\ 'in the file')+ ::Colours.tomato(' checked_card_types.rb') end end |
.sfancy(i = '') ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.sfancy
#
638 639 640 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 638 def self.sfancy(i = '') return ::Colours.sfancy(i) end |
.sfile(i = '') ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.sfile
#
645 646 647 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 645 def self.sfile(i = '') return ::Colours.sfile(i) end |
.show_available_cards ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.show_available_cards
This method will show all the available cards.
Commandline invocation example:
magic --show-available-cards
#
1600 1601 1602 1603 1604 1605 1606 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1600 def self.show_available_cards _ = available_cards?.sort _.each_with_index {|name_of_the_card, number| number += 1 e (number.to_s + ')').ljust(3)+' '+sfancy(name_of_the_card) } end |
.show_content_of_the_main_constant_file(file = "#{PROJECT_DIR}constants/checked_card_types.rb") ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.show_content_of_the_main_constant_file
Use this method if you wish to simply show the content of the main constant file.
This is presently hardcoded.
#
1078 1079 1080 1081 1082 1083 1084 1085 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1078 def self.show_content_of_the_main_constant_file( file = "#{PROJECT_DIR}constants/checked_card_types.rb" ) if File.exist? file puts File.read(file) puts 'The above was read in from the file '+sfile(file) end end |
.show_help ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.show_help (help tag)
To trigger this method, do:
magic --help
#
1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1274 def self.show_help left_pad = ' ' e e "#{rev}These options are available:" e ecomment( ' merge in all yaml files # To merge in all yaml files download # To download the specified (default) set html # To generate the .html page zip # To create (or extract a big .zip file --all-sets # To show all available sets --booster # To create a random booster set (15 cards from one set) --bootstrap # To download all image-files (all card sets - # this may take some hours --price-info? # To show the price-info of my default card set --price-info-file? # To show the path to the price-info-file of my card set --log-dir? # To show the directory into which this project will store generated # data --csv? # To show the location of the local .csv file --show-cards # To show all available cards. Example: magic --show-cards --ncards? # How many cards are available # ^^^ If you pass an argument then we will use # that as name for the card set. Example: magic "--ncards? Guildpact" --missing? # determine which card set is missing locally You can also check individual cards like so: ') e Colours.steelblue(' magic "Mishra\'s Bauble (Coldsnap)"') e ecomment left_pad+ 'Note that you typically omit the leading -- instructions, so' ecomment left_pad+ '"magic zip" is the very same as "magic --zip".' e end |
.show_location_of_the_main_csv_file(i = FILE_KARTENLISTE_CSV) ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.show_location_of_the_main_csv_file
Use this method to show the location of the main .cvs file at hand.
To invoke this method, do:
magic --cvs?
magic --csv?
#
402 403 404 405 406 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 402 def self.show_location_of_the_main_csv_file( i = FILE_KARTENLISTE_CSV ) e sfile(i) end |
.show_n_total_cards ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.show_n_total_cards
This method will report the amount of cards per any given set, at the least from the yaml dataset. We will sort the result alphabetically.
To invoke this method from the commandline, do:
magic --show-n-total-cards
#
1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1098 def self.show_n_total_cards _ = FILE_TOTAL_CARDS if File.exist? _ dataset = YAML.load_file(_) e; e 'The amount of cards per given set are as follows:'; e sorted = dataset.sort sorted.each {|name_of_the_set, amount_of_cards_in_that_set| e (' '+name_of_the_set+':').ljust(25)+ orange(amount_of_cards_in_that_set.to_s.rjust(8)) }; e else opn; e 'No file exists at `'+sfile(_)+'`.' end end |
.show_relevant_statistics ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.show_relevant_statistics
We split between what is available locally and what should be available.
Usage example:
magic --stats
#
1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1552 def self.show_relevant_statistics ljust = 30 e rev+ 'We will now show some statistics about '+ simp('Magic The Gathering')+'.' e e ' Available cards in total: '.ljust(ljust)+ simp(self.n_cards_in_total?.to_s.rjust(4)) e ' Available cards locally: '.ljust(ljust)+ simp(return_only_image_files( Dir[self.log_dir?+'**/**'] ).size.to_s.rjust(4)) e ' Available sets in total: '.ljust(ljust)+ simp(self.n_sets_in_total?.to_s.rjust(4)) e ' Available sets locally: '.ljust(ljust)+ # Here we have to query the local data. simp(Dir[self.log_dir?+'*'].select {|entry| File.directory? entry }.size.to_s.rjust(4)) e end |
.show_the_available_local_sets ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.show_the_available_local_sets
If you wish to invoke this method from the commandline, do:
magic --localset
#
1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1677 def self.show_the_available_local_sets # magic --localset entries = Dir[log_dir?+'*'].select {|entry| File.directory? entry } entries.map! {|entry| File.basename(entry) } if entries.empty? e rev+'Currently no cards sets are presently available locally.' e e 'If you would like to download all images, consider using' e 'an option like this:' e e ' magic --bootstrap' e else e "#{rev}These card sets are presently available locally:" e entries.sort.each_with_index {|name_of_the_set, index| index +=1 n_cards = return_n_cards_from_this_set(name_of_the_set) e simp( (index.to_s+')').rjust(4) )+' '+ sfancy(name_of_the_set.tr('_',' ').ljust(30))+ ::Colours.olivedrab( '('+n_cards.to_s.rjust(3)+' cards)' ) } e end end |
.simp(i = '') ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.simp
#
652 653 654 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 652 def self.simp(i = '') return ::Colours.simp(i) end |
.slateblue(i = '') ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.slateblue
#
631 632 633 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 631 def self.slateblue(i = '') ::Colours.slateblue(i) end |
.this_set_should_have_n_cards(this_card_set) ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.this_set_should_have_n_cards
This method will always return the “real” amount of cards in that given set.
#
703 704 705 706 707 708 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 703 def self.this_set_should_have_n_cards(this_card_set) entry = ARRAY_CHECKED_CARD_TYPES.select {|array| # Use the main constant here. array.first == this_card_set.tr('_',' ') } entry.flatten[2] # This is the right entry - amount of cards (Integer). end |
.total_value_of_all_cards(i = FILE_KARTENLISTE_MIT_PREISEN_CSV) ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.total_value_of_all_cards
This method will calculate the total amount worth of all cards.
The first argument should be a .csv file.
#
1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1521 def self.total_value_of_all_cards( i = FILE_KARTENLISTE_MIT_PREISEN_CSV ) if File.exist? i dataset = File.readlines(i).map(&:chomp) dataset.select! {|line| line.include? '$' } dataset.map! {|line| splitted = line.split(' ') last = splitted.last.strip.delete('$') last.to_f } total_value = dataset.inject(0) {|sum,x| sum + x } return total_value.round(2) else e 'No file exists at `'+sfile(i)+'`.' end end |
.turn_all_strings_in_this_hash_into_iso_encoding(hash) ⇒ Object
#
MagicTheGathering.turn_all_strings_in_this_hash_into_iso_encoding
This is mostly a legacy method for now - but perhaps one day we have to use a YAML file again, so we will keep this method for now.
#
1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1413 def self.turn_all_strings_in_this_hash_into_iso_encoding(hash) _ = {} hash.each_pair {|key, value| unless key.encoding.to_s.include? ISO_ENCODING key = key.dup key = key.force_encoding(ISO_ENCODING) end if value.is_a? Array value[1] = value[1].encode(ISO_ENCODING) unless value[1].encoding.to_s.include? ISO_ENCODING end _[key] = value } return _ end |
.turn_ruby_hash_into_yaml_file(ruby_hash = :use_default_ruby_hash_of_the_main_card_set, name_of_the_set = main_card_set? ) ⇒ Object
#
GamesAndRpgParadise::MagicTheGathering.turn_ruby_hash_into_yaml_file
Use this method to turn a .rb file into a .yml file. This is only meant to convert the .rb dataset for any given card-set into a valid yaml file.
The first argument is the ruby_hash data structure.
#
1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 |
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/module_methods/module_methods.rb', line 1490 def self.turn_ruby_hash_into_yaml_file( ruby_hash = :use_default_ruby_hash_of_the_main_card_set, name_of_the_set = main_card_set? ) case ruby_hash when :use_default_ruby_hash_of_the_main_card_set ruby_hash = main_card_set? path = log_dir?+name_of_the_set+'/'+name_of_the_set+'.rb' require path # This path is hopefully correct - must point to an existing .rb file. ruby_hash = HASH_CARD_SETS # This has one too many indirctions. ruby_hash = ruby_hash[name_of_the_set] end hash = {} hash[name_of_the_set] = {} hash[name_of_the_set].update(ruby_hash) yaml_dump = YAML.dump(hash) what = yaml_dump into = log_dir?+ name_of_the_set.tr(' ','_')+ '/'+name_of_the_set.tr(' ','_')+'.yml' e 'Now saving this hash dataset into `'+sfile(into)+'`.' SaveFile.write_what_into(what, into) end |