private void BlSaveChanges(object sender, DoWorkEventArgs args) { Thread.Sleep(500); GameDb gameDb = new GameDb(); gameDb.SaveChanges(); }
public override Response Interact(Player player, GameDb context, Mediator mediator) { mediator.GetHandler <CombatManager>().StartEncounter(0, player); var response = mediator.GetHandler <GetEncounter>().Get(player.Id); return(Response.From(response)); }
//this is called when a game is finished. //declares the loser to the game db. public void BlLoss(Message m) { UserDb userDb = new UserDb(); User u = userDb.SelectById(m.Target.UserId); GameDb gameDb = new GameDb(); Game g = gameDb.GetGameById(m.GameId); g.Players.RemoveAll(p => p == null); g.EndTime = DateTime.Now; g.Loser = m.Target.Id; u.Score += 200; u.Losses += 1; u.Level = (u.Score - u.Score % 1000) / 1000; userDb.Update(u); gameDb.Update(g); // remove this game from static local list ActiveGameList.Remove(ActiveGameList.Find(gm => gm.Id == m.GameId)); userDb.SaveChanges(); }
private static void CreateLoadMenu(int boardId) { var loadMenu = new Menu { Title = "Loading Game", MenuItems = new List <MenuItem>() { new MenuItem() { Title = "Load Game", Execute = () => PrintGame(GameDb.LoadDataFromDb(boardId)) }, new MenuItem() { Title = "Delete Game", Execute = () => DeleteGame(boardId) }, new MenuItem() { Title = "Go Back", Execute = () => _saveMenu.Run() } } }; loadMenu.Run(); }
public override InteractionDescriptor GetDescriptor(GameDb context) { return(new InteractionDescriptor { ActionName = "Start fight", Id = this.Id }); }
public GameList BlGetMutualGames(int u1, int u2) { GameDb gameDb = new GameDb(); GameList temp = gameDb.SelectByUsersId(u1, u2); return(temp); }
public GameList BlGetAllUserGames(int userId) { GameDb gameDb = new GameDb(); GameList temp = gameDb.SelectByUserId(userId); return(temp); }
public override InteractionDescriptor GetDescriptor(GameDb context) { return(new InteractionDescriptor { ActionName = "Loot", Id = Id }); }
public Mediator(GameDb context, IAlerter alerter) { services = new ServiceCollection(); services.AddSingleton(context); services.AddSingleton(alerter); services.AddSingleton(this); AddHandlers(); CreateProvider(); }
private static void DeleteGame(int boardId) { GameDb.DeleteGameFromDb(boardId); // JSON // SaveGameJson.DeleteGame(fileName); CreateSaveMenu(); _saveMenu.Run(); }
public override InteractionDescriptor GetDescriptor(GameDb context) { context.Interactables.Include("LeadsTo").Single(i => i.Id == Id); return(new InteractionDescriptor { ActionName = $"Path leading to room {LeadsTo.Id}", Id = this.Id }); }
public static void Main(string[] args) { DotNetEnv.Env.Load(); // CreateWebHostBuilder(args).Build().Run(); // GameDb.createFromJSON("games.json"); // Console.WriteLine(GameDb.makeTableIfNone("consoles")); // Console.WriteLine(System.Environment.GetEnvironmentVariable("DB_CONNECT_DEV")); // GameDb.CreateFromJSON("games.json"); GameDb.SearchByName("God of War 17287387382"); }
public Task <int> SaveGameAsync(GameDb item) { if (item.Id != 0) { return(Database.UpdateAsync(item)); } else { return(Database.InsertAsync(item)); } }
public ActionResult NumberGameBS(NumberGameViewModel score) { GameDb context = new GameDb(); NumberGameEntity num = new NumberGameEntity(); num.HighScore = score.HighScore; context.Number.Add(num); context.SaveChanges(); var worstScore =context.Number.OrderByDescending(c => c.HighScore).First(); context.Number.Remove(worstScore); context.SaveChanges(); return RedirectToAction("NumberGame"); }
/// <summary> /// Defines the entry point of the application. /// </summary> private static void Main() { Base.Initialize(); GameDb.Initialize(); Handlers.Handlers.Initialize(); NetworkTcp.Initialize(); Program.Initialized = true; CommandLine.Initialize(); }
public ActionResult SpaceshipGameBS(SpaceshipGameViewModel score) { GameDb context = new GameDb(); SpaceshipGameEntity num = new SpaceshipGameEntity(); num.HighScore = score.HighScore; context.Spaceship.Add(num); context.SaveChanges(); var worstScore = context.Spaceship.OrderBy(c => c.HighScore).First(); context.Spaceship.Remove(worstScore); context.SaveChanges(); return RedirectToAction("SpaceshipGame"); }
static void Main(string[] args) { GameDb gameDb = new GameDb(); var validation = new UserValidationManager(); var gamerManager = new GamerManager(validation, gameDb); Gamer gamer1 = new Gamer { Id = 1, UserName = "******", Email = "salsağ@hotmail.com", FirstName = "Salih", LastName = "Sağsalim", IdentityNo = "11111111111", DOB = new DateTime(01 / 01 / 199) }; Gamer gamer2 = new Gamer { Id = 1, UserName = "******", Email = "salsağ@hotmail.com", FirstName = "Salih", LastName = "Sağsalim", IdentityNo = "11111111111", DOB = new DateTime(01 / 01 / 199) }; gamerManager.Add(gamer1); gamerManager.Add(gamer2); var salesManager = new SalesManager(gameDb); var campaignManager = new CampaignManager(gameDb); var campaignList = new List <Campaign>(); Campaign campaign = new Campaign { Id = 1, Name = "No Campaign", Discount = 0 }; campaignList.Add(campaign); Sale sale = new Sale { Id = 1, GamerId = 1, Gamer = gamer1, SaleDate = DateTime.Now, Campaigns = campaignList }; salesManager.Add(sale); }
void SaveHero(long userID, DHero dHero, GameDb db) { var hero = db.TBPLayerHero.Where(t => t.UserID == userID).SingleOrDefault(); if (hero == null) { return; } hero.Exp = dHero.Exprices; hero.Equips = JsonTool.Serialize(dHero.Equips); hero.Level = dHero.Level; hero.Magics = JsonTool.Serialize(dHero.Magics); }
public async Task <bool> AddAsync(Game item) { var newGame = await GameBackendService.CreateGame(item.Name, item.Players); if (newGame != null) { var newGameDb = new GameDb(newGame); await gameDatabase.SaveGameAsync(newGameDb); return(true); } return(false); }
public Game Get(long id) { GameDb game = gameDAO.GetExtended(id); Game game_newTyped = null; if (game != null) { game_newTyped = mapper.Map(game); } return(game_newTyped); }
///<summary> ///Maps properties from GameDb object to EntityORM object ///</summary> public static EntityORM Map(GameDb game, HashSet <string> attributes) { EntityORM entity = new EntityORM(); foreach (string attribute in attributes) { object value = null; // attribute value switch (attribute) { case "NAME": value = $"\'{game.Name}\'"; break; case "DESCRIPTION": value = $"\'{game.Description}\'"; break; case "GENRE": value = $"\'{game.Genre}\'"; break; case "LINK": value = $"\'{game.Link}\'"; break; case "LOGOURL": value = $"\'{game.LogoURL}\'"; break; case "COVERURL": value = $"\'{game.CoverURL}\'"; break; case "ISVERIFIED": value = (game.IsVerified) ? "\'y\'" : "\'n\'"; break; default: break; } entity.attributeValue.Add(attribute, value); } return(entity); }
public async Task <IEnumerable <Game> > GetAllAsync(bool forceRefresh = false) { var localGames = await gameDatabase.GetGamesAsync(); if (!localGames.Any()) { var remoteGames = await GameBackendService.GetGamesSelf(); foreach (var game in remoteGames) { var newGameDb = new GameDb(game); await gameDatabase.SaveGameAsync(newGameDb); } return(remoteGames); } return(localGames.Select(x => new Game(x))); }
///<summary> ///Maps properties from EntityORM object to GameDb object ///</summary> public static void Map(EntityORM entity, out GameDb game) { game = new GameDb(); foreach (KeyValuePair <string, object> aV in entity.attributeValue) { switch (aV.Key) // entity attribute { case "ID": game.Id = Convert.ToInt64(aV.Value); break; case "NAME": game.Name = aV.Value.ToString(); break; case "DESCRIPTION": game.Description = aV.Value.ToString(); break; case "GENRE": game.Genre = aV.Value.ToString(); break; case "LINK": game.Link = aV.Value.ToString(); break; case "LOGOURL": game.LogoURL = aV.Value.ToString(); break; case "COVERURL": game.CoverURL = aV.Value.ToString(); break; case "ISVERIFIED": game.IsVerified = ((string)aV.Value == "y") ? true : false; break; default: break; } } }
private static void SaveGame(GameBoard board) { Console.Clear(); Console.WriteLine("Saving Game"); Console.WriteLine("Please Write Name For Your Game And Press Enter"); Console.WriteLine("Leave Field Empty And Press Enter To Cancel Saving And Return To Menu"); Console.Write(">"); var title = Console.ReadLine()?.Trim(); if (!string.IsNullOrEmpty(title)) { GameDb.InsertDataToDb(board, title); // JSON // SaveGameJson.SaveGameState(board, title); } else { _gameMenu.Run(); } }
public override Response Interact(Player player, GameDb context, Mediator mediator) { context.Interactables.Where(i => i.Id == Id).Include("LeadsTo"); mediator.GetHandler <RoomUpdateAlerter>().Send(player.LocationId); player.Location = LeadsTo; context.SaveChanges(); mediator.GetHandler <RoomUpdateAlerter>().Send(LeadsTo.Id); string[] peopleInRoom = mediator.GetHandler <GetPlayer>().GetInRoom(LeadsTo.Id).Select(p => p.Name).ToArray(); var interactables = mediator.GetHandler <GetInteractable>().GetInRoom(LeadsTo.Id).ToArray(); return(Response.From(new RoomResponse { RoomId = LeadsTo.Id, Interactions = interactables.Select(i => i.GetDescriptor(context)).ToArray(), PeopleInRoom = peopleInRoom })); }
// insert game into database, including connections in PlayerGameDB and PlayerCardDB public Game BlStartGameDatabase(Game g) { PlayerDb playerDb = new PlayerDb(); GameDb gameDb = new GameDb(); PlayerGameDb playerGameDb = new PlayerGameDb(); PlayerCardDb playerCardDb = new PlayerCardDb(); playerDb.InsertList(g.Players); gameDb.Insert(g); // assign ID to game, and all players' IDs in there playerGameDb.Insert(g); playerCardDb.Insert(g); // save the changes and insert the data into the database gameDb.SaveChanges(); return(g); }
/// <summary> /// Defines the entry point of the application. /// </summary> internal static void Main() { Base.Initialize(); GameDb.Initialize(); HandlerFactory.Initialize(); using (SupercellGameServer GameServer = new SupercellGameServer()) { GameServer.Setup(9339); if (GameServer.Start() == false) { Console.WriteLine("[*] Server failed to start."); } Console.WriteLine("[*] Server is started."); Console.ReadKey(false); } Console.ReadKey(false); }
private static void CreateSaveMenu() { _saveMenu = new Menu(); _saveMenu.Title = "Saved Games"; _saveMenu.MenuItems = new List <MenuItem>(); // JSON // var savedGameFiles = SaveGameJson.GetSavedFileNames(); var savedGameFiles = GameDb.GetSavedGameNames(); foreach (var(key, value) in savedGameFiles) { Action loadOrDelete = () => CreateLoadMenu(key); _saveMenu.MenuItems.Add(new MenuItem() { Title = value, Execute = loadOrDelete }); } _saveMenu.MenuItems.Add( new MenuItem() { Title = "Return to Game Menu", Execute = StartGameMenu.Run }); _saveMenu.MenuItems.Add( new MenuItem() { Title = "Return to Main Menu", Execute = MainMenu.Run }); _saveMenu.MenuItems.Add( new MenuItem() { Title = "Exit", Execute = QuitGame }); }
/// <summary> /// Defines the entry point of the application. /// </summary> internal static void Main() { Base.Initialize(); GameDb.Initialize(); Devices.Initialize(); Players.Initialize(); Clans.Initialize(); Battles.Initialize(); Leaderboards.Initialize(); InboxManager.Initialize(); EventManager.Initialize(); BattleManager.Initialize(); RoyalTvManager.Initialize(); HandlerFactory.Initialize(); NetworkTcp.Initialize(); Program.Initialized = true; Console.CancelKeyPress += ConsoleOnCancelKeyPress; CommandLine.Initialize(); }
public GameDb Map(Game game) { GameDb game_newType = new GameDb(); #region Transfer main attributes game_newType.Id = game.Id; game_newType.Name = game.Name; game_newType.Description = game.Description; game_newType.Genre = game.Genre; game_newType.Link = game.Link; game_newType.LogoURL = game.LogoURL; game_newType.CoverURL = game.CoverURL; game_newType.IsVerified = game.IsVerified; #endregion #region Transfering interop attributes //EMPTY #endregion return(game_newType); }