Skip to content

Commit

Permalink
Include wingman in post and put calls for match creation. (#254)
Browse files Browse the repository at this point in the history
Also include wingman in the config.
  • Loading branch information
PhlexPlexico authored Jun 26, 2023
1 parent fff92cd commit 7172950
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 4 deletions.
29 changes: 29 additions & 0 deletions migrations/development/20230626223210-get5db.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"use strict";

var dbm;
var type;
var seed;
var async = require("async");

/**
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function (options, seedLink) {
dbm = options.dbmigrate;
type = dbm.dataType;
seed = seedLink;
};

exports.up = function (db, callback) {
return db.runSql(
"ALTER TABLE `match` ADD COLUMN wingman tinyint(1) DEFAULT 0 AFTER map_sides;"
);
};

exports.down = function (db, callback) {
return db.removeColumn("match", "wingman");
};
exports._meta = {
version: 25
};
29 changes: 29 additions & 0 deletions migrations/production/20230626223210-get5db.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"use strict";

var dbm;
var type;
var seed;
var async = require("async");

/**
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function (options, seedLink) {
dbm = options.dbmigrate;
type = dbm.dataType;
seed = seedLink;
};

exports.up = function (db, callback) {
return db.runSql(
"ALTER TABLE `match` ADD COLUMN wingman tinyint(1) DEFAULT 0 AFTER map_sides;"
);
};

exports.down = function (db, callback) {
return db.removeColumn("match", "wingman");
};
exports._meta = {
version: 25
};
29 changes: 29 additions & 0 deletions migrations/test/20230626223210-get5db.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"use strict";

var dbm;
var type;
var seed;
var async = require("async");

/**
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function (options, seedLink) {
dbm = options.dbmigrate;
type = dbm.dataType;
seed = seedLink;
};

exports.up = function (db, callback) {
return db.runSql(
"ALTER TABLE `match` ADD COLUMN wingman tinyint(1) DEFAULT 0 AFTER map_sides;"
);
};

exports.down = function (db, callback) {
return db.removeColumn("match", "wingman");
};
exports._meta = {
version: 25
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "g5api",
"version": "2.0.0.1",
"version": "2.0.1.0",
"private": true,
"type": "module",
"licenses": [
Expand Down
12 changes: 9 additions & 3 deletions src/routes/matches/matches.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ import GlobalEmitter from "../../utility/emitter.js";
* match_cvars:
* type: object
* description: An object of key-value pairs containing different unique match CVARs.
* wingman:
* type: boolean
* description: Flag indicating whether the gamemode is wingman or not.
*
* MatchConfig:
* type: object
Expand Down Expand Up @@ -1035,7 +1038,8 @@ router.get("/:match_id/config", async (req, res, next) => {
min_spectators_to_ready:
matchInfo[0].min_spectators_to_ready !== null
? matchInfo[0].min_spectators_to_ready
: 0
: 0,
wingman: matchInfo[0]?.wingman == 1 ? true : false
};
matchJSON.num_maps = parseInt(matchInfo[0].max_maps);
if (matchJSON.skip_veto && matchInfo[0].map_sides)
Expand Down Expand Up @@ -1162,7 +1166,8 @@ router.post("/", Utils.ensureAuthenticated, async (req, res, next) => {
req.body[0].min_spectators_to_ready !== null
? req.body[0].min_spectators_to_ready
: 0,
map_sides: req.body[0].map_sides !== null ? req.body[0].map_sides : null
map_sides: req.body[0].map_sides !== null ? req.body[0].map_sides : null,
wingman: req.body[0]?.wingman
};
let sql = "INSERT INTO `match` SET ?";
let cvarSql =
Expand Down Expand Up @@ -1371,7 +1376,8 @@ router.put("/", Utils.ensureAuthenticated, async (req, res, next) => {
req.body[0].min_spectators_to_ready !== null
? req.body[0].min_spectators_to_ready
: 0,
map_sides: req.body[0].map_sides !== null ? req.body[0].map_sides : null
map_sides: req.body[0].map_sides !== null ? req.body[0].map_sides : null,
wingman: req.body[0]?.wingman
};
// Remove any values that may not be updated.
updateStmt = await db.buildUpdateStatement(updateStmt);
Expand Down

0 comments on commit 7172950

Please sign in to comment.