start group system
This commit is contained in:
@@ -20,4 +20,5 @@
|
|||||||
"watch": "webpack --watch --config webpack.config.development.js",
|
"watch": "webpack --watch --config webpack.config.development.js",
|
||||||
"build:server": "webpack --config webpack.config.build.js"
|
"build:server": "webpack --config webpack.config.build.js"
|
||||||
}
|
}
|
||||||
|
, "-vs-binding":{"ProjectOpened":["watch"]}
|
||||||
}
|
}
|
||||||
|
|||||||
51
ReallifeGamemode.Server/Entities/Group.cs
Normal file
51
ReallifeGamemode.Server/Entities/Group.cs
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using ReallifeGamemode.Server.Models;
|
||||||
|
using ReallifeGamemode.Server.Util;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Server.Entities
|
||||||
|
{
|
||||||
|
public class Group : IBankAccountOwner
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public IBankAccount GetBankAccount(DatabaseContext databaseContext = null)
|
||||||
|
{
|
||||||
|
GroupBankAccount bankAccount = null;
|
||||||
|
if (databaseContext == null)
|
||||||
|
{
|
||||||
|
using (databaseContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
bankAccount = databaseContext.GroupBankAccounts.Include(g => g.Group).Where(g => g.Group == this).FirstOrDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bankAccount = databaseContext.GroupBankAccounts.Include(g => g.Group).Where(g => g.Group == this).FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bankAccount == null)
|
||||||
|
{
|
||||||
|
bankAccount = new GroupBankAccount
|
||||||
|
{
|
||||||
|
Group = this,
|
||||||
|
Balance = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
databaseContext.GroupBankAccounts.Add(bankAccount);
|
||||||
|
databaseContext.SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
return bankAccount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
20
ReallifeGamemode.Server/Entities/GroupBankAccount.cs
Normal file
20
ReallifeGamemode.Server/Entities/GroupBankAccount.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using ReallifeGamemode.Server.Util;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Server.Entities
|
||||||
|
{
|
||||||
|
public class GroupBankAccount : IBankAccount
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public Group Group { get; set; }
|
||||||
|
|
||||||
|
public int Balance { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
16
ReallifeGamemode.Server/Entities/GroupVehicle.cs
Normal file
16
ReallifeGamemode.Server/Entities/GroupVehicle.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Server.Entities
|
||||||
|
{
|
||||||
|
public class GroupVehicle : ServerVehicle
|
||||||
|
{
|
||||||
|
public Group Group { get; set; }
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return "Gruppen Fahrzeug | Gruppe: " + Group.Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -58,6 +58,8 @@ namespace ReallifeGamemode.Server.Entities
|
|||||||
public int? FactionRankId { get; set; }
|
public int? FactionRankId { get; set; }
|
||||||
public FactionRank FactionRank { get; set; }
|
public FactionRank FactionRank { get; set; }
|
||||||
|
|
||||||
|
public Group Group { get; set; }
|
||||||
|
|
||||||
public FactionRank GetFactionRank()
|
public FactionRank GetFactionRank()
|
||||||
{
|
{
|
||||||
using (var dbContext = new DatabaseContext())
|
using (var dbContext = new DatabaseContext())
|
||||||
|
|||||||
1105
ReallifeGamemode.Server/Migrations/20190505145708_Groups.Designer.cs
generated
Normal file
1105
ReallifeGamemode.Server/Migrations/20190505145708_Groups.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
118
ReallifeGamemode.Server/Migrations/20190505145708_Groups.cs
Normal file
118
ReallifeGamemode.Server/Migrations/20190505145708_Groups.cs
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Migrations
|
||||||
|
{
|
||||||
|
public partial class Groups : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "GroupId",
|
||||||
|
table: "Users",
|
||||||
|
nullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "GroupId",
|
||||||
|
table: "ServerVehicles",
|
||||||
|
nullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Groups",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(nullable: false)
|
||||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
|
Name = table.Column<string>(nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Groups", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "GroupBankAccounts",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(nullable: false)
|
||||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
|
GroupId = table.Column<int>(nullable: true),
|
||||||
|
Balance = table.Column<int>(nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_GroupBankAccounts", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_GroupBankAccounts_Groups_GroupId",
|
||||||
|
column: x => x.GroupId,
|
||||||
|
principalTable: "Groups",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Users_GroupId",
|
||||||
|
table: "Users",
|
||||||
|
column: "GroupId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_ServerVehicles_GroupId",
|
||||||
|
table: "ServerVehicles",
|
||||||
|
column: "GroupId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_GroupBankAccounts_GroupId",
|
||||||
|
table: "GroupBankAccounts",
|
||||||
|
column: "GroupId");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_ServerVehicles_Groups_GroupId",
|
||||||
|
table: "ServerVehicles",
|
||||||
|
column: "GroupId",
|
||||||
|
principalTable: "Groups",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Users_Groups_GroupId",
|
||||||
|
table: "Users",
|
||||||
|
column: "GroupId",
|
||||||
|
principalTable: "Groups",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_ServerVehicles_Groups_GroupId",
|
||||||
|
table: "ServerVehicles");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Users_Groups_GroupId",
|
||||||
|
table: "Users");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "GroupBankAccounts");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Groups");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Users_GroupId",
|
||||||
|
table: "Users");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_ServerVehicles_GroupId",
|
||||||
|
table: "ServerVehicles");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "GroupId",
|
||||||
|
table: "Users");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "GroupId",
|
||||||
|
table: "ServerVehicles");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -374,6 +374,34 @@ namespace ReallifeGamemode.Migrations
|
|||||||
b.ToTable("GotoPoints");
|
b.ToTable("GotoPoints");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ReallifeGamemode.Server.Entities.Group", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<string>("Name");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Groups");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ReallifeGamemode.Server.Entities.GroupBankAccount", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<int>("Balance");
|
||||||
|
|
||||||
|
b.Property<int?>("GroupId");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("GroupId");
|
||||||
|
|
||||||
|
b.ToTable("GroupBankAccounts");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("ReallifeGamemode.Server.Entities.Interior", b =>
|
modelBuilder.Entity("ReallifeGamemode.Server.Entities.Interior", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
@@ -744,6 +772,8 @@ namespace ReallifeGamemode.Migrations
|
|||||||
|
|
||||||
b.Property<int?>("FactionRankId");
|
b.Property<int?>("FactionRankId");
|
||||||
|
|
||||||
|
b.Property<int?>("GroupId");
|
||||||
|
|
||||||
b.Property<int>("Handmoney");
|
b.Property<int>("Handmoney");
|
||||||
|
|
||||||
b.Property<int>("LogUserId");
|
b.Property<int>("LogUserId");
|
||||||
@@ -779,6 +809,8 @@ namespace ReallifeGamemode.Migrations
|
|||||||
|
|
||||||
b.HasIndex("FactionRankId");
|
b.HasIndex("FactionRankId");
|
||||||
|
|
||||||
|
b.HasIndex("GroupId");
|
||||||
|
|
||||||
b.ToTable("Users");
|
b.ToTable("Users");
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -870,6 +902,17 @@ namespace ReallifeGamemode.Migrations
|
|||||||
b.HasDiscriminator().HasValue("FactionVehicle");
|
b.HasDiscriminator().HasValue("FactionVehicle");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ReallifeGamemode.Server.Entities.GroupVehicle", b =>
|
||||||
|
{
|
||||||
|
b.HasBaseType("ReallifeGamemode.Server.Entities.ServerVehicle");
|
||||||
|
|
||||||
|
b.Property<int?>("GroupId");
|
||||||
|
|
||||||
|
b.HasIndex("GroupId");
|
||||||
|
|
||||||
|
b.HasDiscriminator().HasValue("GroupVehicle");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("ReallifeGamemode.Server.Entities.Saves.SavedVehicle", b =>
|
modelBuilder.Entity("ReallifeGamemode.Server.Entities.Saves.SavedVehicle", b =>
|
||||||
{
|
{
|
||||||
b.HasBaseType("ReallifeGamemode.Server.Entities.ServerVehicle");
|
b.HasBaseType("ReallifeGamemode.Server.Entities.ServerVehicle");
|
||||||
@@ -960,6 +1003,13 @@ namespace ReallifeGamemode.Migrations
|
|||||||
.OnDelete(DeleteBehavior.Cascade);
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ReallifeGamemode.Server.Entities.GroupBankAccount", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ReallifeGamemode.Server.Entities.Group", "Group")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("GroupId");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("ReallifeGamemode.Server.Entities.Logs.Death", b =>
|
modelBuilder.Entity("ReallifeGamemode.Server.Entities.Logs.Death", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("ReallifeGamemode.Server.Entities.User", "Killer")
|
b.HasOne("ReallifeGamemode.Server.Entities.User", "Killer")
|
||||||
@@ -996,6 +1046,10 @@ namespace ReallifeGamemode.Migrations
|
|||||||
b.HasOne("ReallifeGamemode.Server.Entities.FactionRank", "FactionRank")
|
b.HasOne("ReallifeGamemode.Server.Entities.FactionRank", "FactionRank")
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("FactionRankId");
|
.HasForeignKey("FactionRankId");
|
||||||
|
|
||||||
|
b.HasOne("ReallifeGamemode.Server.Entities.Group", "Group")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("GroupId");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserBankAccount", b =>
|
modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserBankAccount", b =>
|
||||||
@@ -1029,6 +1083,13 @@ namespace ReallifeGamemode.Migrations
|
|||||||
.HasForeignKey("FactionId");
|
.HasForeignKey("FactionId");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ReallifeGamemode.Server.Entities.GroupVehicle", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ReallifeGamemode.Server.Entities.Group", "Group")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("GroupId");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserVehicle", b =>
|
modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserVehicle", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("ReallifeGamemode.Server.Entities.User", "User")
|
b.HasOne("ReallifeGamemode.Server.Entities.User", "User")
|
||||||
|
|||||||
@@ -94,5 +94,10 @@ namespace ReallifeGamemode.Server.Models
|
|||||||
|
|
||||||
// Tuning Garages
|
// Tuning Garages
|
||||||
public DbSet<Entities.TuningGarage> TuningGarages { get; set; }
|
public DbSet<Entities.TuningGarage> TuningGarages { get; set; }
|
||||||
|
|
||||||
|
// Gruppen
|
||||||
|
public DbSet<Entities.Group> Groups { get; set; }
|
||||||
|
public DbSet<Entities.GroupBankAccount> GroupBankAccounts { get; set; }
|
||||||
|
public DbSet<Entities.GroupVehicle> GroupVehicles { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user