|
|
|
@ -16,6 +16,8 @@ namespace App
|
|
|
|
|
{
|
|
|
|
|
internal static class Program
|
|
|
|
|
{
|
|
|
|
|
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
|
|
|
|
|
|
|
|
|
static async Task Main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
// MODEL stuff
|
|
|
|
@ -27,8 +29,7 @@ namespace App
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(ex.Message);
|
|
|
|
|
Console.WriteLine(ex.StackTrace);
|
|
|
|
|
logger.Warn(ex);
|
|
|
|
|
masterOfCeremonies = new(new PlayerManager(), new DiceGroupManager(), null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -43,22 +44,18 @@ namespace App
|
|
|
|
|
PlayerDbManager playerDbManager = new(db);
|
|
|
|
|
IEnumerable<PlayerEntity> entities = await playerDbManager.GetAll();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Debug.WriteLine("Loading players");
|
|
|
|
|
|
|
|
|
|
foreach (PlayerEntity entity in entities)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// persist them as models !
|
|
|
|
|
await masterOfCeremonies.GlobalPlayerManager.Add(entity.ToModel());
|
|
|
|
|
Debug.WriteLine($"{entity.ID} -- {entity.Name}");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex) { Debug.WriteLine($"{ex.Message}\n... Never mind"); }
|
|
|
|
|
catch (Exception ex) { Console.WriteLine($"{ex.Message}\n... Never mind"); }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex) { Debug.WriteLine($"{ex.Message}\n... Couldn't use the database"); }
|
|
|
|
|
catch (Exception ex) { Console.WriteLine($"{ex.Message}\n... Couldn't use the database"); }
|
|
|
|
|
|
|
|
|
|
string menuChoice = "nothing";
|
|
|
|
|
|
|
|
|
@ -186,22 +183,21 @@ namespace App
|
|
|
|
|
// create a PlayerDbManager (and inject it with the DB)
|
|
|
|
|
PlayerDbManager playerDbManager = new(db);
|
|
|
|
|
|
|
|
|
|
Debug.WriteLine("Saving players");
|
|
|
|
|
|
|
|
|
|
foreach (Player model in models)
|
|
|
|
|
{
|
|
|
|
|
try // to persist them
|
|
|
|
|
{ // as entities !
|
|
|
|
|
PlayerEntity entity = model.ToEntity();
|
|
|
|
|
await playerDbManager.Add(entity);
|
|
|
|
|
Debug.WriteLine($"{entity.ID} -- {entity.Name}");
|
|
|
|
|
}
|
|
|
|
|
// what if there's already a player with that name? Exception (see PlayerEntity's annotations)
|
|
|
|
|
catch (ArgumentException ex) { Debug.WriteLine($"{ex.Message}\n... Never mind"); }
|
|
|
|
|
catch (ArgumentException ex) { Console.WriteLine($"{ex.Message}\n... Never mind"); }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// flushing and closing NLog before quitting completely
|
|
|
|
|
NLog.LogManager.Shutdown();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex) { Debug.WriteLine($"{ex.Message}\n... Couldn't use the database"); }
|
|
|
|
|
catch (Exception ex) { Console.WriteLine($"{ex.Message}\n... Couldn't use the database"); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static async Task Play(MasterOfCeremonies masterOfCeremonies, string name)
|
|
|
|
@ -396,7 +392,7 @@ namespace App
|
|
|
|
|
Player player = new(menuChoicePlayers);
|
|
|
|
|
if (!(await masterOfCeremonies.GlobalPlayerManager.GetAll()).Contains(player))
|
|
|
|
|
{
|
|
|
|
|
// if the player didn't exist, now it does... this is temporary
|
|
|
|
|
// if the player didn't exist, now it does...
|
|
|
|
|
await masterOfCeremonies.GlobalPlayerManager.Add(player);
|
|
|
|
|
}
|
|
|
|
|
// almost no checks, this is temporary
|
|
|
|
@ -404,7 +400,7 @@ namespace App
|
|
|
|
|
{
|
|
|
|
|
await result.Add(player);
|
|
|
|
|
}
|
|
|
|
|
catch (ArgumentException ex) { Debug.WriteLine($"{ex.Message}\n... Never mind"); }
|
|
|
|
|
catch (ArgumentException ex) { Console.WriteLine($"{ex.Message}\n... Never mind"); }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|