diff --git a/ServerCore/Pages/Puzzles/Create.cshtml b/ServerCore/Pages/Puzzles/Create.cshtml index e2ef18ec..fe035c6f 100644 --- a/ServerCore/Pages/Puzzles/Create.cshtml +++ b/ServerCore/Pages/Puzzles/Create.cshtml @@ -24,49 +24,6 @@ -
-
- -
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
- - - -
-
- - - -
-
- - - -
@@ -78,41 +35,9 @@
-
- -
-
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - + + +
@@ -121,8 +46,6 @@
- - @section Scripts { @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} } diff --git a/ServerCore/Pages/Puzzles/Create.cshtml.cs b/ServerCore/Pages/Puzzles/Create.cshtml.cs index e424de70..e6d8483a 100644 --- a/ServerCore/Pages/Puzzles/Create.cshtml.cs +++ b/ServerCore/Pages/Puzzles/Create.cshtml.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System.ComponentModel.DataAnnotations; +using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; @@ -11,7 +12,7 @@ namespace ServerCore.Pages.Puzzles public class CreateModel : EventSpecificPageModel { [BindProperty] - public Puzzle Puzzle { get; set; } + public MiniPuzzle Puzzle { get; set; } public CreateModel(PuzzleServerContext serverContext, UserManager userManager) : base(serverContext, userManager) { @@ -20,31 +21,83 @@ public CreateModel(PuzzleServerContext serverContext, UserManager public IActionResult OnGet() { // Populate default fields - Puzzle = new Puzzle(); - Puzzle.IsPuzzle = true; - Puzzle.SolveValue = 10; - Puzzle.OrderInGroup = 0; - Puzzle.MinPrerequisiteCount = 0; + Puzzle = new MiniPuzzle(); return Page(); } public async Task OnPostAsync() { - ModelState.Remove("Puzzle.Event"); if (!ModelState.IsValid) { return Page(); } - Puzzle.Event = Event; + Puzzle p = new Puzzle(); - _context.Puzzles.Add(Puzzle); - _context.PuzzleAuthors.Add(new PuzzleAuthors() { Puzzle = Puzzle, Author = LoggedInUser }); + p.Event = Event; + p.Name = Puzzle.Name; + p.Group = Puzzle.Group; + p.OrderInGroup = Puzzle.OrderInGroup; + + switch (Puzzle.Type) + { + case PuzzleType.FinalMetaPuzzle: + p.IsFinalPuzzle = true; + p.IsMetaPuzzle = true; + p.IsPuzzle = true; + p.SolveValue = 1000; + p.MinPrerequisiteCount = 1; + break; + case PuzzleType.MetaPuzzle: + p.IsMetaPuzzle = true; + p.IsPuzzle = true; + p.SolveValue = 50; + p.MinPrerequisiteCount = 1; + break; + case PuzzleType.CheatCode: + p.IsPuzzle = true; + p.IsCheatCode = true; + p.SolveValue = -1; + p.MinPrerequisiteCount = 1; + break; + case PuzzleType.NormalPuzzle: + p.IsPuzzle = true; + p.SolveValue = 10; + p.MinPrerequisiteCount = 1; + break; + case PuzzleType.InvisiblePuzzle: + p.MinPrerequisiteCount = 1; + break; + case PuzzleType.StartPuzzle: + break; + } + + _context.Puzzles.Add(p); + _context.PuzzleAuthors.Add(new PuzzleAuthors() { Puzzle = p, Author = LoggedInUser }); await _context.SaveChangesAsync(); - return RedirectToPage("./Index"); + return RedirectToPage("./Edit", new { puzzleId = p.ID }); + } + + public class MiniPuzzle + { + [Required] + public string Name { get; set; } + public string Group { get; set; } + public int OrderInGroup { get; set; } + public PuzzleType Type { get; set; } + } + + public enum PuzzleType + { + NormalPuzzle, + MetaPuzzle, + FinalMetaPuzzle, + CheatCode, + StartPuzzle, + InvisiblePuzzle } } } \ No newline at end of file diff --git a/ServerCore/Pages/Puzzles/Edit.cshtml b/ServerCore/Pages/Puzzles/Edit.cshtml index 625e0d1f..28e0eaee 100644 --- a/ServerCore/Pages/Puzzles/Edit.cshtml +++ b/ServerCore/Pages/Puzzles/Edit.cshtml @@ -10,125 +10,135 @@ Layout = "_puzzleManagementLayout.cshtml"; } -

@Model.Puzzle.Name: Edit

- -
- Cancel -
- -
-

Properties

-
+
+

@Model.Puzzle.Name: Properties

-
- - - -
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
-
- -
-
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- -
+ + + + + + + + + + + + + + +
+ Basic + + Advanced +
+
+ + + +
+
+ + + +
+
+ + + +
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+ + + +
+
+ + + +
+
+ + + +
+
+
+
+ +
+
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
-
-

Prerequisites

+

@Model.Puzzle.Name: Prerequisites

These puzzles help to unlock me:

@@ -196,8 +206,8 @@
-
-

Authors

+
+

@Model.Puzzle.Name: Authors