~pyhalebarde/pyhalebarde/theme_cleanup

« back to all changes in this revision

Viewing changes to halebarde/network.py

  • Committer: Olivier Le Thanh Duong
  • Date: 2009-06-07 16:21:15 UTC
  • mfrom: (173.1.54 refactoring)
  • Revision ID: olivier@lethanh.be-20090607162115-5pnfqsk3vs696opo
Merge with refactoring branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
from game import Board
2
2
from units import *
3
 
from globals import Global
 
3
import globals
4
4
 
5
5
import gobject
6
6
import dbus, dbus.service
69
69
    def get_unit(self, x, y):
70
70
        return self.game.get_unit(x, y)
71
71
 
72
 
    # We should probably do that client side since it get called a lot
73
 
    # and doesn't have any relation ship with the state of the game
74
 
    @dbus.service.method(dbus_interface=server_interface,
75
 
                            in_signature='ii',out_signature='b')
76
 
    def position_is_valid(self, x, y):
77
 
        return self.game.position_is_valid(x, y)
78
 
 
79
72
#CB
80
73
    def turn_ended_cb(self, game, turn, turn_number):
81
74
        logger.debug("Turn ended")
190
183
    def __init__(self, server):
191
184
        gobject.GObject.__init__(self) # Call the parent constructeur
192
185
        self.server = server
193
 
        self._create_board(Global.TOTAL_WIDTH, Global.TOTAL_HEIGH)
 
186
        self._create_board(globals.TOTAL_WIDTH, globals.TOTAL_HEIGHT)
194
187
        self.turn = ''
195
188
        self.id_unit = {}
196
189
 
210
203
        # This board serve as a cache so we don't have to make a network
211
204
        # round trip to know what is under the mouse.
212
205
 
213
 
        self.board = [Global.EMPTY] * width
 
206
        self.board = [globals.EMPTY] * width
214
207
        for  w in range(0, width): # we fill all the colon of the board
215
 
            self.board[w] = [Global.EMPTY] * height
 
208
            self.board[w] = [globals.EMPTY] * height
216
209
 
217
210
    def attack(self, to_x, to_y, from_x, from_y):
218
211
        self.server.attack(to_x, to_y, from_x, from_y, dbus_interface=server_interface)
239
232
        unit = self.board[x][y]
240
233
        return unit
241
234
 
242
 
    def position_is_valid(self, x, y):
243
 
        return self.server.position_is_valid(x, y, dbus_interface=server_interface)
244
 
 
245
235
#CB
246
236
    def TurnEnded(self, turn, turn_number):
247
237
        self.turn = turn