diff --git a/src/CraftSharp/Components/ShopOffer.razor b/src/CraftSharp/Components/ShopOffer.razor
new file mode 100644
index 0000000..9c927e5
--- /dev/null
+++ b/src/CraftSharp/Components/ShopOffer.razor
@@ -0,0 +1,9 @@
+
+
+ @centerText
+
+

@outputAmount
+
+
\ No newline at end of file
diff --git a/src/CraftSharp/Components/ShopOffer.razor.cs b/src/CraftSharp/Components/ShopOffer.razor.cs
new file mode 100644
index 0000000..60473b1
--- /dev/null
+++ b/src/CraftSharp/Components/ShopOffer.razor.cs
@@ -0,0 +1,22 @@
+using Microsoft.AspNetCore.Components;
+
+namespace CraftSharp.Components
+{
+ public partial class ShopOffer
+ {
+ [Parameter]
+ public int inputAmount { get; set; }
+
+ [Parameter]
+ public int outputAmount{ get; set; }
+
+ [Parameter]
+ public string centerText { get; set; }
+
+ [Parameter]
+ public string inputIcon { get; set; }
+
+ [Parameter]
+ public string outputIcon { get; set; }
+ }
+}
diff --git a/src/CraftSharp/Components/ShopOffer.razor.css b/src/CraftSharp/Components/ShopOffer.razor.css
new file mode 100644
index 0000000..5546eaa
--- /dev/null
+++ b/src/CraftSharp/Components/ShopOffer.razor.css
@@ -0,0 +1,35 @@
+.offer {
+ width: 100%;
+ text-decoration: none;
+ text-align: center;
+ color: white;
+ cursor: pointer;
+ background: url('Images/btn1.png') center center/contain no-repeat;
+ background-size: 100% 100%;
+ font-family: SilkscreenNormal;
+ line-height: 26px;
+ padding-top: 6px;
+ font-family: Minecraft;
+ position: relative;
+ padding-bottom: 17px;
+}
+
+.offer:hover {
+ background: url('Images/btn2.png')center center/contain no-repeat;
+ background-size: 100% 100%;
+}
+
+
+.input {
+ position: absolute;
+ left: 5px;
+ top: 5px;
+}
+
+.output {
+ position: absolute;
+ right: 5px;
+ top: 9px;
+
+}
+
diff --git a/src/CraftSharp/Models/AppUser.cs b/src/CraftSharp/Models/AppUser.cs
index c73e3e3..b125722 100644
--- a/src/CraftSharp/Models/AppUser.cs
+++ b/src/CraftSharp/Models/AppUser.cs
@@ -4,6 +4,7 @@
{
public int Id { get; set; }
public int numberOfKeys { get; set; } = 10;
+ public int numberOfEmeralds { get; set; } = 250;
public string Password { get; set; }
public List Roles { get; set; } = new List() { UserRoles.User };
diff --git a/src/CraftSharp/Models/CurrentUser.cs b/src/CraftSharp/Models/CurrentUser.cs
index 94c2718..73ecd03 100644
--- a/src/CraftSharp/Models/CurrentUser.cs
+++ b/src/CraftSharp/Models/CurrentUser.cs
@@ -6,6 +6,7 @@
public bool IsAuthenticated { get; set; }
public string UserName { get; set; }
public int NumberOfKeys { get; set; } = 0;
+ public int numberOfEmeralds { get; set; } = 250;
public List- Inventory { get; set; } = new List
- ();
public List Roles { get; set; } = new List() { UserRoles.User };
diff --git a/src/CraftSharp/Models/ShopOfferModel.cs b/src/CraftSharp/Models/ShopOfferModel.cs
new file mode 100644
index 0000000..e5b81bc
--- /dev/null
+++ b/src/CraftSharp/Models/ShopOfferModel.cs
@@ -0,0 +1,10 @@
+namespace CraftSharp.Models
+{
+ public class ShopOfferModel
+ {
+ public string InputIconPath { get; set; }
+ public string OutputIconPath { get; set; }
+ public int InputAmount { get; set; }
+ public int OutputAmount { get; set; }
+ }
+}
diff --git a/src/CraftSharp/Pages/Opening.razor.cs b/src/CraftSharp/Pages/Opening.razor.cs
index a9c132b..5df8f28 100644
--- a/src/CraftSharp/Pages/Opening.razor.cs
+++ b/src/CraftSharp/Pages/Opening.razor.cs
@@ -27,9 +27,6 @@ namespace CraftSharp.Pages
[Inject]
public CustomStateProvider AuthService { get; set; }
- [CascadingParameter]
- public Task Context { get; set; }
-
int NumberOfKeys { get; set; } = 0;
int CostInKeys { get; set; } = 1;
@@ -45,7 +42,6 @@ namespace CraftSharp.Pages
items = await DataService.List(0, totalItem);
- var authState = await Context;
NumberOfKeys = AuthService.GetCurrentUser().NumberOfKeys;
}
diff --git a/src/CraftSharp/Pages/Shop.razor b/src/CraftSharp/Pages/Shop.razor
new file mode 100644
index 0000000..d8cd0f7
--- /dev/null
+++ b/src/CraftSharp/Pages/Shop.razor
@@ -0,0 +1,32 @@
+@using CraftSharp.Components
+
+@page "/shop"
+
+
+
+
+
+
+
+
+
+
+
+
+

+
+
+ @foreach(var offer in offers){
+
buyKeys(offer))"
+ class="@animation[offer]">
+
+
+
+ }
+
+
\ No newline at end of file
diff --git a/src/CraftSharp/Pages/Shop.razor.cs b/src/CraftSharp/Pages/Shop.razor.cs
new file mode 100644
index 0000000..0986aa6
--- /dev/null
+++ b/src/CraftSharp/Pages/Shop.razor.cs
@@ -0,0 +1,76 @@
+using CraftSharp.Models;
+using CraftSharp.Services;
+using Microsoft.AspNetCore.Components;
+using Microsoft.Extensions.Localization;
+using Microsoft.JSInterop;
+using System.Reflection.Metadata;
+
+namespace CraftSharp.Pages
+{
+ public partial class Shop
+ {
+ [Inject]
+ public CustomStateProvider AuthService { get; set; }
+
+ [Inject]
+ public IStringLocalizer Localizer { get; set; }
+
+ [Inject]
+ public IJSRuntime JsRuntime { get; set; }
+ int NumberOfEmeralds { get; set; } = 0;
+
+ List offers = new List()
+ {
+ new ShopOfferModel()
+ {
+ InputAmount=5,
+ InputIconPath="/Images/shop_icon.png",
+ OutputAmount=1,
+ OutputIconPath="/Images/opening_icon.png",
+ },
+ new ShopOfferModel()
+ {
+ InputAmount=20,
+ InputIconPath="/Images/shop_icon.png",
+ OutputAmount=5,
+ OutputIconPath="/Images/opening_icon.png",
+ },
+ new ShopOfferModel()
+ {
+ InputAmount=50,
+ InputIconPath="/Images/shop_icon.png",
+ OutputAmount=15,
+ OutputIconPath="/Images/opening_icon.png",
+ },
+ };
+
+ Dictionary animation = new Dictionary();
+
+ protected override async Task OnInitializedAsync()
+ {
+ NumberOfEmeralds = AuthService.GetCurrentUser().numberOfEmeralds;
+ foreach(ShopOfferModel offer in offers)
+ {
+ animation[offer] = "";
+ }
+ }
+
+ private async void buyKeys(ShopOfferModel offer)
+ {
+ if (offer.InputAmount <= NumberOfEmeralds)
+ {
+ NumberOfEmeralds -= offer.InputAmount;
+ AuthService.GetCurrentUser().NumberOfKeys += offer.OutputAmount;
+ }
+ else
+ {
+ animation[offer] = "buttonShake";
+ StateHasChanged();
+
+ await Task.Delay(500);
+ animation[offer] = "";
+ StateHasChanged();
+ }
+ }
+ }
+}
diff --git a/src/CraftSharp/Pages/Shop.razor.css b/src/CraftSharp/Pages/Shop.razor.css
new file mode 100644
index 0000000..25988d6
--- /dev/null
+++ b/src/CraftSharp/Pages/Shop.razor.css
@@ -0,0 +1,46 @@
+@keyframes buttonShake {
+ 0%, 100% {
+ transform: translateX(0);
+ }
+
+ 10%, 30%, 50%, 70% {
+ transform: translateX(-5px);
+ }
+
+ 20%, 40%, 60% {
+ transform: translateX(5px);
+ }
+
+ 80% {
+ transform: translateX(3px);
+ }
+
+ 90% {
+ transform: translateX(-3px);
+ }
+}
+
+.buttonShake {
+ animation: buttonShake 0.5s cubic-bezier(0.455, 0.030, 0.515, 0.955) both;
+}
+
+.NumberOfEmeralds {
+ float: right;
+ margin: 5px;
+}
+
+
+.shopPanel{
+ display:flex;
+}
+
+.offers {
+ width: 100%;
+ display: flex;
+ flex-direction: column;
+ justify-content: space-evenly;
+}
+
+.villager{
+ width: 66%
+}
diff --git a/src/CraftSharp/Resources/Pages.Shop.fr-FR.resx b/src/CraftSharp/Resources/Pages.Shop.fr-FR.resx
new file mode 100644
index 0000000..e539808
--- /dev/null
+++ b/src/CraftSharp/Resources/Pages.Shop.fr-FR.resx
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ Acheter
+
+
\ No newline at end of file
diff --git a/src/CraftSharp/Resources/Pages.Shop.resx b/src/CraftSharp/Resources/Pages.Shop.resx
new file mode 100644
index 0000000..dde836a
--- /dev/null
+++ b/src/CraftSharp/Resources/Pages.Shop.resx
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ Buy
+
+
\ No newline at end of file
diff --git a/src/CraftSharp/Resources/Pages.Shop.tr-TR.resx b/src/CraftSharp/Resources/Pages.Shop.tr-TR.resx
new file mode 100644
index 0000000..a8a58fe
--- /dev/null
+++ b/src/CraftSharp/Resources/Pages.Shop.tr-TR.resx
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ Satın almak
+
+
\ No newline at end of file
diff --git a/src/CraftSharp/Services/AuthService.cs b/src/CraftSharp/Services/AuthService.cs
index 50c2c55..5652c56 100644
--- a/src/CraftSharp/Services/AuthService.cs
+++ b/src/CraftSharp/Services/AuthService.cs
@@ -11,23 +11,10 @@ namespace CraftSharp.Services
static AuthService()
{
CurrentUser = new List
- {
- new AppUser { UserName = "Admin", Password = "123456", Roles = new List { UserRoles.Admin }, numberOfKeys=999 }
- };
- }
-/* public AppUser GetCurrentUser(string userName)
- {
- var user = CurrentUser.FirstOrDefault(w => w.UserName == userName);
-
- if (user == null)
{
- throw new Exception("User name or password invalid !");
- }
-
- return user;
- }*/
-
-
+ new AppUser { UserName = "Admin", Password = "123456", Roles = new List { UserRoles.Admin }, numberOfKeys=999 }
+ };
+ }
public CurrentUser GetUser(string userName)
{
var user = CurrentUser.FirstOrDefault(w => w.UserName == userName);
@@ -45,6 +32,7 @@ namespace CraftSharp.Services
IsAuthenticated = true,
UserName = user.UserName,
NumberOfKeys = user.numberOfKeys,
+ numberOfEmeralds = user.numberOfEmeralds,
Inventory = user.inventory,
Roles = user.Roles,
Claims = claims.ToDictionary(c => c.Type, c => c.Value)
diff --git a/src/CraftSharp/Services/IAuthService.cs b/src/CraftSharp/Services/IAuthService.cs
index 255eb81..605a089 100644
--- a/src/CraftSharp/Services/IAuthService.cs
+++ b/src/CraftSharp/Services/IAuthService.cs
@@ -5,9 +5,7 @@ namespace CraftSharp.Services
public interface IAuthService
{
CurrentUser GetUser(string userName);
-
void Login(ConnexionModel loginRequest);
-
void Register(InscriptionModel registerRequest);
}
}
diff --git a/src/CraftSharp/wwwroot/Images/villager.png b/src/CraftSharp/wwwroot/Images/villager.png
new file mode 100644
index 0000000..238a501
Binary files /dev/null and b/src/CraftSharp/wwwroot/Images/villager.png differ