commit a1cf96d596c83bde6ee526b47a59eb36afc49762 Author: Flummi Date: Fri Aug 3 23:19:49 2018 +0200 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..25c8fdb --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules +package-lock.json \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..301cbaf --- /dev/null +++ b/package.json @@ -0,0 +1,15 @@ +{ + "name": "skipbo", + "version": "1.0.0", + "description": "", + "main": "index.mjs", + "scripts": { + "start": "node --experimental-modules src" + }, + "author": "Flummi", + "license": "ISC", + "dependencies": { + "express": "^4.16.3", + "socket.io": "^2.1.1" + } +} diff --git a/src/cfg.mjs b/src/cfg.mjs new file mode 100644 index 0000000..91b5e57 --- /dev/null +++ b/src/cfg.mjs @@ -0,0 +1,7 @@ +export default { + iters: { + hand: 5 + , pile: 4 + , stock: 30 + } +}; \ No newline at end of file diff --git a/src/index.mjs b/src/index.mjs new file mode 100644 index 0000000..fcd9405 --- /dev/null +++ b/src/index.mjs @@ -0,0 +1,48 @@ +import cfg from "./cfg"; +import express from "express"; +import http from "http"; +import sio from "socket.io"; +import path from "path"; + +let deck = [ + ...[...Array(12)].map((_, i) => new Array(12).fill(++i)).reduce((a,b)=>[...b,...a]) + , ...[...Array(18).fill(13)] +].map(a => [Math.random(), a]).sort((a, b) => a[0] - b[0]).map(a => a[1]); +const player = new Map(); +function cards() { + this.hand = []; + this.pile = Array(cfg.iters.pile); + this.stock = []; +} + +//player.set("Spieler 1", new cards); +//player.set("Spieler 2", new cards); + +const fillHand = _player => { + _player = player.get(_player); + _player.hand.push(...deck.splice(0, cfg.iters.hand - _player.hand.length)); + _player.hand.sort((a,b)=>a>b); +}; +const begin = () => { + player.forEach((cards, _player) => { + fillHand(_player); + //cards.stock.push(...deck.splice(0, cfg.iters.stock - cards.stock.length)); + }); +}; +begin(); + +const app = express(); +const server = http.Server(app); +const io = sio(server); + +server.listen(8080); + +app + .use(express.static(path.resolve("src", "static"))) + +io.on("connection", socket => { + socket.on("player", data => { + console.log(data); + }); + +}); \ No newline at end of file diff --git a/src/static/index.html b/src/static/index.html new file mode 100644 index 0000000..178e4ec --- /dev/null +++ b/src/static/index.html @@ -0,0 +1,124 @@ + + + + + + +
+
+
+
Spieler 2
+
+
+
+
+
1
+
+
+
+
1
+
1
+
+
+
+
+
+
+
+
2
+
+
+
+
2
+
2
+
+
+
+
+
+
+
+
3
+
+
+
+
3
+
3
+
+
+
+
+
+
+
+
4
+
+
+
+
4
+
4
+
+
+
+
+
+
+
+
+
Spieler 3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
4
+
+
+
+
4
+
4
+
+
+
+
+
+
+
+
+
+
+
Spieler 1
+
+
+
+
+
+
4
+
+
+
+
4
+
4
+
+
+
+
+
+
+
+
+
+
+ + + + \ No newline at end of file diff --git a/src/static/main.js b/src/static/main.js new file mode 100644 index 0000000..2711e0b --- /dev/null +++ b/src/static/main.js @@ -0,0 +1 @@ +const socket = io(); diff --git a/src/static/test.css b/src/static/test.css new file mode 100644 index 0000000..dcabaad --- /dev/null +++ b/src/static/test.css @@ -0,0 +1,141 @@ +* { + margin: 0; + padding: 0; + overflow: hidden; + position: relative; + background-color: rgb(18, 153, 0); +} + +#spielfeld { + display: grid; + grid-template-rows: 1fr auto 1fr; + grid-template-columns: 1fr; + grid-row-gap: 40px; + height: 100%; +} + +#player { + width: 98%; + height: 200px; + margin: auto; + display: grid; + grid-column-gap: 5px; + grid-template-columns: repeat(2, 1fr); +} + +.player { + box-sizing: border-box; + border-style: none solid solid solid; + border-bottom-left-radius: 10px; + border-bottom-right-radius: 10px; +} +#player1 { + width: 95%; + margin: auto; + border-top-left-radius: 10px; + border-top-right-radius: 10px; + border-bottom-left-radius: 0 !important; + border-bottom-right-radius: 0 !important; + border-style: solid solid none solid; +} +.playername { + text-align: center; + font-weight: bold; +} + +.pile { + width: 95%; + margin: auto; + height: 160px; + display: grid; + grid-template-columns: 2fr repeat(4, 1fr); + grid-column-gap: 2px; +} +.pileslot { + width: 110px; + border: 1px solid #000; + background-color: #fff !important; + border-radius: 10px; +} + +.pileslot:nth-child(0) { + border: 0; +} + +#mainstock_pile { + width: 500px; + height: 200px; + display: grid; + margin: auto; + grid-template-columns: repeat(4, 1fr); +} +.mainstock_pile { + width: 110px; + height: 160px; + border: 1px solid #000; + background-color: #fff; + border-radius: 10px; +} + +.card_outer { + position: relative; + height: 100%; + width: 100%; + background-color: #fff; +} +.card_number { + position: absolute; + font-size: 20pt; + font-weight: bold; + background-color: #fff; +} +.card_number1 { + left: 10px; + top: 10px; +} +.card_number2 { + right: 10px; + bottom: 10px; +} +.card_border, .card_tri1_outer, .card_tri2_outer { + position: absolute; +} +.card_border { + width: 0; + height: 0; +} +.card_tri1_outer { + right: 5px; + top: 5px; + height: 50px; + width: 50px; + border-top-right-radius: 10px; +} +.card_tri2_outer { + left: 5px; + bottom: 5px; + height: 50px; + width: 50px; + border-bottom-left-radius: 10px; +} +.card_tri1 { + right: 0; + top: 0; + border-left: 50px solid #fff; + border-top: 50px solid rgb(62, 0, 207); +} +.card_tri2 { + left: 0; + bottom: 0; + border-bottom: 50px solid rgb(62, 0, 207); + border-right: 50px solid #fff; +} +.card_middlenumber { + position: absolute; + background-color: #fff; + font-size: 27pt; + font-weight: bold; + top: 50%; + left: 50%; + transform: translate(-50%,-50%); +} \ No newline at end of file