Skip to content
This repository has been archived by the owner on Aug 4, 2018. It is now read-only.

Commit

Permalink
time
Browse files Browse the repository at this point in the history
  • Loading branch information
aeosynth committed May 1, 2013
1 parent c7233f7 commit 9727cce
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 7 deletions.
2 changes: 1 addition & 1 deletion public/partials/q.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
</div>
<table>
<tr><th>#</th><th>name</th><th>time</th><th>packs</th><th>cockatrice</th><th>mws</th></tr>
<tr ng-repeat="player in players" ng-class="{ self: self == $index }">
<tr ng-repeat="player in players" ng-class="{ self: self == $index, dropped: player.dropped }">
<td>{{ $index + 1 }}</td>
<td ng-switch on="player.edit" ng-click="editName(player, $index)">
<form ng-submit="name(player)" ng-switch-when="true">
Expand Down
17 changes: 15 additions & 2 deletions src/draft.co
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Copy link
@vendethiel

vendethiel May 1, 2013

for id, {players} in drafts

This comment has been minimized.

Copy link
@aeosynth

aeosynth May 2, 2013

Author Owner

less characters as is

for p of d.players
if p.time and !--p.time
p.autopick!
setTimeout decrement, 1e3

class Draft extends EventEmitter
(opts) ->
@ <<<< opts
Expand Down Expand Up @@ -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.

Copy link
@vendethiel

vendethiel May 1, 2013

p{dropped, hash, name, time, packs: fuck}

This comment has been minimized.

Copy link
@aeosynth

aeosynth May 1, 2013

Author Owner

yeah that's really annoying

This comment has been minimized.

Copy link
@vendethiel

vendethiel May 2, 2013

actually
p{ dropped, hash, name, time } <<< packs: p.packs.length
vs
{ p.dropped, p.hash, p.name, p.time, packs: p.packs.length }

This comment has been minimized.

Copy link
@aeosynth

aeosynth May 2, 2013

Author Owner

any chance we could get the intuitive behavior?

This comment has been minimized.

Copy link
@aeosynth

aeosynth May 2, 2013

Author Owner

i'm leaving as is b/c of the (minor) runtime hit for not much benefit

This comment has been minimized.

Copy link
@vendethiel

vendethiel May 2, 2013

any chance we could get the intuitive behavior?

what about YOU ask satyr

This comment has been minimized.

Copy link
@aeosynth

aeosynth May 2, 2013

Author Owner
for p, i of @players
p.send \set { players, self: i }

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
17 changes: 15 additions & 2 deletions src/human.co
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand All @@ -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.

Copy link
@vendethiel

vendethiel May 1, 2013

unless

This comment has been minimized.

Copy link
@aeosynth

aeosynth May 2, 2013

Author Owner

if ! feels different from unless

This comment has been minimized.

Copy link
@vendethiel

vendethiel May 2, 2013

hardly for me but w/e

@time = 0

@send \add @main[* - 1]

module.exports = Human
7 changes: 5 additions & 2 deletions src/player.co
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ class Player extends EventEmitter
@pick index, true

pick: (index, autopick) ->
pack = @packs.shift!
[pick] = pack.splice index, 1
return unless pack = @packs.shift!
return unless pick = pack.splice index, 1 .0

@main.push pick
@round.push { pick.name, autopick }

Expand All @@ -34,4 +35,6 @@ class Player extends EventEmitter

@emit \pass pack, @index

true

module.exports = Player

0 comments on commit 9727cce

Please sign in to comment.