public void Init(Challenges challenges, int _id, Challenges.PlayerData playerData)
    {
        RemindButton.SetActive(false);
        this.playerData = playerData;
        this.challenges = challenges;
        this.id         = _id;

        if (challenges.type == Challenges.types.MADE)
        {
            InactiveButtons();
            RemindButton.SetActive(true);
        }


        if (playerData.winner != "")
        {
            if (playerData.winner == Data.Instance.userData.facebookID)
            {
                result.text  = "YOU WON";
                result.color = WinColor;
            }
            else
            {
                result.text  = "YOU LOST";
                result.color = lostColor;
            }
            InactiveButtons();
        }
        this.objectID   = playerData.objectID;
        this.facebookID = playerData.facebookID;

        username           = Data.Instance.gameSettings.GetUsername(playerData.playerName);
        usernameLabel.text = username;


        levelId    = playerData.level;
        level.text = "LEVEL " + levelId;

        string score = Data.Instance.levelsData.GetScoreString(playerData.level, playerData.score);

        Levels.LevelData data = Data.Instance.levels.GetData(levelId);

        if (data.Sudden_Death)
        {
            scoreLabel.text = score;
        }
        else
        if (data.totalTime > 0)
        {
            scoreLabel.text = score + " in " + Data.Instance.levelsData.GetTimer(data.totalTime);
        }
        else
        {
            scoreLabel.text = data.totalLaps + "000" + "m in " + score;
        }

        op_score = playerData.score;
        profilePicture.setPicture(facebookID);
        infoLoaded = true;
    }
Esempio n. 2
0
        public void LocalRefresh(List <Challenge> challenges)
        {
            try
            {
                var current = Challenges.Select(vm => vm.Challenge).ToList();

                var comparer = new ChallengeComparer();
                var toRemove = current.Except(challenges, comparer).ToList();
                var toAdd    = challenges.Except(current, comparer).ToList();
                toRemove.ForEach(c => Challenges.Remove(Challenges.Single(vm => vm.Challenge == c)));

                var preSort = new List <ChallengeViewModel>();
                toAdd.ForEach(c => preSort.Add(new ChallengeViewModel {
                    Challenge = c
                }));

                preSort.Sort(new ChallengeSortComparer());
                preSort.ForEach(Challenges.Add);

                if (Challenges.Count == 0)
                {
                    Challenges.Add(new ChallengeViewModel()
                    {
                        EmptyMessage = "{0} no challenges for this league".Fmt(Membership.AthleteId == App.CurrentAthlete.Id
                                                        ? "You have" : "{0} has".Fmt(Membership.Athlete.Alias))
                    });
                }
            }
            catch (Exception e)
            {
                InsightsManager.Report(e);
            }
        }
Esempio n. 3
0
    private void AddChallengeEntry(string name)
    {
        // Create ChallengeEntry
        ChallengeEntry ChallengeEntry = new ChallengeEntry {
            name = name
        };

        // Load saved Challenges
        string     jsonString = PlayerPrefs.GetString("challengesTable2");
        Challenges Challenges = JsonUtility.FromJson <Challenges>(jsonString);

        if (Challenges == null)
        {
            // There's no stored table, initialize
            Challenges = new Challenges()
            {
                ChallengeEntryList = new List <ChallengeEntry>()
            };
        }

        // Add new entry to Challenges
        Challenges.ChallengeEntryList.Add(ChallengeEntry);

        // Save updated Challenges
        string json = JsonUtility.ToJson(Challenges);

        PlayerPrefs.SetString("challengesTable2", json);
        PlayerPrefs.Save();
    }
        /// <summary>
        /// Delete the given challenge from the database.
        /// </summary>
        /// <param name="Name">The name of the challenge.</param>
        public void DeleteChallenge(string Name)
        {
            if (Name == null)
            {
                throw new ArgumentNullException();
            }

            // Remove it from the database.
            Challenges.DeleteChallenge(Name);

            // Update the challenge list.
            challengeList = Challenges.GetChallenges();

            // Set a new current challenge.
            if (challengeList.Count == 0)
            {
                CurrentChallenge = "";
            }
            else
            {
                // TODO: Can we assume that the last item in the list is the newest?
                CurrentChallenge = challengeList.Last();
            }

            // We changed some of our public properties.
            NotifyPropertyChanged("ChallengeList");
            // TODO: These are redundant to what was done in CurrentChallenge.set
            // so they can probably be deleted.
            NotifyPropertyChanged("CurrentChallenge");
            NotifyPropertyChanged("SplitList");
        }
        public async Task <IActionResult> PostChallenges([FromBody] Challenges challenges)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Challenges.Add(challenges);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (ChallengesExists(challenges.Id))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetChallenges", new { id = challenges.Id }, challenges));
        }
Esempio n. 6
0
 public bool DeepEquals(DestinyActivityDefinition?other)
 {
     return(other is not null &&
            (DisplayProperties is not null ? DisplayProperties.DeepEquals(other.DisplayProperties) : other.DisplayProperties is null) &&
            (OriginalDisplayProperties is not null ? OriginalDisplayProperties.DeepEquals(other.OriginalDisplayProperties) : other.OriginalDisplayProperties is null) &&
            (SelectionScreenDisplayProperties is not null ? SelectionScreenDisplayProperties.DeepEquals(other.SelectionScreenDisplayProperties) : other.SelectionScreenDisplayProperties is null) &&
            ReleaseIcon == other.ReleaseIcon &&
            ReleaseTime == other.ReleaseTime &&
            ActivityLightLevel == other.ActivityLightLevel &&
            DestinationHash == other.DestinationHash &&
            PlaceHash == other.PlaceHash &&
            ActivityTypeHash == other.ActivityTypeHash &&
            Tier == other.Tier &&
            PgcrImage == other.PgcrImage &&
            Rewards.DeepEqualsList(other.Rewards) &&
            Modifiers.DeepEqualsList(other.Modifiers) &&
            IsPlaylist == other.IsPlaylist &&
            Challenges.DeepEqualsList(other.Challenges) &&
            OptionalUnlockStrings.DeepEqualsList(other.OptionalUnlockStrings) &&
            PlaylistItems.DeepEqualsList(other.PlaylistItems) &&
            ActivityGraphList.DeepEqualsList(other.ActivityGraphList) &&
            (Matchmaking is not null ? Matchmaking.DeepEquals(other.Matchmaking) : other.Matchmaking is null) &&
            (GuidedGame is not null ? GuidedGame.DeepEquals(other.GuidedGame) : other.GuidedGame is null) &&
            DirectActivityModeHash == other.DirectActivityModeHash &&
            DirectActivityModeType == other.DirectActivityModeType &&
            Loadouts.DeepEqualsList(other.Loadouts) &&
            ActivityModeHashes.DeepEqualsListNaive(other.ActivityModeHashes) &&
            ActivityModeTypes.DeepEqualsListNaive(other.ActivityModeTypes) &&
            IsPvP == other.IsPvP &&
            InsertionPoints.DeepEqualsList(other.InsertionPoints) &&
            ActivityLocationMappings.DeepEqualsList(other.ActivityLocationMappings) &&
            Hash == other.Hash &&
            Index == other.Index &&
            Redacted == other.Redacted);
 }
        public bool Equals(DestinyMilestoneChallengeActivity input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     ActivityHash == input.ActivityHash ||
                     (ActivityHash.Equals(input.ActivityHash))
                     ) &&
                 (
                     Challenges == input.Challenges ||
                     (Challenges != null && Challenges.SequenceEqual(input.Challenges))
                 ) &&
                 (
                     ModifierHashes == input.ModifierHashes ||
                     (ModifierHashes != null && ModifierHashes.SequenceEqual(input.ModifierHashes))
                 ) &&
                 (
                     BooleanActivityOptions == input.BooleanActivityOptions ||
                     (BooleanActivityOptions != null && BooleanActivityOptions.SequenceEqual(input.BooleanActivityOptions))
                 ) &&
                 (
                     LoadoutRequirementIndex == input.LoadoutRequirementIndex ||
                     (LoadoutRequirementIndex.Equals(input.LoadoutRequirementIndex))
                 ) &&
                 (
                     Phases == input.Phases ||
                     (Phases != null && Phases.SequenceEqual(input.Phases))
                 ));
        }
 public void Update(DestinyMilestoneChallengeActivityDefinition?other)
 {
     if (other is null)
     {
         return;
     }
     if (ActivityHash != other.ActivityHash)
     {
         ActivityHash = other.ActivityHash;
         OnPropertyChanged(nameof(ActivityHash));
     }
     if (!Challenges.DeepEqualsList(other.Challenges))
     {
         Challenges = other.Challenges;
         OnPropertyChanged(nameof(Challenges));
     }
     if (!ActivityGraphNodes.DeepEqualsList(other.ActivityGraphNodes))
     {
         ActivityGraphNodes = other.ActivityGraphNodes;
         OnPropertyChanged(nameof(ActivityGraphNodes));
     }
     if (!Phases.DeepEqualsList(other.Phases))
     {
         Phases = other.Phases;
         OnPropertyChanged(nameof(Phases));
     }
 }
Esempio n. 9
0
        public void MiniMaxSumTest()
        {
            string outputString   = Challenges.MiniMaxSum(new[] { 1, 2, 3, 4, 5, 1000000000 });
            string expectedString = "15 1000000014";

            Assert.AreEqual(expectedString, outputString);
        }
        public void StartNewRun()
        {
            if (challengeList.Count == 0)
            {
                throw new InvalidOperationException();
            }

            // TODO: Check for a already-active run.
            // NOTE: This is a hack so that I can get start to work.
            if (RunInProgress)
            {
                Challenges.EndRun(currentChallenge);
                RunInProgress = false;
            }

            Challenges.StartNewRun(currentChallenge);

            // Zero out the split counts.
            foreach (var split in SplitList)
            {
                split.CurrentValue = 0;
            }
            splitList.Last().CumulativePbValue = SplitList[0].CumulativePbValue;
            splitList.Last().CurrentPbValue    = SplitList[0].CumulativePbValue;

            // Reset current split number.
            currentSplit = 0;

            RunInProgress = true;

            // We changed some of our public properties.
            NotifyPropertyChanged("SplitList");
        }
Esempio n. 11
0
        private void SwitchLeader(ulong newId, ulong oldId, Challenges type)
        {
            var name = GetGroupName(type);

            if (configData.Options.UseOxideGroups)
            {
                if (oldId != 0U && permission.GroupExists(name))
                {
                    RemoveUserFromGroup(name, oldId.ToString());
                }
                if (newId != 0U && permission.GroupExists(name))
                {
                    AddUserToGroup(name, newId.ToString());
                }
            }

            titleCache[type] = new LeaderData
            {
                Count       = statCache[newId].Stats[type],
                DisplayName = statCache[newId].DisplayName,
                UserID      = newId
            };

            if (configData.Options.AnnounceNewLeaders)
            {
                string message = MSG("newLeader")
                                 .Replace("{playername}", $"<color={configData.Colors.TextColor1}>{statCache[newId].DisplayName}</color><color={configData.Colors.TextColor2}>")
                                 .Replace("{ctype}", $"</color><color={configData.Colors.TextColor1}>{MSG(type.ToString())}</color>");
                PrintToChat(message);
            }
        }
        public async Task <IActionResult> PutChallenges([FromRoute] int id, [FromBody] Challenges challenges)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != challenges.Id)
            {
                return(BadRequest());
            }

            _context.Entry(challenges).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ChallengesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 13
0
        public void PlusMinusTest()
        {
            IList <string> result       = Challenges.PlusMinus(new int[] { -4, 3, -9, 0, 0, 4, 1, 0, });
            int            expectedSize = 3;

            Assert.AreEqual(expectedSize, result.Count);
        }
Esempio n. 14
0
        public DataTable ModifyChallenge()
        {
            Challenge item;

            try
            {
                item     = new Challenge(Kv.Cxt, ChallengeID);
                item.Cxt = base.Kv.Cxt;
                item.ChallengerUserID      = ChallengerUserID;
                item.ChallengeTypeID       = ChallengeTypeID;
                item.ChessTypeID           = ChessTypeID;
                item.ColorID               = ColorID;
                item.IsRated               = IsRated;
                item.WithClock             = WithClock;
                item.IsChallengerSendsGame = IsChallengerSendsGame;
                item.Description           = Description;
                item.GameTypeID            = GameTypeID;
                item.OpponentUserID        = OpponentUserID;
                item.RoomID             = RoomID;
                item.StatusID           = StatusID;
                item.TimeMin            = TimeMin;
                item.GainPerMoveMin     = GainPerMoveMin;
                item.ChallengeStatusIDE = ChallengeStatusE.Seeking;
                item.Cxt.CurrentUserID  = Kv.Cxt.CurrentUserID;

                item.Save();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Challenges.GetChallengesByRoomID(item.Cxt, RoomID, item.Cxt.CurrentUserID));
        }
        public bool Equals(DestinyMilestoneChallengeActivityDefinition input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     ActivityHash == input.ActivityHash ||
                     (ActivityHash.Equals(input.ActivityHash))
                     ) &&
                 (
                     Challenges == input.Challenges ||
                     (Challenges != null && Challenges.SequenceEqual(input.Challenges))
                 ) &&
                 (
                     ActivityGraphNodes == input.ActivityGraphNodes ||
                     (ActivityGraphNodes != null && ActivityGraphNodes.SequenceEqual(input.ActivityGraphNodes))
                 ) &&
                 (
                     Phases == input.Phases ||
                     (Phases != null && Phases.SequenceEqual(input.Phases))
                 ));
        }
Esempio n. 16
0
        public ActionResult DeleteChallenge(int id, Challenges challenges)

        {
            var _challenges = new Challenges();

            _challengeService.DeleteChallenge(id, challenges);
            return(RedirectToAction("GetChallenges", "Challenge", new { id = challenges.Id }));
        }
Esempio n. 17
0
 private void AddMenuStats(ref CuiElementContainer MenuElement, string panel, Challenges type, float left, float bottom, float right, float top)
 {
     if (configData.ChallengeSettings[type].Enabled)
     {
         UI.Panel(ref MenuElement, UIMain, $"{left} {bottom}", $"{right} {top}");
         UI.Label(ref MenuElement, UIMain, GetLeaders(type), 16, $"{left + 0.005f} {bottom + 0.01f}", $"{right - 0.005f} {top - 0.01f}", TextAnchor.UpperLeft);
     }
 }
Esempio n. 18
0
        public void TimeConversionTest()
        {
            string inputString    = "09:05:57PM";
            string outputString   = Challenges.TimeConversion(inputString);
            string expectedString = "21:05:57";

            Assert.AreEqual(expectedString, outputString);
        }
Esempio n. 19
0
        private async Task <bool> ChallengeModelExistsAsync(Guid challengeId)
        {
            var challenges = from challenge in Challenges.AsExpandable()
                             where challenge.Id == challengeId
                             select challenge;

            return(await challenges.AnyAsync());
        }
 public bool DeepEquals(DestinyMilestoneChallengeActivityDefinition?other)
 {
     return(other is not null &&
            ActivityHash == other.ActivityHash &&
            Challenges.DeepEqualsList(other.Challenges) &&
            ActivityGraphNodes.DeepEqualsList(other.ActivityGraphNodes) &&
            Phases.DeepEqualsList(other.Phases));
 }
Esempio n. 21
0
 public bool DeepEquals(MilestoneActivities other)
 {
     return(other != null &&
            ActivityGraphNodes.DeepEqualsReadOnlyCollections(other.ActivityGraphNodes) &&
            Activity.DeepEquals(other.Activity) &&
            Challenges.DeepEqualsReadOnlyCollections(other.Challenges) &&
            Phases.DeepEqualsReadOnlyCollections(other.Phases));
 }
Esempio n. 22
0
    // Start is called before the first frame update
    void Start()
    {
        averageHappiness   = 50;
        stats.happiness    = averageHappiness;
        parkHappiness.text = "Park Happiness: " + averageHappiness.ToString();

        challenge = GameObject.Find("Challenges").GetComponent <Challenges>();
    }
Esempio n. 23
0
        protected override void Cleanup()
        {
            Accounts.RemoveRange(Accounts);

            Challenges.RemoveRange(Challenges);

            Promotions.RemoveRange(Promotions);
        }
Esempio n. 24
0
        private static void CurrentUserMap(IDataReader reader, short set, ref UserBase authUser, ref List <string> Roles, ref List <string> Challenges)
        {
            List <string> extProviders = null;

            switch (set)
            {
            case 0:
                int startingIndex = 0;
                authUser = new UserBase
                {
                    Id       = reader.GetSafeInt32(startingIndex++),
                    Name     = reader.GetSafeString(startingIndex++),
                    PhotoUrl = reader.GetSafeString(startingIndex++)
                };

                break;

            case 1:
                string role = reader.GetSafeString(0);

                if (Roles == null)
                {
                    Roles = new List <string>();
                }
                Roles.Add(role);

                break;

            case 2:
                string extProvider = reader.GetSafeString(0);

                if (extProviders == null)
                {
                    extProviders = new List <string>();
                }

                extProviders.Add("Has" + extProvider);
                break;

            case 3:
                string challenge = reader.GetSafeString(0);

                if (Challenges == null)
                {
                    Challenges = new List <string>();
                }
                Challenges.Add(challenge);

                break;
            }

            if (authUser != null && (extProviders != null || Roles != null || Challenges != null))
            {
                authUser.ExtProviders = extProviders;
                authUser.Roles        = Roles;
                authUser.Challenges   = Challenges;
            }
        }
Esempio n. 25
0
    // Start is called before the first frame update
    void Start()
    {
		parkLevelText = GameObject.Find("ParkLevel").GetComponent<Text>();
		progressBar = parkLevelText.gameObject.transform.GetChild(0).GetComponent<Slider>();
		buttons = GameObject.Find("HUD").GetComponent<HUD>();
		challenge = GameObject.Find("Challenges").GetComponent<Challenges>();
		Invoke("adjustParkLevel", 9);
		progressBar.maxValue = xpGain;
    }
Esempio n. 26
0
 public ActionResult EditChallenge(Challenges challenges)
 {
     if (ModelState.IsValid)
     {
         _challengeService.EditChallenge(challenges);
         return(RedirectToAction("GetChallenges"));
     }
     return(View(challenges));
 }
Esempio n. 27
0
        private void __RollButton_Click(object sender, EventArgs e)
        {
            __IncludeInHTMLSummary.Checked = true;

            __SkillDisplay.Skills = Challenges.MandatoryElites((int)__PartySize.Value, (int)Math.Min(__RatingLow.Value, __RangeMax.Value), (int)Math.Max(__RatingLow.Value, __RangeMax.Value), __NoSkillsFromPrimaries.Checked);
            __SkillDisplay.Redraw();

            refreshHTML?.Invoke();
        }
Esempio n. 28
0
 public ActionResult AddChallenge([Bind(Include = "Id,Description")] Challenges challenges, ApplicationUser user)
 {
     if (ModelState.IsValid)
     {
         _challengeService.AddChallenge(challenges, user);
         return(RedirectToAction("GetChallenges"));
     }
     return(View(challenges));
 }
Esempio n. 29
0
        private void RegisterGroup(Challenges type)
        {
            var name = GetGroupName(type);

            if (!permission.GroupExists(name))
            {
                permission.CreateGroup(name, string.Empty, 0);
            }
        }
Esempio n. 30
0
        private async Task <ChallengeModel?> FindChallengeModelAsync(Guid challengeId)
        {
            var challenges = from challenge in Challenges.Include(challenge => challenge.Participants)
                             .ThenInclude(participant => participant.Matches)
                             .AsExpandable()
                             where challenge.Id == challengeId
                             select challenge;

            return(await challenges.SingleOrDefaultAsync());
        }
Esempio n. 31
0
    public void Init(Challenges challenges, int _id, Challenges.PlayerData playerData)
    {
        RemindButton.SetActive(false);
        this.playerData = playerData;
        this.challenges = challenges;
        this.id = _id;

        if (challenges.type == Challenges.types.MADE)
        {
            InactiveButtons();
            RemindButton.SetActive(true);
        }

        if (playerData.winner != null && playerData.winner.Length > 1)
        {
            if (playerData.winner == SocialManager.Instance.userData.facebookID)
            {
                result.text = "Gantaste";
                scoreLabel.text = "$" + playerData.score;
                result.color = WinColor;
            }
            else
            {
                result.text = "Perdiste!";
                scoreLabel.text = "$" + playerData.score2;
                result.color = lostColor;
            }
            InactiveButtons();
        }
        else
        {
            op_score = playerData.score;
            scoreLabel.text = "$" + playerData.score;
        }
        this.objectID = playerData.objectID;
        this.facebookID = playerData.facebookID;

        username = Data.Instance.gameSettings.GetUsername(playerData.playerName);
        usernameLabel.text = username;

        profilePicture.setPicture(facebookID);
        infoLoaded = true;
    }
Esempio n. 32
0
 void show_Challenges()
 {
     Challenges challenges = new Challenges();
     scrollViewer.Content = challenges;
 }
 // Use this for initialization
 void Start()
 {
     userLogInURL = "http://5.9.251.204/api/user/login";
     completedChallenges = challengesHolder.GetComponent<Challenges>();
 }