mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-15 14:12:27 +00:00
Add page to become a pirate
This commit is contained in:
parent
5fdb9b4f5c
commit
77a2d27f13
7 changed files with 106 additions and 8 deletions
|
@ -53,6 +53,8 @@ public class BaseLayout : PageModel
|
|||
if (ServerStatics.IsUnitTesting) return LocalizationManager.DefaultLang;
|
||||
if (this.language != null) return this.language;
|
||||
|
||||
if (this.User?.IsAPirate ?? false) return "en-PT";
|
||||
|
||||
IRequestCultureFeature? requestCulture = Request.HttpContext.Features.Get<IRequestCultureFeature>();
|
||||
if (requestCulture == null) return this.language = LocalizationManager.DefaultLang;
|
||||
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
@page "/pirate"
|
||||
@model LBPUnion.ProjectLighthouse.Servers.Website.Pages.PirateSignupPage
|
||||
|
||||
@{
|
||||
Layout = "Layouts/BaseLayout";
|
||||
Model.Title = "ARRRRRRRRRR!";
|
||||
}
|
||||
<!--suppress GrazieInspection -->
|
||||
|
||||
@if (!Model.User!.IsAPirate)
|
||||
{
|
||||
<p>So, ye wanna be a pirate? Well, ye came to the right place!</p>
|
||||
<p>Just click this 'ere button, and welcome aboard!</p>
|
||||
<p>If you ever wanna walk the plank, come back 'ere.</p>
|
||||
|
||||
<form method="post">
|
||||
@Html.AntiForgeryToken()
|
||||
<input type="submit" class="ui blue button" value="Aye aye, captain!"/>
|
||||
</form>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>Back so soon, aye?</p>
|
||||
<p>If you're gonna walk the plank, then do it!</p>
|
||||
|
||||
<form method="post">
|
||||
@Html.AntiForgeryToken()
|
||||
<input type="submit" class="ui red button" value="Walk the plank"/>
|
||||
</form>
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
using LBPUnion.ProjectLighthouse.PlayerData.Profiles;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages;
|
||||
|
||||
public class PirateSignupPage : BaseLayout
|
||||
{
|
||||
public PirateSignupPage(Database database) : base(database)
|
||||
{}
|
||||
|
||||
public async Task<IActionResult> OnGet()
|
||||
{
|
||||
User? user = this.Database.UserFromWebRequest(this.Request);
|
||||
if (user == null) return this.RedirectToPage("/login");
|
||||
|
||||
return this.Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPost()
|
||||
{
|
||||
User? user = this.Database.UserFromWebRequest(this.Request);
|
||||
if (user == null) return this.Redirect("/login");
|
||||
|
||||
user.IsAPirate = !user.IsAPirate;
|
||||
await this.Database.SaveChangesAsync();
|
||||
|
||||
return this.Redirect("/");
|
||||
}
|
||||
}
|
|
@ -101,6 +101,7 @@
|
|||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Affero/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=airfryer/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=ARRRRRRRRRR/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=asdf/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=BCAS/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=BCES/@EntryIndexedValue">True</s:Boolean>
|
||||
|
|
31
ProjectLighthouse/Migrations/20220802150408_Arrrrrr.cs
Normal file
31
ProjectLighthouse/Migrations/20220802150408_Arrrrrr.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using LBPUnion.ProjectLighthouse;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ProjectLighthouse.Migrations
|
||||
{
|
||||
[DbContext(typeof(Database))]
|
||||
[Migration("20220802150408_Arrrrrr")]
|
||||
public partial class Arrrrrr : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsAPirate",
|
||||
table: "Users",
|
||||
type: "tinyint(1)",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IsAPirate",
|
||||
table: "Users");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -292,8 +292,7 @@ namespace ProjectLighthouse.Migrations
|
|||
b.Property<bool>("TeamPick")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<string>("Type")
|
||||
.IsRequired()
|
||||
b.Property<int>("Type")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("SlotId");
|
||||
|
@ -429,9 +428,6 @@ namespace ProjectLighthouse.Migrations
|
|||
b.Property<DateTime>("Created")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime>("ExpiresAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("ResetToken")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
|
@ -686,6 +682,9 @@ namespace ProjectLighthouse.Migrations
|
|||
b.Property<string>("IconHash")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<bool>("IsAPirate")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<bool>("IsAdmin")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
|
@ -755,9 +754,6 @@ namespace ProjectLighthouse.Migrations
|
|||
b.Property<DateTime>("Created")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime>("ExpiresAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("Token")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
|
|
|
@ -148,6 +148,11 @@ public class User
|
|||
public string? ApprovedIPAddress { get; set; }
|
||||
#nullable disable
|
||||
|
||||
/// <summary>
|
||||
/// ARRR! Forces the user to see Pirate English translations on the website.
|
||||
/// </summary>
|
||||
public bool IsAPirate { get; set; }
|
||||
|
||||
public string Serialize(GameVersion gameVersion = GameVersion.LittleBigPlanet1)
|
||||
{
|
||||
string user = LbpSerializer.TaggedStringElement("npHandle", this.Username, "icon", this.IconHash) +
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue