Skip to content

Commit

Permalink
file name changes from serverStateMachine to sessionStateMachine
Browse files Browse the repository at this point in the history
  • Loading branch information
keshav2010 committed Apr 27, 2023
1 parent fba277f commit f675a5b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7,595 deletions.
6 changes: 3 additions & 3 deletions gameserver/lib/GameStateManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { Queue } = require("../../common/Queue");
* Manages entire game state.
*/
class GameStateManager {
constructor(io, serverStateMachineJSON, serverStateMachineBehaviour) {
constructor(io, sessionStateMachineJSON, sessionStateMachineActions) {
this.cumulativeUpdates = [];
this.pendingClientRequests = new Queue();

Expand All @@ -25,8 +25,8 @@ class GameStateManager {

this.countdown = process.env.COUNTDOWN; //seconds
this.stateMachine = new StateMachine(
serverStateMachineJSON,
serverStateMachineBehaviour
sessionStateMachineJSON,
sessionStateMachineActions
);
this.alliances = new AllianceTracker();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,19 @@ module.exports = {
(Date.now() - gameStateManager.lastSimulateTime_ms) / 1000;
gameStateManager.lastSimulateTime_ms = Date.now();
//simulate all players.
gameStateManager.getPlayers().forEach((player) => {
const playersConnected = gameStateManager.getPlayers();
if(playersConnected.length == 0) {
gameStateManager.stateMachine.controller.send("BattleEnd");
return;
}
playersConnected.forEach((player) => {
player.tick(deltaTime, gameStateManager);
});
} catch (err) {
console.log(err);
}
},

BattleEndState: ({ gameStateManager }) => {},
BattleEndState: ({ gameStateManager }) => {
},
};
Loading

0 comments on commit f675a5b

Please sign in to comment.