From 6285967d1cf6e9322f584de761eea31ade32b3e5 Mon Sep 17 00:00:00 2001 From: TrueDoctor Date: Mon, 1 Oct 2018 02:28:42 +0200 Subject: Completed Weapon import function to automagically load data from an dsa website into the database --- DSACore/FireBase/Database.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'DSACore/FireBase/Database.cs') diff --git a/DSACore/FireBase/Database.cs b/DSACore/FireBase/Database.cs index 02a4741..12ebb89 100644 --- a/DSACore/FireBase/Database.cs +++ b/DSACore/FireBase/Database.cs @@ -154,24 +154,27 @@ namespace DSACore.FireBase public static async Task AddWeapon(Weapon wep) { + string collection = wep.GetType() == typeof(MeleeWeapon) ? "MeleeWeapons" : "RangedWeapons"; await firebase - .Child("Weapons") + .Child(collection) .Child(wep.Name) .PutAsync(wep); } - public static async Task RemoveWeapon(string weapon) + public static async Task RemoveWeapon(string weapon, bool ranged = false) { + string collection = ranged ? "RangedWeapons" : "MeleeWeapons"; await firebase - .Child("Weapons") + .Child(collection) .Child(weapon) .DeleteAsync(); } - public static async Task< Weapon> GetWeapon(string weapon) + public static async Task< Weapon> GetWeapon(string weapon, bool ranged = false) { + string collection = ranged ? "RangedWeapons" : "MeleeWeapons"; return await firebase - .Child("Weapons") + .Child(collection) .Child(weapon) .OnceSingleAsync(); } -- cgit v1.2.3-70-g09d2