Skip to content

Commit

Permalink
phaser input
Browse files Browse the repository at this point in the history
  • Loading branch information
mailgyc-163 committed Jul 6, 2017
1 parent 32d0299 commit 6ea3568
Show file tree
Hide file tree
Showing 8 changed files with 761 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,4 @@ docs/_build/

# PyBuilder
target/
.vs
5 changes: 5 additions & 0 deletions src/core/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ def calc_coin(self, winner):
coins.append(-coin - tax)
return coins

def handle_chat(self, player, msg):
response = [Pt.RSP_CHAT, player.uid, msg]
for p in self.players:
p.send(response)

def add(self, player):
for i, p in enumerate(self.players):
if not p:
Expand Down
3 changes: 3 additions & 0 deletions src/net/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ class Protocol(IntEnum):

REQ_GAME_OVER = 41
RSP_GAME_OVER = 42

REQ_CHAT = 43
RSP_CHAT = 44
6 changes: 6 additions & 0 deletions src/net/socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ def on_message(self, message):

elif code == Pt.REQ_SHOT_POKER:
self.handle_shot_poker(packet)
elif code == Pt.REQ_CHAT:
self.handle_chat(packet)
else:
logger.info('UNKNOWN PACKET: %s', code)

Expand All @@ -110,6 +112,10 @@ def find_table(self, table_id):
return self.room.first_waiting_table()
return self.room.find_waiting_table(table_id)

def handle_chat(self, packet):
if self.player and self.player.table:
self.player.table.handle_chat(self.player, packet[1])

def write_message(self, message, binary=False):
if self.ws_connection is None:
raise WebSocketClosedError()
Expand Down
15 changes: 15 additions & 0 deletions src/static/js/boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,21 @@ PG.MainMenu.prototype = {
var setting = this.add.button(this.world.width/2, this.world.height * 3/4, 'btn', this.gotoSetting, this, 'setting.png', 'setting.png', 'setting.png');
setting.anchor.set(0.5);
this.world.add(setting);

this.game.add.plugin(PhaserInput.Plugin);
var input = this.add.inputField(100, 90, {
font: '18px Arial',
fill: '#ff0000',
fontWeight: 'bold',
width: 150,
padding: 8,
borderWidth: 1,
borderColor: '#000',
borderRadius: 6,
placeHolder: 'Password',
type: PhaserInput.InputType.password
});
input.setText("My custom text");
},

startGame: function () {
Expand Down
Loading

0 comments on commit 6ea3568

Please sign in to comment.