summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Seguin <guillaume@segu.in>2009-11-23 23:23:00 +0100
committerGuillaume Seguin <guillaume@segu.in>2009-11-23 23:23:00 +0100
commite2b9feaf8149ae3052daa398d25435db30285b6f (patch)
tree5b456dedbb40520516a65547a0e29e35354e06d0
parentc164658ee789b29583d4651d93627720abfe3609 (diff)
downloadnetnavalbattle-e2b9feaf8149ae3052daa398d25435db30285b6f.tar.gz
netnavalbattle-e2b9feaf8149ae3052daa398d25435db30285b6f.tar.bz2
Fix number of args for fire/sink notifications
-rw-r--r--netnavalbattle/context.py9
-rw-r--r--netnavalbattle/event.py17
2 files changed, 17 insertions, 9 deletions
diff --git a/netnavalbattle/context.py b/netnavalbattle/context.py
index 7534509..d825503 100644
--- a/netnavalbattle/context.py
+++ b/netnavalbattle/context.py
@@ -610,16 +610,19 @@ class NetNavalBattleServerContext (object):
return
self._connection.send_event (self, ev = event.FireOkEvent ())
if result in (constants.HIT, constants.SINK):
- ev = event.FireNotificationEvent (target, x, y, "hit")
+ ev = event.FireNotificationEvent (self.username,
+ target, x, y, "hit")
self._game.events_log.append (ev)
self.broadcast (ev)
else:
- ev = event.FireNotificationEvent (target, x, y, "missed")
+ ev = event.FireNotificationEvent (self.username,
+ target, x, y, "missed")
self._game.events_log.append (ev)
self.broadcast (ev)
if result == constants.SINK:
ship = board.get_ship_at (x, y)
- ev = event.SinkNotificationEvent (target, ship.id,
+ ev = event.SinkNotificationEvent (self.username,
+ target, ship.id,
ship.i, ship.j, ship.rotated)
self._game.events_log.append (ev)
self.broadcast (ev)
diff --git a/netnavalbattle/event.py b/netnavalbattle/event.py
index 1aba552..6daaa56 100644
--- a/netnavalbattle/event.py
+++ b/netnavalbattle/event.py
@@ -516,12 +516,14 @@ class ServerNotificationEvent (Event):
class FireNotificationEvent (Event):
+ source = None
target = None
x = None
y = None
result = None
- def __init__ (self, target, x, y, result):
+ def __init__ (self, source, target, x, y, result):
+ self.source = source
self.target = target
self.x = x
self.y = y
@@ -531,21 +533,23 @@ class FireNotificationEvent (Event):
context.fire_notification (self.target, self.x, self.y, self.result)
def get_args (self):
- return [self.target, self.x, self.y, self.result]
+ return [self.source, self.target, self.x, self.y, self.result]
@staticmethod
def describe_args ():
- return ["base64-string", "int", "int", "string"]
+ return ["base64-string", "base64-string", "int", "int", "string"]
class SinkNotificationEvent (Event):
+ source = None
target = None
ship_type = None
x = None
y = None
rotated = None
- def __init__ (self, target, ship_type, x, y, rotated):
+ def __init__ (self, source, target, ship_type, x, y, rotated):
+ self.source = source
self.target = target
self.ship_type = ship_type
self.x = x
@@ -559,11 +563,12 @@ class SinkNotificationEvent (Event):
self.rotated)
def get_args (self):
- return [self.target, self.ship_type, self.x, self.y, self.rotated]
+ return [self.source, self.target,
+ self.ship_type, self.x, self.y, self.rotated]
@staticmethod
def describe_args ():
- return ["base64-string", "string", "int", "int", "bool"]
+ return ["base64-string", "base64-string", "string", "int", "int", "bool"]
class LostNotificationEvent (Event):