Add House Menu
This commit is contained in:
122
ReallifeGamemode.Client/House/house.ts
Normal file
122
ReallifeGamemode.Client/House/house.ts
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
import { Menu, Point, UIMenuItem, Color } from 'NativeUI';
|
||||||
|
import moneyFormat from '../moneyformat';
|
||||||
|
import InputHelper from '../inputhelper';
|
||||||
|
|
||||||
|
export default function house(globalData: GlobalData) {
|
||||||
|
|
||||||
|
var houseMenu: Menu;
|
||||||
|
var houseData: any;
|
||||||
|
var houseState: number;
|
||||||
|
|
||||||
|
var keyBound = false;
|
||||||
|
|
||||||
|
mp.events.add("SERVER:ShowHouseMenu", (dataStr, state: number) => {
|
||||||
|
houseData = JSON.parse(dataStr);
|
||||||
|
houseState = state;
|
||||||
|
mp.gui.chat.push(state.toString());
|
||||||
|
mp.gui.chat.push(dataStr);
|
||||||
|
|
||||||
|
mp.game.ui.setTextComponentFormat('STRING');
|
||||||
|
mp.game.ui.addTextComponentSubstringPlayerName('Drücke ~INPUT_CONTEXT~, um das Hausmenü öffnen');
|
||||||
|
mp.game.ui.displayHelpTextFromStringLabel(0, true, true, -1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
mp.keys.bind(0x45, false, keyPressHandler);
|
||||||
|
keyBound = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
function keyPressHandler() {
|
||||||
|
mp.gui.chat.push("open menu");
|
||||||
|
mp.game.ui.clearHelp(true);
|
||||||
|
houseMenu = new Menu("Hausverwaltung", houseData.Type, new Point(50, 50), null, null);
|
||||||
|
|
||||||
|
globalData.InMenu = true;
|
||||||
|
mp.gui.chat.push(houseState.toString());
|
||||||
|
|
||||||
|
var rentInItem: UIMenuItem;
|
||||||
|
|
||||||
|
var buyHouseItem: UIMenuItem;
|
||||||
|
|
||||||
|
var setRentalFeeItem: UIMenuItem;
|
||||||
|
var cancelRentalsItem: UIMenuItem;
|
||||||
|
|
||||||
|
var houseRentals = 0;
|
||||||
|
|
||||||
|
if (houseData.Rentals) houseRentals = houseData.Rentals.length;
|
||||||
|
|
||||||
|
if (houseState === -1) { // Keine Beziehung zum Haus
|
||||||
|
mp.gui.chat.push("einmieten");
|
||||||
|
rentInItem = new UIMenuItem("Einmieten", "Miete dich in das Haus ein");
|
||||||
|
rentInItem.SetRightLabel(moneyFormat(houseData.RentalFee.toString(), 0));
|
||||||
|
houseMenu.AddItem(rentInItem);
|
||||||
|
} else if (houseState === 0) { // Haus hat keinen Eigentümer
|
||||||
|
mp.gui.chat.push("kaufen");
|
||||||
|
buyHouseItem = new UIMenuItem("Haus kaufen", "Kaufe das Haus");
|
||||||
|
buyHouseItem.SetRightLabel(moneyFormat(houseData.Price, 0) + "$");
|
||||||
|
houseMenu.AddItem(buyHouseItem);
|
||||||
|
} else if (houseState === 1) { // Hausbesitzer
|
||||||
|
mp.gui.chat.push("besitzer");
|
||||||
|
setRentalFeeItem = new UIMenuItem("Miete setzen", "Setze den Mietpreis");
|
||||||
|
setRentalFeeItem.SetRightLabel(moneyFormat(houseData.RentalFee, 0) + "$");
|
||||||
|
houseMenu.AddItem(setRentalFeeItem);
|
||||||
|
|
||||||
|
cancelRentalsItem = new UIMenuItem("Mieter", "Liste deine Mieter auf");
|
||||||
|
cancelRentalsItem.SetRightLabel(houseRentals.toString());
|
||||||
|
|
||||||
|
if (houseRentals > 0) {
|
||||||
|
var cancelRentalsMenu = new Menu("Mieter", "Kündige einen Mieter", new Point(50, 50), null, null);
|
||||||
|
cancelRentalsMenu.Visible = false;
|
||||||
|
|
||||||
|
houseData.Rentals.forEach(rental => {
|
||||||
|
var item = new UIMenuItem(rental.Name, "");
|
||||||
|
item.SetRightLabel("Kündigen");
|
||||||
|
cancelRentalsMenu.AddItem(item);
|
||||||
|
});
|
||||||
|
|
||||||
|
houseMenu.BindMenuToItem(cancelRentalsMenu, cancelRentalsItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var cancelItem = new UIMenuItem("Abbrechen");
|
||||||
|
cancelItem.BackColor = new Color(213, 0, 0);
|
||||||
|
cancelItem.HighlightedBackColor = new Color(229, 57, 53);
|
||||||
|
houseMenu.AddItem(cancelItem);
|
||||||
|
|
||||||
|
houseMenu.Open();
|
||||||
|
|
||||||
|
houseMenu.ItemSelect.on((item, index) => {
|
||||||
|
if (item === cancelItem) {
|
||||||
|
mp.events.call("SERVER:CloseHouseMenu");
|
||||||
|
} else if (item === buyHouseItem) {
|
||||||
|
mp.events.callRemote("CLIENT:House_BuyHouse");
|
||||||
|
mp.events.call("SERVER:CloseHouseMenu");
|
||||||
|
} else if (item === setRentalFeeItem) {
|
||||||
|
var rentalFeeInput = new InputHelper("Wie viel soll die Miete betragen?", globalData);
|
||||||
|
rentalFeeInput.getValue(data => {
|
||||||
|
if (isNaN(data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var rentalFee = parseInt(data);
|
||||||
|
|
||||||
|
mp.events.callRemote("CLIENT:House_SetRentalFee", rentalFee);
|
||||||
|
mp.events.call("SERVER:CloseHouseMenu");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
mp.events.add("SERVER:CloseHouseMenu", () => {
|
||||||
|
mp.game.ui.clearHelp(true);
|
||||||
|
globalData.InMenu = false;
|
||||||
|
if (houseMenu != null) {
|
||||||
|
houseMenu.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (keyBound) {
|
||||||
|
keyBound = false;
|
||||||
|
mp.keys.unbind(0x45, false, keyPressHandler);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -25,6 +25,9 @@ var inMenu = false;
|
|||||||
|
|
||||||
mp.game.vehicle.defaultEngineBehaviour = false;
|
mp.game.vehicle.defaultEngineBehaviour = false;
|
||||||
|
|
||||||
|
import house from './house/house';
|
||||||
|
house(globalData);
|
||||||
|
|
||||||
import vehicleEntering from './vehiclesync/entering';
|
import vehicleEntering from './vehiclesync/entering';
|
||||||
vehicleEntering(globalData);
|
vehicleEntering(globalData);
|
||||||
|
|
||||||
|
|||||||
@@ -2499,6 +2499,13 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(nearHouse.OwnerId != null)
|
||||||
|
{
|
||||||
|
dbContext.Users.Where(u => u.Id == nearHouse.OwnerId).First().HouseId = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
|
||||||
dbContext.Houses.Remove(nearHouse);
|
dbContext.Houses.Remove(nearHouse);
|
||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ namespace ReallifeGamemode.Server.Entities
|
|||||||
public float Y { get; set; }
|
public float Y { get; set; }
|
||||||
public float Z { get; set; }
|
public float Z { get; set; }
|
||||||
|
|
||||||
|
public int RentalFee { get; set; }
|
||||||
|
|
||||||
|
public bool CanRentIn { get; set; }
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public Vector3 Position => new Vector3(X, Y, Z);
|
public Vector3 Position => new Vector3(X, Y, Z);
|
||||||
|
|
||||||
|
|||||||
25
ReallifeGamemode.Server/Entities/HouseRentals.cs
Normal file
25
ReallifeGamemode.Server/Entities/HouseRentals.cs
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Server.Entities
|
||||||
|
{
|
||||||
|
public class HouseRentals
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey("House")]
|
||||||
|
public int? HouseId { get; set; }
|
||||||
|
|
||||||
|
public House House { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey("User")]
|
||||||
|
public int? UserId { get; set; }
|
||||||
|
|
||||||
|
public User User { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@ namespace ReallifeGamemode.Server.Extensions
|
|||||||
}
|
}
|
||||||
public static string ToMoneyString(this int money)
|
public static string ToMoneyString(this int money)
|
||||||
{
|
{
|
||||||
return "$" + string.Format(Main.SERVER_CULTURE, "{0:C0}", money).Replace("€", "");
|
return "$" + string.Format(Main.SERVER_CULTURE, "{0:C0}", money).Replace("€", "").Trim();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using GTANetworkAPI;
|
using GTANetworkAPI;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using ReallifeGamemode.Server.Classes;
|
using ReallifeGamemode.Server.Classes;
|
||||||
using ReallifeGamemode.Server.Finance;
|
using ReallifeGamemode.Server.Finance;
|
||||||
using ReallifeGamemode.Server.Managers;
|
using ReallifeGamemode.Server.Managers;
|
||||||
@@ -32,7 +33,13 @@ namespace ReallifeGamemode.Server
|
|||||||
NAPI.Server.SetAutoRespawnAfterDeath(false);
|
NAPI.Server.SetAutoRespawnAfterDeath(false);
|
||||||
NAPI.Data.SetWorldData("playerCreatorDimension", 0);
|
NAPI.Data.SetWorldData("playerCreatorDimension", 0);
|
||||||
|
|
||||||
|
JsonConvert.DefaultSettings = () =>
|
||||||
|
{
|
||||||
|
return new JsonSerializerSettings()
|
||||||
|
{
|
||||||
|
NullValueHandling = NullValueHandling.Ignore
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
InventoryManager.LoadItems();
|
InventoryManager.LoadItems();
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
using GTANetworkAPI;
|
using GTANetworkAPI;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using ReallifeGamemode.Server.Entities;
|
using ReallifeGamemode.Server.Entities;
|
||||||
using ReallifeGamemode.Server.Extensions;
|
using ReallifeGamemode.Server.Extensions;
|
||||||
using ReallifeGamemode.Server.Models;
|
using ReallifeGamemode.Server.Models;
|
||||||
|
using ReallifeGamemode.Server.Services;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -10,24 +12,25 @@ using System.Text;
|
|||||||
|
|
||||||
namespace ReallifeGamemode.Server.Managers
|
namespace ReallifeGamemode.Server.Managers
|
||||||
{
|
{
|
||||||
class HouseManager
|
class HouseManager : Script
|
||||||
{
|
{
|
||||||
private static readonly Dictionary<int, NetHandle> houseMarkers = new Dictionary<int, NetHandle>();
|
private static readonly Dictionary<int, NetHandle> houseMarkers = new Dictionary<int, NetHandle>();
|
||||||
private static readonly Dictionary<int, NetHandle> houseLabels = new Dictionary<int, NetHandle>();
|
private static readonly Dictionary<int, NetHandle> houseLabels = new Dictionary<int, NetHandle>();
|
||||||
private static readonly Dictionary<int, NetHandle> houseColShapes = new Dictionary<int, NetHandle>();
|
private static readonly Dictionary<int, NetHandle> houseColShapes = new Dictionary<int, NetHandle>();
|
||||||
|
|
||||||
public static void LoadHouses()
|
public static async void LoadHouses()
|
||||||
{
|
{
|
||||||
using (var dbContext = new DatabaseContext())
|
using (var dbContext = new DatabaseContext())
|
||||||
{
|
{
|
||||||
foreach (House house in dbContext.Houses.Include(h => h.Owner))
|
List<House> houses = await dbContext.Houses.Include(h => h.Owner).ToListAsync();
|
||||||
|
foreach (House house in houses)
|
||||||
{
|
{
|
||||||
LoadHouse(house, false);
|
LoadHouse(house, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async static void ReloadAllHouses()
|
public static async void ReloadAllHouses()
|
||||||
{
|
{
|
||||||
using (var dbContext = new DatabaseContext())
|
using (var dbContext = new DatabaseContext())
|
||||||
{
|
{
|
||||||
@@ -45,12 +48,12 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
{
|
{
|
||||||
using (dbContext = new DatabaseContext())
|
using (dbContext = new DatabaseContext())
|
||||||
{
|
{
|
||||||
return dbContext.Houses.Where(h => h.Position.DistanceTo(position) <= 5f).FirstOrDefault();
|
return dbContext.Houses.Where(h => h.Position.DistanceTo(position) <= 5f).OrderBy(h => h.Position.DistanceTo(position)).FirstOrDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return dbContext.Houses.Where(h => h.Position.DistanceTo(position) <= 5f).FirstOrDefault();
|
return dbContext.Houses.Where(h => h.Position.DistanceTo(position) <= 5f).OrderBy(h => h.Position.DistanceTo(position)).FirstOrDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,17 +77,80 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static House GetHouseById(int id, DatabaseContext dbContext = null)
|
||||||
|
{
|
||||||
|
if (dbContext == null)
|
||||||
|
{
|
||||||
|
using (dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
return dbContext.Houses.Where(h => h.Id == id).FirstOrDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return dbContext.Houses.Where(h => h.Id == id).FirstOrDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void LoadHouse(House house, bool loadUser = true)
|
public static void LoadHouse(House house, bool loadUser = true)
|
||||||
{
|
{
|
||||||
if (loadUser) house = house.Refresh();
|
if (loadUser) house = house.Refresh();
|
||||||
|
|
||||||
houseMarkers[house.Id] = NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, house.Position.Subtract(new Vector3(0, 0, 1.7)), new Vector3(), new Vector3(), 1.6f, new Color(255, 255, 255));
|
houseMarkers[house.Id] = NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, house.Position.Subtract(new Vector3(0, 0, 1.7)), new Vector3(), new Vector3(), 1.6f, new Color(255, 255, 255));
|
||||||
string text = $"~g~Zum Verkauf\n~s~{house.Type}\nPreis: ~y~{house.Price.ToMoneyString()}";
|
string text = $"~g~Zum Verkauf\n~s~{house.Type}\nPreis: ~y~{(house.Price == 0 ? "~r~Nicht verkäuflich" : house.Price.ToMoneyString())}";
|
||||||
if (house.User != null)
|
if (house.OwnerId != null)
|
||||||
{
|
{
|
||||||
text = $"{house.Type}\n~s~Besitzer: ~y~{house.User.Name}";
|
text = $"{house.Type}\n~s~Besitzer: ~y~{house.Owner.Name}\n~s~Mietpreis: ~g~{house.RentalFee.ToMoneyString()}";
|
||||||
}
|
}
|
||||||
houseLabels[house.Id] = NAPI.TextLabel.CreateTextLabel(text, house.Position, 10f, 1f, 0, new Color(255, 255, 255));
|
houseLabels[house.Id] = NAPI.TextLabel.CreateTextLabel(text, house.Position, 10f, 1f, 0, new Color(255, 255, 255));
|
||||||
|
|
||||||
|
if (house.Price != 0)
|
||||||
|
{
|
||||||
|
houseColShapes[house.Id] = NAPI.ColShape.CreateCylinderColShape(house.Position.Subtract(new Vector3(0, 0, 2)), 2.0f, 5f);
|
||||||
|
|
||||||
|
houseColShapes[house.Id].Entity<ColShape>().OnEntityEnterColShape += HouseManager_OnEntityEnterColShape;
|
||||||
|
houseColShapes[house.Id].Entity<ColShape>().OnEntityExitColShape += HouseManager_OnEntityExitColShape;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void HouseManager_OnEntityExitColShape(ColShape colShape, Client client)
|
||||||
|
{
|
||||||
|
client.TriggerEvent("SERVER:CloseHouseMenu");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void HouseManager_OnEntityEnterColShape(ColShape colShape, Client client)
|
||||||
|
{
|
||||||
|
if (!client.IsLoggedIn()) return;
|
||||||
|
if (!houseColShapes.ContainsValue(colShape.Handle))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int houseId = houseColShapes.Where(p => p.Value.Value == colShape.Handle.Value).FirstOrDefault().Key;
|
||||||
|
House house = GetHouseById(houseId);
|
||||||
|
User user = client.GetUser();
|
||||||
|
|
||||||
|
var userHouseStatus = -1;
|
||||||
|
|
||||||
|
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
if (house.OwnerId == null) userHouseStatus = 0;
|
||||||
|
else if (house.OwnerId == user?.Id) userHouseStatus = 1;
|
||||||
|
else if (dbContext.HouseRentals.Where(h => h.HouseId == houseId && h.UserId == user.Id).Count() == 1) userHouseStatus = 2;
|
||||||
|
|
||||||
|
var newHouse = new
|
||||||
|
{
|
||||||
|
house.RentalFee,
|
||||||
|
house.Price,
|
||||||
|
house.Type,
|
||||||
|
Rentals = dbContext.HouseRentals.Where(h => h.Id == houseId).Include(h => h.UserId).Select(h => new
|
||||||
|
{
|
||||||
|
h.User.Name
|
||||||
|
}).ToList()
|
||||||
|
};
|
||||||
|
|
||||||
|
client.TriggerEvent("SERVER:ShowHouseMenu", JsonConvert.SerializeObject(newHouse), userHouseStatus);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RemoveHouse(House house)
|
public static void RemoveHouse(House house)
|
||||||
@@ -100,6 +166,70 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
houseLabels[house.Id].Entity<TextLabel>().Delete();
|
houseLabels[house.Id].Entity<TextLabel>().Delete();
|
||||||
houseLabels.Remove(house.Id);
|
houseLabels.Remove(house.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (houseColShapes.ContainsKey(house.Id))
|
||||||
|
{
|
||||||
|
houseColShapes[house.Id].Entity<ColShape>().Delete();
|
||||||
|
houseColShapes.Remove(house.Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("CLIENT:House_BuyHouse")]
|
||||||
|
public void HouseManagerBuyHouseEvent(Client player)
|
||||||
|
{
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
User user = player.GetUser(dbContext);
|
||||||
|
|
||||||
|
if(user.HouseId != null)
|
||||||
|
{
|
||||||
|
ChatService.ErrorMessage(player, "Du kann nicht mehrere Häuser besitzen");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
House house = GetNearHouse(player.Position, dbContext);
|
||||||
|
|
||||||
|
var userBank = user.GetBankAccount(dbContext);
|
||||||
|
|
||||||
|
if (userBank.Balance < house.Price)
|
||||||
|
{
|
||||||
|
ChatService.ErrorMessage(player, $"Du hast nicht genug Geld für das Haus ({house.Price.ToMoneyString()})");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
house.Owner = user;
|
||||||
|
user.House = house;
|
||||||
|
|
||||||
|
userBank.Balance -= house.Price;
|
||||||
|
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
|
||||||
|
RemoveHouse(house);
|
||||||
|
LoadHouse(house);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("CLIENT:House_SetRentalFee")]
|
||||||
|
public void HouseManagerSetRentalFeeEvent(Client player, int rentalFee)
|
||||||
|
{
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
User user = player.GetUser(dbContext);
|
||||||
|
|
||||||
|
if (user.HouseId == null)
|
||||||
|
{
|
||||||
|
ChatService.ErrorMessage(player, "Du besitzt kein Haus");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
House house = GetHouseById(user.HouseId.Value, dbContext);
|
||||||
|
|
||||||
|
house.RentalFee = rentalFee;
|
||||||
|
|
||||||
|
player.SendNotification($"Der Mietpreis wurde auf ~g~{rentalFee.ToMoneyString()}~s~ gesetzt");
|
||||||
|
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1269
ReallifeGamemode.Server/Migrations/20190728142431_HouseEnhancments.Designer.cs
generated
Normal file
1269
ReallifeGamemode.Server/Migrations/20190728142431_HouseEnhancments.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,73 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Migrations
|
||||||
|
{
|
||||||
|
public partial class HouseEnhancments : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<bool>(
|
||||||
|
name: "CanRentIn",
|
||||||
|
table: "Houses",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: false);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "RentalFee",
|
||||||
|
table: "Houses",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0);
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "HouseRentals",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(nullable: false)
|
||||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
|
HouseId = table.Column<int>(nullable: true),
|
||||||
|
UserId = table.Column<int>(nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_HouseRentals", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_HouseRentals_Houses_HouseId",
|
||||||
|
column: x => x.HouseId,
|
||||||
|
principalTable: "Houses",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_HouseRentals_Users_UserId",
|
||||||
|
column: x => x.UserId,
|
||||||
|
principalTable: "Users",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_HouseRentals_HouseId",
|
||||||
|
table: "HouseRentals",
|
||||||
|
column: "HouseId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_HouseRentals_UserId",
|
||||||
|
table: "HouseRentals",
|
||||||
|
column: "UserId");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "HouseRentals");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "CanRentIn",
|
||||||
|
table: "Houses");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "RentalFee",
|
||||||
|
table: "Houses");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -463,10 +463,14 @@ namespace ReallifeGamemode.Migrations
|
|||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd();
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<bool>("CanRentIn");
|
||||||
|
|
||||||
b.Property<int?>("OwnerId");
|
b.Property<int?>("OwnerId");
|
||||||
|
|
||||||
b.Property<int>("Price");
|
b.Property<int>("Price");
|
||||||
|
|
||||||
|
b.Property<int>("RentalFee");
|
||||||
|
|
||||||
b.Property<string>("Type");
|
b.Property<string>("Type");
|
||||||
|
|
||||||
b.Property<float>("X");
|
b.Property<float>("X");
|
||||||
@@ -482,6 +486,24 @@ namespace ReallifeGamemode.Migrations
|
|||||||
b.ToTable("Houses");
|
b.ToTable("Houses");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ReallifeGamemode.Server.Entities.HouseRentals", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<int?>("HouseId");
|
||||||
|
|
||||||
|
b.Property<int?>("UserId");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("HouseId");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("HouseRentals");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("ReallifeGamemode.Server.Entities.Interior", b =>
|
modelBuilder.Entity("ReallifeGamemode.Server.Entities.Interior", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
@@ -1137,6 +1159,17 @@ namespace ReallifeGamemode.Migrations
|
|||||||
.HasForeignKey("OwnerId");
|
.HasForeignKey("OwnerId");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ReallifeGamemode.Server.Entities.HouseRentals", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ReallifeGamemode.Server.Entities.House", "House")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("HouseId");
|
||||||
|
|
||||||
|
b.HasOne("ReallifeGamemode.Server.Entities.User", "User")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId");
|
||||||
|
});
|
||||||
|
|
||||||
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")
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ namespace ReallifeGamemode.Server.Models
|
|||||||
|
|
||||||
// Houses
|
// Houses
|
||||||
public DbSet<Entities.House> Houses { get; set; }
|
public DbSet<Entities.House> Houses { get; set; }
|
||||||
|
public DbSet<Entities.HouseRentals> HouseRentals { get; set; }
|
||||||
|
|
||||||
// Bus Routes
|
// Bus Routes
|
||||||
public DbSet<Entities.BusRoute> BusRoutes { get; set; }
|
public DbSet<Entities.BusRoute> BusRoutes { get; set; }
|
||||||
|
|||||||
Reference in New Issue
Block a user