opt-cc/server/models/player.js

106 lines
2.0 KiB
JavaScript
Raw Permalink Normal View History

2018-03-12 09:26:44 +01:00
'use strict';
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const PlayerSchema = new Schema({
name: {
type: String,
2018-03-12 09:26:44 +01:00
required: true,
},
fraction: {
type: String,
enum: ['BLUFOR', 'OPFOR'],
2018-03-12 09:26:44 +01:00
required: true,
},
warId: {
type: mongoose.Schema.Types.ObjectId,
ref: 'War',
2018-03-12 09:26:44 +01:00
required: true,
},
kill: {
type: Number,
2018-03-12 09:26:44 +01:00
get: (v) => Math.round(v),
set: (v) => Math.round(v),
required: true,
},
vehicleLight: {
type: Number,
get: (v) => Math.round(v),
set: (v) => Math.round(v),
required: true,
},
vehicleHeavy: {
type: Number,
get: (v) => Math.round(v),
set: (v) => Math.round(v),
required: true,
},
vehicleAir: {
type: Number,
2018-03-12 09:26:44 +01:00
get: (v) => Math.round(v),
set: (v) => Math.round(v),
required: true,
},
death: {
type: Number,
2018-03-12 09:26:44 +01:00
get: (v) => Math.round(v),
set: (v) => Math.round(v),
required: true,
},
friendlyFire: {
type: Number,
2018-03-12 09:26:44 +01:00
get: (v) => Math.round(v),
set: (v) => Math.round(v),
required: true,
},
2017-08-05 23:19:23 +02:00
revive: {
type: Number,
2018-03-12 09:26:44 +01:00
get: (v) => Math.round(v),
set: (v) => Math.round(v),
required: true,
2017-08-05 23:19:23 +02:00
},
respawn: {
type: Number,
2018-03-12 09:26:44 +01:00
get: (v) => Math.round(v),
set: (v) => Math.round(v),
required: true,
},
flagTouch: {
type: Number,
2018-03-12 09:26:44 +01:00
get: (v) => Math.round(v),
set: (v) => Math.round(v),
required: true,
},
2018-02-26 09:33:28 +01:00
steamUUID: {
type: Number,
2018-03-12 09:26:44 +01:00
get: (v) => Math.round(v),
set: (v) => Math.round(v),
},
performance: {
type: mongoose.Schema.Types.ObjectId,
2019-02-11 18:45:21 +01:00
ref: 'LogServerFps',
required: false,
},
travelDistance: {
type: Number,
get: (v) => Math.round(v),
set: (v) => Math.round(v),
required: false,
},
driverDistance: {
type: Number,
get: (v) => Math.round(v),
set: (v) => Math.round(v),
required: false,
},
},
{
collection: 'player',
2018-03-12 09:26:44 +01:00
timestamps: {createdAt: 'timestamp'},
});
// optional more indices
2018-02-26 09:33:28 +01:00
PlayerSchema.index({warId: 1});
module.exports = mongoose.model('Player', PlayerSchema);