forked from mle-moni/ft_transcendence
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
152 changed files
with
623 additions
and
52 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
5 changes: 1 addition & 4 deletions
5
app/assets/javascripts/templates/game/game.hbs
100644 → 100755
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
<h1>Game</h1> | ||
|
||
<canvas style="background-color: antiquewhite;" width="300" height="300" id="{{canvasID}}"> | ||
Your web browser is probably almost older than me, time to update ? | ||
</canvas> | ||
<div id="game_page_id"></div> | ||
|
||
<br> | ||
<a href="#">Home</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<p>You are on the game page nb : {{ room_id }}</p> | ||
<div id="in_game_id" data-id="{{ room_id }}"></div> | ||
<style> | ||
* { | ||
padding: 0; | ||
margin: 0; | ||
} | ||
canvas { | ||
background: #013333; | ||
display: block; | ||
margin: 0 auto; | ||
} | ||
</style> | ||
<canvas id="myCanvas" width="800" height="600"></canvas> | ||
|
||
<div class="btn"></div> |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
AppClasses.Views.GamePlay = class extends Backbone.View { | ||
constructor(opts) { | ||
super(opts); | ||
this.tagName = "div"; | ||
this.template = App.templates["game/show"]; | ||
} | ||
updateRender(room_id) { | ||
this.$el.html(this.template({ | ||
room_id | ||
})); | ||
|
||
return (this); | ||
} | ||
render(room_id) { | ||
this.updateRender(room_id); // generates HTML | ||
// the game has to be started in the router | ||
return (this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
@import "bootstrap/scss/bootstrap"; |
Empty file.
Empty file.
Empty file.
Empty file.
15 changes: 15 additions & 0 deletions
15
app/channels/application_cable/connection.rb
100644 → 100755
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,19 @@ | ||
module ApplicationCable | ||
class Connection < ActionCable::Connection::Base | ||
identified_by :current_user | ||
|
||
def connect | ||
self.current_user = find_verified_user.email | ||
end | ||
|
||
protected | ||
|
||
def find_verified_user | ||
if verified_user = env['warden'].user | ||
verified_user | ||
else | ||
reject_unauthorized_connection | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class GameChannel < ApplicationCable::Channel | ||
def subscribed | ||
stream_from "player_#{ current_user }" | ||
Matchmaking.create(current_user) | ||
end | ||
|
||
def unsubscribed | ||
if Redis.current.get('matches') == current_user | ||
Redis.current.set('matches', nil) | ||
end | ||
# Any cleanup needed when channel is unsubscribed | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class PlayChannel < ApplicationCable::Channel | ||
def subscribed | ||
stream_from "play_channel_#{params[:game_room_id]}" | ||
end | ||
|
||
def unsubscribed | ||
# Any cleanup needed when channel is unsubscribed | ||
end | ||
|
||
def take_turn(data) | ||
last = Redis.current.get("play_channel_#{data['room_id']}_#{data['player']}"); | ||
return unless last.blank? || last == 'w' || data['input'] == 'quit' | ||
return if !last.blank? && last == 'quit' | ||
|
||
Redis.current.set("play_channel_#{data['room_id']}_#{data['player']}", data['input']) | ||
end | ||
|
||
def start_game(data) | ||
return unless Redis.current.get("#{data['room_id']}_has_start").blank? | ||
|
||
Redis.current.set("#{data['room_id']}_has_start", 'ok') | ||
Game.start_game("play_channel_#{data['room_id']}") | ||
end | ||
end |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Oops, something went wrong.