SplatNet-Backend/judd/titles/splatoon.js

104 lines
No EOL
3.9 KiB
JavaScript

const multer = require('multer');
const { joi } = require('../util');
const { SplatfestResult } = require('../models/splatfest_result');
const { Equipment } = require('../models/equipment');
const { EquipmentLast } = require('../models/equipmentLast');
module.exports = {
type: 'telemetry',
result_model: {
create: async (data) => {
const result = await SplatfestResult.create(data);
await Equipment.create({
PId: data.PId,
weapon: data.Weapon,
sumpaint: data.SumPaint
});
await EquipmentLast.upsert({
PId: data.PId,
weapon: data.Weapon,
Gear_Shoes: data.Gear_Shoes,
Gear_Shoes_Skill0: data.Gear_Shoes_Skill0,
Gear_Shoes_Skill1: data.Gear_Shoes_Skill1,
Gear_Shoes_Skill2: data.Gear_Shoes_Skill2,
Gear_Clothes: data.Gear_Clothes,
Gear_Clothes_Skill0: data.Gear_Clothes_Skill0,
Gear_Clothes_Skill1: data.Gear_Clothes_Skill1,
Gear_Clothes_Skill2: data.Gear_Clothes_Skill2,
Gear_Head: data.Gear_Head,
Gear_Head_Skill0: data.Gear_Head_Skill0,
Gear_Head_Skill1: data.Gear_Head_Skill1,
Gear_Head_Skill2: data.Gear_Head_Skill2,
Rank: data.Rank,
Udemae: data.Udemae
});
return result;
}
},
validation_schema: joi.object({
ServerEnv: joi.string(),
PId: joi.numberstring(),
MiiName: joi.string(),
Model: joi.numberstring(),
Skin: joi.numberstring(),
EyeColor: joi.numberstring(),
Weapon: joi.numberstring(),
SumPaint: joi.numberstring(),
Gear_Shoes: joi.numberstring(),
Gear_Shoes_Skill0: joi.numberstring(),
Gear_Shoes_Skill1: joi.numberstring(),
Gear_Shoes_Skill2: joi.numberstring(),
Gear_Clothes: joi.numberstring(),
Gear_Clothes_Skill0: joi.numberstring(),
Gear_Clothes_Skill1: joi.numberstring(),
Gear_Clothes_Skill2: joi.numberstring(),
Gear_Head: joi.numberstring(),
Gear_Head_Skill0: joi.numberstring(),
Gear_Head_Skill1: joi.numberstring(),
Gear_Head_Skill2: joi.numberstring(),
Rank: joi.numberstring(),
Udemae: joi.numberstring(),
RegularKillSum: joi.numberstring(),
WinSum: joi.numberstring(),
LoseSum: joi.numberstring(),
TodaysCondition: joi.numberstring(),
Region: joi.string(),
Area: joi.numberstring(),
FesID: joi.numberstring(),
FesState: joi.numberstring(),
FesTeam: joi.numberstring(),
FesGrade: joi.numberstring(),
FesPoint: joi.numberstring(),
FesPower: joi.numberstring(),
BestFesPower: joi.numberstring(),
Money: joi.numberstring(),
Shell: joi.numberstring(),
TotalBonusShell: joi.numberstring(),
MatchingTime: joi.numberstring(),
IsRematch: joi.numberstring(),
SaveDataCorrupted: joi.numberstring(),
DisconnectedPId: joi.numberstring(),
DisconnectedMemHash: joi.numberstring(),
SessionID: joi.numberstring(),
StartNetworkTime: joi.numberstring(),
GameMode: joi.numberstring(),
Rule: joi.numberstring(),
Stage: joi.numberstring(),
Team: joi.numberstring(),
IsWinGame: joi.numberstring(),
Kill: joi.numberstring(),
Death: joi.numberstring(),
Paint: joi.numberstring(),
IsNetworkBurst: joi.numberstring(),
BottleneckPlayerNum: joi.numberstring(),
MaxSilenceFrame: joi.numberstring(),
MemoryHash: joi.numberstring(),
Paint_Alpha: joi.numberstring(),
Paint_Bravo: joi.numberstring(),
FaceImg: joi.binary()
}).unknown(true).options({ presence: 'optional' }).required(),
multipart_validator: multer().any()
};