673 lines
12 KiB
JavaScript
673 lines
12 KiB
JavaScript
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const Games = db.games;
|
|
|
|
const GameTactics = db.game_tactics;
|
|
|
|
const GameTacticActions = db.game_tactic_actions;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const GamesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"game_prefix": "CHESS",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"game_name": "Chess",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"game_desc": "Classic strategy board game focused on calculation, positional play, and endgame technique.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"game_prefix": "GOW",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"game_name": "Gears of War",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"game_desc": "Cover based third person shooter emphasizing flanks, team coordination, and power weapon control.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"game_prefix": "DOTA",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"game_name": "Dota 2",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"game_desc": "Competitive MOBA featuring drafting, lanes, objectives, and coordinated team fights.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const GameTacticsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tactic_prefix": "CH-OPN",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tactic_name": "Openings Fundamentals",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tactic_desc": "Establish sound development, control the center, and safeguard the king through early castling.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tactic_prefix": "CH-END",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tactic_name": "Basic Endgame Technique",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tactic_desc": "Convert common winning positions using opposition, key squares, and simplified material.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tactic_prefix": "VAL-EXE",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tactic_name": "Site Execute Playbook",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tactic_desc": "Coordinate utility to take space, clear angles, and plant with structured post plant roles.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const GameTacticActionsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tactic_action_sequence": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tactic_action_name": "Develop minor pieces",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tactic_action_desc": "Prioritize knights and bishops to active squares before moving the same piece repeatedly.",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tactic_action_sequence": 2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tactic_action_name": "Control the center",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tactic_action_desc": "Use pawns and pieces to influence key central squares and restrict opponent options.",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tactic_action_sequence": 3,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tactic_action_name": "Castle early",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tactic_action_desc": "Secure king safety and connect rooks once basic development is complete.",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateGameTacticWithGame() {
|
|
|
|
const relatedGame0 = await Games.findOne({
|
|
offset: Math.floor(Math.random() * (await Games.count())),
|
|
});
|
|
const GameTactic0 = await GameTactics.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (GameTactic0?.setGame)
|
|
{
|
|
await
|
|
GameTactic0.
|
|
setGame(relatedGame0);
|
|
}
|
|
|
|
const relatedGame1 = await Games.findOne({
|
|
offset: Math.floor(Math.random() * (await Games.count())),
|
|
});
|
|
const GameTactic1 = await GameTactics.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (GameTactic1?.setGame)
|
|
{
|
|
await
|
|
GameTactic1.
|
|
setGame(relatedGame1);
|
|
}
|
|
|
|
const relatedGame2 = await Games.findOne({
|
|
offset: Math.floor(Math.random() * (await Games.count())),
|
|
});
|
|
const GameTactic2 = await GameTactics.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (GameTactic2?.setGame)
|
|
{
|
|
await
|
|
GameTactic2.
|
|
setGame(relatedGame2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateGameTacticActionWithGame_tactic() {
|
|
|
|
const relatedGame_tactic0 = await GameTactics.findOne({
|
|
offset: Math.floor(Math.random() * (await GameTactics.count())),
|
|
});
|
|
const GameTacticAction0 = await GameTacticActions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (GameTacticAction0?.setGame_tactic)
|
|
{
|
|
await
|
|
GameTacticAction0.
|
|
setGame_tactic(relatedGame_tactic0);
|
|
}
|
|
|
|
const relatedGame_tactic1 = await GameTactics.findOne({
|
|
offset: Math.floor(Math.random() * (await GameTactics.count())),
|
|
});
|
|
const GameTacticAction1 = await GameTacticActions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (GameTacticAction1?.setGame_tactic)
|
|
{
|
|
await
|
|
GameTacticAction1.
|
|
setGame_tactic(relatedGame_tactic1);
|
|
}
|
|
|
|
const relatedGame_tactic2 = await GameTactics.findOne({
|
|
offset: Math.floor(Math.random() * (await GameTactics.count())),
|
|
});
|
|
const GameTacticAction2 = await GameTacticActions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (GameTacticAction2?.setGame_tactic)
|
|
{
|
|
await
|
|
GameTacticAction2.
|
|
setGame_tactic(relatedGame_tactic2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await Games.bulkCreate(GamesData);
|
|
|
|
|
|
|
|
|
|
await GameTactics.bulkCreate(GameTacticsData);
|
|
|
|
|
|
|
|
|
|
await GameTacticActions.bulkCreate(GameTacticActionsData);
|
|
|
|
|
|
await Promise.all([
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateGameTacticWithGame(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateGameTacticActionWithGame_tactic(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
]);
|
|
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await queryInterface.bulkDelete('games', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('game_tactics', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('game_tactic_actions', null, {});
|
|
|
|
|
|
},
|
|
}; |