public void GetNextChallengeBoardCategory() { var repository = new TestRepository(); // create a game with some challenges var board = new Board(); repository.Add(board); var game = new Game() { BoardId = board.Id }; repository.Add(game); var category = new ChallengeCategory(); repository.Add(category); var challenge1 = new Challenge() { ChallengeCategoryId = category.Id }; var challenge2 = new Challenge() { ChallengeCategoryId = category.Id }; var challenge3 = new Challenge() { ChallengeCategoryId = category.Id }; var challenges = new Challenge[] { challenge1, challenge2, challenge3 }; repository.AddAll(challenges); repository.Add(new BoardChallengeCategory() { BoardId = board.Id, ChallengeCategoryId = category.Id }); // keep getting the next challenge until all challenges should have been used var usedChallenges = new List<Challenge>(); foreach (Challenge challenge in challenges) { usedChallenges.Add(game.GetNextChallenge(0)); } // verify that all challenges were used CollectionAssert.AreEqual(challenges.Select(x => x.Id).OrderBy(x => x), usedChallenges.Select(x => x.Id).OrderBy(x => x)); // verify that more challenges can be retrieved Assert.IsNotNull(game.GetNextChallenge(0)); }
public IChallengeHandler GetHandler(Challenge c, IReadOnlyDictionary<string, object> initParams) { var h = new ManualChallengeHandler(); // Start off with the current (default) settings var p = h.WriteOutPath; var a = h.Append; var o = h.Overwrite; if (initParams?.Count > 0) { // See which ones are overridden if (initParams.ContainsKey(WRITE_OUT_PATH.Name)) p = (string) initParams[WRITE_OUT_PATH.Name]; if (initParams.ContainsKey(APPEND.Name)) a = (bool) initParams[APPEND.Name]; if (initParams.ContainsKey(OVERWRITE.Name)) o = (bool) initParams[OVERWRITE.Name]; // Apply any changes h.SetOut(p, a, o); } return h; }
public void DeleteChallenge() { var repository = new TestRepository(); // add test challenges var challenge1 = new Challenge() { Question = "Test Question 1" }; var challenge2 = new Challenge() { Question = "Test Question 2" }; repository.Add(challenge1); repository.Add(challenge2); // add answers var answer1a = new ChallengeAnswer() { Answer = "Test Answer 1a", Correct = true, ChallengeId = challenge1.Id }; var answer1b = new ChallengeAnswer() { Answer = "Test Answer 1b", Correct = false, ChallengeId = challenge1.Id }; var answer2a = new ChallengeAnswer() { Answer = "Test Answer 2a", Correct = true, ChallengeId = challenge2.Id }; var answer2b = new ChallengeAnswer() { Answer = "Test Answer 2b", Correct = false, ChallengeId = challenge2.Id }; repository.AddAll(new ChallengeAnswer[] { answer1a, answer1b, answer2a, answer2b }); // delete one challenge challenge1.Delete(); // verify challenge and answers are deleted Assert.IsEmpty(repository.Find<Challenge>(x => x.Id == challenge1.Id)); Assert.IsEmpty(repository.Find<ChallengeAnswer>(x => x.Id == answer1a.Id)); Assert.IsEmpty(repository.Find<ChallengeAnswer>(x => x.Id == answer1b.Id)); // verify other challenge is not deleted Assert.IsNotEmpty(repository.Find<Challenge>(x => x.Id == challenge2.Id)); Assert.IsNotEmpty(repository.Find<ChallengeAnswer>(x => x.Id == answer2a.Id)); Assert.IsNotEmpty(repository.Find<ChallengeAnswer>(x => x.Id == answer2b.Id)); }
public GameResultFormView(Challenge challenge, GameResult gameResult, int index) { Index = index; Challenge = challenge; GameResult = gameResult; BindingContext = this; InitializeComponent(); }
public virtual Challenge[] ToChallengeArray() { Challenge[] result = new Challenge[content.Count]; for (int i = 0; i != result.Length; ++i) { result[i] = Challenge.GetInstance(content[i]); } return result; }
// Use this for initialization void Start() { if (doors == null) { Debug.LogError ("ChallengeRoom (" + name + ") has no associated doors."); } challenge = GetComponent <Challenge> (); if (challenge == null) { Debug.LogError ("ChallengeRoom (" + name + ") has no associated challenge."); } }
void CreateChallengeDescriptions(Challenge[] challenges) { foreach (Challenge challenge in challenges) { GameObject challengeDescription = Instantiate(challengeDescriptionPrefab) as GameObject; challengeDescription.name = challenge.Name + "Description"; challengeDescription.transform.SetParent(challengeDescriptionParent.transform, false); GameObject titleChild = challengeDescription.transform.FindChild("Title").gameObject; Text titleText = titleChild.GetComponent<Text>(); titleText.text = challenge.Name; colors[0] = Color.white; colors[1] = Color.white; colors[2] = Color.white; if (challenge.Difficulty.Trim() == "Easy") { titleText.color = colors[0]; } if (challenge.Difficulty.Trim() == "Medium") { titleText.color = colors[1]; } if (challenge.Difficulty.Trim() == "Hard") { titleText.color = colors[2]; } GameObject descriptionChild = challengeDescription.transform.FindChild("Description").gameObject; Text descriptionText = descriptionChild.GetComponent<Text>(); GameObject factChild1 = challengeDescription.transform.FindChild("Fact").gameObject; GameObject factChild2 = factChild1.transform.FindChild("scrollBox").gameObject; GameObject factChild = factChild2.transform.FindChild("Text").gameObject; Text factText = factChild.GetComponent<Text>(); String[] strings = challenge.Description.Split(new char[] { '/' }); if (strings.Length > 1) { factText.text = strings[1]; factText.color = new Color(0.01960f, 0.066666f, 0.05882f, 1.0f); } descriptionText.text = strings[0]; GameObject takeSelfieChild = challengeDescription.transform.FindChild("Take Selfie Button").gameObject; TakeSelfieButton buttonId = takeSelfieChild.GetComponent<TakeSelfieButton>(); buttonId.buttonId = challenge.Id; } }
public void SetCurrentChallenge(Challenge challenge, bool resuming) { Debug.PrintMessage("SetCurrentChallenge()"); if(m_challenge != null){ //ensures the previous challenge has been removed DestroyChallenge (); } Debug.PrintMessage("Post DestroyChallenge()"); m_challenge = challenge; //populate goal panels IGoal[] goals = m_challenge.Goals; this.height = HEAD + GoalProgressPanel.SPACING + goals.Length * (GoalProgressPanel.HEIGHT+GoalProgressPanel.SPACING); Debug.PrintMessage ("Number of goals = " + goals.Length); Debug.PrintMessage ("Height of panel = " + this.height); for (int pos = 0; pos < goals.Length; pos++) { goalPanels.Add (GoalProgressPanel.CreateProgressPanel (this, pos, goals[pos])); } if (resuming) { if (m_challenge.m_finished) { Debug.PrintMessage ("Challenges have finished already"); } else if (m_challenge.m_started) { //has started before hand Debug.PrintMessage ("Challenge had been started"); } else { Debug.PrintMessage ("Challenge has neither started nor finished but was found in save"); } m_challenge.Resume(); } else { Debug.PrintMessage("Starting Challenges First Time"); m_challenge.MapStartTime = Data.GetGameDateTime (); m_challenge.Start(); } OnChallengeStarted (); m_challenge.OnChallengeFinished += (ChallengeEventType type) => { switch(type){ case(ChallengeEventType.ACED): case(ChallengeEventType.COMPLETED): Debug.PrintMessage("Completed"); CompleteChallenge(); break; case(ChallengeEventType.FAILED): case(ChallengeEventType.TOO_LATE): Debug.PrintMessage("Failed"); ForfeitChallenge(); break; } }; Debug.PrintMessage ("Showing ChallengePanel"); this.Show (); }
public void GagneEnergyCoin(Challenge p_challenge, int p_quantite, DateTime p_date, string p_meta) { GainEnergyCoin l_newCoin = new GainEnergyCoin(); l_newCoin.Appartement = this; l_newCoin.Challenge = p_challenge; l_newCoin.Quantite = p_quantite; l_newCoin.Meta = p_meta; l_newCoin.Date = p_date; l_newCoin.Save(); SoldeEnergyCoin += p_quantite; }
public void MultipleChoiceAnswer() { var repository = new TestRepository(); // create a multiple choice challenge var challenge = new Challenge() { Question = "Test Question 1", ChallengeCategoryId = 2, OwnerId = 3 }; repository.Add(challenge); var answer1 = new ChallengeAnswer() { Answer = "Test Answer 1", Correct = true, ChallengeId = challenge.Id }; var answer2 = new ChallengeAnswer() { Answer = "Test Answer 2", Correct = false, ChallengeId = challenge.Id }; repository.AddAll(new ChallengeAnswer[] { answer1, answer2 }); // verify that correct answer is acknowledged as correct Assert.True(challenge.CorrectAnswer(answer1.Id)); Assert.False(challenge.CorrectAnswer(answer2.Id)); }
public void CreateChallenge(Athlete challenger, Athlete challengee, League league) { var time = TimeSpan.FromTicks(DateTime.Now.AddMinutes(60).Subtract(DateTime.Today).Ticks); if(time.Ticks > TimeSpan.TicksPerDay) time = time.Subtract(TimeSpan.FromTicks(TimeSpan.TicksPerDay)); SelectedTime = time; SelectedDate = DateTime.Today; var membership = league.Memberships.SingleOrDefault(m => m.AthleteId == challengee.Id); Challenge = new Challenge { BattleForRank = membership.CurrentRank, ChallengerAthleteId = challenger.Id, ChallengeeAthleteId = challengee.Id, ProposedTime = SelectedDateTime, LeagueId = league.Id, }; }
public void CloneChallenge() { var repository = new TestRepository(); // create a challenge var challenge = new Challenge() { Question = "Test Question 1", ChallengeCategoryId = 2, OwnerId = 3, OpenEnded = true }; repository.Add(challenge); var answer1 = new ChallengeAnswer() { Answer = "Test Answer 1", Correct = true, ChallengeId = challenge.Id }; var answer2 = new ChallengeAnswer() { Answer = "Test Answer 2", Correct = false, ChallengeId = challenge.Id }; repository.AddAll(new ChallengeAnswer[] { answer1, answer2 }); // clone the challenge var clonedChallenge = challenge.Clone(); // verify that challenge and answers were cloned Assert.AreNotEqual(challenge.Id, clonedChallenge.Id); Assert.AreEqual(challenge.Question, clonedChallenge.Question); Assert.AreEqual(challenge.ChallengeCategoryId, clonedChallenge.ChallengeCategoryId); Assert.AreEqual(challenge.OwnerId, clonedChallenge.OwnerId); Assert.AreEqual(challenge.OpenEnded, clonedChallenge.OpenEnded); Assert.AreNotEqual(challenge.Answers.Select(x => x.Id), clonedChallenge.Answers.Select(x => x.Id)); Assert.AreEqual(challenge.Answers.Select(x => x.Answer), clonedChallenge.Answers.Select(x => x.Answer)); Assert.AreEqual(challenge.Answers.Select(x => x.Correct), clonedChallenge.Answers.Select(x => x.Correct)); }
private void _WireDesignerData() { if (!DesignerProperties.IsInDesignTool) return; var challenge = new Challenge() { Id = 1, Title = "another trial", Description = "A new challenge to fight over!", Created = System.DateTime.Now, Modified = System.DateTime.Now, Location = new System.Device.Location.GeoPosition<System.Device.Location.GeoCoordinate>( new System.DateTimeOffset(), new System.Device.Location.GeoCoordinate(32, 32)), Image = "SampleData/Images/img1.jpg", SolvedCount = 3, MissedCount = 2 }; var challenge2 = new Challenge() { Id = 1, Title = "On the edge", Description = "Of the world", Created = System.DateTime.Now, Modified = System.DateTime.Now, Location = new System.Device.Location.GeoPosition<System.Device.Location.GeoCoordinate>( new System.DateTimeOffset(), new System.Device.Location.GeoCoordinate(32, 32)), Image = "SampleData/Images/img2.jpg", SolvedCount = 2, MissedCount = 8 }; Challenges.Add(challenge); Challenges.Add(challenge2); }
public bool OnPrtc_Challenge(OctetsStream os) { try { Challenge prtc = new Challenge(); prtc.unmarshal(os); Debug.Log(string.Format("On protocol using C#: {0}", (NetProtocolType)Challenge.PROTOCOL_TYPE)); //检查版本 { LuaDLL.lua_getglobal(wLua.L.L, "OnChallengeCheckVersion"); LuaDLL.lua_pushinteger(wLua.L.L, (Int32)prtc.version); LuaStatic.addGameObject2Lua(wLua.L.L, prtc.res_version, "Octets"); if (wLua.L.PCall(2, 1)) { Boolean bCheckSucc = LuaDLL.lua_toboolean(wLua.L.L, -1); LuaDLL.lua_pop(wLua.L.L, 1); if (!bCheckSucc) { return false; } } else { String errInfo = LuaDLL.lua_tostring(wLua.L.L, -1); LuaDLL.lua_pop(wLua.L.L, 1); Debug.LogWarning("OnChallengeCheckVersion failed: " + errInfo); } } //HMAC_MD5Hash hmac_md5 = new HMAC_MD5Hash(); Octets id = new Octets(UserName); Octets pwd = new Octets(Password); Response p = new Response(); // { // MD5Hash md5 = new MD5Hash(); // md5.Update(id); // md5.Update(pwd); // md5.Final(Nonce); // hmac_md5.SetParameter(Nonce); // // hmac_md5.Update(prtc.nonce); // p.identity = id; // p.userid = 0; // p.algo = prtc.algo; // hmac_md5.Final(p.response); // } //使用token登录 { p.identity = id; p.userid = 0; p.algo = prtc.algo; p.response = pwd; Nonce = pwd; } string strInfo = ECGame.GenerateDeviceInfo(); p.device_info.setString(strInfo); SendNetData(p); } catch (Exception e) { Debug.Log(e.ToString()); } return true; }
public FightChallengeFail(Challenge c) { this.Challenge = c; }
public void AddTest() { string path = @"D:\challenges.xml"; DataContext context = new DataContext(path); List <Answer> answers1 = new List <Answer> { new Answer { Value = "Первый ответ", IsCorrect = false }, new Answer { Value = "Второй ответ", IsCorrect = false }, new Answer { Value = "Третий ответ (правильный)", IsCorrect = true }, new Answer { Value = "Четвертый ответ", IsCorrect = false }, new Answer { Value = "Пятый ответ", IsCorrect = false }, new Answer { Value = "Шестой ответ", IsCorrect = false }, }; List <Answer> answers2 = new List <Answer> { new Answer { Value = "Ответ первый", IsCorrect = false }, new Answer { Value = "Ответ второй(правильный)", IsCorrect = true }, new Answer { Value = "Ответ третий", IsCorrect = false }, new Answer { Value = "Ответ четвертый(правильный)", IsCorrect = true }, new Answer { Value = "Ответ пятый(правильный)", IsCorrect = true }, new Answer { Value = "Ответ шестой", IsCorrect = false }, }; Question question1 = new Question(QuestionType.SingleSelect) { Title = "Первый вопрос", Value = "Первый вопрос первой задачи", Score = 9, }; Question question2 = new Question(QuestionType.MultipleSelect) { Title = "Второй вопрос", Value = "Второй вопрос первой задачи", Score = 10, }; question1.Answers.AddRange(answers1); question2.Answers.AddRange(answers2); Challenge challenge = new Challenge { Name = "Первая задача", }; challenge.Questions.Add(question1); challenge.Questions.Add(question2); //сохраняем в файл context.Add(challenge); Assert.Inconclusive(); }
public bool IsSupported(Challenge c) { return(c is DnsChallenge); }
public void ShouldDetectDoubleRepeatingStrings() { Assert.AreEqual(false, Challenge.PrimeString("abab")); Assert.AreEqual(false, Challenge.PrimeString("xyzxyz")); }
public PhotoPage(Challenge challenge) { InitializeComponent(); Challenge = challenge; BindingContext = this; }
public async Task ChallengePlayer(string playerB) { var challenge = new Challenge(Context.UserIdentifier, playerB); await Clients.Group(playerB).SendAsync("ChallengeReceived", challenge, challenge.Encrypt()); }
public async Task DeclineChallenge(string state) { var challenge = Challenge.DecryptAndVerify(state, Context.UserIdentifier); await Clients.Group(challenge.PlayerA).SendAsync("NoGame", challenge.PlayerB); }
public async Task Create(string title, string description, ChallengeDifficulty difficulty, string url) { if (!Uri.TryCreate(url, UriKind.Absolute, out var result)) { await ReplyAsync("Invalid URL format"); return; } if (result.Host != "gist.githubusercontent.com") { await ReplyAsync("URL must begin with `gist.githubusercontent.com`"); return; } Data?data; try { using var wc = new WebClient(); var json = wc.DownloadString(result); data = JsonConvert.DeserializeObject <Data>(json, new JsonSerializerSettings { Converters = new JsonConverter[] { new YololValueConverter() }, FloatParseHandling = FloatParseHandling.Decimal }); } catch (Exception e) { await ReplyAsync("Failed: " + e.Message.Substring(0, Math.Min(1000, e.Message.Length))); return; } if (data == null) { await ReplyAsync("Test cases cannot be null"); return; } if (data.In == null) { await ReplyAsync("Input values cannot be null"); return; } if (data.Out == null) { await ReplyAsync("Output values cannot be null"); return; } var c = new Challenge(0, title, "done", data.In, data.Out, null, difficulty, description, data.Shuffle ?? true, ScoreMode.BasicScoring); await _challenges.Create(c); await ReplyAsync("Challenge added to queue"); }
public async Task <IActionResult> CreateChallenge([FromBody] Challenge challenge) { var challengeId = await _challengeService.CreateChallenge(challenge.CategoryId, challenge.ChallengerId, challenge.OpponentId); return(Ok(ApiHelper.ResponseWrapper(challengeId))); }
public IChallenge FakeChallenge(ChallengeModel model) { var challengeFaker = new ChallengeFaker(); challengeFaker.CustomInstantiator( faker => { faker.User().Reset(); var name = new ChallengeName(model.Name); var game = Game.FromValue(model.Game); var entries = new Entries(model.Entries); var bestOf = new BestOf(model.BestOf); var duration = new ChallengeDuration(TimeSpan.FromTicks(model.Timeline.Duration)); var state = ChallengeState.FromValue(model.State); var utcNowDate = DateTime.UtcNow.Date; var createdAt = faker.Date.Recent(1, utcNowDate); var startedAt = faker.Date.Between(createdAt, utcNowDate); var endedAt = startedAt + duration; var synchronizationBuffer = endedAt + TimeSpan.FromHours(2); var closedAt = faker.Date.Soon(1, synchronizationBuffer); var synchronizedAt = faker.Date.Between(synchronizationBuffer, closedAt); var timeline = new ChallengeTimeline(new DateTimeProvider(startedAt), duration); var scoring = new Scoring { [new StatName("StatName1")] = new StatWeighting(0.00015F), [new StatName("StatName2")] = new StatWeighting(1), [new StatName("StatName3")] = new StatWeighting(0.77F), [new StatName("StatName4")] = new StatWeighting(100), [new StatName("StatName5")] = new StatWeighting(-3) }; var challenge = new Challenge( model.Id.ConvertTo <ChallengeId>(), name, game, bestOf, entries, timeline, scoring); var participantFaker = new ParticipantFaker(game, createdAt, startedAt); participantFaker.UseSeed(faker.Random.Int()); var participants = participantFaker.Generate(this.ParticipantCount(state, challenge.Entries)); participants.ForEach(participant => challenge.Register(participant)); if (state != ChallengeState.Inscription) { challenge.Start(new DateTimeProvider(startedAt)); participants.ForEach( participant => { var matchFaker = new MatchFaker(challenge.Scoring, synchronizedAt); matchFaker.UseSeed(faker.Random.Int()); var matches = matchFaker.Generate(this.MatchCount(state, challenge.BestOf)); participant.Snapshot(matches, new DateTimeProvider(synchronizedAt)); }); challenge.Synchronize(new DateTimeProvider(synchronizedAt)); if (state == ChallengeState.Ended || state == ChallengeState.Closed) { challenge.Start(new DateTimeProvider(startedAt - duration)); } if (state == ChallengeState.Closed) { challenge.Close(new DateTimeProvider(closedAt)); } } return(challenge); }); return(challengeFaker.Generate()); }
protected override void Unpack(Unpacker unpacker) { base.Unpack(unpacker); ChallengeData = new Challenge(unpacker); }
public KademliaPingMessage(Challenge challenge) : base(KademliaMessageTypes.Ping) { ChallengeData = challenge; }
protected override void FillSpecificData(Challenge challenge, RestContext context, ChallengeViewModel data) { var recipe = context.Recipes.FirstOrDefault(r => r.RecipeId == data.RecipeId); var c = (challenge as RecipeChallenge); if (recipe == null) throw new NullReferenceException($"Recipe with id {data.RecipeId} was not found."); c.Recipe = recipe; c.PrepareFor = (TargetSubject)R.Next(0, 4); c.Earnings = 1; c.Thumbnail = recipe.Image; }
/// <summary> /// Executes the GET method on the resource. /// </summary> /// <param name="Request">HTTP Request</param> /// <param name="Response">HTTP Response</param> /// <exception cref="HttpException">If an error occurred when processing the method.</exception> public void GET(HttpRequest Request, HttpResponse Response) { if (!Request.Header.TryGetHeaderField("Upgrade", out HttpField Upgrade) || Upgrade.Value != "websocket") { throw new UpgradeRequiredException("websocket"); } string Challenge; string WebSocketProtocol = null; int? WebSocketVersion; int i; if (Request.Header.TryGetHeaderField("Sec-WebSocket-Key", out HttpField Field)) { Challenge = Field.Value; } else { throw new BadRequestException(); } if (Request.Header.TryGetHeaderField("Sec-WebSocket-Protocol", out Field)) { string[] Options = Field.Value.Split(','); foreach (string Option in Options) { i = Array.IndexOf <string>(this.subProtocols, Option.Trim().ToLower()); if (i >= 0) { WebSocketProtocol = this.subProtocols[i]; break; } } if (WebSocketProtocol is null) { throw new NotSupportedException(); } } if (Request.Header.TryGetHeaderField("Sec-WebSocket-Version", out Field) && int.TryParse(Field.Value, out i)) { if (i < 13) { throw new PreconditionFailedException(); } WebSocketVersion = i; } else { throw new BadRequestException(); } if (Request.Header.TryGetHeaderField("Sec-WebSocket-Extensions", out Field)) { // TODO: §9.1 } if (Request.clientConnection is null) { throw new ForbiddenException("Invalid connection."); } WebSocket Socket = new WebSocket(this, Request, Response); this.Accept?.Invoke(this, new WebSocketEventArgs(Socket)); string ChallengeResponse = Convert.ToBase64String(Hashes.ComputeSHA1Hash( Encoding.UTF8.GetBytes(Challenge.Trim() + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"))); Response.StatusCode = 101; Response.StatusMessage = "Switching Protocols"; Response.SetHeader("Upgrade", "websocket"); Response.SetHeader("Connection", "Upgrade"); Response.SetHeader("Sec-WebSocket-Accept", ChallengeResponse); if (WebSocketProtocol != null) { Response.SetHeader("Sec-WebSocket-Protocol", WebSocketProtocol); } Request.clientConnection.Upgrade(Socket); Response.SendResponse(); this.Connected?.Invoke(this, new WebSocketEventArgs(Socket)); }
protected override void FillSpecificData(Challenge challenge, RestContext context, ChallengeViewModel data) { }
protected abstract ChallengeSolveResult ValidateAnswer(Challenge challenge, string answer);
public void Handle(Challenge c) { AssertNotDisposed(); var dnsChallenge = c as DnsChallenge; var httpChallenge = c as HttpChallenge; if (dnsChallenge != null) { _writer.WriteLine($"== Manual Challenge Handler - DNS =="); _writer.WriteLine($" * Handle Time: [{DateTime.Now}]"); _writer.WriteLine($" * Challenge Token: [{dnsChallenge.Token}]"); _writer.WriteLine($"To complete this Challenge please create a new Resource"); _writer.WriteLine($"Record (RR) with the following characteristics:"); _writer.WriteLine($" * RR Type: [TXT]"); _writer.WriteLine($" * RR Name: [{dnsChallenge.RecordName}]"); _writer.WriteLine($" * RR Value: [{dnsChallenge.RecordValue}]"); _writer.WriteLine($"------------------------------------"); _writer.Flush(); } else if (httpChallenge != null) { _writer.WriteLine($"== Manual Challenge Handler - HTTP =="); _writer.WriteLine($" * Handle Time: [{DateTime.Now}]"); _writer.WriteLine($" * Challenge Token: [{httpChallenge.Token}]"); _writer.WriteLine($"To complete this Challenge please create a new file"); _writer.WriteLine($"under the server that is responding to the hostname"); _writer.WriteLine($"and path given with the following characteristics:"); _writer.WriteLine($" * HTTP URL: [{httpChallenge.FileUrl}]"); _writer.WriteLine($" * File Path: [{httpChallenge.FilePath}]"); _writer.WriteLine($" * File Content: [{httpChallenge.FileContent}]"); _writer.WriteLine($" * MIME Type: [text/plain]"); _writer.WriteLine($"------------------------------------"); _writer.Flush(); } else { var ex = new InvalidOperationException("unsupported Challenge type"); ex.Data["challengeType"] = c.GetType(); throw ex; } }
private void Start() { GameObject gameObject = base.transform.Find("ObjectivePanel").gameObject; if (WPFMonoBehaviour.levelManager.m_sandbox) { gameObject.SetActive(false); return; } this.m_objectiveOne = gameObject.transform.Find("ObjectiveSlot1").GetComponent <ObjectiveSlot>(); this.m_objectiveTwo = gameObject.transform.Find("ObjectiveSlot2").GetComponent <ObjectiveSlot>(); this.m_objectiveThree = gameObject.transform.Find("ObjectiveSlot3").GetComponent <ObjectiveSlot>(); if (this.m_challenges.Count >= 2) { bool flag = GameProgress.IsChallengeCompleted(Singleton <GameManager> .Instance.CurrentSceneName, this.m_challenges[0].ChallengeNumber); bool flag2 = GameProgress.IsChallengeCompleted(Singleton <GameManager> .Instance.CurrentSceneName, this.m_challenges[1].ChallengeNumber); if (!flag && flag2) { Challenge value = this.m_challenges[0]; this.m_challenges[0] = this.m_challenges[1]; this.m_challenges[1] = value; } } if (this.m_challenges == null || this.m_challenges.Count == 0) { return; } string currentSceneName = Singleton <GameManager> .Instance.CurrentSceneName; bool flag3 = GameProgress.HasCollectedSnoutCoins(currentSceneName, 0); bool flag4 = GameProgress.HasCollectedSnoutCoins(currentSceneName, this.m_challenges[0].ChallengeNumber); bool flag5 = GameProgress.HasCollectedSnoutCoins(currentSceneName, this.m_challenges[1].ChallengeNumber); this.m_objectiveOne.ShowSnoutReward(!flag3, 1, false); this.m_objectiveTwo.ShowSnoutReward(!flag4, 1, false); this.m_objectiveThree.ShowSnoutReward(!flag5, 1, false); bool flag6 = GameProgress.IsLevelCompleted(Singleton <GameManager> .Instance.CurrentSceneName); if (flag6) { this.m_objectiveOne.SetSucceededImmediate(); } this.m_objectiveOne.SetChallenge(this.m_goal); if (this.m_challenges.Count >= 1) { this.m_objectiveTwo.SetChallenge(this.m_challenges[0]); bool flag7 = GameProgress.IsChallengeCompleted(Singleton <GameManager> .Instance.CurrentSceneName, this.m_challenges[0].ChallengeNumber); if (flag7) { this.m_objectiveTwo.SetSucceededImmediate(); } } if (this.m_challenges.Count >= 2) { this.m_objectiveThree.SetChallenge(this.m_challenges[1]); bool flag8 = GameProgress.IsChallengeCompleted(Singleton <GameManager> .Instance.CurrentSceneName, this.m_challenges[1].ChallengeNumber); if (flag8) { this.m_objectiveThree.SetSucceededImmediate(); } } }
public void AddChallenge(Challenge challenge) { challenges.Add(challenge); }
// Use this for initialization void Start() { challenges = new ArrayList(); GSApi = GameObject.FindObjectOfType(typeof(GameSparks)) as GameSparks; Hashtable challengesHash = GSApi.listRunningChallenges(); ArrayList challengeInstances = challengesHash["challengeInstances"] as ArrayList; foreach (Hashtable challenge in challengeInstances) { Challenge c = new Challenge(); c.id = (string)challenge["challengeId"]; c.displayName = (string)(((Hashtable)challenge["challenger"])["name"]); c.pot = challenge["currency3Wager"] == null? 0: (double)challenge["currency3Wager"]; c.status = Challenge.ChallengeStatus.waiting; c.ends = (string)challenge["endDate"]; challenges.Add(c); Debug.Log(challenge["endDate"]); } challengesHash = GSApi.listRecievedChallenges(); challengeInstances = challengesHash["challengeInstances"] as ArrayList; if (challengeInstances != null) { foreach (Hashtable challenge in challengeInstances) { Challenge c = new Challenge(); c.id = (string)challenge["challengeId"]; c.displayName = (string)(((Hashtable)challenge["challenger"])["name"]); c.pot = challenge["currency3Wager"] == null? 0: (double)challenge["currency3Wager"]; c.status = Challenge.ChallengeStatus.recieved; c.ends = (string)challenge["endDate"]; challenges.Add(c); } } challengesHash = GSApi.listCompletedChallenges(); challengeInstances = challengesHash["challengeInstances"] as ArrayList; if (challengeInstances != null) { foreach (Hashtable challenge in challengeInstances) { Challenge c = new Challenge(); c.id = (string)challenge["challengeId"]; c.displayName = (string)(((Hashtable)challenge["challenger"])["name"]); c.pot = challenge["currency3Wager"] == null? 0: (double)challenge["currency3Wager"]; c.status = Challenge.ChallengeStatus.complete; c.ends = (string)challenge["endDate"]; challenges.Add(c); } } /* * * challenges = new ArrayList(); * //populate from gamespark * challenges.Add(new Challenge{id = "a", displayName = "Alex", pot = 100, status = Challenge.ChallengeStatus.waiting, ends = 0}); * challenges.Add(new Challenge{id = "b", displayName = "Billy", pot = 200, status = Challenge.ChallengeStatus.waiting, ends = 1}); * challenges.Add(new Challenge{id = "c", displayName = "Claire", pot = 300, status = Challenge.ChallengeStatus.waiting, ends = 2}); * challenges.Add(new Challenge{id = "d", displayName = "Derick", pot = 400, status = Challenge.ChallengeStatus.waiting, ends = 3}); * challenges.Add(new Challenge{id = "e", displayName = "Emmet", pot = 500, status = Challenge.ChallengeStatus.waiting, ends = 25}); * challenges.Add(new Challenge{id = "f", displayName = "Frank", pot = 600, status = Challenge.ChallengeStatus.waiting, ends = 49}); * challenges.Add(new Challenge{id = "g", displayName = "Gregory", pot = 700, status = Challenge.ChallengeStatus.waiting, ends = 73}); */ //PopulateList("waiting"); }
internal async Task <IChallengeValidationDetails> DecodeChallengeValidation(Authorization auth, Challenge challenge) { var client = await GetClient(); return(AuthorizationDecoder.DecodeChallengeValidation(auth, challenge.Type, client.Signer)); }
internal static void ConfigureFromWizard(object o, OneSecondUpdateTickedEventArgs e) { // check if host if (!Context.IsWorldReady) { return; } if (!Context.IsMainPlayer) { return; } // see if event has run if (!Game1.player.eventsSeen.Contains(117780001)) { Game1.getFarm().modData.Remove($"{MarketDay.SMod.ModManifest.UniqueID}/ConfigurationWizardDone"); return; } // see if already configured if (Game1.getFarm().modData.ContainsKey($"{MarketDay.SMod.ModManifest.UniqueID}/ConfigurationWizardDone")) { return; } // set marker that config is done Game1.getFarm().modData[$"{MarketDay.SMod.ModManifest.UniqueID}/ConfigurationWizardDone"] = "true"; // collect answers from event Challenge p = Challenge.NotAnswered; if (Game1.player.dialogueQuestionsAnswered.Contains(117789010)) { p = Challenge.Yes; } if (Game1.player.dialogueQuestionsAnswered.Contains(117789011)) { p = Challenge.No; } if (Game1.player.dialogueQuestionsAnswered.Contains(117789012)) { p = Challenge.Rude; } Shops s = Shops.NotAnswered; if (Game1.player.dialogueQuestionsAnswered.Contains(117789020)) { s = Shops.S3; } if (Game1.player.dialogueQuestionsAnswered.Contains(117789021)) { s = Shops.S6; } if (Game1.player.dialogueQuestionsAnswered.Contains(117789022)) { s = Shops.S9; } if (Game1.player.dialogueQuestionsAnswered.Contains(117789023)) { s = Shops.S12; } if (Game1.player.dialogueQuestionsAnswered.Contains(117789024)) { s = Shops.S15; } Day d = Day.NotAnswered; if (Game1.player.dialogueQuestionsAnswered.Contains(117789030)) { d = Day.Friday; } if (Game1.player.dialogueQuestionsAnswered.Contains(117789031)) { d = Day.Saturday; } if (Game1.player.dialogueQuestionsAnswered.Contains(117789032)) { d = Day.Sunday; } Weather w = Weather.NotAnswered; if (Game1.player.dialogueQuestionsAnswered.Contains(117789040)) { w = Weather.Fine; } if (Game1.player.dialogueQuestionsAnswered.Contains(117789041)) { w = Weather.Any; } ShowGMCM g = ShowGMCM.NotAnswered; if (Game1.player.dialogueQuestionsAnswered.Contains(117789050)) { g = ShowGMCM.Yes; } if (Game1.player.dialogueQuestionsAnswered.Contains(117789051)) { g = ShowGMCM.No; } // set config accordingly if (p is Challenge.Rude or Challenge.NotAnswered) { return; } MarketDay.Config.Progression = p != Challenge.No; switch (d) { case Day.Friday: MarketDay.Config.DayOfWeek = 5; break; case Day.Saturday: MarketDay.Config.DayOfWeek = 6; break; case Day.Sunday: MarketDay.Config.DayOfWeek = 0; break; case Day.NotAnswered: break; default: throw new Exception($"Unhandled value {d} for Day"); } switch (w) { case Weather.Fine: MarketDay.Config.OpenInRain = false; MarketDay.Config.OpenInSnow = false; break; case Weather.Any: MarketDay.Config.OpenInRain = true; MarketDay.Config.OpenInSnow = true; break; case Weather.NotAnswered: break; default: throw new Exception($"Unhandled value {w} for Weather"); } switch (s) { case Shops.S3: MarketDay.Config.NumberOfShops = 3; break; case Shops.S6: MarketDay.Config.NumberOfShops = 6; break; case Shops.S9: MarketDay.Config.NumberOfShops = 9; break; case Shops.S12: MarketDay.Config.NumberOfShops = 12; break; case Shops.S15: MarketDay.Config.NumberOfShops = 15; break; case Shops.NotAnswered: break; default: throw new Exception($"Unhandled value {s} for Shops"); } switch (s) { case Shops.S3: MarketDay.Config.NumberOfShops = 3; break; case Shops.S6: MarketDay.Config.NumberOfShops = 6; break; case Shops.S9: MarketDay.Config.NumberOfShops = 9; break; case Shops.S12: MarketDay.Config.NumberOfShops = 12; break; case Shops.S15: MarketDay.Config.NumberOfShops = 15; break; case Shops.NotAnswered: break; default: throw new Exception($"Unhandled value {s} for Shops"); } // save config MarketDay.SaveConfig(); // pop up GMCM if requested if (g == ShowGMCM.Yes) { var configMenu = MarketDay.helper.ModRegistry.GetApi <IGenericModConfigMenuApi>("spacechase0.GenericModConfigMenu"); if (configMenu is null) { MessageUtility.SendMessage(MarketDay.Get("wizard.edit-options")); MessageUtility.SendMessage(MarketDay.Get("wizard.install-gmcm")); return; } ShowConfigurationMenu(); } }
public async Task UpdateChallenge(Challenge challenge) { _challengeRepository.Update(challenge); await _unit.Commit(); }
void SetChallengePosition(Challenge challenge, int playerID) { GameObject go = challenge.attachedGameObject; if (go != null) { float targetX = playerDatas[playerID].xPos + extraDetectionDistance; //At judgment time, its pos is equal to player pos targetX += challenge.timeLeftUntilJudgment * movementPerSecond; //Move it away from player depending on judgment time targetX -= challenge.xOffset; //Adjust for location on object where challenge occurs go.transform.localPosition = new Vector3(targetX, go.transform.localPosition.y, go.transform.localPosition.z); } else { Static.WarningOnce("Null object on challenge for player " + playerID, "nullobject"); } }
public void ShouldHandleSimplePrimesOfUniqueLetterCombinations() { Assert.AreEqual(true, Challenge.PrimeString("xyz")); Assert.AreEqual(true, Challenge.PrimeString("abcdef")); }
void DestroyChallenge(Challenge challenge, int playerID) { if (playerDatas.Count > playerID) { PlayerData data = playerDatas[playerID]; if (data != null) { data.challenges.Remove(challenge); } } Destroy(challenge.attachedGameObject); Destroy(challenge.gameObject); }
void webClient_LoadProfileCompleted(object sender, DownloadStringCompletedEventArgs e) { try { JObject o = (JObject)JToken.Parse(e.Result); UserProfile userProfile = new UserProfile() { Name = o["Name"].ToString(), ProfileImageUrl = o["ImageUrl"].ToString() }; this.MyUserProfile = userProfile; JArray challenges = (JArray)o["Challenges"]; if (challenges != null && challenges.Count > 0) { JObject objChallenge = (JObject)challenges[0]; Challenge myChallenge = new Challenge(); myChallenge.Message = objChallenge["Messages"].HasValues ? objChallenge["Messages"].ToString() : string.Empty; var strTime = objChallenge["WakeUpTime"].ToString(); myChallenge.WakeupTime = Convert.ToDateTime(strTime); myChallenge.ChallengeId = Convert.ToInt16(objChallenge["Id"]); myChallenge.DonateId = objChallenge["DonationId"].HasValues ? Convert.ToInt16(objChallenge["DonationId"]) : -1; myChallenge.Duration = objChallenge["Duration"].HasValues ? Convert.ToInt16(objChallenge["Duration"]) : 1; //temp data for changle this.MyChallenge = myChallenge; SetAlarm(myChallenge.WakeupTime, myChallenge.Duration); } } catch { SetAlarm(DateTime.Now.AddMinutes(1)); } this.IsLoadCompleted = true; }
// Use this for initialization void Start() { challenge = new Challenge(); url = "http://5.9.251.204/api/challenge/create"; // input = name.GetComponent<InputField>(); modifyURL = "http://5.9.251.204/api/challenge/modify"; Debug.Log(getChallengeURL); }
protected override void FillSpecificData(Challenge challenge, RestContext context, ChallengeViewModel data) { var c = challenge as CreativeCookingChallenge; if (data.IngredientsId == null) throw new NullReferenceException("Ingredients are required."); if (data.RecipeId == -1) throw new ArgumentException("Well then please just give a recipe."); var recipe = context.Recipes.FirstOrDefault(r => r.RecipeId == data.RecipeId); if (recipe == null) throw new NullReferenceException($"No recipe was found with id {data.RecipeId}."); c.Recipe = recipe; foreach (int ingredientId in data.IngredientsId) { var ingredient = context.Ingredients.FirstOrDefault(i => i.IngredientId == ingredientId); if (ingredient != null) c.Ingredients.Add(ingredient); } c.Thumbnail = recipe.Image; c.Earnings = (int)(1.5 * c.Ingredients.Count); }
void CreateChallengesM(Challenge[] challenges) { GameObject gameobje = new GameObject(); foreach (Challenge challenge in challenges) { //Creates the button string challengeCategory = challenge.Type.Trim(); if (!categories.Contains(challengeCategory)) { categories.Add(challengeCategory); } if (challenge.Type.Trim() == "Travel/Tourism" && challenge.Difficulty.Trim() == "Easy") easyTravelandTourismChallenge.Add(challenge); if (challenge.Type.Trim() == "Travel/Tourism" && challenge.Difficulty.Trim() == "Medium") mediumTravelandTourismChallenge.Add(challenge); if (challenge.Type.Trim() == "Travel/Tourism" && challenge.Difficulty.Trim() == "Hard") hardTravelandTourismChallenge.Add(challenge); if (challenge.Type.Trim() == "Sports" && challenge.Difficulty.Trim() == "Easy") easySportsChallenge.Add(challenge); if (challenge.Type.Trim() == "Sports" && challenge.Difficulty.Trim() == "Medium") mediumSportsChallenge.Add(challenge); if (challenge.Type.Trim() == "Sports" && challenge.Difficulty.Trim() == "Hard") hardSportsChallenge.Add(challenge); if (challenge.Type.Trim() == "Cars" && challenge.Difficulty.Trim() == "Easy") easyCarsChallenge.Add(challenge); if (challenge.Type.Trim() == "Cars" && challenge.Difficulty.Trim() == "Medium") mediumCarsChallenge.Add(challenge); if (challenge.Type.Trim() == "Cars" && challenge.Difficulty.Trim() == "Hard") hardCarsChallenge.Add(challenge); if (challenge.Type.Trim() == "Dare to be Digital" && challenge.Difficulty.Trim() == "Easy") easyDareToBeDigitalChallenge.Add(challenge); if (challenge.Type.Trim() == "Dare to be Digital" && challenge.Difficulty.Trim() == "Medium") mediumDareToBeDigitalChallenge.Add(challenge); if (challenge.Type.Trim() == "Dare to be Digital" && challenge.Difficulty.Trim() == "Hard") hardDareToBeDigitalChallenge.Add(challenge); if (challenge.Type.Trim() == "People and Places" && challenge.Difficulty.Trim() == "Easy") easyPeopleAndPlacesChallenge.Add(challenge); if (challenge.Type.Trim() == "People and Places" && challenge.Difficulty.Trim() == "Medium") mediumPeopleAndPlacesChallenge.Add(challenge); if (challenge.Type.Trim() == "People and Places" && challenge.Difficulty.Trim() == "Hard") hardPeopleAndPlacesChallenge.Add(challenge); if (challenge.Type.Trim() == "Miscellaneous" && challenge.Difficulty.Trim() == "Easy") easyMiscellaneousChallenge.Add(challenge); if (challenge.Type.Trim() == "Miscellaneous" && challenge.Difficulty.Trim() == "Medium") mediumMiscellaneousChallenge.Add(challenge); if (challenge.Type.Trim() == "Miscellaneous" && challenge.Difficulty.Trim() == "Hard") hardMiscellaneousChallenge.Add(challenge); if (challenge.Type.Trim() == "Animals" && challenge.Difficulty.Trim() == "Easy") easyAnimalsChallenge.Add(challenge); if (challenge.Type.Trim() == "Animals" && challenge.Difficulty.Trim() == "Medium") mediumAnimalsChallenge.Add(challenge); if (challenge.Type.Trim() == "Animals" && challenge.Difficulty.Trim() == "Hard") hardAnimalsChallenge.Add(challenge); if (challenge.Type.Trim() == "Food/Drink" && challenge.Difficulty.Trim() == "Easy") easyFoodAndDrinkChallenge.Add(challenge); if (challenge.Type.Trim() == "Food/Drink" && challenge.Difficulty.Trim() == "Medium") mediumFoodAndDrinkChallenge.Add(challenge); if (challenge.Type.Trim() == "Food/Drink" && challenge.Difficulty.Trim() == "Hard") hardFoodAndDrinkChallenge.Add(challenge); if (challenge.Type.Trim() == "Great Outdoors" && challenge.Difficulty.Trim() == "Easy") easyGreatOutdoorsChallenge.Add(challenge); if (challenge.Type.Trim() == "Great Outdoors" && challenge.Difficulty.Trim() == "Medium") mediumGreatOutdoorsChallenge.Add(challenge); if (challenge.Type.Trim() == "Great Outdoors" && challenge.Difficulty.Trim() == "Hard") hardGreatOutdoorsChallenge.Add(challenge); if (challenge.Type.Trim() == "Everyday Life" && challenge.Difficulty.Trim() == "Easy") easyEverydayLifeChallenge.Add(challenge); if (challenge.Type.Trim() == "Everyday Life" && challenge.Difficulty.Trim() == "Medium") mediumEverydayLifeChallenge.Add(challenge); if (challenge.Type.Trim() == "Everyday Life" && challenge.Difficulty.Trim() == "Hard") hardEverydayLifeChallenge.Add(challenge); if (challenge.Type.Trim() == "Events" && challenge.Difficulty.Trim() == "Easy") easyEventsChallenge.Add(challenge); if (challenge.Type.Trim() == "Events" && challenge.Difficulty.Trim() == "Medium") mediumEventsChallenge.Add(challenge); if (challenge.Type.Trim() == "Events" && challenge.Difficulty.Trim() == "Hard") hardEventsChallenge.Add(challenge); } CreateCategories(); CreateChallenge(); }
protected override void FillSpecificData(Challenge challenge, RestContext context, ChallengeViewModel data) { var restaurant = context.Restaurants.FirstOrDefault(r => r.RestaurantId == data.RestaurantId); var c = (challenge as RestaurantChallenge); if (restaurant == null) throw new NullReferenceException($"Restaurant with id {data.RestaurantId} was not found."); c.Earnings = 3; c.Restaurant = restaurant; }
public void ShouldHandleMoreComplexPrimes() { Assert.AreEqual(true, Challenge.PrimeString("utdutdtdutd")); Assert.AreEqual(true, Challenge.PrimeString("abba")); }
void CreateDemChallenges(Challenge[] jsonObject) { foreach (Challenge challenge in jsonObject) { challenges.Add(challenge); if (challenge.Difficulty.Trim() == "Easy") easyChallenges.Add(challenge); if (challenge.Difficulty.Trim() == "Medium") mediumChallenges.Add(challenge); if (challenge.Difficulty.Trim() == "Hard") hardChallenges.Add(challenge); } SetButtons(buttonRect, easyButtonContainer.GetComponent<RectTransform>(), easyChallenges, buttonPrefab, easyButtonContainer, textColor); SetButtons(buttonRect, mediumButtonContainer.GetComponent<RectTransform>(), mediumChallenges, buttonPrefab, mediumButtonContainer, textColor); SetButtons(buttonRect, hardButtonContainer.GetComponent<RectTransform>(), hardChallenges, buttonPrefab, hardButtonContainer, textColor); }
/// <summary> /// Make sure we have authorization for every host in target /// </summary> /// <param name="target"></param> /// <returns></returns> private Challenge Authorize(ILifetimeScope execute, RunLevel runLevel, OrderDetails order, ValidationPluginOptions options, TargetPart targetPart, Authorization authorization) { var invalid = new Challenge { Status = _authorizationInvalid }; var valid = new Challenge { Status = _authorizationValid }; var client = execute.Resolve <AcmeClient>(); var identifier = authorization.Identifier.Value; try { _log.Information("Authorize identifier: {identifier}", identifier); if (authorization.Status == _authorizationValid && !runLevel.HasFlag(RunLevel.Test)) { _log.Information("Cached authorization result: {Status}", authorization.Status); return(valid); } else { using (var validation = _scopeBuilder.Validation(execute, options, targetPart, identifier)) { IValidationPlugin validationPlugin = null; try { validationPlugin = validation.Resolve <IValidationPlugin>(); } catch (Exception ex) { _log.Error(ex, "Error resolving validation plugin"); } if (validationPlugin == null) { _log.Error("Validation plugin not found or not created."); return(invalid); } var challenge = authorization.Challenges.FirstOrDefault(c => c.Type == options.ChallengeType); if (challenge == null) { _log.Error("Expected challenge type {type} not available for {identifier}.", options.ChallengeType, authorization.Identifier.Value); return(invalid); } if (challenge.Status == _authorizationValid && !runLevel.HasFlag(RunLevel.Test)) { _log.Information("{dnsIdentifier} already validated by {challengeType} validation ({name})", authorization.Identifier.Value, options.ChallengeType, options.Name); return(valid); } _log.Information("Authorizing {dnsIdentifier} using {challengeType} validation ({name})", identifier, options.ChallengeType, options.Name); try { var details = client.DecodeChallengeValidation(authorization, challenge); validationPlugin.PrepareChallenge(details); } catch (Exception ex) { _log.Error(ex, "Error preparing for challenge answer"); return(invalid); } _log.Debug("Submitting challenge answer"); challenge = client.AnswerChallenge(challenge); // Have to loop to wait for server to stop being pending var tries = 0; var maxTries = 4; while (challenge.Status == _authorizationPending) { _log.Debug("Refreshing authorization"); Thread.Sleep(2000); // this has to be here to give ACME server a chance to think challenge = client.GetChallengeDetails(challenge.Url); tries += 1; if (tries > maxTries) { _log.Error("Authorization timed out"); return(invalid); } } if (challenge.Status != _authorizationValid) { _log.Error("Authorization result: {Status}", challenge.Status); return(invalid); } else { _log.Information("Authorization result: {Status}", challenge.Status); return(valid); } } } } catch (Exception ex) { _log.Error("Error authorizing {renewal}", targetPart); HandleException(ex); return(invalid); } }
public void CleanUp(Challenge c) { AssertNotDisposed(); var dnsChallenge = c as DnsChallenge; var httpChallenge = c as HttpChallenge; if (dnsChallenge != null) { _writer.WriteLine($"== Manual Challenge Handler - DNS =="); _writer.WriteLine($" * CleanUp Time: [{DateTime.Now}]"); _writer.WriteLine($" * Challenge Token: [{dnsChallenge.Token}]"); _writer.WriteLine($"The Challenge has been completed -- you can now remove the"); _writer.WriteLine($"Resource Record created previously with the following"); _writer.WriteLine($"characteristics:"); _writer.WriteLine($" * RR Type: [TXT]"); _writer.WriteLine($" * RR Name: [{dnsChallenge.RecordName}]"); _writer.WriteLine($" * RR Value: [{dnsChallenge.RecordValue}]"); _writer.WriteLine($"------------------------------------"); _writer.Flush(); } else if (httpChallenge != null) { _writer.WriteLine($"== Manual Challenge Handler - HTTP =="); _writer.WriteLine($" * CleanUp Time: [{DateTime.Now}]"); _writer.WriteLine($" * Challenge Token: [{httpChallenge.Token}]"); _writer.WriteLine($"The Challenge has been completed -- you can now remove the"); _writer.WriteLine($"file created previously with the following characteristics:"); _writer.WriteLine($" * HTTP URL: [{httpChallenge.FileUrl}]"); _writer.WriteLine($" * File Path: [{httpChallenge.FilePath}]"); _writer.WriteLine($" * File Content: [{httpChallenge.FileContent}]"); _writer.WriteLine($" * MIME Type: [text/plain]"); _writer.WriteLine($"------------------------------------"); _writer.Flush(); } else { var ex = new InvalidOperationException("unsupported Challenge type"); ex.Data["challengeType"] = c.GetType(); throw ex; } }
public async Task <Challenge> UpdateChallenge(Challenge challenge) { var result = await ChallengeEntityService.Update(challenge); return(result); }
public async Task <Challenge> Hints(Challenge challenge) { throw new NotImplementedException(); }
public void ShouldDetectMoreMultipleRepeatingStrings() { Assert.AreEqual(false, Challenge.PrimeString("zzz")); Assert.AreEqual(false, Challenge.PrimeString("abcabcabcabc")); Assert.AreEqual(false, Challenge.PrimeString("fdsyffdsyffdsyffdsyffdsyf")); }
bool JudgePlayerState(Challenge challenge, int playerID) { //playerDatas[i].character._currentState PlayerCharacter.CharacterState state = playerDatas[playerID].character.CurrentState; switch(challenge.requiredInput) { case Challenge.InputType.Jump: if (state == PlayerCharacter.CharacterState.Jumping) return true; break; case Challenge.InputType.Duck: if (state == PlayerCharacter.CharacterState.Sliding) return true; break; } return false; }
public void MergeFrom(BonusMetadata other) { if (other == null) { return; } switch (other.MetadataTypeCase) { case MetadataTypeOneofCase.Potion: if (Potion == null) { Potion = new global::WUProtos.Data.Potion.PotionBonusMetadata(); } Potion.MergeFrom(other.Potion); break; case MetadataTypeOneofCase.Wrackspurt: if (Wrackspurt == null) { Wrackspurt = new global::WUProtos.Data.WrackspurtBonusMetadata(); } Wrackspurt.MergeFrom(other.Wrackspurt); break; case MetadataTypeOneofCase.FirstTimeCollection: if (FirstTimeCollection == null) { FirstTimeCollection = new global::WUProtos.Data.FirstTimeCollectionBonusMetadata(); } FirstTimeCollection.MergeFrom(other.FirstTimeCollection); break; case MetadataTypeOneofCase.Challenge: if (Challenge == null) { Challenge = new global::WUProtos.Data.Challenge.ChallengeBonus(); } Challenge.MergeFrom(other.Challenge); break; case MetadataTypeOneofCase.SpellGame: if (SpellGame == null) { SpellGame = new global::WUProtos.Data.SpellGameBonusMetadata(); } SpellGame.MergeFrom(other.SpellGame); break; case MetadataTypeOneofCase.ChallengeBonus: if (ChallengeBonus == null) { ChallengeBonus = new global::WUProtos.Data.Challenge.ChallengeBonusMetadata(); } ChallengeBonus.MergeFrom(other.ChallengeBonus); break; case MetadataTypeOneofCase.ShardConversion: if (ShardConversion == null) { ShardConversion = new global::WUProtos.Data.ShardConversionBonusMetadata(); } ShardConversion.MergeFrom(other.ShardConversion); break; case MetadataTypeOneofCase.ChallengeChamberBonus: if (ChallengeChamberBonus == null) { ChallengeChamberBonus = new global::WUProtos.Data.Challenge.ChallengeChamberBonusMetadata(); } ChallengeChamberBonus.MergeFrom(other.ChallengeChamberBonus); break; } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); }
protected override void Initialize() { base.Initialize (); int total; switch (CurrentDifficulty) { case GameDifficulty.Easy: total = 5; break; case GameDifficulty.Medium: default: total = 7; break; case GameDifficulty.Master: total = 9; break; } int[] nums = new int [total]; for (int i = 0; i < nums.Length; i++) { nums[i] = GetUniqueRandomNumber (nums); } switch (random.Next (num_games)) { case 0: current_game = new ChallengeOdds (); break; case 1: current_game = new ChallengeEvens (); break; case 2: current_game = new ChallengeTwoDigits (); break; } Challenge.Numbers = nums; Answer.Correct = current_game.Answer; }
public TextAnswerPage(Challenge challenge, bool isCompleted) { InitializeComponent(); Challenge = challenge; BindingContext = this; }
void CreateChallengeDescriptions(Challenge[] challenges) { foreach (Challenge challenge in challenges) { GameObject challengeDescription = Instantiate(challengeDescriptionPrefab) as GameObject; challengeDescription.name = challenge.Name + "Description"; if (challenge.Type.Trim() == "Travel/Tourism") challengeDescription.transform.SetParent(TravelDescriptionParentObject.transform,false); if (challenge.Type.Trim() == "Sports") challengeDescription.transform.SetParent(SportsDescriptionParentObject.transform, false); if (challenge.Type.Trim() == "Cars") challengeDescription.transform.SetParent(CarsDescriptionParentObject.transform, false); if (challenge.Type.Trim() == "Dare to be Digital") challengeDescription.transform.SetParent(DareToBeDigitalParentObject.transform, false); if (challenge.Type.Trim() == "People and Places") challengeDescription.transform.SetParent(PeopleAndPlacesDescriptionParentObject.transform, false); if (challenge.Type.Trim() == "Miscellaneous") challengeDescription.transform.SetParent(miscellaneousDescriptionObject.transform, false); if (challenge.Type.Trim() == "Animals") challengeDescription.transform.SetParent(AnimalsDescriptionParentObject.transform, false); if (challenge.Type.Trim() == "Food/Drink") challengeDescription.transform.SetParent(FoodParentDescriptionObject.transform, false); if (challenge.Type.Trim() == "Great Outdoors") challengeDescription.transform.SetParent(GreatOutdoorsDescriptionParentObject.transform, false); if (challenge.Type.Trim() == "Everyday Life") challengeDescription.transform.SetParent(EveryDayLifeDescriptionParentObject.transform, false); if (challenge.Type.Trim() == "Events") challengeDescription.transform.SetParent(eventsDescriptionObject.transform, false); GameObject titleChild = challengeDescription.transform.FindChild("Title").gameObject; Text titleText = titleChild.GetComponent<Text>(); titleText.text = challenge.Name; if (challenge.Difficulty.Trim() == "Easy") { titleText.color = colors[0]; } if (challenge.Difficulty.Trim() == "Medium") { titleText.color = colors[1]; } if (challenge.Difficulty.Trim() == "Hard") { titleText.color = colors[2]; } GameObject descriptionChild = challengeDescription.transform.FindChild("Description").gameObject; Text descriptionText = descriptionChild.GetComponent<Text>(); //DEPRICATED // descriptionText.text = challenge.Description; GameObject factChild1 = challengeDescription.transform.FindChild("Fact").gameObject; GameObject factChild2 = factChild1.transform.FindChild("scrollBox").gameObject; GameObject factChild = factChild2.transform.FindChild("Text").gameObject; Text factText = factChild.GetComponent<Text>(); String[] strings = challenge.Description.Split(new char[] { '/' }); if (strings.Length >1) { factText.text = strings[1]; } Debug.LogError("this should disable: " + factChild1.name); descriptionText.text = strings[0]; GameObject takeSelfieChild = challengeDescription.transform.FindChild("Take Selfie Button").gameObject; TakeSelfieButton buttonId = takeSelfieChild.GetComponent<TakeSelfieButton>(); buttonId.buttonId = challenge.Id; //factChild1.SetActive(false); } }
internal IChallengeValidationDetails DecodeChallengeValidation(Authorization auth, Challenge challenge) { return(AuthorizationDecoder.DecodeChallengeValidation(auth, challenge.Type, _client.Signer)); }
public static Situation loadup(){ //ideally this would be loaded from a file or something (json) Situation s = new Situation (); s.Name = "Home/Morning"; Word w; w = new Word (); w.key = "toilet"; w.langs.Add ("en", "toilet"); w.langs.Add ("zh", "卫生间"); w.langs.Add ("ja", "トイレ"); s.WordBank.Add (w.key, w); w = new Word (); w.key = "shower"; w.langs.Add ("en", "shower"); w.langs.Add ("zh", "洗澡"); w.langs.Add ("ja", "シャワー"); s.WordBank.Add (w.key, w); w = new Word (); w.key = "clothes"; w.langs.Add ("en", "clothes"); w.langs.Add ("zh", "衣服"); w.langs.Add ("ja", "服"); s.WordBank.Add (w.key, w); w = new Word (); w.key = "refrigerator"; w.langs.Add ("en", "refrigerator"); w.langs.Add ("zh", "冰箱"); w.langs.Add ("ja", "冷蔵庫"); s.WordBank.Add (w.key, w); w = new Word (); w.key = "breakfast"; w.langs.Add ("en", "breakfast"); w.langs.Add ("zh", "早餐"); w.langs.Add ("ja", "朝ごはん"); s.WordBank.Add (w.key, w); w = new Word (); w.key = "newspaper"; w.langs.Add ("en", "newspaper"); w.langs.Add ("zh", "报纸"); w.langs.Add ("ja", "新聞"); s.WordBank.Add (w.key, w); w = new Word (); w.key = "shoes"; w.langs.Add ("en", "shoes"); w.langs.Add ("zh", "鞋子"); w.langs.Add ("ja", "靴"); s.WordBank.Add (w.key, w); Challenge c; c = new Challenge (); c.Phrases.Add("en", "Tom pees in the _."); c.Phrases.Add ("zh", "汤姆在 _ 小便。"); c.Phrases.Add ("ja", "トムさんは_を使いました。"); c.Answer = s.WordBank["toilet"]; c.Animation = "pee"; s.Challenges.Add (c); c = new Challenge (); c.Phrases.Add("en", "Tom takes a _."); c.Phrases.Add("zh", "汤姆去 _。"); c.Phrases.Add("ja", "トムさんは_を浴びました。"); c.Answer = s.WordBank["shower"]; c.Animation = "shower"; s.Challenges.Add (c); c = new Challenge (); c.Phrases.Add("en", "Tom wears his _."); c.Phrases.Add("zh", "汤姆穿他的 _。"); c.Phrases.Add("ja", "トムさんは_を着ました。"); c.Answer = s.WordBank["clothes"]; c.Animation = "wear"; s.Challenges.Add (c); c = new Challenge (); c.Phrases.Add("en", "Tom opens the _."); c.Phrases.Add("zh", "汤姆打开 _。"); c.Phrases.Add("ja", "トムさんは_を開けました。"); c.Answer = s.WordBank["refrigerator"]; c.Animation = "open"; s.Challenges.Add (c); c = new Challenge (); c.Phrases.Add("en", "Tom eats a big _."); c.Phrases.Add("zh", "汤姆吃一个 _。"); c.Phrases.Add("ja", "トムさんは_を食べました。"); c.Answer = s.WordBank["breakfast"]; c.Animation = "eat"; s.Challenges.Add (c); c = new Challenge (); c.Phrases.Add("en", "Tom reads the _."); c.Phrases.Add("zh", "汤姆读 _。"); c.Phrases.Add("ja", "トムさんは_を読みました。"); c.Answer = s.WordBank["newspaper"]; c.Animation = "read"; s.Challenges.Add (c); c = new Challenge (); c.Phrases.Add("en", "Tom puts on his _."); c.Phrases.Add("zh", "汤姆穿 _。"); c.Phrases.Add("ja", "トムさんは_を履きました。"); c.Answer = s.WordBank["shoes"]; c.Animation = "putOn"; s.Challenges.Add (c); return s; }
internal Challenge AnswerChallenge(Challenge challenge) { return(Retry(() => _client.AnswerChallengeAsync(challenge.Url).Result)); }