Skip to content
This repository has been archived by the owner on May 24, 2020. It is now read-only.

Enhancement/foil #28

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added public/media/foil.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions public/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ let App = {
isPrivate: false,
type: 'draft',
sets: [
'EMN',
'EMN',
'SOI',
'SOI',
'SOI',
'SOI',
'SOI',
'EMN',
'EMN',
'SOI'
],
list: '',
Expand Down
2 changes: 1 addition & 1 deletion public/src/components/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function zone(zoneName) {
let items = cards.map(card =>
d.span(
{
className: `card ${isAutopickable(card) ? 'autopick-card' : ''}`,
className: `card ${isAutopickable(card) ? 'autopick-card ' : ''} card ${card.foil ? 'foil-card ' : ''}`,
title: isAutopickable(card) ? 'This card will be automatically picked if your time expires.' : '',
onClick: App._emit('click', zoneName, card.name),
},
Expand Down
1 change: 1 addition & 0 deletions public/src/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export default {
"Random Set": "RNG"
},
expansion: {
"Eldritch Moon": "EMN",
"Shadows Over Innistrad": "SOI",
"Oath of the Gatewatch": "OGW",
"Battle for Zendikar": "BFZ",
Expand Down
40 changes: 36 additions & 4 deletions src/make/cards.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,22 @@ function before() {
})

var card
for (card of raw.EMN.cards)
if (card.layout === 'double-faced' || card.layout === 'meld')
card.rarity = 'special'
for (card of raw.SOI.cards)
if (card.layout === 'double-faced')
card.rarity = 'special'

for (card of raw.ISD.cards)
if (card.layout === 'double-faced')
card.rarity = 'special'

for (card of raw.DGM.cards)
if (/Guildgate/.test(card.name))
card.rarity = 'special'

for (card of raw.CNS.cards)
if ((card.type === 'Conspiracy')
|| /draft/.test(card.text))
card.rarity = 'special'

for (card of raw.FRF.cards)
if (card.types[0] === 'Land'
&& (card.name !== 'Crucible of the Spirit Dragon'))
Expand All @@ -81,6 +80,39 @@ function before() {
}

function after() {
var {EMN} = Sets
EMN.special = {
"mythic":[
"gisela, the broken blade",
"ulrich of the krallenhorde"
],
"rare":[
"voldaren pariah",
"docent of perfection",
"bruna, the fading light",
"hanweir garrison",
"hanweir battlements"
],
"common":[
"ulvenwald captive",
"vildin-pack outcast",
"midnight scavengers",
"graf rats"
],
"uncommon":[
"tangleclaw werewolf",
"shrill howler",
"conduit of storms",
"extricator of sin",
"kessig prowler",
"smoldering werewolf",
"curious homunculus",
"grizzled angler",
"lone rider",
"cryptolith fragment"
]
}
EMN.size = 8
var {SOI} = Sets
SOI.special = {
"mythic": [
Expand Down
163 changes: 105 additions & 58 deletions src/pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,28 @@ function selectRarity(set) {
return set.common
}

function pickFoil(set) {
var rngFoil = _.rand(6)
if (rngFoil < 1)
if (set.mythic)
if (_.rand(set.mythic.length + set.rare.length) < set.mythic.length)
return set.mythic
else
return set.rare
else
return set.rare
if (rngFoil < 3)
return set.uncommon
return set.common
}

function toPack(code) {
var set = Sets[code]
var {common, uncommon, rare, mythic, special, size} = set
if (mythic && !_.rand(8))
rare = mythic
//make small sets draftable.
if (size < 9 && code != 'SOI')
if (size < 9 && code != 'SOI' && code != 'EMN')
size = 10
var pack = [].concat(
_.choose(size, common),
Expand All @@ -43,71 +58,98 @@ function toPack(code) {
pack.push(_.choose(1, special.rare))
else
pack.push(_.choose(1, common))
if (code == 'EMN')
if (_.rand(8) == 0)
if (_.rand(5) < 1)
pack.push(_.choose(1, special.mythic))
else
pack.push(_.choose(1, special.rare))
else
pack.push(_.choose(1, common))


let specialrnd
switch (code) {
case 'SOI':
if (_.rand(106) < 38)
special = special.uncommon
else
special = special.common
break
case 'DGM':
special = _.rand(20)
? special.gate
: special.shock
break
case 'MMA':
special = selectRarity(set)
break
case 'MM2':
special = selectRarity(set)
break
case 'VMA':
//http://www.wizards.com/magic/magazine/article.aspx?x=mtg/daily/arcana/1491
if (_.rand(53))
case 'EMN':
if (_.rand(2) < 1)
special = special.uncommon
else
special = special.common
break
case 'SOI':
if (_.rand(106) < 38)
special = special.uncommon
else
special = special.common
break
case 'EMA':
special = selectRarity(set)
break
case 'FRF':
special = _.rand(20)
? special.common
: special.fetch
break
case 'ISD':
//http://www.mtgsalvation.com/forums/magic-fundamentals/magic-general/327956-innistrad-block-transforming-card-pack-odds?comment=4
//121 card sheet, 1 mythic, 12 rare (13), 42 uncommon (55), 66 common
specialrnd = _.rand(121)
if (specialrnd == 0)
special = special.mythic
else if (specialrnd < 13)
special = special.rare
else if (specialrnd < 55)
special = special.uncommon
else
special = special.common
break
case 'DKA':
//http://www.mtgsalvation.com/forums/magic-fundamentals/magic-general/327956-innistrad-block-transforming-card-pack-odds?comment=4
//80 card sheet, 2 mythic, 6 rare (8), 24 uncommon (32), 48 common
specialrnd = _.rand(80)
if (specialrnd <= 1)
special = special.mythic
else if (specialrnd < 8)
special = special.rare
else if (specialrnd < 32)
special = special.uncommon
else
special = special.common
break
break
case 'DGM':
special = _.rand(20)
? special.gate
: special.shock
break
case 'MMA':
special = selectRarity(set)
break
case 'MM2':
special = selectRarity(set)
break
case 'VMA':
//http://www.wizards.com/magic/magazine/article.aspx?x=mtg/daily/arcana/1491
if (_.rand(53))
special = selectRarity(set)
break
case 'FRF':
special = _.rand(20)
? special.common
: special.fetch
break
case 'ISD':
//http://www.mtgsalvation.com/forums/magic-fundamentals/magic-general/327956-innistrad-block-transforming-card-pack-odds?comment=4
//121 card sheet, 1 mythic, 12 rare (13), 42 uncommon (55), 66 common
specialrnd = _.rand(121)
if (specialrnd == 0)
special = special.mythic
else if (specialrnd < 13)
special = special.rare
else if (specialrnd < 55)
special = special.uncommon
else
special = special.common
break
case 'DKA':
//http://www.mtgsalvation.com/forums/magic-fundamentals/magic-general/327956-innistrad-block-transforming-card-pack-odds?comment=4
//80 card sheet, 2 mythic, 6 rare (8), 24 uncommon (32), 48 common
specialrnd = _.rand(80)
if (specialrnd <= 1)
special = special.mythic
else if (specialrnd < 8)
special = special.rare
else if (specialrnd < 32)
special = special.uncommon
else
special = special.common
break
}

if (special)
pack.push(_.choose(1, special))

return toCards(pack, code)
if (special) {
var specialpick = _.choose(1, special)
pack.push(specialpick)
if (foilCard) {
foilCard = specialpick
}
}
//insert foil
if (_.rand(6) < 1 && !(foilCard)) {
var foilCard = _.choose(1, pickFoil(set))
pack.push(foilCard)
}
return toCards(pack, code, foilCard)
}

function toCards(pool, code) {
function toCards(pool, code, foilCard) {
var isCube = !code
return pool.map(cardName => {
var card = Object.assign({}, Cards[cardName])
Expand All @@ -117,6 +159,11 @@ function toCards(pool, code) {
[code] = Object.keys(sets)
card.code = mws[code] || code
var set = sets[code]
card.foil = false
if (foilCard == cardName.toString().toLowerCase()) {
card.foil = true
foilCard = ''
}
delete card.sets
return Object.assign(card, set)
})
Expand Down