-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,15 @@ _ = require \./_ | |
genCube = require \./generate/cube | ||
genPack = require \./generate/pack | ||
|
||
drafts = {} | ||
|
||
do decrement = -> | ||
for id, d in drafts | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
for p of d.players | ||
if p.time and !--p.time | ||
p.autopick! | ||
setTimeout decrement, 1e3 | ||
|
||
class Draft extends EventEmitter | ||
(opts) -> | ||
@ <<<< opts | ||
|
@@ -71,7 +80,7 @@ class Draft extends EventEmitter | |
meta: !-> | ||
# TODO only send time + packs | ||
players = for p of @players | ||
{ p.hash, p.name, p.time, packs: p.packs.length } | ||
{ p.dropped, p.hash, p.name, p.time, packs: p.packs.length } | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
vendethiel
|
||
for p, i of @players | ||
p.send \set { players, self: i } | ||
|
||
|
@@ -85,6 +94,8 @@ class Draft extends EventEmitter | |
p.send \set { main, @round } | ||
return | ||
|
||
drafts[@id] = @ | ||
|
||
if @addBots | ||
while @players.length < @seats | ||
@add new Bot | ||
|
@@ -123,12 +134,14 @@ class Draft extends EventEmitter | |
else if !--@activePacks | ||
@startRound! | ||
|
||
# TODO ignore bot passes | ||
# TODO ignore bot, dropped passes | ||
@meta! | ||
|
||
end: -> | ||
console.log \end @id | ||
|
||
delete drafts[@id] | ||
|
||
data = @{ sets, start: startTime } | ||
data.end = Date.now! / 1e3 | 0 | ||
data.players = for p of @players | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ class Human extends Player | |
@ <<<< sock{ name, id } | ||
@attach sock | ||
|
||
dropped: false | ||
|
||
attach: (sock) -> | ||
# TODO auto reconnect, d/c notice | ||
@sock.removeAllListeners! | ||
|
@@ -29,13 +31,24 @@ class Human extends Player | |
sendPack: -> | ||
pack = @packs.0 | ||
|
||
if pack.length is 1 | ||
@time = pack.length * 5 | ||
|
||
if @dropped or pack.length is 1 | ||
process.nextTick ~> @pick 0 true | ||
else | ||
@send \set { pack } | ||
|
||
autopick: -> | ||
super! | ||
@dropped = true | ||
@send \set pack: [] | ||
|
||
pick: (index) -> | ||
super index | ||
return unless super index | ||
|
||
if [email protected] | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
@time = 0 | ||
|
||
@send \add @main[* - 1] | ||
|
||
module.exports = Human |
for id, {players} in drafts