From 5be43939561dab4cf19ff177510564d63b1672c2 Mon Sep 17 00:00:00 2001 From: krystian kempski Date: Tue, 7 May 2024 00:39:19 +0200 Subject: [PATCH] Addin equipment --- .../CharacterPages/CharacterUpsert.razor.css | 2 +- .../Pages/Components/EquipmentComponent.razor | 121 +++++++++++++----- .../Components/EquipmentComponent.razor.css | 70 ++++++++-- .../Components/ProfessionComponent.razor.css | 3 +- .../Pages/Components/RaceComponent.razor.css | 3 +- .../Components/TraitsComponent.razor.css | 3 +- .../Pages/Dialogs/CharDescriptionDialog.razor | 15 ++- .../Dialogs/CharDescriptionDialog.razor.css | 17 ++- .../Pages/Dialogs/CustomEquipmentDialog.razor | 8 +- DagoniteEmpire/Service/DbInitializer.cs | 6 + 10 files changed, 189 insertions(+), 59 deletions(-) diff --git a/DagoniteEmpire/Pages/CharacterPages/CharacterUpsert.razor.css b/DagoniteEmpire/Pages/CharacterPages/CharacterUpsert.razor.css index 14a028f..201669c 100644 --- a/DagoniteEmpire/Pages/CharacterPages/CharacterUpsert.razor.css +++ b/DagoniteEmpire/Pages/CharacterPages/CharacterUpsert.razor.css @@ -8,6 +8,7 @@ border: 1px solid rgb(72, 69, 69); border-radius: 10px; margin: 6px; + padding:0 6px 0 6px; } .loading-gif{ @@ -92,7 +93,6 @@ td { display: flex; flex-direction: column; width: 450px; - height: 565px; position: relative; } diff --git a/DagoniteEmpire/Pages/Components/EquipmentComponent.razor b/DagoniteEmpire/Pages/Components/EquipmentComponent.razor index b9cf6c8..7c8d5f0 100644 --- a/DagoniteEmpire/Pages/Components/EquipmentComponent.razor +++ b/DagoniteEmpire/Pages/Components/EquipmentComponent.razor @@ -6,7 +6,7 @@ Name - Description + Count Price Weight Actions @@ -16,26 +16,54 @@ @foreach (var obj in AllParams.Equipment) { - + - - + +
+ @obj.Count +
+ + +
+
- - + + - - + + - +
+ + + + + } + + + + + + + + + + + + + + + + + @@ -66,6 +94,9 @@ private SfRichTextEditor DescrEdit = new(); + private decimal EquipmentWeight; + private decimal EquipmentPrice; + private CustomEquipmentModel _customEquipmentComponent = new(); private CustomEquipmentModel CustomEquipmentComponent @@ -109,10 +140,25 @@ } } OnTraitsChange.InvokeAsync(); + CalculateEquipWeightAndPrice(); + } if (_equipmentChosen == value) return; _equipmentChosen = value; + + } + } + + private async Task CalculateEquipWeightAndPrice() + { + EquipmentWeight = 0.0m; + EquipmentPrice = 0.0m; + foreach (var equ in AllParams.Equipment) + { + EquipmentWeight += equ.Weight; + EquipmentPrice += equ.Price; } + StateHasChanged(); } private async Task AddCustomEquipment() @@ -120,13 +166,11 @@ CustomEquipmentComponent.EquipmentDTO = new(); CustomEquipmentComponent.Traits = new List(); CustomEquipmentComponent.IsVisible = true; - StateHasChanged(); } private async Task AddExistingEquipment() { EquipmentChosen = new(); EquipmentChosen.IsVisible = true; - StateHasChanged(); } private async Task EditEquipment(EquipmentDTO equ) @@ -135,7 +179,7 @@ CustomEquipmentComponent.Traits = CustomEquipmentComponent.EquipmentDTO.Traits.OfType().ToList(); CustomEquipmentComponent.IsVisible = true; CustomEquipmentComponent.IsEditMode = true; - StateHasChanged(); + CalculateEquipWeightAndPrice(); } private async Task DeleteEquipment(EquipmentDTO equ) @@ -151,23 +195,42 @@ } AllParams.Equipment = AllParams.Equipment.Where(u => u.Name != equ.Name).ToList(); OnTraitsChange.InvokeAsync(); - StateHasChanged(); + CalculateEquipWeightAndPrice(); } - // protected override async Task OnAfterRenderAsync(bool firstRender) - // { - // if (firstRender) - // { - // if (_customEquipmentComponent.EquipmentDTO is not null) - // { - // var shortDescr = (await DescrEdit.GetTextAsync()); - // if (shortDescr is not null) - // { - // if (shortDescr.Length > 100) - // shortDescr = shortDescr?[0..100] + "..."; - // CustomEquipmentComponent.EquipmentDTO.ShortDescr = shortDescr; - // } - // } - // } - // } + + private async Task IncrCount(EquipmentDTO obj) + { + + decimal unitWeigh = obj.Weight / obj.Count; + decimal unitPrice = obj.Price / obj.Count; + obj.Count++; + obj.Weight = unitWeigh * obj.Count; + obj.Price = unitPrice * obj.Count; + + CalculateEquipWeightAndPrice(); + } + + private async Task DecrCount(EquipmentDTO obj) + { + if (obj.Count>1) + { + decimal unitWeigh = obj.Weight / obj.Count; + decimal unitPrice = obj.Price / obj.Count; + + obj.Count--; + + obj.Weight = unitWeigh * obj.Count; + obj.Price = unitPrice * obj.Count; + CalculateEquipWeightAndPrice(); + } + } + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + CalculateEquipWeightAndPrice(); + } + } } \ No newline at end of file diff --git a/DagoniteEmpire/Pages/Components/EquipmentComponent.razor.css b/DagoniteEmpire/Pages/Components/EquipmentComponent.razor.css index 47de0c1..c528092 100644 --- a/DagoniteEmpire/Pages/Components/EquipmentComponent.razor.css +++ b/DagoniteEmpire/Pages/Components/EquipmentComponent.razor.css @@ -6,13 +6,16 @@ align-items: center; } -.name-row { - width: 80px; -} -.name-label { + +.text-label { font-size: 13px; } +.name-label { + font-size: 15px; + font-weight:bold; +} + .description-row { font-size: 13px; @@ -33,16 +36,11 @@ padding: 2px; } -.add-trait { - border: 1px solid gray; - border-radius: 3px; - font-size: 14px; -} + .name-row { font-size: 13px; - width: 40px; text-align: left; - padding: 5px; + padding: 2px; vertical-align: middle; } td { @@ -73,9 +71,56 @@ h3 { flex: 2; } +.carret { + padding: 0px 0px 0px 0px; + margin: 0px 0px 0px 0px; + margin-top: 0px; + height: 18px; + width: 18px; + font-size: 18px; + color: dimgray; + border: 0px solid gray; + background-color: transparent; + text-align: start; +} + +/*arrows*/ +.control { + display: flex; + flex-direction: row; + width: 50px; + height: 30px; + justify-items: right; + align-items: center +} + +.indicator { + display: flex; + justify-content: center; + align-items: center; + border: 1px solid gray; + font-size: 12px; + border-radius: 4px; + width: 100%; + height: 28px; + margin-top: 0px; + margin-right: 2px; +} +.arrows { + display: grid; + padding: 0px; + margin: 0px; + margin-top: 2px; +} + +.nobottomborder { + border: 0px solid black; +} + + .add-trait { - border: 1px solid black; + border: 1px solid darkgray; border-radius: 6px; width: 120px; height: 32px; @@ -86,6 +131,7 @@ h3 { background-size: cover; background-position: center; font-weight: bold; + font-size: 14px; transition: transform 0.1s; } diff --git a/DagoniteEmpire/Pages/Components/ProfessionComponent.razor.css b/DagoniteEmpire/Pages/Components/ProfessionComponent.razor.css index b522e52..3d95052 100644 --- a/DagoniteEmpire/Pages/Components/ProfessionComponent.razor.css +++ b/DagoniteEmpire/Pages/Components/ProfessionComponent.razor.css @@ -56,7 +56,7 @@ h3 { } .add-trait { - border: 1px solid black; + border: 1px solid darkgray; border-radius: 6px; width: 120px; height: 32px; @@ -67,6 +67,7 @@ h3 { background-size: cover; background-position: center; font-weight: bold; + font-size: 14px; transition: transform 0.1s; } .add-trait:hover { diff --git a/DagoniteEmpire/Pages/Components/RaceComponent.razor.css b/DagoniteEmpire/Pages/Components/RaceComponent.razor.css index 9065f7b..cd50f34 100644 --- a/DagoniteEmpire/Pages/Components/RaceComponent.razor.css +++ b/DagoniteEmpire/Pages/Components/RaceComponent.razor.css @@ -91,7 +91,7 @@ h3 { } .add-trait { - border: 1px solid black; + border: 1px solid darkgray; border-radius: 6px; width: 120px; height: 32px; @@ -102,6 +102,7 @@ h3 { background-size: cover; background-position: center; font-weight: bold; + font-size: 14px; transition: transform 0.1s; } diff --git a/DagoniteEmpire/Pages/Components/TraitsComponent.razor.css b/DagoniteEmpire/Pages/Components/TraitsComponent.razor.css index feada1b..86cd08b 100644 --- a/DagoniteEmpire/Pages/Components/TraitsComponent.razor.css +++ b/DagoniteEmpire/Pages/Components/TraitsComponent.razor.css @@ -36,7 +36,7 @@ } .add-trait { - border: 1px solid black; + border: 1px solid darkgray; border-radius: 6px; width: 120px; height: 32px; @@ -47,6 +47,7 @@ background-size: cover; background-position: center; font-weight: bold; + font-size: 14px; transition: transform 0.1s; } diff --git a/DagoniteEmpire/Pages/Dialogs/CharDescriptionDialog.razor b/DagoniteEmpire/Pages/Dialogs/CharDescriptionDialog.razor index 3a3c355..58dd918 100644 --- a/DagoniteEmpire/Pages/Dialogs/CharDescriptionDialog.razor +++ b/DagoniteEmpire/Pages/Dialogs/CharDescriptionDialog.razor @@ -4,14 +4,15 @@ @* *@

DESCRIPTION

-
- - -

Here write a description of your character

-
+
+
+ + +

Here write a description of your character

+
+
+
- - diff --git a/DagoniteEmpire/Pages/Dialogs/CharDescriptionDialog.razor.css b/DagoniteEmpire/Pages/Dialogs/CharDescriptionDialog.razor.css index 7e5fed1..11745e2 100644 --- a/DagoniteEmpire/Pages/Dialogs/CharDescriptionDialog.razor.css +++ b/DagoniteEmpire/Pages/Dialogs/CharDescriptionDialog.razor.css @@ -7,13 +7,21 @@ align-items: center; margin: 0px; height: 100%; - padding: 3px; + padding: 0; z-index: 1002; } +.descr-container { + width: 100%; + display: flex; + flex-direction: column; + align-items: center; +} .description-richtext { width: 100%; - height: 100%; + flex: 2; + padding: 0; + margin: 0; } h3 { @@ -37,7 +45,7 @@ h3 { } .add-trait { - border: 1px solid black; + border: 1px solid darkgray; border-radius: 6px; width: 120px; height: 32px; @@ -48,9 +56,12 @@ h3 { background-size: cover; background-position: center; font-weight: bold; + font-size: 14px; transition: transform 0.1s; } + + .add-trait:hover { transform: scale(1.1) } \ No newline at end of file diff --git a/DagoniteEmpire/Pages/Dialogs/CustomEquipmentDialog.razor b/DagoniteEmpire/Pages/Dialogs/CustomEquipmentDialog.razor index 21d1bff..24586a8 100644 --- a/DagoniteEmpire/Pages/Dialogs/CustomEquipmentDialog.razor +++ b/DagoniteEmpire/Pages/Dialogs/CustomEquipmentDialog.razor @@ -26,11 +26,11 @@
- +
- +
@if (IsAdminOrMG) { @@ -54,11 +54,11 @@
- +
- +
@if (IsAdminOrMG) { diff --git a/DagoniteEmpire/Service/DbInitializer.cs b/DagoniteEmpire/Service/DbInitializer.cs index c174bed..799c72b 100644 --- a/DagoniteEmpire/Service/DbInitializer.cs +++ b/DagoniteEmpire/Service/DbInitializer.cs @@ -541,6 +541,7 @@ public void Initialize() { Name = "Long sword", Description = "Main tool of all adventurers", + ShortDescr = "Main tool of all adventurers", Weight = 3.0m, Price = 1.0m, IsApproved = true, @@ -554,6 +555,7 @@ public void Initialize() { Name = "Leather armor", Description = "Light but sturdy", + ShortDescr = "Light but sturdy", Weight = 10.0m, Price = 5.0m, Count = 1, @@ -569,6 +571,7 @@ public void Initialize() { Name = "Bandage", Description = "For dressing wounds", + ShortDescr = "For dressing wounds", Weight = 0.2m, Price = 0.01m, Count = 1, @@ -584,6 +587,7 @@ public void Initialize() { Name = "Wound balm", Description = "Helps with healing wounds. 20 doses, +2 to tending wounds. 1 Dose for ligth and medium wounds, 2 for heavy, and 4 for critical", + ShortDescr = "Helps with healing wounds. 20 doses, +2 to tending wounds. 1 Dose for ligth and medium wounds, 2 for heavy, and 4 for critical", Weight = 1.0m, Price = 0.1m, Count = 1, @@ -599,6 +603,7 @@ public void Initialize() { Name = "Dagger", Description = "Small and deadly", + ShortDescr = "Small and deadly", Weight = 1.0m, Price = 0.1m, Count = 1, @@ -614,6 +619,7 @@ public void Initialize() { Name = "Rope", Description = "20 feat of strong rope", + ShortDescr = "20 feat of strong rope", Weight = 5.0m, Price = 0.1m, Count = 1,