示例#1
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 0:
                m_Challenger = reader.ReadMobile();

                m_Organizers.Add(m_Challenger);

                m_GameLocked     = reader.ReadBool();
                m_GameInProgress = reader.ReadBool();
                m_TotalPurse     = reader.ReadInt();
                m_EntryFee       = reader.ReadInt();
                m_ArenaSize      = reader.ReadInt();
                m_TargetScore    = reader.ReadInt();
                m_DeathBall      = (DeathBall)reader.ReadItem();

                int count = reader.ReadInt();
                for (int i = 0; i < count; i++)
                {
                    ChallengeEntry entry = new ChallengeEntry();
                    entry.Participant = reader.ReadMobile();
                    string sname = reader.ReadString();
                    // look up the enum by name
                    ChallengeStatus status = ChallengeStatus.None;
                    try{
                        status = (ChallengeStatus)Enum.Parse(typeof(ChallengeStatus), sname);
                    } catch {}
                    entry.Status          = status;
                    entry.Accepted        = reader.ReadBool();
                    entry.PageBeingViewed = reader.ReadInt();
                    entry.Score           = reader.ReadInt();
                    entry.Winner          = reader.ReadBool();
                    entry.Team            = reader.ReadInt();

                    Participants.Add(entry);
                }
                break;
            }

            if (GameCompleted)
            {
                Timer.DelayCall(PostGameDecayTime, new TimerCallback(Delete));
            }

            // start the challenge timer
            StartChallengeTimer();

            SetNameHue();
        }
        private void UpdateStatusForChallengeEntry(int challengeEntryId, ChallengeStatus newStatus, DateTime timestamp)
        {
            using var serviceScope = Context.CreateScope();
            var challengePersistence = ServiceScopeHelper.GetService <ChallengePersistence>(serviceScope);

            var eventStream = Context.System.EventStream;

            challengePersistence.UpdateStatusInDb(challengeEntryId, newStatus, timestamp)
            .ContinueWith(updateTask =>
                          eventStream.Publish(
                              new ChallengeStatusUpdatedMessage
                                  (ChallengeEntry: updateTask.Result, NewStatus: newStatus)));
        }
        public async Task<ChallengeEntry> UpdateStatusInDb(
            int challengeEntryId, ChallengeStatus newStatus, DateTime timestamp)
        {
            var challengeBeforeUpdate = await _dbContext.ChallengeEntries.FindAsync(challengeEntryId);
            // if (challengeToUpdate == null)
            // TODO: return OperationResult.NotFound;
            _dbContext.Entry(challengeBeforeUpdate).State = EntityState.Detached;

            var updatedChallenge = challengeBeforeUpdate with { Date = timestamp, Status = newStatus };
            _dbContext.ChallengeEntries.Update(updatedChallenge);
            await _dbContext.SaveChangesAsync();

            return updatedChallenge;
        }
    }
示例#4
0
        public override void On活性化()
        {
            if (TJAPlayer4.stage選曲.n確定された曲の難易度[0] != (int)Difficulty.Dan)
            {
                return;
            }

            NowShowingNumber = 0;

            if (TJAPlayer4.DTX[0].Dan_Gauge != null)
            {
                Challenge_Gauge = new Dan_C(TJAPlayer4.DTX[0].Dan_Gauge);
            }
            Challenge = new Dan_C[TJAPlayer4.DTX[0].List_DanSongs.Count][];
            for (int i = 0; i < TJAPlayer4.DTX[0].List_DanSongs.Count; i++)
            {
                Challenge[i] = new Dan_C[3];
                for (int n = 0; n < 3; n++)
                {
                    if (TJAPlayer4.DTX[0].List_DanSongs[i] != null && TJAPlayer4.DTX[0].List_DanSongs[i].Dan_C[n] != null)
                    {
                        Challenge[i][n] = new Dan_C(TJAPlayer4.DTX[0].List_DanSongs[i].Dan_C[n]);
                    }
                }
            }

            for (int i = 0; i < 3; i++)
            {
                Status[i] = new ChallengeStatus();
                Status[i].Timer_Amount = new CCounter();
                Status[i].Timer_Gauge  = new CCounter();
                Status[i].Timer_Failed = new CCounter();
            }
            //IsEnded = false;

            nPerfect = new int[TJAPlayer4.DTX[0].List_DanSongs.Count];
            nGood    = new int[TJAPlayer4.DTX[0].List_DanSongs.Count];
            nMiss    = new int[TJAPlayer4.DTX[0].List_DanSongs.Count];
            nRoll    = new int[TJAPlayer4.DTX[0].List_DanSongs.Count];
            nCombo   = new int[TJAPlayer4.DTX[0].List_DanSongs.Count];
            nScore   = new int[TJAPlayer4.DTX[0].List_DanSongs.Count];

            if (TJAPlayer4.stage選曲.n確定された曲の難易度[0] == (int)Difficulty.Dan)
            {
                IsAnimating = true;
            }
            base.On活性化();
        }
示例#5
0
            private ChallengeStatus DeserializeChallengeStatus(object challengeObject, object metadataObject)
            {
                Dictionary <string, object> challengeDictionary = challengeObject as Dictionary <string, object>;
                Dictionary <string, object> metadataDictionary  = metadataObject as Dictionary <string, object>;

                var status = new ChallengeStatus();

                status.id               = challengeDictionary["id"] as string;
                status.name             = challengeDictionary["template_name"] as string;
                status.description      = challengeDictionary["template_description"] as string;
                status.templateImageURL = challengeDictionary["template_image"] as string;
                status.metadata         = metadataDictionary;
                status.opponents        = DeserializeChallengeParticipants(challengeDictionary["participants"]);
                status.extra            = challengeDictionary["extra"] as Dictionary <string, object>;

                return(status);
            }
        private void ThrowIfNotInStatus(ChallengeStatus expectedStatus, Challenge[] challenges)
        {
            if (challenges.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(challenges));
            }

            var failures = challenges
                           .Where(c => c.Status != expectedStatus)
                           .Select(f => f.Error)
                           .ToArray();

            if (failures.Any())
            {
                var errors = string.Join(Environment.NewLine, failures.Select(f => f.Detail));
                throw new RenewalException($"Expected all challenges to be in status {expectedStatus}, but {failures.Length} where not: {errors}", failures);
            }
        }
        public override void On活性化()
        {
            for (int i = 0; i < 4; i++)
            {
                if (TJAPlayer3.DTX.Dan_C[i] != null)
                {
                    Challenge[i] = new Dan_C(TJAPlayer3.DTX.Dan_C[i]);
                }
            }
            FirstSectionAnime = false;
            // 始点を決定する。
            ExamCount        = 0;
            songsnotesremain = new int[TJAPlayer3.stage選曲.r確定された曲.DanSongs.Count];
            this.ct虹アニメ      = new CCounter(0, TJAPlayer3.Skin.Game_Gauge_Dan_Rainbow_Ptn - 1, 30, TJAPlayer3.Timer);
            this.ct虹透明度      = new CCounter(0, TJAPlayer3.Skin.Game_Gauge_Rainbow_Timer - 1, 1, TJAPlayer3.Timer);
            for (int i = 0; i < 4; i++)
            {
                if (Challenge[i] != null && Challenge[i].GetEnable() == true)
                {
                    this.ExamCount++;
                }
            }

            bExamChangeCheck = false;

            for (int i = 0; i < 4; i++)
            {
                Status[i] = new ChallengeStatus();
                Status[i].Timer_Amount = new CCounter();
                Status[i].Timer_Gauge  = new CCounter();
                Status[i].Timer_Failed = new CCounter();
            }
            IsEnded = false;

            if (TJAPlayer3.stage選曲.n確定された曲の難易度 == (int)Difficulty.Dan)
            {
                IsAnimating = true;
            }
            base.On活性化();
        }
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 0:
                this.m_Challenger = reader.ReadMobile();

                this.m_Organizers.Add(this.m_Challenger);

                this.m_GameLocked     = reader.ReadBool();
                this.m_GameInProgress = reader.ReadBool();
                this.m_TotalPurse     = reader.ReadInt();
                this.m_EntryFee       = reader.ReadInt();
                this.m_ArenaSize      = reader.ReadInt();
                this.m_TargetScore    = reader.ReadInt();
                this.m_MatchLength    = reader.ReadTimeSpan();

                TimeSpan elapsed = reader.ReadTimeSpan();

                if (elapsed > TimeSpan.Zero)
                {
                    this.m_MatchStart = DateTime.UtcNow - elapsed;
                }

                int count = reader.ReadInt();
                for (int i = 0; i < count; i++)
                {
                    ChallengeEntry entry = new ChallengeEntry();
                    entry.Participant = reader.ReadMobile();
                    string sname = reader.ReadString();
                    // look up the enum by name
                    ChallengeStatus status = ChallengeStatus.None;
                    try
                    {
                        status = (ChallengeStatus)Enum.Parse(typeof(ChallengeStatus), sname);
                    }
                    catch
                    {
                    }
                    entry.Status          = status;
                    entry.Accepted        = reader.ReadBool();
                    entry.PageBeingViewed = reader.ReadInt();
                    entry.Score           = reader.ReadInt();
                    entry.Winner          = reader.ReadBool();

                    this.Participants.Add(entry);
                }
                break;
            }

            if (this.GameCompleted)
            {
                Timer.DelayCall(this.PostGameDecayTime, new TimerCallback(Delete));
            }

            // start the challenge timer
            this.StartChallengeTimer();
        }
示例#9
0
 public ConflictRequestException(ChallengeStatus expectedStatus, ChallengeStatus actualStatus)
     : this("challenge", $"{expectedStatus}", $"{actualStatus}")
 {
 }
示例#10
0
 public ConflictRequestException(ChallengeStatus attemptedStatus)
     : this("challenge", $"{attemptedStatus}")
 {
 }
示例#11
0
        public async Task <UserChallenge> SetUserChallengeStatus(string email, long challengeId, ChallengeStatus status)
        {
            if (!_context.UserChallenges.Any(uc => uc.UserEmail == email && uc.ChallengeId == challengeId))
            {
                var newUserChallenge = new UserChallenge()
                {
                    UserEmail      = email,
                    ChallengeId    = challengeId,
                    Status         = ChallengeStatus.None,
                    CompletedTimes = 0
                };
                await _context.UserChallenges.AddAsync(newUserChallenge);

                _context.SaveChanges();
            }

            var userChallenge = await _context.UserChallenges
                                .Where(uc => uc.UserEmail == email && uc.ChallengeId == challengeId)
                                .Include(uc => uc.Challenge)
                                .FirstOrDefaultAsync();

            if (status == ChallengeStatus.Completed && userChallenge.CompletedTimes < userChallenge.Challenge.MaxCompletionCount)
            {
                userChallenge.CompletedTimes++;
                userChallenge.Status = userChallenge.CompletedTimes == userChallenge.Challenge.MaxCompletionCount
                    ? ChallengeStatus.Completed
                    : ChallengeStatus.Assigned;
            }
            else
            {
                userChallenge.Status = status;
            }

            var result = _context.UserChallenges.Update(userChallenge);

            _context.SaveChanges();

            return(result.Entity);
        }