Skip to content
Merged
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
16 changes: 13 additions & 3 deletions public/src/cards.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,20 @@ function cube() {
}

function clickPack(cardName) {
if (clicked !== cardName)
return clicked = cardName

let index = rawPack.findIndex(x => x.name === cardName)
let card = rawPack[index]

if (clicked !== cardName) {
clicked = cardName
// There may be duplicate cards in a pack, but only one copy of a card is
// shown in the pick view. We must be sure to mark them all since we don't
// know which one is being displayed.
rawPack.forEach(card => card.isAutopick = card.name === cardName)
App.update()
App.send('autopick', index)
return clicked
}

clicked = null
Zones.pack = {}
App.update()
Expand Down
17 changes: 12 additions & 5 deletions public/src/components/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,19 @@ function zone(zoneName) {
let values = _.values(zone)
let cards = _.flat(values)

let isAutopickable = card => zoneName === 'pack' && card.isAutopick

let items = cards.map(card =>
d.img({
onClick: App._emit('click', zoneName, card.name),
src: card.url,
alt: card.name
}))
d.span(
{
className: `card ${isAutopickable(card) ? 'autopick-card' : ''}`,
title: isAutopickable(card) ? 'This card will be automatically picked if your time expires.' : '',
onClick: App._emit('click', zoneName, card.name),
},
d.img({
src: card.url,
alt: card.name,
})))

return d.div({ className: 'zone' },
d.h1({}, `${zoneName} ${cards.length}`),
Expand Down
44 changes: 44 additions & 0 deletions public/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,50 @@ time {
color: white;
}

.card {
display: inline-block;
position: relative;
margin: 0;
cursor: pointer;
}

.card:hover:before, .autopick-card:before {
content: '';

display: block;
position: absolute;

top: 0;
bottom: 0;
left: 0;
right: 0;

margin-bottom: 5px;
border-radius: 12px;

background: rgba(200, 200, 200, 0.25);
}

.autopick-card:after {
content: 'Autopick';

display: inline-block;
position: absolute;

/* Center in the middle of the bottom border on the card. */
line-height: 25px;
bottom: 5px;
left: 0;
right: 0;

color: #fff;
font-family: Verdana, Arial, sans-serif;
font-size: 13px;
font-weight: 700;
text-align: center;
text-shadow: 0px 0px 2px #000;
}

.error {
color: red;
}
Expand Down
2 changes: 1 addition & 1 deletion src/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var games = {}
continue
for (var p of game.players)
if (p.time && !--p.time)
p.pickRand()
p.pickOnTimeout()
}
setTimeout(playerTimer, SECOND)
})()
Expand Down
18 changes: 14 additions & 4 deletions src/human.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = class extends EventEmitter {
name: sock.name,
time: 0,
packs: [],
autopick_index: -1,
pool: []
})
this.attach(sock)
Expand All @@ -19,6 +20,7 @@ module.exports = class extends EventEmitter {
this.sock.ws.close()

sock.mixin(this)
sock.on('autopick', this._autopick.bind(this))
sock.on('pick', this._pick.bind(this))
sock.on('hash', this._hash.bind(this))

Expand All @@ -34,6 +36,11 @@ module.exports = class extends EventEmitter {
this.hash = hash(deck)
this.emit('meta')
}
_autopick(index) {
var [pack] = this.packs
if (pack && index < pack.length)
this.autopick_index = index
}
_pick(index) {
var [pack] = this.packs
if (pack && index < pack.length)
Expand Down Expand Up @@ -65,17 +72,20 @@ module.exports = class extends EventEmitter {
else
this.sendPack(next)

this.autopick_index = -1
this.emit('pass', pack)
}
pickRand() {
var index = _.rand(this.packs[0].length)
pickOnTimeout() {
let index = this.autopick_index
if (index === -1)
index = _.rand(this.packs[0].length)
this.pick(index)
}
kick() {
this.send = ()=>{}
while(this.packs.length)
this.pickRand()
this.sendPack = this.pickRand
this.pickOnTimeout()
this.sendPack = this.pickOnTimeout
this.isBot = true
}
}
56 changes: 55 additions & 1 deletion src/make/cards.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,60 @@ function before() {
}

function after() {
var {ISD} = Sets
ISD.special = {
mythic: [
'garruk relentless'
],
rare: [
'bloodline keeper',
'daybreak ranger',
'instigator gang',
'kruin outlaw',
'ludevic\'s test subject',
'mayor of avabruck'
],
uncommon: [
'civilized scholar',
'cloistered youth',
'gatstaf shepherd',
'hanweir watchkeep',
'reckless waif',
'screeching bat',
'ulvenwald mystics'
],
common: [
'delver of secrets',
'grizzled outcasts',
'thraben sentry',
'tormented pariah',
'village ironsmith',
'villagers of estwald'
]
}
var {DKA} = Sets
DKA.special = {
mythic: [
'elbrus, the binding blade',
'huntmaster of the fells'
],
rare: [
'mondronen shaman',
'ravenous demon'
],
uncommon: [
'afflicted deserter',
'chalice of life',
'lambholt elder',
'soul seizer'
],
common: [
'chosen of markov',
'hinterland hermit',
'loyal cathar',
'scorned villager'
]
}
var {DGM} = Sets
DGM.mythic.splice(DGM.mythic.indexOf("maze's end"), 1)
DGM.special = {
Expand Down Expand Up @@ -167,7 +221,7 @@ function doCard(rawCard, cards, code, set) {

var {name} = rawCard
if (['double-faced', 'flip'].indexOf(rawCard.layout) > -1
&& name !== rawCard.names[0])
&& rawCard.number.indexOf('b') > -1)
return

if (rawCard.layout === 'split')
Expand Down
30 changes: 29 additions & 1 deletion src/pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ function toPack(code) {
_.choose(1, rare)
)

let specialrnd

switch (code) {
case 'DGM':
special = _.rand(20)
Expand All @@ -53,7 +55,33 @@ function toPack(code) {
special = _.rand(20)
? special.common
: special.fetch
break
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)
Expand Down