Ejemplo n.º 1
0
        public static Played[] GetBoardResult(Played[][] board)
        {
            var stopWatch = new Stopwatch();

            stopWatch.Start();
            var result = new Played[9];

            for (var boardPos = 0; boardPos < 9; boardPos++)
            {
                var sBoard = board[boardPos];
                if (IsWinOneBoard(sBoard, Player.Self))
                {
                    result[boardPos] = Played.Self;
                }
                else if (IsWinOneBoard(sBoard, Player.Opponent))
                {
                    result[boardPos] = Played.Opponent;
                }
                else
                {
                    result[boardPos] = Played.Empty;
                }
            }
            stopWatch.Stop();
            Monitoring.ComputeBoardResultTime += stopWatch.Elapsed.TotalSeconds;
            return(result);
        }
Ejemplo n.º 2
0
    public void OnPlay()
    {
        Played evt = Pools.Claim <Played>();

        evt.Init(this);
        EventManager.SendEvent(evt);
    }
Ejemplo n.º 3
0
        public void Play()
        {
            BodyPart randomBodyPart = (BodyPart)rnd.Next(Enum.GetNames(typeof(BodyPart)).Length);

            HitEnemyBodyPart = BlockBodyPart = randomBodyPart;
            Played?.Invoke(this, BlockBodyPart);
        }
Ejemplo n.º 4
0
 public void UserProtect(BodyPart bodyPart)
 {
     if (humanTurn)
     {
         BlockBodyPart = bodyPart;
         Played?.Invoke(this, bodyPart);
     }
 }
Ejemplo n.º 5
0
 public void UserAttack(BodyPart bodyPart)
 {
     if (humanTurn)
     {
         HitEnemyBodyPart = bodyPart;
         Played?.Invoke(this, bodyPart);
     }
 }
Ejemplo n.º 6
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hash = 17;
         hash = hash * 23 + TitleUnicode.GetHashCode();
         hash = hash * 23 + TitleRoman.GetHashCode();
         hash = hash * 23 + ArtistUnicode.GetHashCode();
         hash = hash * 23 + ArtistRoman.GetHashCode();
         hash = hash * 23 + Creator.GetHashCode();
         hash = hash * 23 + DiffName.GetHashCode();
         hash = hash * 23 + Mp3Name.GetHashCode();
         hash = hash * 23 + Md5.GetHashCode();
         hash = hash * 23 + OsuFileName.GetHashCode();
         hash = hash * 23 + Tags.GetHashCode();
         hash = hash * 23 + Somestuff.GetHashCode();
         hash = hash * 23 + _state.GetHashCode();
         hash = hash * 23 + Circles.GetHashCode();
         hash = hash * 23 + Sliders.GetHashCode();
         hash = hash * 23 + Spinners.GetHashCode();
         hash = hash * 23 + EditDate.GetHashCode();
         hash = hash * 23 + ApproachRate.GetHashCode();
         hash = hash * 23 + CircleSize.GetHashCode();
         hash = hash * 23 + HpDrainRate.GetHashCode();
         hash = hash * 23 + OverallDifficulty.GetHashCode();
         hash = hash * 23 + SliderVelocity.GetHashCode();
         hash = hash * 23 + DrainingTime.GetHashCode();
         hash = hash * 23 + TotalTime.GetHashCode();
         hash = hash * 23 + PreviewTime.GetHashCode();
         hash = hash * 23 + MapId.GetHashCode();
         hash = hash * 23 + MapSetId.GetHashCode();
         hash = hash * 23 + ThreadId.GetHashCode();
         hash = hash * 23 + OsuGrade.GetHashCode();
         hash = hash * 23 + TaikoGrade.GetHashCode();
         hash = hash * 23 + CatchGrade.GetHashCode();
         hash = hash * 23 + ManiaGrade.GetHashCode();
         hash = hash * 23 + Offset.GetHashCode();
         hash = hash * 23 + StackLeniency.GetHashCode();
         hash = hash * 23 + PlayMode.GetHashCode();
         hash = hash * 23 + Source.GetHashCode();
         hash = hash * 23 + AudioOffset.GetHashCode();
         hash = hash * 23 + LetterBox.GetHashCode();
         hash = hash * 23 + Played.GetHashCode();
         hash = hash * 23 + LastPlayed.GetHashCode();
         hash = hash * 23 + IsOsz2.GetHashCode();
         hash = hash * 23 + Dir.GetHashCode();
         //hash = hash * 23 + LastSync.GetHashCode(); //This value is updated by osu even if no changes were made to the actual data
         hash = hash * 23 + DisableHitsounds.GetHashCode();
         hash = hash * 23 + DisableSkin.GetHashCode();
         hash = hash * 23 + DisableSb.GetHashCode();
         hash = hash * 23 + BgDim.GetHashCode();
         hash = hash * 23 + ModPpStars.GetHashCode();
         hash = hash * 23 + MaxBpm.GetHashCode();
         hash = hash * 23 + MinBpm.GetHashCode();
         hash = hash * 23 + MainBpm.GetHashCode();
         return(hash);
     }
 }
Ejemplo n.º 7
0
 public void AddPlayedCard(Card card)
 {
     if (card == null)
     {
         return;
     }
     card.User = this.BasicUser();
     Played.Add(card);
 }
Ejemplo n.º 8
0
    public void Play(int multiplier = 1)
    {
        Modifier = multiplier;

        _isPlaying   = true;
        _isRewinding = false;

        Played?.Invoke(this, EventArgs.Empty);
    }
Ejemplo n.º 9
0
        public Task NotifyPlay()
        {
            if (Played != null)
            {
                return(Played.Invoke());
            }

            return(Task.CompletedTask);
        }
Ejemplo n.º 10
0
        public IActionResult Create(AssetCreateIndex assetCreate)
        {
            if (ModelState.IsValid)
            {
                var webRoot = _env.WebRootPath;

                List <Image> images = new List <Image>();

                if (assetCreate.imageUpload != null)
                {
                    foreach (var file in assetCreate.imageUpload)
                    {
                        var filePath = Path.Combine(webRoot.ToString() + "\\images\\plays\\" + file.FileName);

                        if (file.FileName.Length > 0)
                        {
                            using (var stream = new FileStream(filePath, FileMode.Create))
                            {
                                file.CopyTo(stream);
                            }

                            images.Add(new Image
                            {
                                Url = "\\images\\plays\\" + file.FileName
                            });
                        }
                    }
                }

                List <PlayerPlayed> players = new List <PlayerPlayed>();

                foreach (var playerId in assetCreate.PlayerIds)
                {
                    players.Add(new PlayerPlayed
                    {
                        Player = _assets.GetPlayerById(playerId)
                    });
                }

                var played = new Played()
                {
                    Date        = DateTime.Now,
                    Description = assetCreate.Descryption,
                    Boardgame   = _assetBoardgame.GetById(assetCreate.BoardgameId),
                    Images      = images,
                    Players     = players.AsEnumerable()
                };

                _assets.Add(played);
                return(RedirectToAction("Index"));
            }

            return(View(assetCreate));
        }
        void OnResumed(PlayableDirector director)
        {
            if (m_ControlsMarsLifecycle)
            {
                MarsTime.Play();
            }

            PlaybackPauseTime = m_Duration;
            m_Paused          = false;
            Played?.Invoke();
        }
Ejemplo n.º 12
0
 public void Play(int i)
 {
     for (var j = 0; j < i; j++)
     {
         if (Deck.Cards.Count > 0)
         {
             Played.Add(Deck.Remove());
             ActiveCard = Played[Played.Count - 1];
         }
     }
 }
Ejemplo n.º 13
0
        protected override WebRequest CreateWebRequest()
        {
            var req = base.CreateWebRequest();

            if (query != null)
            {
                req.AddParameter("q", query);
            }

            if (General != null && General.Any())
            {
                req.AddParameter("c", string.Join('.', General.Select(e => e.ToString().Underscore())));
            }

            if (ruleset.OnlineID >= 0)
            {
                req.AddParameter("m", ruleset.OnlineID.ToString());
            }

            req.AddParameter("s", SearchCategory.ToString().ToLowerInvariant());

            if (Genre != SearchGenre.Any)
            {
                req.AddParameter("g", ((int)Genre).ToString());
            }

            if (Language != SearchLanguage.Any)
            {
                req.AddParameter("l", ((int)Language).ToString());
            }

            req.AddParameter("sort", $"{SortCriteria.ToString().ToLowerInvariant()}_{directionString}");

            if (Extra != null && Extra.Any())
            {
                req.AddParameter("e", string.Join('.', Extra.Select(e => e.ToString().ToLowerInvariant())));
            }

            if (Ranks != null && Ranks.Any())
            {
                req.AddParameter("r", string.Join('.', Ranks.Select(r => r.ToString())));
            }

            if (Played != SearchPlayed.Any)
            {
                req.AddParameter("played", Played.ToString().ToLowerInvariant());
            }

            req.AddParameter("nsfw", ExplicitContent == SearchExplicit.Show ? "true" : "false");

            req.AddCursor(cursor);

            return(req);
        }
Ejemplo n.º 14
0
        public override string ToString()
        {
            var final = new StringBuilder();

            final.Append($"{Name.PadRight(30)} | ");
            final.Append($"{Played.ToString().PadLeft(2)} | ");
            final.Append($"{Won.ToString().PadLeft(2)} | ");
            final.Append($"{Drawn.ToString().PadLeft(2)} | ");
            final.Append($"{Lost.ToString().PadLeft(2)} | ");
            final.Append($"{Point.ToString().PadLeft(2)}");

            return(final.ToString());
        }
Ejemplo n.º 15
0
        public IActionResult Update(AssetPlayedUpdate assetCreate)
        {
            if (ModelState.IsValid)
            {
                var webRoot = _env.WebRootPath;

                List <Image> images = new List <Image>();

                if (assetCreate.imageUpload != null)
                {
                    foreach (var file in assetCreate.imageUpload)
                    {
                        var filePath = Path.Combine(webRoot.ToString() + "\\images\\plays\\" + file.FileName);

                        if (file.FileName.Length > 0)
                        {
                            using (var stream = new FileStream(filePath, FileMode.Create))
                            {
                                file.CopyTo(stream);
                            }

                            images.Add(new Image
                            {
                                Url = "\\images\\plays\\" + file.FileName
                            });
                        }
                    }
                }

                var played = new Played()
                {
                    Id          = assetCreate.Id,
                    Date        = DateTime.Now,
                    Description = assetCreate.Descryption,
                    Boardgame   = _assetBoardgame.GetById(assetCreate.BoardgameId)
                };

                if (images.Count > 0)
                {
                    played.Images = images;
                }

                _assets.Update(played);
                return(RedirectToAction("Detail", new { Id = played.Id }));
            }

            return(View());
        }
Ejemplo n.º 16
0
        public void TestScoringEmpty()
        {
            var board = new Played[9][];

            for (var i = 0; i < 9; i++)
            {
                board[i] = new Played[9];
                for (var j = 0; j < 9; j++)
                {
                    board[i][j] = Played.Empty;
                }
            }

            var score = AlgoHeuristic.ComputeScore(board, AlgoHeuristic.GetBoardResult(board));

            Assert.AreEqual(score, 0);
        }
        protected override WebRequest CreateWebRequest()
        {
            var req = base.CreateWebRequest();

            req.AddParameter("q", query);

            if (ruleset.ID.HasValue)
            {
                req.AddParameter("m", ruleset.ID.Value.ToString());
            }

            req.AddParameter("s", SearchCategory.ToString().ToLowerInvariant());

            if (Genre != SearchGenre.Any)
            {
                req.AddParameter("g", ((int)Genre).ToString());
            }

            if (Language != SearchLanguage.Any)
            {
                req.AddParameter("l", ((int)Language).ToString());
            }

            req.AddParameter("sort", $"{SortCriteria.ToString().ToLowerInvariant()}_{directionString}");

            if (Extra != null && Extra.Any())
            {
                req.AddParameter("e", string.Join('.', Extra.Select(e => e.ToString().ToLowerInvariant())));
            }

            if (Ranks != null && Ranks.Any())
            {
                req.AddParameter("r", string.Join('.', Ranks.Select(r => r.ToString())));
            }

            if (Played != SearchPlayed.Any)
            {
                req.AddParameter("played", Played.ToString().ToLowerInvariant());
            }

            req.AddCursor(cursor);

            return(req);
        }
Ejemplo n.º 18
0
        private List <Played[]> Combine(int n)
        {
            if (n == 1)
            {
                var first = new Played[9];
                first[0] = Played.Empty;
                var second = new Played[9];
                second[0] = Played.Opponent;
                var third = new Played[9];
                third[0] = Played.Self;
                return(new List <Played[]>()
                {
                    first, second, third
                });
            }
            else
            {
                var minusOne  = Combine(n - 1);
                var newResult = new List <Played[]>();
                foreach (var previous in minusOne)
                {
                    var first = new Played[9];
                    Array.Copy(previous, 0, first, 0, 9);
                    first[n - 1] = Played.Empty;
                    newResult.Add(first);
                    var second = new Played[9];
                    Array.Copy(previous, 0, second, 0, 9);
                    second[n - 1] = Played.Opponent;
                    newResult.Add(second);
                    var third = new Played[9];
                    Array.Copy(previous, 0, third, 0, 9);
                    third[n - 1] = Played.Self;
                    newResult.Add(third);
                }

                return(newResult);
            }
        }
Ejemplo n.º 19
0
 public void Add(Played played)
 {
     _dbContext.Add(played);
     _dbContext.SaveChanges();
 }
        void OnEnable()
        {
            if (Director == null || Director.playableAsset == null)
            {
                Debug.LogError(
                    $"You must call {nameof(SetupFromRecordingInfo)} on {nameof(RecordedSessionDirector)} before enabling it");

                enabled = false;
                return;
            }

            IsStarting = true;
            m_Paused   = false;
            Director.RebuildGraph(); // Ensure new playables are created
            SetTime(0d);
            Director.Play();
            Director.played  += OnResumed;
            Director.paused  += OnPaused;
            Director.stopped += OnStopped;
            IsPlaying         = true;
            IsStarting        = false;
            Played?.Invoke();

            // Notifications do not fire from manual timeline updates.
            // https://answers.unity.com/questions/1665172/markers-and-signal-emitters-not-working-when-timel.html
            // We must sort notifications by time and then directly send them to receivers for manual evaluation.
            var playableGraph = Director.playableGraph;
            var outputCount   = playableGraph.GetOutputCount();

            m_TimelineNotifications.Clear();
            m_NotificationReceivers.Clear();
            m_NotificationsSent = 0;
            for (var i = 0; i < outputCount; i++)
            {
                var output   = playableGraph.GetOutput(i);
                var playable = output.GetSourcePlayable().GetInput(i);
                var track    = output.GetReferenceObject() as TrackAsset;
                if (track == null || !(track is MarkerTrack))
                {
                    continue;
                }

                var targetObject = Director.GetGenericBinding(track);
                if (targetObject == null)
                {
                    continue;
                }

                var targetGameObject = targetObject as GameObject;
                var targetComponent  = targetObject as Component;
                if (targetGameObject == null && targetComponent == null)
                {
                    continue;
                }

                var notificationReceivers = new List <INotificationReceiver>();
                if (targetGameObject != null)
                {
                    targetGameObject.GetComponents(notificationReceivers);
                }
                else
                {
                    targetComponent.GetComponents(notificationReceivers);
                }

                m_NotificationReceivers[playable] = notificationReceivers;

                foreach (var marker in track.GetMarkers())
                {
                    if (!(marker is INotification notification))
                    {
                        continue;
                    }

                    m_TimelineNotifications.Add(new NotificationData
                    {
                        Notification = notification,
                        Time         = marker.time,
                        Origin       = playable
                    });
                }
            }

            m_TimelineNotifications.Sort((first, second) => first.Time.CompareTo(second.Time));
        }
Ejemplo n.º 21
0
 public void Update(Played played)
 {
     _dbContext.Update(played);
     _dbContext.SaveChanges();
 }
Ejemplo n.º 22
0
 public void Play()
 {
     _videoPlayer.Play();
     Played?.Invoke();
 }
Ejemplo n.º 23
0
        public void Play(int index)
        {
            // Check if he can play
            if (IsGameOver)
            {
                throw new GameException(GameErrorType.GameOver);
            }
            if (index <= 0 && index >= 8)
            {
                throw new GameException(GameErrorType.IndexOutOfRange);
            }
            if (plays[index] != GamePlay.None)
            {
                throw new GameException(GameErrorType.IndexPlayedOn);
            }

            // Play
            plays[index] = CurrentPlayer;


            // Chack if current player wins
            foreach (var winLine in Winners)
            {
                if (plays[winLine[0]] == GamePlay.None || plays[winLine[1]] == GamePlay.None || plays[winLine[2]] == GamePlay.None)
                {
                    continue;
                }

                if (plays[winLine[0]] == plays[winLine[1]] && plays[winLine[1]] == plays[winLine[2]])
                {
                    Winning = new GameWin(CurrentPlayer, winLine);

                    IsGameOver = true;
                    Played?.Invoke(this, EventArgs.Empty);
                    GameOver?.Invoke(this, new GameOverEventArgs(Winning));
                    return;
                }
            }

            // Chack if game is over with no winner
            if (!plays.Contains(GamePlay.None) ||
                (!plays.Select((value, i) => new { value, index = i })
                 .Where((play) => Array.IndexOf(new int[] { 0, 1, 2, 6, 7, 8 }, play.index) > -1)
                 .Select(p => p.value).Contains(GamePlay.None) &&
                 plays[0] == plays[2] && plays[2] == plays[7] &&
                 plays[1] == plays[6] && plays[6] == plays[8]) ||
                (!plays.Select((value, i) => new { value, index = i })
                 .Where((play) => Array.IndexOf(new int[] { 0, 2, 3, 5, 6, 8 }, play.index) > -1)
                 .Select(p => p.value).Contains(GamePlay.None) &&
                 plays[0] == plays[5] && plays[5] == plays[6] &&
                 plays[2] == plays[3] && plays[3] == plays[8]))
            {
                Winning = new GameWin(GamePlay.None, null);

                IsGameOver = true;
                Played?.Invoke(this, EventArgs.Empty);
                GameOver?.Invoke(this, new GameOverEventArgs(Winning));
                return;
            }

            Played?.Invoke(this, EventArgs.Empty);
            // If not over get ready for next round
            CurrentPlayer = (GamePlay)((int)CurrentPlayer % 2 + 1);

            // Auto play if only one left
            if (plays.Where((p) => p == GamePlay.None).Count() == 1)
            {
                Play(plays.IndexOf(GamePlay.None));
            }
        }
Ejemplo n.º 24
0
 public void Delete(Played played)
 {
     _dbContext.Remove(played);
     _dbContext.SaveChanges();
 }
Ejemplo n.º 25
0
 public void PlayedTest()
 {
     var s = new Played().Scrape("http://played.to/embed-vadzbjzqsuw5-640x360.html");
 }
Ejemplo n.º 26
0
 public override string ToString() => $"{Type}: {Played.ToCardString()}";