Compare commits

...

98 Commits

Author SHA1 Message Date
Emre KARTAL 40c5239b0f Fixed README errors
2 years ago
Emre KARTAL b4ffdeb9a3 Update README, Added explanation of how the app works
2 years ago
Emre KARTAL 26d7173167 Transférer les fichiers vers 'doc/Images'
2 years ago
Emre KARTAL a477f62c43 Uptade README
2 years ago
Emre KARTAL 532288f95d Added more image for explanation in README
2 years ago
Emre KARTAL 01dc4505f5 Adding a CI file
2 years ago
Emre KARTAL 9297be76f1 Image Correction
2 years ago
Arthur VALIN 86bf90927f Merge pull request 'arthur_misc' (#25) from arthur_misc into master
2 years ago
Arthur VALIN d7a487adab Adding localization to error view
2 years ago
Arthur VALIN 3742924748 creating separate code for unknown page
2 years ago
Emre KARTAL a37fbfe3ca Added application operation in the README
2 years ago
Emre KARTAL 885efdaabb Added more new images for the Readme
2 years ago
Arthur VALIN 8881c0f4be Correcting registration bug
2 years ago
Arthur VALIN 99fc95ca3d Edit resources
2 years ago
Emre KARTAL 0b45c8a73c Added Images for the Readme
2 years ago
Emre KARTAL 7628efc340 (Merge) Realization of the localization on the Login and Registration pages (#24) from Emre_LanguePageConnectionInscription into master
2 years ago
Emre KARTAL 725c19cd6f Realization of the localization on the Login and Registration pages
2 years ago
Emre KARTAL c22fd74fe1 (Merge) Deleting an item works (#23) from Emre_DeleteItem into master
2 years ago
Emre KARTAL a153ffcb79 Deleting an item works
2 years ago
Arthur VALIN 3cd454ae36 Merge pull request 'arthur_errorview' (#22) from arthur_errorview into master
2 years ago
Arthur VALIN 871816f192 Adding error handler
2 years ago
Emre KARTAL 57bebfc958 (Merge) Added background sound and languages ​​for the crafting table page (#21) from Emre_SonEtLanguePageCraft into master
2 years ago
Emre KARTAL 54543d44fd Added background sound and languages ​​for the crafting table page
2 years ago
Arthur VALIN 7abf0c6240 Adding ErrorLayout
2 years ago
Arthur VALIN ab45651328 Merge pull request 'arthur_logs' (#20) from arthur_logs into master
2 years ago
Arthur VALIN d078305d4f Adding DataApi Log and Debug logs
2 years ago
Arthur VALIN 9c7c0d044e Adding auth logs
2 years ago
Arthur VALIN 3ba2cba88f Merge pull request 'arthur_usercookies' (#19) from arthur_usercookies into master
2 years ago
Arthur VALIN db3d01df6f Correcting bug in shop and in opening
2 years ago
Arthur VALIN 1af61f0c5d Automatic connexion
2 years ago
Arthur VALIN 249df5cfe0 Protection routes
2 years ago
Arthur VALIN 7a0a4e4204 updating auth
2 years ago
Arthur VALIN 4b31e3ff78 Adding cookie authentication
2 years ago
Arthur VALIN 410c7cd4c2 Creating UserController
2 years ago
Arthur VALIN 07ce065627 merge shop
2 years ago
Emre KARTAL 5d648425b6 (Merge) Inventory done, the addition of an item in the inventory via the chest and adjustment of the duplication and the deletion on the crafting table is also done, and the improvement of the view of the list of items has been made ' (#17) from Emre_Inventaire into master
2 years ago
Emre KARTAL f9d0dd8513 Inventory done, the addition of an item in the inventory via the chest and adjustment of the duplication and the deletion on the crafting table is also done, and the improvement of the view of the list of items has been made
2 years ago
Arthur VALIN 11b4bb7d45 Edit visuals
2 years ago
Arthur VALIN b68b1cbe7c Edit visuals for shop
2 years ago
Arthur VALIN f9bd286b23 Adding working shop page
2 years ago
Arthur VALIN dc934f727c Merge pull request 'arthur_menu' (#16) from arthur_menu into master
2 years ago
Arthur VALIN 3b96b44989 Misc
2 years ago
Arthur VALIN 7883166abe Correcting bug with GetCurrentUser function
2 years ago
Arthur VALIN 905db68161 Adding admin option to the menu
2 years ago
Arthur VALIN 27bf855998 Merge pull request 'Update user class and Add key system to the openings' (#15) from arthur_userkeys into master
2 years ago
Arthur VALIN 18df6e40c6 Merge branch 'master' into arthur_userkeys
2 years ago
Arthur VALIN 89df124ba8 Update user class and Add key system to the openings
2 years ago
Rayhân HASSOU 2f7ed1c01a Merge pull request 'modif probleme lors du chagement de langue' (#14) from modif into master
2 years ago
Rayhân HASSOU 9c0d49f079 modif probleme lors du chagement de langue
2 years ago
Arthur VALIN 1b502e73d6 Merge branch 'master' of https://codefirst.iut.uca.fr/git/rayhan.hassou/Projet_Blazor
2 years ago
Arthur VALIN bed4a8e2f7 merge arthur_opening
2 years ago
Arthur VALIN 1697d3a900 Update opening visuals and craftlayout
2 years ago
Arthur VALIN 1f21598656 Update opening animation
2 years ago
Arthur VALIN 41c947b0e2 Starting creation of Opening page
2 years ago
Rayhân HASSOU 690ae940ca Merge pull request 'log' (#12) from log into master
2 years ago
Rayhân HASSOU e1aca0e715 log
2 years ago
Emre KARTAL 71055aa9db Distribution of documentation and addition of the use case diagram (small push)
2 years ago
Arthur VALIN 6633055249 Merge branch 'arthur'
2 years ago
Rayhân HASSOU b284b2188a Merge pull request 'inscription_fonctionnelle' (#11) from inscription_fonctionnelle into master
2 years ago
rahassou 124bfb8074 modif
2 years ago
rahassou d5fe0df397 Connexion et inscription marche
2 years ago
rahassou 7255cd2aed Ajout models et page
2 years ago
Emre KARTAL 54a6d4f9c4 Addition of the shop model and chest opening
2 years ago
Clément LAPORTE eb5977b570 finish craftlayout according to initial model
2 years ago
Emre KARTAL e52800b920 Merge pull request 'Realization of the "Craft Table" page (it works)' (#9) from Emre_TableDeCraft into master
2 years ago
Emre KARTAL f8963bb662 Realization of the "Craft Table" page (it works)
2 years ago
Emre KARTAL 8d8b37aaee Mise à jour de 'README.md'
2 years ago
Emre KARTAL 422550f2c2 Mise à jour de 'README.md'
2 years ago
Emre KARTAL 60c1aea3d5 Mise à jour de 'README.md'
2 years ago
Emre KARTAL dc4bebc057 Mise à jour de 'README.md'
2 years ago
Emre KARTAL cecfa3e049 Mise à jour de 'README.md'
2 years ago
Emre KARTAL 92b2a04999 Mise à jour de 'README.md'
2 years ago
Emre KARTAL 76ad80fdb8 Mise à jour de 'README.md'
2 years ago
Arthur VALIN 99533e3408 edit header style
2 years ago
Rayhân HASSOU c2ee0f5797 Merge pull request 'ajout de la page connexion et inscription' (#8) from rayhan into master
2 years ago
rahassou 50c3f428ca ajout de la page connexion et inscription
2 years ago
Emre KARTAL 2dbb56e681 Merge pull request 'Affichage des listes de l'Api fait et traduction des titres de la page List fait ' (#7) from Emre_ApiListe into master
2 years ago
Emre KARTAL a479fef2c0 Affichage des listes de l'Api fait et traduction des titres de la page List fait
2 years ago
Emre KARTAL 0d0dab1263 Ajout des List, Des fonctionnalités Ajouter, Suprimer, Editer... Pas de connexion à l'API pour l'instant
2 years ago
arthur.valin 3202354037 save
2 years ago
arthur.valin 1e32c18d94 Start updating style of header
2 years ago
arthur.valin 3991b1127e Add icon resources
2 years ago
Emre KARTAL ec55936591 Merge pull request 'Creation de la page List et des localizer qui sont avec, plus l'ajout de la page dans le HeaderLayout' (#4) from Emre_ListInventaire into master
2 years ago
Emre KARTAL aa369d75d2 Creation de la page List et des localizer qui sont avec, plus l'ajout de la page dans le HeaderLayout
2 years ago
arthur.valin 9018cf60d9 Merge branch 'arthur'
2 years ago
arthur.valin 372f926ed9 Adding api to solution
2 years ago
arthur.valin cde7cca0e5 Adding API project
2 years ago
Arthur VALIN bd71463df9 Mise à jour de 'src/CraftSharp/CraftSharp.csproj'
2 years ago
Arthur VALIN 017dc3c092 Mise à jour de 'src/CraftSharp/CraftSharp.csproj'
2 years ago
arthur.valin c9ae9a5e4b Merge branch 'arthur_classes'
2 years ago
arthur.valin 93dfd84ee7 Updating csproj
2 years ago
arthur.valin f28ee32cca Adding DataService and Crafting Components
2 years ago
emkartal1 e73355af8c Ajout du layout et du navbar
2 years ago
Arthur VALIN 093d1050c9 starting api
2 years ago
Emre KARTAL 58496cddf0 Merge pull request 'Modification des Layout, ajout de bouton, changement de coulour, ajout d'image...' (#2) from Emre_Layout into master
2 years ago
Emre KARTAL 0b201bc54e Modification des Layout, ajout de bouton, changement de coulour, ajout d'image...
2 years ago
Arthur VALIN 2cb9fb797a Add item classes
2 years ago
Arthur VALIN ea5e7f3189 Merge pull request 'arthur_localisation' (#1) from arthur_localisation into master
2 years ago

@ -0,0 +1,22 @@
kind: pipeline
type: docker
name: default
trigger:
event:
- push
steps:
- name: build
image: mcr.microsoft.com/dotnet/sdk:6.0
commands:
- cd src/CraftSharp
- dotnet restore CraftSharp.sln
- dotnet build CraftSharp.sln -c Release --no-restore
- name: tests
image: mcr.microsoft.com/dotnet/sdk:6.0
commands:
- cd src/CraftSharp
- dotnet restore CraftSharp.sln
- dotnet test CraftSharp.sln --no-restore
depends_on: [build]

@ -1,38 +1,280 @@
# Projet_Blazor
<div align = center>
**<p align="center">
![Image de l'application](CraftSharp-Logo.png)
</p>**
**Nom de lapplication** : Craft#
</div>
**Nom de lapplication** : Craft# 🕹
</br>
**Thème de lapplication** : Répertorier son inventaire.
</br>
**Récapitulation de notre application** :
**Récapitulation de notre application** : 👇
</br>
:information_source: Une application Web dans le thème de minecraft, dans lequel les utilisateur pourront Répertorier leur item, crafter, ajouter ...
:information_source: Une application Web dans le thème de Minecraft, dans lequel les utilisateurs pourront répertorier leur item, crafter, acheter ...
# Repartition du Gitlab
# Répartition du Gitlab
La racine de notre gitlab est composé de deux dossiers essentiels au projet:
La racine de notre gitlab est composée de deux dossiers essentiels au projet:
[**src**](src) : **Toute la partie codage de l'application web**
[**doc**](doc) : **Documentation de l'application**
[**Solution de l'application**](src/CraftSharp/CraftSharp.sln) : **Documentation de l'application**
👉 [**Solution de l'application**](src/CraftSharp/CraftSharp.sln)
# Fonctionnement
- ### Comment lancer le projet ?
Tout d'abord si ce n'est pas fait cloner le dépôt de la branche **master/main**, pour cela copier le lien URL du dépôt git :
<div align = center>
![Comment cloner](doc/Images/HowToClone.png)
</div>
Puis aller sur Visual Studio et cloner en entrant le lien :
<div align = center>
![Ou mettre sur Visual studio](doc/Images/CloneVS.png)
</div>
<br>
:information_source: *Si vous ne disposez pas de Visual Studio, allé sur le site [Microsoft Visual Studio](https://visualstudio.microsoft.com/fr/downloads/) pour pouvoir le télécharger !!!*
<br>
Une fois cela fait, cliquer sur la solution du projet **CraftSharp.sln**, il devra être normalement affiché en haut à droite de Visual studio :
<div align = center>
![Page Visual studio](doc/Images/PageVS.png)
</div>
:information_source: *Si ce n'est pas le cas aller dans l'onglet **affichage** puis cliquer sur **Explorateur de solutions**, si le problème persiste recommencer le clone ou vérifier que vous avez la bonne version de Visual studio !!!*
Maintenant il ne reste plus qu'à le lancer ! Pour cela cliquer sur la **Solution** et aller dans les propriétés :
<div align = center>
![Comment accéder aux propriétés de l'application](doc/Images/PropriétésApplication.png)
</div>
Et pour finir rajouter les modifications suivantes pour lancer les plusieurs projets au démarrage :
<div align = center>
![Comment lancer les plusieurs projets de démarrage](doc/Images/DémarrerProjet.png)
</div>
Maintenant il ne reste plus qu'à lancer l'application :satisfied:
<div align = center>
![HowToLaunch](doc/Images/LancerApplication.png)
</div>
- ### Comment changer la langue ?
Notre application possède plusieurs langue tel que :
- L'anglais
- Le français
- Le turc
Si vous êtes plus habilités avec une plus que les autres, vous pouvez la changer dans la page **Connexion** et **Inscription** en cliquant juste en haut à gauche de la page :
<div align = center>
![HowToChange](doc/Images/ChangerLangue1.png)
</div>
Pour les autres, il se trouvera tout en bas à gauche de la page :
<div align = center>
![HowToChange](doc/Images/ChangerLangue2.png)
</div>
- ### Comment fonctionne l'application ?
Pas très compliqué! Tout d'abord il est à savoir qu'il existe deux utilisateurs différents avec des droits qui sont aussi différents (Même si ce n'est pas tant que sa):
- L'utilisateur simple qui s'est inscrit sur l'application via le formulaire d'inscription.
- L'admin enregistrer directement dans l'application (Il n'y a pas de formulaire d'inscription pour être admin), qui lui à en plus la possibilité d'accéder directement avec l'API.
Vous voulez être Admin et profiter pleinement des fonctionnalités de l'Application, voici un compte avec lequel vous pourrez vous connecter:
-**pseudonyme** : Admin
-**Mot de passe** : 123456
En effet on retrouve deux menus différents pour les deux utilisateurs:
- Pour l'utilisateur simple:
<div align = center>
![utilisateurMenu](doc/Images/VueUtilisateur.png)
</div>
- Pour l'admin:
<div align = center>
![adminMenu](doc/Images/VueAdmin.png)
</div>
La page **Admin** (qu'y est comme son nom l'indique que pour l'admin) permet de voir tous les items de l'API (et leur spécificités), mais pas seulement il peut si il le souhaite ajouter un nouveau, en supprime un qui ne lui pas plaît modifier, tout cela en navigant simplement et efficacement grâce à une pagination :
<div align = center>
![Liste Page](doc/Images/ListePage.png)
</div>
Tandis que pour les autres pages, ils sont les mêmes que celui d'un utilisateur simple !
On retrouve tout d'abord la page **Boutique/Magasin**, un utilisateur lors de son inscription possède déjà *250 Émeraude*, qui sont l'argent nécessaire pour acheter des clés, il peut en acheter soit acheter par 5, par 20 ou bien par 50 :
<div align = center>
![Vue de la boutique](doc/Images/PageBoutique.png)
</div>
Puis grâce à ces clés qu'il accumule, il peut ouvrir des coffres pour avoir des items (fantastique non?) dans la page **Ouverture** qui se trouve dans le menu :
<div align = center>
![Vue du coffre](doc/Images/PageCoffre.png)
</div>
Lorsqu'on clique sur *Ouvrir* (il faut aussi prendre en compte qu'on perd une clé à chaque fois que l'on ouvre un coffre) :
<div align = center>
![Vue du coffre ouvert](doc/Images/PageCoffreOuverture.png)
</div>
Une fois après avoir eu plein d'items, il peut aller dans la page **Inventaire** situé dans le menu, pour retrouver son inventaire avec tous les items qu'il à accumuler et crafter ce que bon lui semble (Il existe des milliers de combinaisons possible! pour les connaîtres voici un [site](https://fr-minecraft.net/5-aide-crafting-sur-minecraft.php) qui les regroupes tous), il a aussi la possibilité de supprimer un item de son inventaire en glissant l'objet dans la *corbeille*:
<div align = center>
![Vue du coffre ouvert](doc/Images/PageCraft.png)
</div>
Ai-je vraiment besoin d'expliquer le bouton **Déconnexion** ?!
- ### Gestion des erreurs
Maintenant passons à la gestion des erreurs sur notre application !
<br>
Commençons par la page **Connexion** et **Inscription**, comme toute bonne application, nous veillons à faire attention :
-A si le pseudonyme qu'on choisit lors de l'inscription n'existe pas :
<div align = center>
![Erreur pseudonyme déjà utiliser](doc/Images/GestionErreur1.png)
</div>
-A vérifier la connexion (En cas de pseudonyme ou mot de passe incorrect) :
<div align = center>
![Erreur pseudonyme ou mot de passe](doc/Images/GestionErreur2.png)
</div>
-Mais aussi la taille des éléments qu'on rentre lors de l'inscription et la confirmation du mot de passe :
<div align = center>
![Erreur Taille Inscription](doc/Images/GestionErreur3.png)
</div>
-Une erreur un peu plus spécifique qui a était gérer, est dans le cas où un utilisateur souhaite accéder à une page qui n'existe pas:
<div align = center>
![Erreur Url inexistant](doc/Images/GestionErreurUrl.png)
</div>
:information_source: Va être alors redirigé sur une page d'erreur qui au bout de 5secondes le ramènera à la page d'accueil.
- ### Comment ça marche au niveau du code ?
<div align = center>
![Erreur Url inexistant](doc/Images/CodeApplication.png)
</div>
Nous avons tout d'abord, dans la solution deux grands projets, un qui est l'api qui va contenir tous les objets(**Minecraft.Crafting.Api**) et l'autre qui regroupe tout le code de notre application qui va utiliser l'API (**CraftSharp**) !
Notre application est composée de plusieurs dossiers et fichier importants :
- **Program.cs** : Il contient le code qui est exécuté lorsque l'application est lancée et qui configure les différents composants de l'application, tels que les services et les middlewares.
- **_Imports.razor** : Il contient des directives de compilation Razor qui indiquent à Blazor les assemblys et les espaces de noms à inclure dans le projet.
- **App.razor** : Il définit la structure de base de l'application et inclut des composants tels que le menu de navigation, la barre latérale, le contenu principal de l'application et la sélection des langues.
- **Componants** : Dossier qui contient tous les composants, qui sont des unités de code réutilisables dans notre application Blazor qui permettent de définir une interface utilisateur et un comportement spécifiques. Tel que le componant **CraftingItem** qui permet de contenir un item et qui va être utilisé plusieurs fois...
- **wwwroot** : Dossier de l'application qui contient les fichiers statiques qui sont accessibles par les utilisateurs, tels que les fichiers HTML, CSS, JavaScript, les images et les audios. Ces fichiers sont généralement servis directement par le serveur web sans passer par le code de l'application.
- **Ressources** : Dossier qui va stocker des fichiers de ressources, tels que des fichiers de traduction.
- **Shared** : Dossier de l'application qui contient des composants et des pages qui sont partagés par plusieurs pages et composants de l'application.
- **Pages** : Contient toutes les pages (HTML et CS).
- **Services** : Dossier qui contient des classes de service qui sont utilisées pour fournir des fonctionnalités spécifiques à l'application. Telles que l'accès aux données, la gestion des utilisateurs ou la communication avec des API externes.
- **Models** : Dossier qui va stocker les classes de modèle qui sont utilisées pour représenter les données de l'application et qui peuvent être utilisées par différents composants et pages de l'application. Pour permettre de structurer les données de l'application de manière cohérente et faciliter leur utilisation dans le code de l'application.
- **Modals** : Dossier qui contient des classes de modèle qui représentent les données utilisées par l'application. Tel que la classe *Item* qui va contenir toutes les informations d'un item dans l'API.
- **Factories** : Dossier qui contient toutes les classes de factory qui sont utilisées pour créer des objets de données ou des services.
Globalement Blazor est un framework MVVM, un patron de conception qui peut être utilisé pour structurer une application Blazor en séparant la logique de présentation de l'interface utilisateur de la logique de données et de traitement. Selon ce patron de conception, l'interface utilisateur de l'application est représentée par une vue (View), qui est généralement définie en utilisant du code HTML et des composants Blazor. La logique de données et de traitement de l'application est représentée par un modèle (Model), qui peut être défini en utilisant des classes de modèle C#.
Le troisième élément du patron MVVM est le ViewModel, qui est une classe C# qui joue le rôle d'intermédiaire entre la vue et le modèle. Le ViewModel expose les données et les commandes de l'application de manière adaptée à la vue, en utilisant des propriétés et des méthodes qui sont accessibles depuis la vue. Il peut également être utilisé pour effectuer des opérations de traitement de données avant de les envoyer au modèle ou pour mettre à jour le modèle en fonction des actions de l'utilisateur.
# Environnement de Travail
Notre environnement de travail se base essentiellement sur du HTML, C# (via Blazor)
Notre environnement de travail se base sur plusieurs outils :👇
<div align = center>
---
&nbsp; ![HTML](https://img.shields.io/badge/HTML-000?style=for-the-badge&logo=html5&logoColor=white&color=orange)
&nbsp; ![CSS](https://img.shields.io/badge/CSS-000?style=for-the-badge&logo=css3&logoColor=white&color=darkblue)
&nbsp; ![Blazor](https://img.shields.io/badge/Blazor-000?style=for-the-badge&logo=blazor&logoColor=white&color=purple)
&nbsp; ![C#](https://img.shields.io/badge/Csharp-000?style=for-the-badge&logo=csharp&logoColor=white&color=blue)
---
</div>
# Technicien en charge de l'application
La composition pour le projet se voit réaliser par trois élèves de l'IUT d'aubière:
- Emre KARTAL (Groupe 4)
- Rayhan HASSOU (Groupe 4)
- Arthur VALIN (Groupe 4)
La composition pour le projet se voit réaliser par trois élèves de l'IUT d'Aubière:
<br>
⚙️ Emre KARTAL
<br>
⚙️ Rayhan HASSOU
<br>
⚙️ Arthur VALIN
<div align = center>
© Groupe 4
</div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 743 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 768 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 570 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 852 KiB

Before

Width:  |  Height:  |  Size: 587 KiB

After

Width:  |  Height:  |  Size: 587 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 877 KiB

@ -0,0 +1,449 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="CraftingController.cs" company="UCA Clermont-Ferrand">
// Copyright (c) UCA Clermont-Ferrand All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace Minecraft.Crafting.Api.Controllers
{
using Microsoft.AspNetCore.Mvc;
using Minecraft.Crafting.Api.Models;
using System.Text.Json;
using System.Text.Json.Serialization;
/// <summary>
/// The crafting controller.
/// </summary>
[ApiController]
[Route("api/[controller]")]
public class CraftingController : ControllerBase
{
/// <summary>
/// The json serializer options.
/// </summary>
private readonly JsonSerializerOptions _jsonSerializerOptions = new()
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
WriteIndented = true,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault
};
/// <summary>
/// Adds the specified item.
/// </summary>
/// <param name="item">The item.</param>
/// <returns>The async task.</returns>
[HttpPost]
[Route("")]
public Task Add(Item item)
{
var data = JsonSerializer.Deserialize<List<Item>>(System.IO.File.ReadAllText("Data/items.json"), _jsonSerializerOptions);
if (data == null)
{
throw new Exception("Unable to get the items.");
}
data.Add(item);
System.IO.File.WriteAllText("Data/items.json", JsonSerializer.Serialize(data, _jsonSerializerOptions));
return Task.CompletedTask;
}
/// <summary>
/// Get all items.
/// </summary>
/// <returns>All items.</returns>
[HttpGet]
[Route("all")]
public Task<List<Item>> All()
{
var data = JsonSerializer.Deserialize<List<Item>>(System.IO.File.ReadAllText("Data/items.json"), _jsonSerializerOptions);
if (data == null)
{
throw new Exception("Unable to get the items.");
}
return Task.FromResult(data.ToList());
}
/// <summary>
/// Count the number of items.
/// </summary>
/// <returns>The number of items.</returns>
[HttpGet]
[Route("count")]
public Task<int> Count()
{
var data = JsonSerializer.Deserialize<List<Item>>(System.IO.File.ReadAllText("Data/items.json"), _jsonSerializerOptions);
if (data == null)
{
throw new Exception("Unable to get the items.");
}
return Task.FromResult(data.Count);
}
/// <summary>
/// Deletes the specified identifier.
/// </summary>
/// <param name="id">The identifier.</param>
/// <returns>The async task.</returns>
[HttpDelete]
[Route("{id}")]
public Task Delete(int id)
{
var data = JsonSerializer.Deserialize<List<Item>>(System.IO.File.ReadAllText("Data/items.json"), _jsonSerializerOptions);
if (data == null)
{
throw new Exception("Unable to get the items.");
}
var item = data.FirstOrDefault(w => w.Id == id);
if (item == null)
{
throw new Exception($"Unable to found the item with ID: {id}");
}
data.Remove(item);
System.IO.File.WriteAllText("Data/items.json", JsonSerializer.Serialize(data, _jsonSerializerOptions));
return Task.CompletedTask;
}
/// <summary>
/// Gets the item by identifier.
/// </summary>
/// <param name="id">The identifier.</param>
/// <returns>The item.</returns>
[HttpGet]
[Route("{id}")]
public Task<Item> GetById(int id)
{
var data = JsonSerializer.Deserialize<List<Item>>(System.IO.File.ReadAllText("Data/items.json"), _jsonSerializerOptions);
if (data == null)
{
throw new Exception("Unable to get the items.");
}
var item = data.FirstOrDefault(w => w.Id == id);
if (item == null)
{
throw new Exception($"Unable to found the item with ID: {id}");
}
return Task.FromResult(item);
}
/// <summary>
/// Gets the item by name.
/// </summary>
/// <param name="name">The name.</param>
/// <returns>
/// The item.
/// </returns>
[HttpGet]
[Route("by-name/{name}")]
public Task<Item> GetByName(string name)
{
var data = JsonSerializer.Deserialize<List<Item>>(System.IO.File.ReadAllText("Data/items.json"), _jsonSerializerOptions);
if (data == null)
{
throw new Exception("Unable to get the items.");
}
var item = data.FirstOrDefault(w => w.Name.ToLowerInvariant() == name.ToLowerInvariant());
if (item == null)
{
throw new Exception($"Unable to found the item with name: {name}");
}
return Task.FromResult(item);
}
/// <summary>
/// Gets the recipes.
/// </summary>
/// <returns>The recipes.</returns>
[HttpGet]
[Route("recipe")]
public Task<List<Recipe>> GetRecipe()
{
if (!System.IO.File.Exists("Data/convert-recipes.json"))
{
ResetRecipes();
}
var data = JsonSerializer.Deserialize<List<Recipe>>(System.IO.File.ReadAllText("Data/convert-recipes.json"), _jsonSerializerOptions);
if (data == null)
{
throw new Exception("Unable to get the recipes.");
}
return Task.FromResult(data);
}
/// <summary>
/// Get the items with pagination.
/// </summary>
/// <param name="currentPage">The current page.</param>
/// <param name="pageSize">Size of the page.</param>
/// <returns>The items.</returns>
[HttpGet]
[Route("")]
public Task<List<Item>> List(int currentPage, int pageSize)
{
var data = JsonSerializer.Deserialize<List<Item>>(System.IO.File.ReadAllText("Data/items.json"), _jsonSerializerOptions);
if (data == null)
{
throw new Exception("Unable to get the items.");
}
return Task.FromResult(data.Skip((currentPage - 1) * pageSize).Take(pageSize).ToList());
}
/// <summary>
/// Resets the items.
/// </summary>
/// <returns>The async task.</returns>
[HttpGet]
[Route("reset-items")]
public Task ResetItems()
{
if (!System.IO.File.Exists("Data/items.json"))
{
System.IO.File.Delete("Data/items.json");
}
var data = JsonSerializer.Deserialize<List<Item>>(System.IO.File.ReadAllText("Data/items-original.json"), _jsonSerializerOptions);
if (data == null)
{
throw new Exception("Unable to get the items.");
}
var defaultImage = Convert.ToBase64String(System.IO.File.ReadAllBytes("Images/default.png"));
var imageTranslation = new Dictionary<string, string>
{
{ "stone_slab", "smooth_stone_slab_side" },
{ "sticky_piston", "piston_top_sticky" },
{ "mob_spawner", "spawner" },
{ "chest", "chest_minecart" },
{ "stone_stairs", "stairs" },
};
foreach (var item in data)
{
var imageFilepath = defaultImage;
if (System.IO.File.Exists($"Images/{item.Name}.png"))
{
imageFilepath = Convert.ToBase64String(System.IO.File.ReadAllBytes($"Images/{item.Name}.png"));
}
if (imageFilepath == defaultImage && System.IO.File.Exists($"Images/{item.Name}_top.png"))
{
imageFilepath = Convert.ToBase64String(System.IO.File.ReadAllBytes($"Images/{item.Name}_top.png"));
}
if (imageFilepath == defaultImage && System.IO.File.Exists($"Images/{item.Name}_front.png"))
{
imageFilepath = Convert.ToBase64String(System.IO.File.ReadAllBytes($"Images/{item.Name}_front.png"));
}
if (imageFilepath == defaultImage && System.IO.File.Exists($"Images/white_{item.Name}.png"))
{
imageFilepath = Convert.ToBase64String(System.IO.File.ReadAllBytes($"Images/white_{item.Name}.png"));
}
if (imageFilepath == defaultImage && System.IO.File.Exists($"Images/oak_{item.Name}.png"))
{
imageFilepath = Convert.ToBase64String(System.IO.File.ReadAllBytes($"Images/oak_{item.Name}.png"));
}
if (imageFilepath == defaultImage && System.IO.File.Exists($"Images/{item.DisplayName.ToLower().Replace(" ", "_")}.png"))
{
imageFilepath = Convert.ToBase64String(System.IO.File.ReadAllBytes($"Images/{item.DisplayName.ToLower().Replace(" ", "_")}.png"));
}
if (imageFilepath == defaultImage && imageTranslation.ContainsKey(item.Name))
{
imageFilepath = Convert.ToBase64String(System.IO.File.ReadAllBytes($"Images/{imageTranslation[item.Name]}.png"));
}
item.ImageBase64 = imageFilepath;
}
System.IO.File.WriteAllText("Data/items.json", JsonSerializer.Serialize(data, _jsonSerializerOptions));
return Task.FromResult(data);
}
/// <summary>
/// Resets the recipes.
/// </summary>
/// <returns>The async task.</returns>
[HttpGet]
[Route("reset-recipes")]
public Task ResetRecipes()
{
if (!System.IO.File.Exists("Data/convert-recipes.json"))
{
System.IO.File.Delete("Data/convert-recipes.json");
}
ConvertRecipes();
return Task.CompletedTask;
}
/// <summary>
/// Updates the specified identifier.
/// </summary>
/// <param name="id">The identifier.</param>
/// <param name="item">The item.</param>
/// <returns>The async task.</returns>
[HttpPut]
[Route("{id}")]
public Task Update(int id, Item item)
{
var data = JsonSerializer.Deserialize<List<Item>>(System.IO.File.ReadAllText("Data/items.json"), _jsonSerializerOptions);
var itemOriginal = data?.FirstOrDefault(w => w.Id == id);
if (itemOriginal == null)
{
throw new Exception($"Unable to found the item with ID: {id}");
}
itemOriginal.Id = item.Id;
itemOriginal.Name = item.Name;
itemOriginal.CreatedDate = item.CreatedDate;
itemOriginal.DisplayName = item.DisplayName;
itemOriginal.EnchantCategories = item.EnchantCategories;
itemOriginal.MaxDurability = item.MaxDurability;
itemOriginal.RepairWith = item.RepairWith;
itemOriginal.StackSize = item.StackSize;
itemOriginal.UpdatedDate = item.UpdatedDate;
System.IO.File.WriteAllText("Data/items.json", JsonSerializer.Serialize(data, _jsonSerializerOptions));
return Task.CompletedTask;
}
/// <summary>
/// Gets the name of the item.
/// </summary>
/// <param name="items">The items.</param>
/// <param name="inShape">The in shape.</param>
/// <param name="line">The line.</param>
/// <param name="row">The row.</param>
/// <returns>The name of the item.</returns>
private static string GetItemName(List<Item> items, InShape[][] inShape, int line, int row)
{
if (inShape.Length < line + 1)
{
return null;
}
if (inShape[line].Length < row + 1)
{
return null;
}
var id = inShape[line][row].Integer ?? inShape[line][row].IngredientClass?.Id;
if (id == null)
{
return null;
}
return GetItemName(items, id.Value);
}
/// <summary>
/// Gets the name of the item.
/// </summary>
/// <param name="items">The items.</param>
/// <param name="id">The identifier.</param>
/// <returns>The name of the item.</returns>
private static string GetItemName(List<Item> items, long id)
{
var item = items.FirstOrDefault(w => w.Id == id);
return item?.Name;
}
/// <summary>
/// Converts the recipes.
/// </summary>
private void ConvertRecipes()
{
var data = JsonSerializer.Deserialize<List<Item>>(System.IO.File.ReadAllText("Data/items.json"), _jsonSerializerOptions);
if (data == null)
{
return;
}
var recipes = Recipes.FromJson(System.IO.File.ReadAllText("Data/recipes.json"));
var items = new List<Recipe>();
foreach (var recipe in recipes.SelectMany(s => s.Value))
{
if (recipe.InShape == null)
{
continue;
}
var giveItem = data.FirstOrDefault(w => w.Id == recipe.Result.Id);
if (giveItem == null)
{
continue;
}
items.Add(new Recipe
{
Give = new Item { DisplayName = giveItem.DisplayName, Name = giveItem.Name },
Have = new List<List<string>>
{
new()
{
GetItemName(data, recipe.InShape, 0, 0),
GetItemName(data, recipe.InShape, 0, 1),
GetItemName(data, recipe.InShape, 0, 2)
},
new()
{
GetItemName(data, recipe.InShape, 1, 0),
GetItemName(data, recipe.InShape, 1, 1),
GetItemName(data, recipe.InShape, 1, 2)
},
new()
{
GetItemName(data, recipe.InShape, 2, 0),
GetItemName(data, recipe.InShape, 2, 1),
GetItemName(data, recipe.InShape, 2, 2)
}
}
});
}
System.IO.File.WriteAllText("Data/convert-recipes.json", JsonSerializer.Serialize(items, _jsonSerializerOptions));
}
}
}

@ -0,0 +1,143 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="InventoryController.cs" company="UCA Clermont-Ferrand">
// Copyright (c) UCA Clermont-Ferrand All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace Minecraft.Crafting.Api.Controllers
{
using Microsoft.AspNetCore.Mvc;
using Minecraft.Crafting.Api.Models;
using System.Text.Json;
using System.Text.Json.Serialization;
/// <summary>
/// The inventory controller.
/// </summary>
[ApiController]
[Route("api/[controller]")]
public class InventoryController : ControllerBase
{
/// <summary>
/// The json serializer options.
/// </summary>
private readonly JsonSerializerOptions _jsonSerializerOptions = new()
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
WriteIndented = true,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault
};
/// <summary>
/// Adds to inventory.
/// </summary>
/// <param name="item">The item.</param>
/// <returns>The async task.</returns>
[HttpPost]
[Route("")]
public Task AddToInventory(InventoryModel item)
{
var data = JsonSerializer.Deserialize<List<InventoryModel>>(System.IO.File.ReadAllText("Data/inventory.json"), _jsonSerializerOptions);
if (data == null)
{
throw new Exception("Unable to get the inventory.");
}
data.Add(item);
System.IO.File.WriteAllText("Data/inventory.json", JsonSerializer.Serialize(data, _jsonSerializerOptions));
return Task.CompletedTask;
}
/// <summary>
/// Deletes from inventory.
/// </summary>
/// <param name="item">The item.</param>
/// <returns>The async task.</returns>
[HttpDelete]
[Route("")]
public Task DeleteFromInventory(InventoryModel item)
{
if (!System.IO.File.Exists("Data/inventory.json"))
{
throw new Exception($"Unable to found the item with name: {item.ItemName}");
}
var data = JsonSerializer.Deserialize<List<InventoryModel>>(System.IO.File.ReadAllText("Data/inventory.json"), _jsonSerializerOptions);
if (data == null)
{
throw new Exception("Unable to get the inventory.");
}
var inventoryItem = data.FirstOrDefault(w => w.ItemName == item.ItemName && w.Position == item.Position);
if (inventoryItem == null)
{
throw new Exception($"Unable to found the item with name: {item.ItemName} at position: {item.Position}");
}
data.Remove(inventoryItem);
System.IO.File.WriteAllText("Data/inventory.json", JsonSerializer.Serialize(data, _jsonSerializerOptions));
return Task.CompletedTask;
}
/// <summary>
/// Gets the inventory.
/// </summary>
/// <returns>The inventory.</returns>
[HttpGet]
[Route("")]
public Task<List<InventoryModel>> GetInventory()
{
if (!System.IO.File.Exists("Data/inventory.json"))
{
return Task.FromResult(new List<InventoryModel>());
}
var data = JsonSerializer.Deserialize<List<InventoryModel>>(System.IO.File.ReadAllText("Data/inventory.json"), _jsonSerializerOptions);
if (data == null)
{
throw new Exception("Unable to get the inventory.");
}
return Task.FromResult(data);
}
/// <summary>
/// Updates the inventory.
/// </summary>
/// <param name="item">The item.</param>
/// <returns>The async task.</returns>
[HttpPut]
[Route("")]
public Task UpdateInventory(InventoryModel item)
{
var data = JsonSerializer.Deserialize<List<InventoryModel>>(System.IO.File.ReadAllText("Data/inventory.json"), _jsonSerializerOptions);
if (data == null)
{
throw new Exception("Unable to get the inventory.");
}
var inventoryItem = data.FirstOrDefault(w => w.ItemName == item.ItemName && w.Position == item.Position);
if (inventoryItem == null)
{
throw new Exception($"Unable to found the item with name: {item.ItemName} at position: {item.Position}");
}
inventoryItem.ItemName = item.ItemName;
inventoryItem.Position = item.Position;
System.IO.File.WriteAllText("Data/inventory.json", JsonSerializer.Serialize(data, _jsonSerializerOptions));
return Task.CompletedTask;
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,20 @@
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["src/Minecraft.Crafting.Api/Minecraft.Crafting.Api.csproj", "Minecraft.Crafting.Api/"]
RUN dotnet restore "Minecraft.Crafting.Api/Minecraft.Crafting.Api.csproj"
COPY src/. .
WORKDIR "/src/Minecraft.Crafting.Api"
RUN dotnet build "Minecraft.Crafting.Api.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Minecraft.Crafting.Api.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Minecraft.Crafting.Api.dll"]

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 376 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 301 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 295 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 284 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 298 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 282 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 287 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 270 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 B

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save