update
This commit is contained in:
parent
73958b9252
commit
d3aed9e5a5
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,4 +1,3 @@
|
||||
node_modules
|
||||
npm-debug.log*
|
||||
log.txt
|
||||
node_modules/
|
||||
package-lock.json
|
||||
paper-io.log
|
||||
|
18
README.md
18
README.md
@ -20,13 +20,9 @@ After cloning this repository, run the follow commands to install dependencies a
|
||||
npm start
|
||||
```
|
||||
|
||||
You can configure the game by editing `config.json`. WARNING: DO NOT EDIT THE `consts` SETTINGS UNLESS YOU KNOW WHAT YOU ARE DOING.
|
||||
You can configure the game by editing `config.json`.
|
||||
|
||||
## Bots
|
||||
|
||||
```bash
|
||||
node src/paper-io-bot.js ws://localhost:8081
|
||||
```
|
||||
**WARNING: DO NOT EDIT THE `consts` SETTINGS UNLESS YOU KNOW WHAT YOU ARE DOING.**
|
||||
|
||||
## Build
|
||||
|
||||
@ -35,8 +31,18 @@ sudo npm install -g browserify uglify-es
|
||||
browserify client.js | uglifyjs > public/bundle.js
|
||||
```
|
||||
|
||||
**WARNING: REMEMBER TO BUILD AGAIN AFTER EDITING ANY FILE.**
|
||||
|
||||
## Bots
|
||||
|
||||
```bash
|
||||
node paper-io-bot.js ws://localhost:8081
|
||||
```
|
||||
|
||||
## Roadmap & TODO List
|
||||
|
||||
- [x] 统一配置文件
|
||||
- [ ] 更多游戏模式
|
||||
- [ ] 多个游戏房间
|
||||
- [ ] 加快渲染速度
|
||||
- [ ] 优化胜负判定
|
||||
|
@ -7,9 +7,9 @@ if (process.argv.length < 3) {
|
||||
//TODO: add weight to the max land area and last land area, and also the number of kills
|
||||
//TODO: genetic gene pooling
|
||||
|
||||
var core = require("./core");
|
||||
var client = require("./game-client");
|
||||
var consts = require("../config.json").consts;
|
||||
var core = require("./src/core");
|
||||
var client = require("./src/game-client");
|
||||
var consts = require("./config.json").consts;
|
||||
|
||||
var MOVES = [[-1, 0], [0, 1], [1, 0], [0, -1]];
|
||||
|
||||
@ -99,7 +99,10 @@ function foundProto(func) {
|
||||
}
|
||||
|
||||
function connect() {
|
||||
client.connectGame(process.argv[2], process.argv[3] || "[BOT]", function(success, msg) {
|
||||
var prefixes = consts.PREFIXES.split(" ");
|
||||
var names = consts.NAMES.split(" ");
|
||||
var name = process.argv[3] || ["[BOT]", prefixes[Math.floor(Math.random() * prefixes.length)], names[Math.floor(Math.random() * names.length)]].join(" ");
|
||||
client.connectGame(process.argv[2], name, function(success, msg) {
|
||||
if (!success) setTimeout(connect, 1000);
|
||||
});
|
||||
}
|
@ -3,9 +3,9 @@ if (process.argv.length < 3) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
var core = require("./core");
|
||||
var client = require("./game-client");
|
||||
var consts = require("../config.json").consts;
|
||||
var core = require("./src/core");
|
||||
var client = require("./src/game-client");
|
||||
var consts = require("./config.json").consts;
|
||||
|
||||
var MOVES = [[-1, 0], [0, 1], [1, 0], [0, -1]];
|
||||
|
||||
@ -24,7 +24,10 @@ function mod(x) {
|
||||
}
|
||||
|
||||
function connect() {
|
||||
client.connectGame(process.argv[2], process.argv[3] || "[BOT]", function(success, msg) {
|
||||
var prefixes = consts.PREFIXES.split(" ");
|
||||
var names = consts.NAMES.split(" ");
|
||||
var name = process.argv[3] || ["[BOT]", prefixes[Math.floor(Math.random() * prefixes.length)], names[Math.floor(Math.random() * names.length)]].join(" ");
|
||||
client.connectGame(process.argv[2], name, function(success, msg) {
|
||||
if (!success) setTimeout(connect, 1000);
|
||||
});
|
||||
}
|
File diff suppressed because one or more lines are too long
1
public/static/wasted.svg
Normal file
1
public/static/wasted.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 18 KiB |
@ -1,6 +1,4 @@
|
||||
const fs = require("fs"),
|
||||
path = require("path");
|
||||
var config = require(path.join(__dirname, "config.json"));
|
||||
var config = require("./config.json");
|
||||
|
||||
if (!(config.http_port >= 0 && config.http_port < 65536 && config.http_port % 1 === 0)) {
|
||||
console.error("[ERROR] http_port argument must be an integer >= 0 and < 65536.");
|
||||
@ -43,7 +41,7 @@ io.on("connection", function(socket) {
|
||||
socket.on("hello", function(data, fn) {
|
||||
//TODO: error checking.
|
||||
if (data.name && data.name.length > 32) fn(false, "Your name is too long!");
|
||||
else if (!game.addPlayer(socket, data.name)) fn(false, "Game is too full!");
|
||||
else if (!game.addPlayer(socket, data.name)) fn(false, "There're too many platers!");
|
||||
else fn(true);
|
||||
});
|
||||
socket.on("pings", function(fn) {
|
||||
|
@ -295,7 +295,7 @@ function Player(grid, sdata) {
|
||||
|
||||
//Parameters
|
||||
data.num = sdata.num;
|
||||
data.name = sdata.name || ""; //|| "Player " + (data.num + 1);
|
||||
data.name = sdata.name || "Player " + (data.num + 1);
|
||||
data.grid = grid;
|
||||
data.posX = sdata.posX;
|
||||
data.posY = sdata.posY;
|
||||
|
@ -255,7 +255,7 @@ function setUser(player) {
|
||||
|
||||
function update() {
|
||||
var dead = [];
|
||||
core.updateFrame(grid, players, dead, function addKill(killer, other) {
|
||||
core.updateFrame(grid, players, dead, function(killer, other) { //addKill
|
||||
if (players[killer] === user && killer !== other) kills++;
|
||||
});
|
||||
dead.forEach(function(val) {
|
||||
|
Loading…
Reference in New Issue
Block a user