Merge pull request #1 from viastolfi/deployement
continuous-integration/drone/push Build is passing Details

Deployement
deployement
Vincent ASTOLFI 1 year ago committed by GitHub
commit 31fb6525d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,30 @@
kind: pipeline
type: docker
name: maettleship
trigger:
event:
- push
steps:
- name: maettleship-build
image: plugins/docker
settings:
dockerfile: Dockerfile
context: .
registry: hub.codefirst.iut.uca.fr
repo: hub.codefirst.iut.uca.fr/vincent.astolfi/maettleship
username:
from_secret: registry-username
password:
from_secret: registry-password
- name: maettleship-deployment
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
environment:
IMAGENAME: hub.codefirst.iut.uca.fr/vincent.astolfi/maettleship:latest
CONTAINERNAME: maettleship
COMMAND: create
OVERWRITE: true
ADMINS: vincentastolfi
depends_on: [maettleship-build]

@ -0,0 +1,7 @@
FROM node:10
WORKDIR /usr/src/app
COPY ./ ./
RUN sed -i '1i\<base href="https://codefirst.iut.uca.fr/containers/vincentastolfi-maettleship">' ./public/index.html
RUN npm install
EXPOSE 8081
CMD [ "npm", "run", "dev" ]

@ -1,5 +1,3 @@
const { io } = require(`${__dirname}/index.js`);
class Game { class Game {
constructor(room) { constructor(room) {
this.room = room; this.room = room;

@ -1,7 +1,7 @@
const { io } = require(`${__dirname}/index.js`);
const { Player } = require(`${__dirname}/businesses/Player.js`); const { Player } = require(`${__dirname}/businesses/Player.js`);
const { Room } = require(`${__dirname}/businesses/Room.js`); const { Room } = require(`${__dirname}/businesses/Room.js`);
const { Game } = require(`${__dirname}/game.js`); const { Game } = require(`${__dirname}/game.js`);
const { io } = require(`${__dirname}/index.js`);
let room; let room;
let game; let game;

@ -4,6 +4,12 @@ const http = require("http").createServer(app);
const path = require("path"); const path = require("path");
const port = 8081; const port = 8081;
const io = require("socket.io")(http); const io = require("socket.io")(http);
const { Player } = require(`${__dirname}/businesses/Player.js`);
const { Room } = require(`${__dirname}/businesses/Room.js`);
const { Game } = require(`${__dirname}/game.js`);
let room;
let game;
app.use(express.static("public")); app.use(express.static("public"));
@ -15,6 +21,36 @@ app.get("/", (req, res) => {
res.sendFile(path.join(__dirname, "/public/index.html")); res.sendFile(path.join(__dirname, "/public/index.html"));
}); });
io.on("connection", (socket) => {
socket.on("Hello", (callback) => {
callback({
Hello: "World",
});
});
socket.on("room creation", (socketId) => {
let player = new Player(socketId);
player.grid.cases[2][2].isShip = true;
player.grid.cases[3][2].isShip = true;
room = new Room();
room.addPlayer(player);
});
socket.on("ask for room", (socketId) => {
if (room.players.length === 1) {
let player = new Player(socketId);
player.grid.cases[2][2].isShip = true;
room.addPlayer(player);
game = new Game(room);
game.start();
}
});
socket.on("play", (move) => {
game.move(move);
});
});
module.exports = { module.exports = {
io, io,
}; };

@ -42,7 +42,7 @@
<h2 class="hidden-element" id="win_notification">WIN !</h2> <h2 class="hidden-element" id="win_notification">WIN !</h2>
<script src="/socket.io/socket.io.js"></script> <script src="/socket.io/socket.io.js"></script>
<script type="module" src="scripts/game.js"></script> <script type="module" src="./scripts/game.js"></script>
<script type="module" src="scripts/index.js"></script> <script type="module" src="./scripts/index.js"></script>
</body> </body>
</html> </html>

Loading…
Cancel
Save