private static bool DetectPal(GameInfo game, byte[] rom) { // force NTSC mode for the new core we instantiate var newGame = game.Clone(); if (newGame["PAL"]) { newGame.RemoveOption("PAL"); } if (!newGame["NTSC"]) { newGame.AddOption("NTSC", ""); } // here we advance past start up irregularities to see how long a frame is based on calls to Vsync // we run 72 frames, then run 270 scanlines worth of cycles. // if we don't hit a new frame, we can be pretty confident we are in PAL using var emu = new Atari2600(newGame, rom, null, null); for (int i = 0; i < 72; i++) { emu.FrameAdvance(NullController.Instance, false, false); } for (int i = 0; i < 61560; i++) { emu.Cycle(); } bool pal = !emu._tia.New_Frame; Console.WriteLine("PAL Detection: {0}", pal); return(pal); }
private static bool DetectPal(GameInfo game, byte[] rom) { // force NTSC mode for the new core we instantiate var newgame = game.Clone(); if (newgame["PAL"]) { newgame.RemoveOption("PAL"); } if (!newgame["NTSC"]) { newgame.AddOption("NTSC"); } // give the emu a minimal of input\output connections so it doesn't crash var comm = new CoreComm(null, null); using (Atari2600 emu = new Atari2600(new CoreComm(null, null), newgame, rom, null, null)) { emu.Controller = new NullController(); List <int> framecounts = new List <int>(); emu._tia.FrameEndCallBack = (i) => framecounts.Add(i); for (int i = 0; i < 71; i++) // run for 71 * 262 lines, since we're in NTSC mode { emu.FrameAdvance(false, false); } int numpal = framecounts.Count((i) => i > 287); bool pal = numpal >= 25; Console.WriteLine("PAL Detection: {0} lines, {1}", numpal, pal); return(pal); } }
public GameInfo OpenGame(Rules rules = null, string gameName = "Game", string team1Name = "Team1", string team2Name = "Team2") { rules = rules ?? new Rules(); Log.Verbose($"{this}: OpenGame({rules}, {gameName}, {team1Name}, {team2Name})"); if (gameName == null || team1Name == null || team2Name == null) { return(null); } var playerGroupInfo = new PlayerGroupInfo { Team1 = new TeamInfo { TeamName = team1Name, TeamId = Guid.NewGuid().ToString() }, Team2 = new TeamInfo { TeamName = team2Name, TeamId = Guid.NewGuid().ToString() } }; var gameInfo = new GameInfo { GameName = gameName, GameId = Guid.NewGuid().ToString(), Rules = rules, PlayerGroupInfo = playerGroupInfo }; _gameServiceDictionary[gameInfo.GameId] = new GameService(gameInfo); return((GameInfo)gameInfo?.Clone()); }
private PlayerGameInfo GetPlayerGameInfo(string playerId, bool calculateActions = true) { var playerGroupInfo = GameInfo.PlayerGroupInfo; var relativeGameInfo = (GameInfo)GameInfo.Clone(); relativeGameInfo.PlayerGroupInfo = playerGroupInfo.GetRelativePlayerGroupInfo(playerId); var relativePlayerInfo = relativeGameInfo.PlayerGroupInfo.Team1.Player1; var validActionIdList = calculateActions ? GetValidActionIdList(playerId) : new List <int>(); var playerHand = GetPlayerHand(GameStage, playerId)?.Cards ?.Select(c => (Card)c?.Clone()) .ToList(); var gameStageInfo = MapToGameStageInfo(GameStage); var relativeGameStageInfo = gameStageInfo.GetRelativeGameStageInfo(playerGroupInfo, playerId); return(new PlayerGameInfo { GameInfo = relativeGameInfo, PlayerInfo = relativePlayerInfo, ValidActionIdList = validActionIdList, PlayerHand = playerHand, GameStageInfo = relativeGameStageInfo }); }
public override object Clone() { return(new PlayAction { GameInfo = (GameInfo)GameInfo?.Clone(), PlayerInfo = (PlayerInfo)PlayerInfo?.Clone(), Card = (Card)Card?.Clone() }); }
public override object Clone() { return(new BetAction { GameInfo = (GameInfo)GameInfo?.Clone(), PlayerInfo = (PlayerInfo)PlayerInfo?.Clone(), Type = Type, Bet = (Bet)Bet?.Clone() }); }
public async Task <GameInfo> RetrieveQuestion(long gameId, string userId) { GameInfo gameInfo = await gameInfoService.RetrieveQuestion(gameId, userId); gameInfo = gameInfo.Clone(); foreach (QuestionInfo questionInfo in gameInfo.GameQuestionInfo.QuestionInfoList) { questionInfo.CorrectAnswer = null; } return(gameInfo); }