Skip to content

Commit

Permalink
Merge branch 'master' of github.com:azram19/trading-game
Browse files Browse the repository at this point in the history
  • Loading branch information
robert3005 committed Jun 19, 2012
2 parents a16bc4c + be3a851 commit edf2ffc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
17 changes: 6 additions & 11 deletions dev/client/Negotiator.coffee
Expand Up @@ -29,17 +29,12 @@ class Negotiator
console.log "[NEGOTIATOR]: FULL FULL CHANNEL": x1, y1
@ui.showTextBubble "Channel full", x1, y1, color: [159, 17, 27, 1]

@on 'owner:channel', (dest, src, ownerid) ->
console.log "OWNING SHIT"
#console.debug 'owner:channel', xy, dir, state.owner
field = (_.intersection dest, src)[0]
field2 = (_.difference dest, src)[0]
#console.log "NEG: field", field, dest, src
console.log "[NEG]: FIELD", field
@renderer.captureOwnership field.xy[0], field.xy[1], ownerid, 1
if not (field2.platform.type?)
console.log "[NEG]: FIELD2", field2
@renderer.captureOwnership field2.xy[0], field2.xy[1], ownerid, 2
@on 'owner:channel', (dest, src, ownerid, status) ->
field = (_.intersection dest, src)[0]
field2 = (_.difference dest, src)[0]
@renderer.captureOwnership field.xy[0], field.xy[1], ownerid, 1
if not (field2.platform.type?)
@renderer.captureOwnership field2.xy[0], field2.xy[1], ownerid, 2

@on 'owner:platform', (xy, ownerid) ->
#console.debug 'owner:platform', xy, state
Expand Down
10 changes: 5 additions & 5 deletions dev/client/renderer/Board.coffee
Expand Up @@ -265,11 +265,11 @@ class BoardDrawer extends Drawer
@ownership = @without @ownership, [x,y]
@setVisibility [x, y], false, ownerid
when 2
@owner[x][y].visibility = false
if ownerid is @myPlayer.id
@setVisibility [x, y], false, ownerid
else
@ownership = @without @ownership, point
@owner[x][y] = null
@updateAll()

changeOwnership: (x, y, ownerid) ->
Expand Down Expand Up @@ -574,7 +574,7 @@ class SignalsDrawer extends Drawer
@stage.update()

tick: () ->
###

for signal in @stage.children
if signal.isSignal and signal.isVisible
signal.visible = true
Expand All @@ -584,7 +584,7 @@ class SignalsDrawer extends Drawer
signal.x += signal.tickSizeX
signal.y += signal.tickSizeY
signal.k += 1
###

@fpsLabel.text = Math.round(Ticker.getMeasuredFPS())+" fps"
@stage.update()

Expand Down Expand Up @@ -681,8 +681,8 @@ class Renderer

# moves signal from field (x,y) in particular direction
moveSignal: (x, y, direction) ->
#@signalsDR.createSignal(x, y, direction)
@signalsDR.drawWorker(x, y, direction)
@signalsDR.createSignal(x, y, direction)
#@signalsDR.drawWorker(x, y, direction)

# builds a channel at field (x,y) in given direction
buildChannel: (x, y, direction, channel) ->
Expand Down
5 changes: 4 additions & 1 deletion dev/common/behaviours/ChannelBehaviour.coffee
Expand Up @@ -49,7 +49,10 @@ class ChannelBehaviour
state.owner = signal.owner
state.life = S.Properties.channel.life
#console.log "[ChannelBehaviour]: source", signal.source
@eventBus.trigger 'owner:channel', state.fields, signal.source.fields, signal.owner.id
if signal.source.type is S.Types.Entities.Channel
@eventBus.trigger 'owner:channel', state.fields, signal.source.fields, signal.owner.id
else
@eventBus.trigger 'owner:channel', state.fields, [signal.source.field], signal.owner.id

route: ( state, ownObject ) ->
signal = ownObject.state.signals.shift()
Expand Down
2 changes: 1 addition & 1 deletion dev/common/behaviours/PlatformBehaviour.coffee
Expand Up @@ -39,7 +39,7 @@ class PlatformBehaviour

accept: ( signal, state, callback, ownObject ) ->
callback signal
if signal.owner?.id is state.owner.id or S.Types.Resources.Gold <= signal.type <= S.Types.Resources.Food
if signal.owner?.id is state.owner.id
addSignal = (signal) =>
ownObject.state.signals.push signal
ownObject.trigger 'route'
Expand Down

0 comments on commit edf2ffc

Please sign in to comment.