public void InteractWithAdjacentCharacter(ICharacter adjacentCharacter, GameProcessor gameProcessor) { if (adjacentCharacter is DumbGhostCharacter) { gameProcessor.LoseGame(); } }
private void OnThrowUndo() { if (GameProcessor.CanUndoThrow) { GameProcessor.UndoThrow(); } }
static void Main(string[] args) { GameProcessor gameProcessor = new GameProcessor(); gameProcessor.CreateNewGame(); gameProcessor.StartGame(); }
public ActionResult Account() { var data = UserProcessor.LoadUser(User.Identity.GetUserId()); GameUser user = new GameUser { FirstName = data.Fname, LastName = data.Lname, Age = data.Age, Balance = data.Balance }; user.GamesBought = PurchaseProcessor.GetGamesBought(User.Identity.GetUserId()); user.GamesSold = PurchaseProcessor.GetGamesSold(User.Identity.GetUserId()); var list = GameProcessor.GetGamesOnSale(User.Identity.GetUserId()); user.GamesOnSale = new List <Game>(); foreach (var row in list) { user.GamesOnSale.Add(new Game { Name = row.Name, CreatedBy = row.CreatedBy, Year = row.Year, GameConsole = row.Console }); } return(View(user)); }
public async Task <IActionResult> Post([FromForm] GameDTO game) { try { GameProcessor processor = new GameProcessor(game); GameResult gameResult = processor.Process(); HistoryDTO historyDTO = new HistoryDTO { GameResultType = gameResult.GameResultType, FirstPlayerName = game.FirstPlayerName, FirstPlayerElement = game.FirstPlayerElement, SecondPlayerName = game.SecondPlayerName, SecondPlayerElement = game.SecondPlayerElement }; await historyService.AddAsync(historyMapper.ToEntity(historyDTO)); return(Ok(gameResult)); } catch (Exception ex) { return(StatusCode(500, ex.Message)); } }
static void Main(string[] args) { var proc = new GameProcessor(); proc.SetPreset(new ClassicChessPreset()); proc.Start(); }
public void TakeTurn() { ++turnCount; if (sim.currentTurn == Turn.Type.Player) { var playerProcessor = new PlayerProcessor(sim); playerProcessor.TakeTurn(); } else if (sim.currentTurn == Turn.Type.Game) { var gameProcessor = new GameProcessor(sim); gameProcessor.TakeTurn(); } bool atTurnLimit = (turnCount >= maxTurnCount); if (sim.requiresInput || atTurnLimit) { NotificationCenter.PostNotification(Constants.OnRenderEvents); return; } else { TakeTurn(); } }
public GameProcessorTests() { var collisionMapProcessor = new Mock <ICollisionMapProcessor>(); _gameProcessor = new GameProcessor(new FrameProcessor(new OutcomeProcessor(new OutcomeScoreProcessor()), collisionMapProcessor.Object)); _sourceGame = new Game(); _sourceGame.Id = "test123"; var snake = new Snake { Ang = 0 }; _sourceGame.Frames = new List <SlitherFrame>(); _sourceGame.Frames.Add(new SlitherFrame { Kills = 0, SnakeLength = 10, Time = DateTimeOffset.Now.ToUnixTimeMilliseconds() - 60000, Snake = snake }); _sourceGame.Frames.Add(new SlitherFrame { Kills = 0, SnakeLength = 50, Time = DateTimeOffset.Now.ToUnixTimeMilliseconds() - 30000, Snake = snake }); _sourceGame.Frames.Add(new SlitherFrame { Kills = 2, SnakeLength = 105, Time = DateTimeOffset.Now.ToUnixTimeMilliseconds(), Snake = snake }); _processedGame = _gameProcessor.ProcessGame(_sourceGame); }
static void Main(string[] args) { Console.WriteLine("Starting"); GameDatabase.DatabaseFolder = "C:\\SlitherShark\\database\\processed"; GameDatabase.LoadGames(); var frameProcessor = new FrameProcessor(new OutcomeProcessor(new OutcomeScoreProcessor()), new CollisionMapProcessor(new CollisionMapResolutionProcessor(new CollisionSliceProcessor(new FoodSliceProcessor(new CollisionService()), new BadCollisionSliceProcessor(new CollisionService()), new SelfSliceProcessor(new CollisionService()))), new SlitherFrameNormalizer())); var gameProcessor = new GameProcessor(frameProcessor); var sourceFolder = "C:\\SlitherShark\\database\\source"; foreach (var fileName in Directory.GetFiles(sourceFolder)) { Console.WriteLine(fileName); var jsonString = File.ReadAllText(fileName); var sourceGame = JsonConvert.DeserializeObject <Game>(jsonString, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto, NullValueHandling = NullValueHandling.Ignore, }); var processedGame = gameProcessor.ProcessGame(sourceGame); GameDatabase.AddGame(processedGame); } Console.WriteLine("Done"); }
public void GameProcessor_Step_0() { Map map = GetMap(); GameProcessor processor = new GameProcessor(map, new GameRulesDefault()); Assert.AreEqual(7, map.Fields.Count(x => x.Live)); }
public CharacterProcessor(ICharacterInteractionProcessor interactionProcessor, IGameTileInteractionProcessor gameTileInteractionProcessor, GameProcessor gameProcessor) { CharacterInteractionProcessor = interactionProcessor; GameTileInteractionProcessor = gameTileInteractionProcessor; GameProcessor = gameProcessor; GameState = gameProcessor.GameState; }
public LoopingGameClient(GameProcessor gameProcessor, INewGameProvider localNewGameProvider, IGamePersistence gamePersistence, IGameRendererFactory gameRendererFactory, string savePath) { _gameProcessor = gameProcessor; _localNewGameProvider = localNewGameProvider; _gamePersistence = gamePersistence; _gameRendererFactory = gameRendererFactory; _savePath = savePath; }
public Cell(int index, Windows.UI.Xaml.Media.Brush foregroundBrush, GameProcessor gameProcessor, char mark) { m_index = index; m_mark = mark; m_gameProcessor = new WeakReference(gameProcessor); ForegroundBrush = foregroundBrush; m_selectCommand = new DelegateCommand(new ExecuteDelegate(Select), null); }
public static void Main(string[] args) { var randomBoardFactory = new RandomBoardFactory(); var consoleInterface = new ConsoleInterface(); var game = new GameProcessor(randomBoardFactory, consoleInterface); game.Play(); Environment.Exit(0); }
private void saveB_Click(object sender, EventArgs e) { int pegi = int.Parse(pegiTB.Text); float priceNew = float.Parse(priceNewTB.Text); float priceOld = float.Parse(priceOldTB.Text); float pricePurchase = float.Parse(pricePurchaseTB.Text); int result = GameProcessor.CreateGame(nameTB.Text, pegi, descriptionTB.Text, priceNew, priceOld, pricePurchase, imageTB.Text, availabilityTB.Text); }
public async Task <List <Games> > GetUpcomingGames() { DateTime weekAgo = DateTime.Today.AddDays(-7); long weekAgoUnix = DateToUnix.GetUnixTime(weekAgo); return(await GameProcessor .LoadGames("fields *; limit 500; where themes = 19 & first_release_date >" + weekAgoUnix + "; sort first_release_date asc;").ConfigureAwait(false)); }
public async Task <List <Games> > GetLatestGames() { DateTime today = DateTime.Today; long todayUnix = DateToUnix.GetUnixTime(today); return(await GameProcessor .LoadGames("fields *; limit 20; where themes = 19 & first_release_date < " + todayUnix + "; sort first_release_date desc;").ConfigureAwait(false)); }
public static async void InitializeGameClient() { await GameProcessor.AuthenticateGameApi(); GameApiClient = new HttpClient(); GameApiClient.DefaultRequestHeaders.Accept.Clear(); GameApiClient.DefaultRequestHeaders.Add("Client-ID", GameProcessor.ClientId); GameApiClient.DefaultRequestHeaders.Add("Authorization", "Bearer " + GameProcessor.GameApiData.Access_token); ApiClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); }
public ActionResult AddGame(Game game) { if (ModelState.IsValid) { int recs = GameProcessor.CreateGame(game.Name, game.CreatedBy, game.Year, game.GameConsole, User.Identity.GetUserId()); return(RedirectToAction("BrowseGames")); } return(View()); }
public ActionResult BuyGame(Game game) { if (UserProcessor.CheckBalance(User.Identity.GetUserId())) { var data = GameProcessor.LoadGame(game.Id.ToString()); int rec = PurchaseProcessor.PurchaseGame(data.Name, data.OwnerId, User.Identity.GetUserId()); int recs = GameProcessor.BuyGame(game.Id); return(RedirectToAction("BrowseGames")); } return(RedirectToAction("UpdateBalance")); }
public void GameFactoryReturnsGame() { //Arrange UserInterface userInterface = new UserInterface(new Utility()); BoardFactory boardFactory = new BoardFactory(); PlayerFactory playerFactory = new PlayerFactory(); //Act GameProcessor gameProcessor = new GameProcessor(userInterface, boardFactory, playerFactory); //Asset Assert.That(gameProcessor, Is.TypeOf <GameProcessor>()); }
public async Task <List <Cover> > GetGameCoverById(int?id) { if (id == null) { return(null); } int coverId = (int)id; string query = "fields *; where game =" + coverId + ";"; return(await GameProcessor.LoadCover(query).ConfigureAwait(false)); }
public async Task <List <Games> > GetGameById(int?id) { if (id == null) { return(null); } int gameId = (int)id; string query = "fields *; where id =" + gameId + ";"; return(await GameProcessor.LoadGames(query).ConfigureAwait(false)); }
/// <summary> /// Creates a new TurnManager instance. /// </summary> /// <param name="context"></param> public TurnManager(ServerContext context) { this.context = context; this.game = context.GameProcessor; this.queueMngr = QueueManager.Singletone; this.timer = new Stopwatch(); // Create a server timer for executing turns. double clockCycleDuration = (double)context.TurnDuration; clockCycleDuration *= 0.9; // TODO: [LOW] thislooks like an ugly hack, reconsider implementing dynamic clock frequency balancing. clock = new System.Timers.Timer(clockCycleDuration); clock.Elapsed += new System.Timers.ElapsedEventHandler(clock_Elapsed); }
public MainGame(Player[] players, Player organellePlayer, StaticsDB statics, StatesDB states, TemporaryDB derivates) { this.Turn = 0; this.StareaterOrganelles = organellePlayer; this.MainPlayers = players; this.IsReadOnly = false; this.Statics = statics; this.States = states; this.Derivates = derivates; this.Processor = new GameProcessor(this); }
static void Main(string[] args) { GameProcessor gameProcessor = new GameProcessor(); //controller ConsoleOutput ConsoleOutput = new ConsoleOutput(); //view ConsoleInput ConsoleInput = new ConsoleInput(gameProcessor); ConsoleOutput.ListenTo(gameProcessor); ConsoleInput.StartGame(); }
public ActionResult BuyGame(int id) { var data = GameProcessor.LoadGame(id.ToString()); Game game = new Game { Id = data.Id, Name = data.Name, CreatedBy = data.CreatedBy, Year = data.Year, GameConsole = data.Console }; return(View(game)); }
static void Main(string[] args) { var arguments = ArgumentParser.ParseArguments(args); RegisterComponents(); var loaderFactory = new LoaderFactory(); var newGameProvider = new LocalNewGameProvider(loaderFactory); var gameProcessor = new GameProcessor(Configuration.TickPeriod); var gamePersistence = new LocalGamePersistence(loaderFactory, Configuration.DefaultSaveDirectory); var gameRendererFactory = new GameRendererFactory(); var client = new LoopingGameClient(gameProcessor, newGameProvider, gamePersistence, gameRendererFactory, arguments.SaveFileName); client.PlayGame(arguments); }
private static void FinalCheck(ActionKey actionKey) { if (!KeyboardMouseUtility.AnyButtonsPressed() && actionKey.actionIndentifierString.Equals(Game1.cancelString)) { GameProcessor.bInGameMenu = false; if (CombatProcessor.bIsRunning) { GameProcessor.DisableMenuStage(); PlayerController.currentController = PlayerController.Controllers.Combat; } else { PlayerController.currentController = PlayerController.Controllers.NonCombat; } } }
public void RightButtonPlayerAction() { if (selectedCharTurn != null && !selectedCharTurn.bIsCompleted) { BaseCharacter selectedChar = selectedCharTurn.character; #region Right Button Logic Vector2 temp = new Vector2(-1); if (selectedCharTurn.returnCompleteArea().Find(t => t.mapPosition.Contains(GameProcessor.EditorCursorPos)) != null) { temp = (GameProcessor.EditorCursorPos / 64).ToPoint().ToVector2() * 64; } if (temp != new Vector2(-1)) // if (temp != new Vector2(-1) && !selectedChar.spriteGameSize.Contains(temp)) { if (CombatProcessor.zone.Contains(GameProcessor.EditorCursorPos) && !PathMoveHandler.bIsBusy) { CombatProcessor.allPossibleNodes = PathFinder.NewPathSearch(selectedChar.position, GameProcessor.EditorCursorPos, selectedCharTurn.returnCompleteArea()); PathMoveHandler.Start(selectedChar, CombatProcessor.allPossibleNodes); bPlayerMustSelectAction = true; BattleGUI.InitializePopUpMenu(); //FinalizeCharacterRound(); } else if (CombatProcessor.zone.Contains(GameProcessor.EditorCursorPos) && PathMoveHandler.bIsBusy) { PathMoveHandler.SkipPathMovement(); CombatProcessor.allPossibleNodes = PathFinder.NewPathSearch(selectedChar.position, GameProcessor.EditorCursorPos, selectedCharTurn.returnCompleteArea()); PathMoveHandler.Start(selectedChar, CombatProcessor.allPossibleNodes); } } #endregion } if (selectedCharTurn == null) { foreach (var item in CombatProcessor.zoneTiles) { if (item.mapPosition.Contains(KeyboardMouseUtility.gameMousePos)) { GameProcessor.GenerateCameraInstant(KeyboardMouseUtility.gameMousePos, 3, GameProcessor.zoom); } } } }
private void HandleLoadGame() { if (selectedTab != null) { if (func != null) { func(selectedTab.getParentSaveData().saveDataName); return; } if (sc != null) { sc.End(); } GameProcessor.LaunchFromSaveFile(selectedTab.getParentSaveData(), Game1.rootTBAGW); } }
/// <summary> /// 初始化网络监听 /// </summary> /// <param name="crossdomain"></param> private void InitNetFacade(string crossdomain) { string policy = null; try { if (!string.IsNullOrEmpty(crossdomain)) { using (FileStream fs = File.OpenRead(crossdomain)) using (StreamReader sr = new StreamReader(fs, Encoding.UTF8, false)) { policy = sr.ReadToEnd(); } } } catch { } int maxClient = ConfigLoader.Config.MaxClient; int sendQueueSize = ConfigLoader.Config.SendQueueSize; const int receiveSize = 8 * 1024; const int sendSize = 64 * 1024; AmfCodec.Init(maxClient, CommandManager.Instance); IHandshake hander = new Handshaker(policy); GMProcessor gmProcessor = new GMProcessor(receiveSize); SessionFactory gmFactory = new SessionFactory(8, receiveSize, sendSize, 8, gmProcessor); gmServer = new AmfServer(gmFactory, gmFactory, hander); gmServer.Start(ConfigLoader.Config.EpGM); GameProcessor gameProcessor = new GameProcessor(receiveSize); SessionFactory gameFactory = new SessionFactory(maxClient, receiveSize, sendSize, sendQueueSize, gameProcessor); server = new AmfServer(gameFactory, gameFactory, hander); server.Start(ConfigLoader.Config.EpGame); Notifier.Instance.Publish(new Notification(GMCommand.GMStart, new object[] { this }), false); }