sql stuff
This commit is contained in:
@@ -22,26 +22,34 @@ class GameList extends Phaser.GameObjects.Group {
|
||||
const WIDTH = GAME_LIST.width();
|
||||
const HEIGHT = GAME_LIST.height();
|
||||
|
||||
console.log(GAME_LIST.y(0))
|
||||
|
||||
const pvp = list.add
|
||||
.rectangle(X, GAME_LIST.y(0), WIDTH, HEIGHT, 0x440000)
|
||||
.setInteractive()
|
||||
.setOrigin(0);
|
||||
|
||||
this
|
||||
.add(list.add.text(pvp.getCenter().x, pvp.getCenter().y, 'PVP', TEXT.HEADER));
|
||||
.add(list.add.text(pvp.getCenter().x, pvp.getCenter().y, 'NEW', TEXT.HEADER));
|
||||
|
||||
const pve = list.add
|
||||
.rectangle(X, GAME_LIST.y(1), WIDTH, HEIGHT, 0x004400)
|
||||
.rectangle(X, GAME_LIST.y(1), Math.floor(WIDTH / 2), HEIGHT, 0x004400)
|
||||
.setInteractive()
|
||||
.setOrigin(0);
|
||||
|
||||
this
|
||||
.add(list.add.text(pve.getCenter().x, pve.getCenter().y, 'PVE', TEXT.HEADER));
|
||||
|
||||
const refresh = list.add
|
||||
.rectangle(X + Math.floor(WIDTH / 2), GAME_LIST.y(1), Math.floor(WIDTH / 2), HEIGHT, 0x000044)
|
||||
.setInteractive()
|
||||
.setOrigin(0);
|
||||
|
||||
this
|
||||
.add(list.add.text(refresh.getCenter().x, refresh.getCenter().y, 'REFRESH', TEXT.HEADER));
|
||||
|
||||
|
||||
pvp.on('pointerdown', () => {
|
||||
const team = cryps.filter(c => c.active).map(c => c.id);
|
||||
list.scene.switch('Combat');
|
||||
return ws.sendGamePvp(team);
|
||||
});
|
||||
|
||||
@@ -51,8 +59,10 @@ class GameList extends Phaser.GameObjects.Group {
|
||||
return ws.sendGamePve(team);
|
||||
});
|
||||
|
||||
this.add(pve);
|
||||
this.add(pvp);
|
||||
refresh.on('pointerdown', () => {
|
||||
return ws.sendGameJoinableList();
|
||||
});
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+31
-1
@@ -22,6 +22,23 @@ function createSocket(store) {
|
||||
|
||||
let gameStateTimeout;
|
||||
|
||||
function bootstrap() {
|
||||
send({ method: 'account_create', params: { name: 'ntr', password: 'grepgrepgrep' } });
|
||||
send({ method: 'cryp_spawn', params: { name: 'muji' } });
|
||||
send({ method: 'cryp_spawn', params: { name: 'drake' } });
|
||||
send({ method: 'cryp_spawn', params: { name: 'xray' } });
|
||||
}
|
||||
|
||||
function bootstrapMashy() {
|
||||
send({ method: 'account_create', params: { name: 'mashy', password: 'grepgrepgrep' } });
|
||||
send({ method: 'cryp_spawn', params: { name: 'maury' } });
|
||||
send({ method: 'cryp_spawn', params: { name: 'midshaker' } });
|
||||
send({ method: 'cryp_spawn', params: { name: 'artour' } });
|
||||
}
|
||||
|
||||
window.bootstrap = bootstrap;
|
||||
window.bootstrapMashy = bootstrapMashy;
|
||||
|
||||
function connect() {
|
||||
ws = new WebSocket(SOCKET_URL);
|
||||
ws.binaryType = 'arraybuffer';
|
||||
@@ -61,7 +78,6 @@ function createSocket(store) {
|
||||
|
||||
account = login;
|
||||
store.dispatch(actions.setAccount(login));
|
||||
// send({ method: 'cryp_spawn', params: { name: 'bees' } });
|
||||
send({ method: 'account_cryps', params: {} });
|
||||
send({ method: 'item_list', params: {} });
|
||||
console.log(account);
|
||||
@@ -80,6 +96,12 @@ function createSocket(store) {
|
||||
store.dispatch(actions.setGame(game));
|
||||
}
|
||||
|
||||
function gameJoinableList(response) {
|
||||
const [structName, gameList] = response;
|
||||
gameStateTimeout = setTimeout(() => sendGameState(game.id), 1000);
|
||||
store.dispatch(actions.setGame(game));
|
||||
}
|
||||
|
||||
function crypSpawn(response) {
|
||||
const [structName, cryp] = response;
|
||||
console.log('got a new cryp', cryp);
|
||||
@@ -140,6 +162,11 @@ function createSocket(store) {
|
||||
send({ method: 'game_join', params: { game_id: gameId, cryp_ids: crypIds } });
|
||||
}
|
||||
|
||||
function sendGameJoinableList() {
|
||||
send({ method: 'game_joinable_list', params: { } });
|
||||
}
|
||||
|
||||
|
||||
function sendGameSkill(gameId, crypId, targetTeamId, skill) {
|
||||
send({
|
||||
method: 'game_skill',
|
||||
@@ -179,6 +206,7 @@ function createSocket(store) {
|
||||
cryp_spawn: crypSpawn,
|
||||
game_pve: gamePve,
|
||||
game_state: gameState,
|
||||
game_joinable_list: gameJoinableList,
|
||||
account_login: accountLogin,
|
||||
account_create: accountLogin,
|
||||
account_cryps: accountCryps,
|
||||
@@ -208,6 +236,7 @@ function createSocket(store) {
|
||||
sendGamePve,
|
||||
sendGamePvp,
|
||||
sendGameJoin,
|
||||
sendGameJoinableList,
|
||||
sendGameSkill,
|
||||
sendGameTarget,
|
||||
sendCrypSpawn,
|
||||
@@ -215,6 +244,7 @@ function createSocket(store) {
|
||||
sendCrypForget,
|
||||
sendItemUse,
|
||||
connect,
|
||||
bootstrap,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user