Skip to content

Commit

Permalink
Define data schema for CSGO stats (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
niekcandaele authored Jul 24, 2020
1 parent 53ce1c8 commit 94056b5
Show file tree
Hide file tree
Showing 22 changed files with 1,292 additions and 2 deletions.
50 changes: 50 additions & 0 deletions entities/bombStatus.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import {
BaseEntity,
Column,
CreateDateColumn,
Entity,
JoinColumn,
ManyToOne,
OneToOne,
PrimaryGeneratedColumn
} from 'typeorm';
import { BombStatusChange } from 'types/BombStatusChange.enum';

import { PlayerInfo } from './playerInfo.entity';
import { Position } from './position.entity';
import { Round } from './round.entity';

/**
* Database record
*/
@Entity()
export class BombStatus extends BaseEntity {
/**
* Primary key
*/
@PrimaryGeneratedColumn()
id: number;

@CreateDateColumn()
createdAt: Date;

@Column()
tick: number;

@Column({
type: "enum",
enum: Object.values(BombStatusChange)
})
type: BombStatusChange;

@OneToOne(() => PlayerInfo)
@JoinColumn()
player: PlayerInfo;

@OneToOne(() => Position)
@JoinColumn()
position: Position;

@ManyToOne(() => Round)
round: Round;
}
55 changes: 55 additions & 0 deletions entities/kill.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import {
BaseEntity,
Column,
CreateDateColumn,
Entity,
JoinColumn,
ManyToOne,
OneToOne,
PrimaryGeneratedColumn
} from 'typeorm';

import { PlayerInfo } from './playerInfo.entity';
import { Round } from './round.entity';

/**
* Database record
*/
@Entity()
export class Kill extends BaseEntity {
/**
* Primary key
*/
@PrimaryGeneratedColumn()
id: number;

@CreateDateColumn()
createdAt: Date;

@Column()
tick: number;

@Column()
throughSmoke: boolean;

@Column()
whileBlind: boolean;

@Column()
throughWall: boolean;

@OneToOne(() => PlayerInfo)
@JoinColumn()
attacker: PlayerInfo;

@OneToOne(() => PlayerInfo)
@JoinColumn()
victim: PlayerInfo;

@OneToOne(() => PlayerInfo, { nullable: true })
@JoinColumn()
assister: PlayerInfo;

@ManyToOne(() => Round)
round: Round;
}
6 changes: 5 additions & 1 deletion entities/match.entity.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { BaseEntity, Column, Entity, JoinTable, ManyToMany, PrimaryGeneratedColumn, Unique } from 'typeorm';
import { BaseEntity, Column, Entity, JoinTable, ManyToMany, OneToMany, PrimaryGeneratedColumn, Unique } from 'typeorm';

import { IMatchType } from '../types/matchType.interface';
import { Player } from './player.entity';
import { Round } from './round.entity';

/**
* Match database record
Expand Down Expand Up @@ -63,4 +64,7 @@ export class Match extends BaseEntity {
@ManyToMany(() => Player, (player) => player.matches)
@JoinTable()
players: Player[];

@OneToMany(() => Round, (round) => round.match)
rounds: Round[];
}
48 changes: 48 additions & 0 deletions entities/playerBlind.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import {
BaseEntity,
Column,
CreateDateColumn,
Entity,
JoinColumn,
ManyToOne,
OneToOne,
PrimaryGeneratedColumn
} from 'typeorm';

import { PlayerInfo } from './playerInfo.entity';
import { Round } from './round.entity';

/**
* Database record
*/
@Entity()
export class PlayerBlind extends BaseEntity {
/**
* Primary key
*/
@PrimaryGeneratedColumn()
id: number;

@CreateDateColumn()
createdAt: Date;

@Column()
tick: number;

/**
* How long a player was blinded, in ticks
*/
@Column()
duration: number;

@OneToOne(() => PlayerInfo)
@JoinColumn()
attacker: PlayerInfo;

@OneToOne(() => PlayerInfo)
@JoinColumn()
victim: PlayerInfo;

@ManyToOne(() => Round)
round: Round;
}
56 changes: 56 additions & 0 deletions entities/playerHurt.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import {
BaseEntity,
Column,
CreateDateColumn,
Entity,
JoinColumn,
ManyToOne,
OneToOne,
PrimaryGeneratedColumn
} from 'typeorm';
import { HurtSources } from 'types/HurtSources.enum';

import { PlayerInfo } from './playerInfo.entity';
import { Round } from './round.entity';

/**
* Database record
*/
@Entity()
export class PlayerHurt extends BaseEntity {
/**
* Primary key
*/
@PrimaryGeneratedColumn()
id: number;

@CreateDateColumn()
createdAt: Date;

@Column()
tick: number;

@Column()
damageArmour: number;

@Column()
damageHealth: number;

// TODO: Should be an enum but cba checking what values are possible right now :)
@Column()
hitGroup: number;

@Column()
source: HurtSources;

@OneToOne(() => PlayerInfo)
@JoinColumn()
attacker: PlayerInfo;

@OneToOne(() => PlayerInfo)
@JoinColumn()
victim: PlayerInfo;

@ManyToOne(() => Round)
round: Round;
}
69 changes: 69 additions & 0 deletions entities/playerInfo.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import {
BaseEntity,
Column,
CreateDateColumn,
Entity,
JoinColumn,
ManyToOne,
OneToOne,
PrimaryGeneratedColumn
} from 'typeorm';
import { Weapon } from 'types/Weapon.enum';

import { Player } from './player.entity';
import { Position } from './position.entity';

/**
* Database record
*/
@Entity()
export class PlayerInfo extends BaseEntity {
/**
* Primary key
*/
@PrimaryGeneratedColumn()
id: number;

@CreateDateColumn()
createdAt: Date;

@Column()
tick: number;

@Column()
equipmentValue: number;

@Column()
freezeTimeEndEquipmentValue: number;

@Column()
cashSpentInRound: number;

@Column()
hasC4: boolean;

@Column()
health: number;

@Column()
armour: number;

@Column()
isScoped: boolean;

@Column({
type: "enum",
enum: Object.values(Weapon)
})
weapon: Weapon;

@Column()
bulletsInMagazine: number;

@OneToOne(() => Position)
@JoinColumn()
position: Position;

@ManyToOne(() => Player)
player: Player;
}
38 changes: 38 additions & 0 deletions entities/playerJump.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {
BaseEntity,
Column,
CreateDateColumn,
Entity,
JoinColumn,
ManyToOne,
OneToOne,
PrimaryGeneratedColumn
} from 'typeorm';

import { PlayerInfo } from './playerInfo.entity';
import { Round } from './round.entity';

/**
* Database record
*/
@Entity()
export class PlayerJump extends BaseEntity {
/**
* Primary key
*/
@PrimaryGeneratedColumn()
id: number;

@CreateDateColumn()
createdAt: Date;

@Column()
tick: number;

@OneToOne(() => PlayerInfo)
@JoinColumn()
player: PlayerInfo;

@ManyToOne(() => Round)
round: Round;
}
25 changes: 25 additions & 0 deletions entities/position.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { BaseEntity, Column, CreateDateColumn, Entity, PrimaryGeneratedColumn } from 'typeorm';

/**
* Database record
*/
@Entity()
export class Position extends BaseEntity {
/**
* Primary key
*/
@PrimaryGeneratedColumn()
id: number;

@CreateDateColumn()
createdAt: Date;

@Column()
x: number;

@Column()
y: number;

@Column()
z: number;
}
Loading

0 comments on commit 94056b5

Please sign in to comment.