continuation charg sauv

master
Cedric CHARBONNEL 2 years ago
parent f0e77b1e09
commit 7649b9aa9b

@ -8,15 +8,33 @@ namespace LOLAPP;
public partial class App : Application
{
public Manager ChampionManager { get; set; } = new Manager(new Stub());
public App()
public Manager MyManager { get; private set; } = new Manager(new Stub());
public string FileNameC { get; set; } = "champions.xml";
public string FileNameU { get; set; } = "utilisateur.xml";
public string FilePath { get; set; } = FileSystem.AppDataDirectory;
public App()
{
ChampionManager.Chargdon();
ChampionManager.Persistance = new DataContractPersistance.DataContract();
ChampionManager.Sauvdon();
Debug.WriteLine("Application lancééé!");
InitializeComponent();
string champPath = Path.Combine(FilePath, FileNameC);
string utilPath = Path.Combine(FilePath, FileNameU);
/*Si les fichiers existent déjà, on récupère la persistance car on a donc des champions à récupérer*/
if (File.Exists(champPath) && File.Exists(utilPath))
{
MyManager = new Manager(new DataContractPersistance.DataContract());
}
MyManager.Chargdon();
MainPage = new AppShell();
MainPage = new AppShell();
if (!File.Exists(champPath) && !File.Exists(utilPath))
{
MyManager.Persistance = new DataContractPersistance.DataContract();
}
MyManager.Sauvdon();
Debug.WriteLine("Application lancééé!");
}
}

@ -1,5 +1,6 @@
using LOLAPP.Modele;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
@ -12,19 +13,28 @@ namespace LOLAPP.DataContractPersistance
{
public class DataContract : IPersistanceManager
{
public string FilePath2 {get; set;} = Path.Combine(Directory.GetCurrentDirectory(),"//Doss1_XML");
public string FileName { get; set; } = "Test2.xml";
public string FilePath { get; set; } = "C:\\Users\\cecharbonn5\\LOLAPP\\LOLAPP";
public string FilePath { get; set; } = FileSystem.AppDataDirectory;
public string FileNameC { get; set; } = "champions.xml";
public string FileNameU { get; set; } = "utilisateur.xml";
public (List<Utilisateur>, List<Champion>) Chargdon()
public (List<Champion>, List<Utilisateur>) Chargdon()
{
var serializer = new DataContractSerializer(typeof(DataToPersist));
DataToPersist data;
using (Stream s = File.OpenRead(Path.Combine(FilePath, FileName)))
var champserializer = new DataContractSerializer(typeof(DataToPersist));
var utilserializer = new DataContractSerializer(typeof(List<Utilisateur>));
List<Utilisateur> util = new List<Utilisateur>();
List<Champion> champ = new List<Champion>();
using (Stream champstream = File.OpenRead(Path.Combine(FilePath, FileNameC)))
{
DataToPersist data = champserializer.ReadObject(champstream) as DataToPersist;
champ = data.champ;
}
using (Stream utilstream = File.OpenRead(Path.Combine(FilePath, FileNameU)))
{
data = serializer.ReadObject(s) as DataToPersist;
util = utilserializer.ReadObject(utilstream) as List<Utilisateur>;
}
return (data.util, data.champ);
return (champ, util);
}
public void Sauvdon(List<Utilisateur> s, List<Champion> c)
@ -38,7 +48,7 @@ namespace LOLAPP.DataContractPersistance
if (!Directory.Exists(FilePath))
{
Debug.WriteLine("Directory crée à l'instant");
Debug.WriteLine(Directory.GetDirectoryRoot(FileName));
Debug.WriteLine(Directory.GetDirectoryRoot(FileNameC));
Debug.WriteLine(FilePath);
Directory.CreateDirectory(FilePath);
}
@ -47,7 +57,7 @@ namespace LOLAPP.DataContractPersistance
data.util = s;
data.champ = c;
var settings = new XmlWriterSettings() { Indent = true };
using (TextWriter st = File.CreateText(Path.Combine(FilePath, FileName)))
using (TextWriter st = File.CreateText(Path.Combine(FilePath, FileNameC)))
{
using (XmlWriter writer = XmlWriter.Create(st, settings))
{
@ -55,5 +65,33 @@ namespace LOLAPP.DataContractPersistance
}
}
}
/*Méthode permettant de sauvegarder les données*/
public void Sauvdon(List<Champion> c, List<Utilisateur> u)
{
var champserializer = new DataContractSerializer(typeof(DataToPersist));
var utilserializer = new DataContractSerializer(typeof(List<Utilisateur>));
if (!Directory.Exists(FilePath))
{
Debug.WriteLine("Directory créé à l'instant");
Debug.WriteLine(Directory.GetDirectoryRoot(FilePath));
Debug.WriteLine(FilePath);
Directory.CreateDirectory(FilePath);
}
DataToPersist data = new DataToPersist();
data.champ= c;
using (Stream champstream = File.Create(Path.Combine(FilePath, FileNameC)))
{
champserializer.WriteObject(champstream,data);
}
using (Stream utilstream = File.Create(Path.Combine(FilePath, FileNameU)))
{
utilserializer.WriteObject(utilstream, u);
}
}
}
}

@ -11,12 +11,18 @@ namespace LOLAPP.Modele
public class Ability
{
[DataMember]
public string Name { get; set; }
public string Name { get; private set; }
[DataMember]
public string Image { get; private set; }
[DataMember]
public string Description { get; private set; }
public Ability(string name)
public Ability(string name,string image,string description)
{
// Le constructeur de la classe Ability initialise le nom de l'abilitée.
Name = name;
Image= image;
Description = description;
}
}
}

@ -13,19 +13,28 @@ namespace LOLAPP.Modele
[DataMember]
public string Name { get; private set; }
[DataMember]
public string Titre { get; private set; }
[DataMember]
public string Image { get; private set; }
[DataMember]
public List<Ability> Abilities { get; private set; }
public Champion(string name, List<Ability> abilities)
public Champion(string name,string titre,string image, List<Ability> abilities)
{
// Le constructeur de la classe Champion initialise le nom et les abilités du champion.
Name = name;
Titre = titre;
Image = image;
Abilities = abilities;
}
public Champion(string name)
public Champion(string name, string titre, string image)
{
// Le constructeur de la classe Champion initialise le nom et les abilités du champion.
Name = name;
Abilities = null;
Titre = titre;
Image = image;
Abilities = new List<Ability>();
}
}
}

@ -8,7 +8,7 @@ namespace LOLAPP.Modele
{
public interface IPersistanceManager
{
(List<Utilisateur>, List<Champion>) Chargdon();
void Sauvdon(List<Utilisateur> s, List<Champion> c);
(List<Champion>, List<Utilisateur>) Chargdon();
void Sauvdon(List<Champion> c, List<Utilisateur> u);
}
}

@ -1,4 +1,5 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -28,55 +29,6 @@ namespace LOLAPP.Modele
_utilisateur = new List<Utilisateur>();
}
public void AddChampion(Champion champion)
{
_champions.Add(champion);
}
public void RemoveChampion(Champion champion)
{
_champions.Remove(champion);
}
public List<Champion> GetAllChampions()
{
return _champions;
}
public void AddAbility(Champion champion, string abilityName)
{
var ability = new Ability(abilityName);
champion.Abilities.Add(ability);
}
public void RemoveAbility(Champion champion, string abilityName)
{
var ability = champion.Abilities.FirstOrDefault(a => a.Name == abilityName);
if (ability != null)
{
champion.Abilities.Remove(ability);
}
}
public void AddStrategie(Strategie strategie)
{
_strategies.Add(strategie);
}
public void RemoveStrategie(Strategie strategie)
{
_strategies.Remove(strategie);
}
public List<Strategie> GetAllStrategies()
{
return _strategies;
}
public void AddUtilisateur(Utilisateur utilisateur)
{
@ -91,22 +43,14 @@ namespace LOLAPP.Modele
public void Chargdon() {
var don = Persistance.Chargdon();
foreach (var i in don.Item1)
{
AddUtilisateur(i);
}
foreach (var j in don.Item2)
{
AddChampion(j);
}
_champions.AddRange(don.Item1);
_utilisateur.AddRange(don.Item2);
}
public void Sauvdon()
{
Persistance.Sauvdon(_utilisateur, _champions);
Persistance.Sauvdon(_champions, _utilisateur);
}
}
}

@ -11,9 +11,11 @@ namespace LOLAPP.Modele
public class Strategie
{
[DataMember]
public string Name { get; set; }
public string Name { get; private set; }
[DataMember]
public List<Champion> Champions { get; set; }
public string Description { get; private set; }
[DataMember]
public List<Champion> Champions { get; private set; }
public Strategie(string name, List<Champion> champions)
{

@ -9,23 +9,88 @@ namespace LOLAPP.Modele
public class Stub : IPersistanceManager
{
public Stub() {}
public (List<Utilisateur>, List<Champion>) Chargdon()
public (List<Champion>, List<Utilisateur>) Chargdon()
{
List<Utilisateur> s = new List<Utilisateur>();
List<Utilisateur> u = new List<Utilisateur>();
List<Champion> c = new List<Champion>();
List<Ability> a = new List<Ability>();
Ability a1 = new Ability("Broken Wings");
a.Add(a1);
Champion c1 = new Champion("Riven", a);
Champion c2 = new Champion("Braum");
Ability c1a1 = new Ability("Runic Blade", "RunicBlade.jpg", "Riven's abilities charge her blade, and her basic attacks expend charges to deal an additional damage.");
Ability c1a2 = new Ability("Broken Wings", "BrokenWings.jpg", "Riven lashes out in a series of strikes. This ability can be reactivated three times in a short time frame with the third hit knocking back nearby enemies.");
Ability c1a3 = new Ability("Ki Burst", "KiBurst.jpg", "Riven emits a Ki Burst, damaging and stunning nearby enemies.");
Ability c1a4 = new Ability("Valor", "Valor.jpg", "Riven steps forward a short distance and blocks incoming damage.");
Ability c1a5 = new Ability("Blade of the Exile", "BladeoftheExile.jpg", "Riven empowers her keepsake weapon with energy, and gains Attack Damage and Range. During this time, she also gains the ability to use Wind Slash, a powerful ranged attack, once.");
a.Add(c1a1);
a.Add(c1a2);
a.Add(c1a3);
a.Add(c1a4);
a.Add(c1a5);
Champion c1 = new Champion("Riven","The Exile", "Riven.jpg", a);
c.Add(c1);
a.Clear();
Ability c2a1 = new Ability("Rage Gene", "RageGene.jpg", "While in combat Gnar generates Rage. At maximum Rage his next ability will transform him into Mega Gnar, granting increased survivability and access to new spells.");
Ability c2a2 = new Ability("Boomerang Throw / Boulder Toss", "BoomerangThrow/BoulderToss.jpg", "Gnar throws a boomerang that damages and slows enemies it hits before returning to him. If he catches the boomerang its cooldown is reduced.\r\n\r\nMega Gnar instead throws a boulder that stops on the first unit hit, damaging and slowing everything nearby. It can then be picked up to reduce the cooldown.");
Ability c2a3 = new Ability("Hyper / Wallop", "Hyper/Wallop.jpg", "Gnar's attacks and spells hype him up, dealing bonus damage and granting him Movement Speed.\r\n\r\nMega Gnar is too enraged to be hyper and instead can rear up on his hind legs and smash down on the area in front of him, stunning enemies in an area.");
Ability c2a4 = new Ability("Hop / Crunch", "Hop/Crunch.jpg", "Gnar leaps to a location and bounces off the head of any unit he lands on, traveling further.\r\n\r\nMega Gnar is too large to bounce and instead lands with earth-shattering force, dealing damage in an area around him.");
Ability c2a5 = new Ability("GNAR!", "GNAR!.jpg", "Mega Gnar throws everything around him in a chosen direction, dealing damage and slowing them. Any enemy that hits a wall is stunned and takes bonus damage.");
a.Add(c2a1);
a.Add(c2a2);
a.Add(c2a3);
a.Add(c2a4);
a.Add(c2a5);
Champion c2 = new Champion("Gnar", "The Missing Link", "Gnar.jpg", a);
c.Add(c2);
a.Clear();
Ability c3a1 = new Ability("Daredevil Impulse", "DaredevilImpulse.jpg", "Samira builds a combo by hitting attacks or abilities unique from the previous hit. Samira's attacks in melee range deal additional magic damage. Samira's attacks against enemies affected by Immobilizing effects will dash her to her attack range. If the enemy is Knocked Up, she also keeps them Knocked Up briefly.");
Ability c3a2 = new Ability("Flair", "Flair.jpg", "Samira fires a shot or swings her sword, dealing damage. If cast during Wild Rush, strike all enemies in her path upon completion.");
Ability c3a3 = new Ability("Blade Whirl", "BladeWhirl.jpg", "Samira slashes around her, damaging enemies and destroying enemy missiles.");
Ability c3a4 = new Ability("Wild Rush", "WildRush.jpg", "Samira dashes through an enemy (including structures), slashing enemies she passes through and gaining Attack Speed. Killing an enemy champion refreshes this ability's cooldown.");
Ability c3a5 = new Ability("Inferno Trigger", "InfernoTrigger.jpg", "Samira unleashes a torrent of shots from her weapons, wildly shooting all enemies surrounding her.");
a.Add(c1a1);
a.Add(c1a2);
a.Add(c1a3);
a.Add(c1a4);
a.Add(c1a5);
Champion c3 = new Champion("Samira", "The Desert Rose", "Samira.jpg", a);
c.Add(c3);
a.Clear();
Ability c4a1 = new Ability("Bop 'n' Block", "Bop'n'Block.jpg", "Periodically, when Yuumi attacks a champion, she restores mana and gains a shield that follows her, protecting her and the ally she's attached to.");
Ability c4a2 = new Ability("Prowling Projectile", "ProwlingProjectile.jpg", "Yuumi fires a missile, dealing damage to the first target hit. It deals bonus damage and slows if it takes at least 1 second to get to its target.\r\n\r\nWhile Attached, the missile can be controlled with your cursor.");
Ability c4a3 = new Ability("You and Me!", "YouandMe!.jpg", "Passively, Yuumi increases her ally's Adaptive Force and her own. Actively, Yuumi dashes to a target ally, becoming untargetable from everything except turrets.");
Ability c4a4 = new Ability("Zoomies", "Zoomies.jpg", "Heals Yuumi and boosts Movement Speed and Attack Speed. If she's attached, she passes it to her ally instead.");
Ability c4a5 = new Ability("Final Chapter", "FinalChapter.jpg", "Yuumi channels seven waves of damage, rooting anyone hit by three or more. Yuumi can move, attach, and cast Zoomies! while channeling.");
a.Add(c4a1);
a.Add(c4a2);
a.Add(c4a3);
a.Add(c4a4);
a.Add(c4a5);
Champion c4 = new Champion("Yuumi", "The Magical Cat", "Yuumi.jpg", a);
c.Add(c4);
a.Clear();
Ability c5a1 = new Ability("The Relentless Storm", "TheRelentlessStorm.jpg", "Riven's abilities charge her blade, and her basic attacks expend charges to deal an additional damage.");
Ability c5a2 = new Ability("Thundering Smash", "ThunderingSmash.jpg", "Riven lashes out in a series of strikes. This ability can be reactivated three times in a short time frame with the third hit knocking back nearby enemies.");
Ability c5a3 = new Ability("Frenzied Maul", "FrenziedMaul.jpg", "Riven emits a Ki Burst, damaging and stunning nearby enemies.");
Ability c5a4 = new Ability("Sky Splitter", "SkySplitter.jpg", "Riven steps forward a short distance and blocks incoming damage.");
Ability c5a5 = new Ability("Stormbringer", "Stormbringer.jpg", "Riven empowers her keepsake weapon with energy, and gains Attack Damage and Range. During this time, she also gains the ability to use Wind Slash, a powerful ranged attack, once.");
a.Add(c5a1);
a.Add(c5a2);
a.Add(c5a3);
a.Add(c5a4);
a.Add(c5a5);
Champion c5 = new Champion("Volibear", "The Relentless Storm", "Volibear.jpg", a);
c.Add(c5);
a.Clear();
Utilisateur s1 = new Utilisateur("Broken", "Kala");
s.Add(s1);
return (s,c);
return (c,u);
}
public void Sauvdon(List<Utilisateur> s, List<Champion> c)
public void Sauvdon(List<Champion> c, List<Utilisateur> u)
{
throw new NotImplementedException();
}

@ -11,13 +11,28 @@ namespace LOLAPP.Modele
public class Utilisateur
{
[DataMember]
public string User { get; set; }
public string Username { get; private set; }
[DataMember]
public string Password { get; set; }
public string Password { get; private set; }
[DataMember]
public List<Strategie> _strat { get; private set; }
public Utilisateur(string user,string password)
{ User = user;
public Utilisateur(string username,string password)
{ Username = username;
Password = password;
_strat = new List<Strategie>();
}
public void AddStrategie(Strategie strat)
{
_strat.Add(strat);
}
public void RemoveStrategie(Strategie strat)
{
_strat.Remove(strat);
}
}
}

Loading…
Cancel
Save