private static void TestGameDB() { var db = new UserDBHelper(); using (var gamedb = new GameDBHelper()) { List <GameUnitsTable> GetCoreArmy(int coreId) { var result = new List <GameUnitsTable>(); var warriorUnit = gamedb.GetUnitProperty("Warrior"); var attackAircraftUnit = gamedb.GetUnitProperty("AttackAircraft"); var numberWarriors = gamedb.CasernGetNumberOfWarriors(coreId); var numberAttackAircraft = gamedb.CasernGetNumberOfAttackAircraft(coreId); for (int i = 0; i < numberWarriors; i++) { result.Add( new GameUnitsTable() { GameUnitId = warriorUnit.GameUnitId, GameUnitType = warriorUnit.GameUnitType, GameUnitName = warriorUnit.GameUnitName, GameUnitHP = warriorUnit.GameUnitHP, GameUnitAttack = warriorUnit.GameUnitAttack, GameUnitDefence = warriorUnit.GameUnitDefence, GameUnitGoldIncome = warriorUnit.GameUnitGoldIncome, GameUnitGoldOutcome = warriorUnit.GameUnitGoldOutcome }); } for (int i = 0; i < numberAttackAircraft; i++) { result.Add(new GameUnitsTable() { GameUnitId = attackAircraftUnit.GameUnitId, GameUnitType = attackAircraftUnit.GameUnitType, GameUnitName = attackAircraftUnit.GameUnitName, GameUnitHP = attackAircraftUnit.GameUnitHP, GameUnitAttack = attackAircraftUnit.GameUnitAttack, GameUnitDefence = attackAircraftUnit.GameUnitDefence, GameUnitGoldIncome = attackAircraftUnit.GameUnitGoldIncome, GameUnitGoldOutcome = attackAircraftUnit.GameUnitGoldOutcome }); } return(result); } bool run = true; while (run) { Console.WriteLine( "1. Show all\n" + "2. Show battle\n" + "3. Random registration\n" + "4. Show all cores\n" + "5. Build casern test\n" + "6. Core info\n" ); var key = Console.ReadKey().Key; Console.WriteLine(); switch (key) { case ConsoleKey.D1: { break; } case ConsoleKey.D2: { Console.WriteLine(); Console.WriteLine("Battle begins"); List <GameUnitsTable> attackers = GetCoreArmy(1); List <GameUnitsTable> defenders = GetCoreArmy(2); var result = 0; // GameEngine.Battle(attackers, defenders); Console.WriteLine(result == 0 ? "Attackers won the battle!" : "Defenders won the battle!"); break; } case ConsoleKey.D3: { Console.WriteLine(); RandomUserRegistration( db.RegisterUserToTable, db.RemoveUserByIdFromTable, db.FindUserByNickname); break; } case ConsoleKey.D4: { Console.WriteLine(); Console.WriteLine("Cores: "); var coreList = gamedb.GetAllCores() .FromJson <List <SessionCoresTable> >(); foreach (var el in coreList) { var elmap = gamedb .FindCoreMapByMapIdAsNoTracking(el.CoreMapId) .FromJson <SessionMapTable>(); Console.WriteLine( $"userid: {el.UserId} " + $"mapid: {el.CoreMapId} " + $"map [{elmap.XCoord}, {elmap.YCoord}]" ); } break; } case ConsoleKey.D5: { Console.Clear(); Console.WriteLine("Build casern"); gamedb.CoreBuildCasern(1); Console.Read(); break; } case ConsoleKey.D6: { Console.Clear(); Console.WriteLine("Core info"); var list = db.GetAllUsers(); foreach (var el in list) { var coreId = UserDBHelper.GetCoreIdByUserId(el.UserId); if (coreId != -1) { var coreInfo = gamedb .GetCoreInfoById(coreId) .FromJson <CoreInfo>(); //var coreMap = gamedb // .FindCoreMapByMapIdAsNoTracking(coreInfo.CoreMapId) // .FromJson<SessionMapTable>(); // //Console.WriteLine($"Core info [UserId={el.UserId}]"); //Console.WriteLine($"coreid: {coreInfo.CoreId} " + // $"money: {coreInfo.Money} " + // $"base capacity: {coreInfo.BaseCapacity}"+ // $"map[{coreMap.XCoord}, {coreMap.YCoord}]"); } else { Console .WriteLine($"Can not find core id for userid: {el.UserId}"); } } Console.WriteLine(); break; } case ConsoleKey.C: { Console.Clear(); break; } case ConsoleKey.Escape: { run = false; break; } default: { break; } } } } }