public void GenerateMap(Problem problem) { map = problem; tableController.Table.Cells = ParseMap(problem.Map); tableController.Table.Boxes = ParseBox(problem.Box); tableController.RenderTable(); tableController.SolveTableBeforeGame(solverCtrl); mainWindow.SetActualMapName(problem.Name); statCtrl.CreateNewStat(); mainWindow.TheEnd.Visibility = Visibility.Hidden; }
public void GameEnded(Problem map) { switch (map.Difficulty) { case MapEnum.Difficulty.Easy: points = 20; break; case MapEnum.Difficulty.Medium: points = 40; break; case MapEnum.Difficulty.Hard: points = 60; break; case MapEnum.Difficulty.Expert: points = 80; break; } if (showedCandidates) points /= 2; if (cheating) points = 0; }
public void LoadMapsFromDB() { if (db.OpenConnection()) { using (var com = new MySqlCommand("SELECT * FROM Maps", db.Connection)) { try { var reader = com.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { var problem = new Problem(); problem.Id = int.Parse(reader["Id"].ToString()); problem.AuthorId = int.Parse(reader["AuthorId"].ToString()); problem.Name = reader["Name"].ToString(); problem.IsPublic = reader["IsPublic"].ToString() == "1"; problem.Map = reader["Map"].ToString(); problem.Box = reader["Boxes"].ToString(); problem.Difficulty = (Difficulty)System.Enum.Parse(typeof(Difficulty), reader["Difficulty"].ToString()); maps.Add(problem); } } } catch (Exception exception) { MessageBox.Show("Error happend: Could not read group list. (" + exception.Message + ")"); } finally { db.CloseConnection(); } } } }