Skip to content

Commit 4f330ef

Browse files
author
Batiste Bieler
committed
Fix npc to work with public/private key
1 parent 980ab81 commit 4f330ef

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

chat/views.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,21 @@ def __init__(self, room_id):
3333
for v in range(0, 9):
3434
self.event_buffer.append(None)
3535
npc = Player(name='Wise man')
36-
self.players.append(npc)
36+
self.npc = npc
37+
self.players.append(self.npc)
3738
self.new_room_event(['new_player', npc.pub()])
3839

3940
def move_pnj(self):
40-
npc = self.get_player('old')
41+
npc = self.npc
4142
if npc:
42-
pos = [npc['position'][0], npc['position'][1]]
43+
pos = [npc.position[0], npc.position[1]]
4344
pos[0] += random.randint(-50, 50)
4445
pos[1] += random.randint(-50, 50)
4546
safe = self.room_map.is_safe_position(pos)
4647
if safe:
47-
npc['position'] = pos
48+
npc.position = pos
4849
self.new_room_event(['update_player_position',
49-
['old', npc['position']]])
50+
[npc.public_key, npc.position]])
5051
spawn_later(5, self.move_pnj)
5152

5253
def main(self, request):

0 commit comments

Comments
 (0)