Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,51 @@
/bwo-server/node_modules
/bwo-server/resources/data/tmp/
/bwo-server/resources/data/service-account-file.json
/.vscode
/.vscode
.DS_Store


# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
17 changes: 13 additions & 4 deletions bwo-server/core/core_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ import moment from 'moment';
import express from 'express'
import http from 'http'
import game_server from "./game.js"
import socketio from 'socket.io'
import { Server } from "socket.io";

import { loadLog, saveLog } from '../resources/data/state_manager.js'

export default function startServer(config) {
const app = express()
const server = http.createServer(app)
const sockets = socketio(server)
const sockets = new Server(server, {
cors: {
origin: "*",
},
});

const game = game_server();

Expand All @@ -21,7 +26,10 @@ export default function startServer(config) {

sockets.on('connection', (socket) => {
const playerId = socket.id;
//console.log(`Player on lobby: ${playerId}`)
console.log(`Player on lobby: ${playerId}`)
// sockets.to(playerId).emit('onSetup', playerId)
// console.log(`Player on lobby2: ${playerId}`)

game.addSocket(socket)

var lastMoveUpdateTime = moment().format();
Expand Down Expand Up @@ -136,6 +144,7 @@ export default function startServer(config) {
})

//app.use(express.static('public'))
app.use(express.json());

app.get('/', (request, response) => {
saveLog('server-info', `Requested ./ from web.`);
Expand Down Expand Up @@ -165,7 +174,7 @@ export default function startServer(config) {
return response.send(isEmpty);
})

server.listen(config.port, () => {
server.listen(config.port, "0.0.0.0",() => {
saveLog('server-status', 'server started successfully');
console.log(`Server running on port: ${config.port} in [${config.environment}] mode.`)
})
Expand Down
5 changes: 3 additions & 2 deletions bwo-server/core/entity/enemy/enemys.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,13 @@ export function simulateMove(state, callback) {

function isInsideFoundation(state, player) {
var isInside = false;
if (state.foundations == null) return false;
Object.entries(state.foundations).forEach(foundation => {
//console.log(foundation[1].walls)
var pX = player.x / 16;
var pY = player.y / 16;
if (pX >= foundation[1].x-1 && pX <= foundation[1].x + foundation[1].w+1 &&
pY >= foundation[1].y-1 && pY <= foundation[1].y + foundation[1].h+1) {
if (pX >= foundation[1].x - 1 && pX <= foundation[1].x + foundation[1].w + 1 &&
pY >= foundation[1].y - 1 && pY <= foundation[1].y + foundation[1].h + 1) {
isInside = true;
return isInside;
}
Expand Down
5 changes: 5 additions & 0 deletions bwo-server/core/entity/foundation/foundation.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ export function getAllFoundationsAroundPlayer(playerId) {
var width = 40
var height = 50


console.log("state !!!",state);

if(state.foundations == null) return [];

var foundationArray = Object.entries(state.foundations).filter((foundation) => {
return foundation[1].x > mPlayer.x/16 - width
&& foundation[1].y > mPlayer.y/16 - height
Expand Down
Loading