/// <summary> /// Initializes a new instance of the <see cref="Pokeball"/> class. /// </summary> /// <param name="_pokeType">Type of the _poke.</param> /// <param name="sprite">The sprite.</param> /// <param name="position">The position.</param> /// <param name="actualCase">The actual case.</param> public Pokeball(BadgeType _pokeType, Texture2D sprite, Vector2 position, Case actualCase) : base(sprite, position, actualCase) { pokeType = _pokeType; switch (_pokeType) { case BadgeType.Boulder: pokeColor = Color.Gray; break; case BadgeType.Cascade: pokeColor = Color.Blue; break; case BadgeType.Lightning: pokeColor = Color.Yellow; break; case BadgeType.March: pokeColor = Color.Salmon; break; case BadgeType.Rainbow: pokeColor = Color.Lime; break; case BadgeType.Soul: pokeColor = Color.Magenta; break; case BadgeType.Volcano: pokeColor = Color.Orange; break; case BadgeType.Earth: pokeColor = Color.SandyBrown; break; } }
protected IActionResult ShowEvidenceInternal(BadgeType badgeType, int year, string token) { var badge = (from b in Database.Badges where b.Type == badgeType where b.Year == new DateTime(year, 1, 1) where b.EvidenceToken == token select b).SingleOrDefault(); if (badge == null) { Logger.LogDebug(LoggingEvents.Badges, "Badge of type {0} year {1} and token '{2}' not found", badgeType, year, token); return(NotFound()); } var user = (from u in Database.Donations where u.Email == badge.Email where u.Year == new DateTime(year, 1, 1) select u).FirstOrDefault(); if (user == null) { Logger.LogError(LoggingEvents.Badges, "Donation for badge email {0} not found", badge.Email); return(NotFound()); } return(View("Evidence", new BadgeEvidenceViewModel { Name = user.Name, Surname = user.Surname, Email = user.Email, BadgeType = badge.Type, Year = year, IssueTimestamp = badge.IssueTimestamp })); }
public EquipBadgeResponse EquipBadge(BadgeType type) { return(PostProtoPayload <Request, EquipBadgeResponse>(RequestType.EquipBadge, new EquipBadgeMessage() { BadgeType = type })); }
public void Badge_DisplayOptionTest() { ScryberBadgeStyle target = new ScryberBadgeStyle(); //Default Value BadgeType expected = ScryberBadgeStyle.DefaultDisplayOption; Assert.AreEqual(expected, target.DisplayOption); //Set value expected = BadgeType.WhiteOnBlack; BadgeType actual; target.DisplayOption = expected; actual = target.DisplayOption; Assert.AreEqual(expected, actual); // Change Value expected = BadgeType.BlackOnWhite; target.DisplayOption = expected; actual = target.DisplayOption; Assert.AreEqual(expected, actual); //Remove value expected = ScryberBadgeStyle.DefaultDisplayOption; target.RemoveDisplayOption(); actual = target.DisplayOption; Assert.AreEqual(expected, actual); }
public override int GetHashCode() { int hash = 1; if (BadgeType != 0) { hash ^= BadgeType.GetHashCode(); } if (BadgeRank != 0) { hash ^= BadgeRank.GetHashCode(); } hash ^= targets_.GetHashCode(); hash ^= captureReward_.GetHashCode(); if (EventBadge != false) { hash ^= EventBadge.GetHashCode(); } if (eventBadgeSettings_ != null) { hash ^= EventBadgeSettings.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public async Task LoseMostValuableBadge(Hero hero) { BadgeType mostValuableBadgeType = _rewardService.GetMostValuableBadgeType(hero); await _rewardService.DeleteBadge(mostValuableBadgeType, hero); await _context.SaveChangesAsync(); }
/// <summary> /// Processes the user for the specified badge type /// </summary> /// <param name="badgeType"></param> /// <param name="user"></param> /// <returns>True if badge was awarded</returns> public bool ProcessBadge(BadgeType badgeType, MembershipUser user) { var databaseUpdateNeeded = false; var e = new BadgeEventArgs { User = user, BadgeType = badgeType }; EventManager.Instance.FireBeforeBadgeAwarded(this, e); if (!e.Cancel) { if (_badges.ContainsKey(badgeType)) { if (!RecentlyProcessed(badgeType, user)) { databaseUpdateNeeded = true; var badgeSet = _badges[badgeType]; foreach (var badgeMapping in badgeSet) { if (!BadgeCanBeAwarded(user, badgeMapping)) { continue; } // Instantiate the badge and execute the rule var badge = GetInstance <IBadge>(badgeMapping); // Award badge? if (badge != null && badge.Rule(user)) { // Re-fetch the badge otherwise system will try and create new badges! var dbBadge = _badgeRepository.Get(badgeMapping.DbBadge.Id); if (dbBadge.AwardsPoints != null && dbBadge.AwardsPoints > 0) { var points = new MembershipUserPoints { DateAdded = DateTime.UtcNow, Points = (int)dbBadge.AwardsPoints }; user.Points.Add(points); } user.Badges.Add(dbBadge); _activityService.BadgeAwarded(badgeMapping.DbBadge, user, DateTime.UtcNow); EventManager.Instance.FireAfterBadgeAwarded(this, new BadgeEventArgs { User = user, BadgeType = badgeType }); } } } } } return(databaseUpdateNeeded); }
public bool SetBadgeOccurence(Guid userId, BadgeType type, Guid referenceId) { IQueryable <UserBadge> items = userBadgeRepository.Get(x => x.UserId == userId && x.Badge == type); UserBadge model = items.FirstOrDefault(); if (model == null) { model = new UserBadge { UserId = userId, Badge = type }; } if (model.References.Any(x => x == referenceId)) { return(false); } else { model.References.Add(referenceId); if (model.Id == Guid.Empty) { userBadgeRepository.Add(model); } else { userBadgeRepository.Update(model); } return(true); } }
public Badge(Guid userId, BadgeType type) { UserId = userId; Type = type; AwardThreshold = type == BadgeType.Beginner ? 1 : 5; }
private void OnBadgeTypeChanged(BadgeType type) { var text = string.Empty; switch (type) { case BadgeType.Circle: text = "\uf111"; break; case BadgeType.Square: text = "\uf0c8"; break; case BadgeType.Certificate: text = "\uf0a3"; break; case BadgeType.Bell: text = "\uf0f3"; break; case BadgeType.СircleThin: text = "\uf1db"; break; } BadgeShape.Text = text; }
public async Task <EquipBadgeResponse> EquipBadge(BadgeType type) { var equipBadgeRequest = new Request { RequestType = RequestType.EquipBadge, RequestMessage = new EquipBadgeMessage { BadgeType = type }.ToByteString() }; var request = await GetRequestBuilder().GetRequestEnvelope(CommonRequest.FillRequest(equipBadgeRequest, Client)).ConfigureAwait(false); Tuple <EquipBadgeResponse, CheckChallengeResponse, GetHatchedEggsResponse, GetInventoryResponse, CheckAwardedBadgesResponse, DownloadSettingsResponse, GetBuddyWalkedResponse> response = await PostProtoPayload <Request, EquipBadgeResponse, CheckChallengeResponse, GetHatchedEggsResponse, GetInventoryResponse, CheckAwardedBadgesResponse, DownloadSettingsResponse, GetBuddyWalkedResponse>(request).ConfigureAwait(false); CheckChallengeResponse checkChallengeResponse = response.Item2; CommonRequest.ProcessCheckChallengeResponse(Client, checkChallengeResponse); GetInventoryResponse getInventoryResponse = response.Item4; CommonRequest.ProcessGetInventoryResponse(Client, getInventoryResponse); DownloadSettingsResponse downloadSettingsResponse = response.Item6; CommonRequest.ProcessDownloadSettingsResponse(Client, downloadSettingsResponse); return(response.Item1); }
public async Task <EquipBadgeResponse> EquipBadge(BadgeType type) { return(await PostProtoPayload <Request, EquipBadgeResponse>(RequestType.EquipBadge, new EquipBadgeMessage() { BadgeType = type })); }
public static string ToCssClass(this BadgeType type) { string suffix = null; switch (type) { case BadgeType.DefaultGray: suffix = "default"; break; case BadgeType.PrimaryBlue: suffix = "primary"; break; case BadgeType.SuccessGreen: suffix = "success"; break; case BadgeType.WarningOrange: suffix = "warning"; break; case BadgeType.DangerRed: suffix = "danger"; break; case BadgeType.InfoCyan: suffix = "info"; break; default: return(string.Empty); } return("badge badge-" + suffix); }
public override int GetHashCode() { int hash = 1; if (BadgeType != 0) { hash ^= BadgeType.GetHashCode(); } if (Rank != 0) { hash ^= Rank.GetHashCode(); } if (StartValue != 0) { hash ^= StartValue.GetHashCode(); } if (EndValue != 0) { hash ^= EndValue.GetHashCode(); } if (CurrentValue != 0D) { hash ^= CurrentValue.GetHashCode(); } return(hash); }
public static List <BadgeType> GetList() { if (BadgeTypesList.Count == 0) { using (MySqlConnection conn = new MySqlConnection(cmstrDefualts.ConnStr)) { conn.Open(); string sql = "Select tblBadgeTypesid,tblBadgeTypesName From tblbadgetypes"; MySqlCommand cmd = new MySqlCommand(sql, conn); MySqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { int id = 0; int.TryParse(dr["tblBadgeTypesid"].ToString(), out id); string name = dr["tblBadgeTypesName"].ToString(); BadgeType myTag = new BadgeType(name, id); if (!BadgeTypesList.Contains(myTag)) { BadgeTypesList.Add(myTag); } } dr.Close(); } } return(BadgeTypesList); }
public void CssClassInitialized(Color color, BadgeType badgeType, string expectedCssClass) { _ = new Badge { Color = color, Type = badgeType }.CssClasses.Should().Be(expectedCssClass); }
public override int GetHashCode() { int hash = 1; if (BadgeType != 0) { hash ^= BadgeType.GetHashCode(); } if (Rank != 0) { hash ^= Rank.GetHashCode(); } if (StartValue != 0) { hash ^= StartValue.GetHashCode(); } if (EndValue != 0) { hash ^= EndValue.GetHashCode(); } if (CurrentValue != 0D) { hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(CurrentValue); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public async Task AddBadgeTypeAsync(string title, string description, int value, string imageUrl, string imageSmallUrl, int badgeCategoryId) { var alreadyExists = await _badgeTypesDbSet .AnyAsync(t => t.Title == title); if (alreadyExists) { throw new ValidationException(ErrorCodes.DuplicatesIntolerable, $"Badge type {title} already exists"); } var entity = new BadgeType { Title = title, Description = description, Value = value, ImageUrl = imageUrl, ImageSmallUrl = imageSmallUrl, BadgeCategoryId = badgeCategoryId }; _badgeTypesDbSet.Add(entity); await SaveChangesAsync(); }
public static string ToCssClass(this BadgeType type) { // String concatenation will be optimized at compile time const string prefix = "badge badge-"; switch (type) { case BadgeType.DefaultGray: return(prefix + "default"); case BadgeType.PrimaryBlue: return(prefix + "primary"); case BadgeType.SuccessGreen: return(prefix + "success"); case BadgeType.WarningOrange: return(prefix + "warning"); case BadgeType.DangerRed: return(prefix + "danger"); case BadgeType.InfoCyan: return(prefix + "info"); default: return(string.Empty); } }
public BadgeViewModel(BadgeType obj) { if (obj == null) { throw new ArgumentNullException("BadgeType"); } this.Model = obj; }
private async Task DataPortal_Fetch(BadgeType badgeType) { var dal = IoC.Container.Resolve <IBadgeCollectionDAL>(); var result = await dal.GetBadgesByBadgeTypeAsync(badgeType); this.LoadData(result); }
public virtual IBadgeStrategy GetBadgeStrategy(BadgeType badgeType) { if (!this.availableStrategies.ContainsKey(badgeType.Code)) { throw new ArgumentException("Badge type not supported", badgeType.Code); } return(this.availableStrategies[badgeType.Code]); }
public void SetBadgeType(BadgeType badgeType, bool show) { if (!this.m_dicBadgeType.ContainsKey(badgeType)) { Debug.LogError("字典内不存在 badgeType " + badgeType); return; } this.m_dicBadgeType.set_Item(badgeType, show); }
/// <summary> /// /// </summary> /// <param name="type"></param> /// <returns></returns> public bool QueueEquipBadgeRequest(BadgeType type) { var message = new EquipBadgeMessage { BadgeType = type }; return(Client.QueueRequest(RequestType.EquipBadge, message)); }
public Badge(string n, string d, Func <Task <bool> > cc, int pt, BadgeType tp = BadgeType.General, bool hid = false) { name = n; description = d; ConditionCheck = cc; points = pt; type = tp; hidden = hid; }
public void CssClassWellFormatted(Color color, BadgeType badgeType, string expectedCssClass) { Services.AddSingleton <NavigationManager>(new MockNavigationManager("http://localhost/")); var component = RenderComponent <BadgeLink>( ComponentParameter.CreateParameter(nameof(BadgeLink.Color), color), ComponentParameter.CreateParameter(nameof(BadgeLink.Type), badgeType)); component.Find("a").ClassName.Should().Be(expectedCssClass); }
public static async Task SendAccess(string itemName, BadgeType type, string subject, string color) { var content = new StringContent(JsonConvert.SerializeObject(new { Item = itemName, Type = type.ToString(), Subject = subject, Color = color }), Encoding.UTF8, "application/json"); if (apiKey != null) { await client.PostAsync($"https://logs-01.loggly.com/inputs/{apiKey}/tag/access/", content); } }
internal static BadgeType GetBadgeType(BadgeData badgeData) { BadgeType badgeType = BadgeType.Invalid; switch (badgeData.Type) { case "ActiveAlbumListener_Bronze": badgeType = BadgeType.BronzeAlbum; break; case "ActiveAlbumListener_Silver": badgeType = BadgeType.SilverAlbum; break; case "ActiveAlbumListener_Gold": badgeType = BadgeType.GoldAlbum; break; case "ActiveArtistListener_Bronze": badgeType = BadgeType.BronzeArtist; break; case "ActiveArtistListener_Silver": badgeType = BadgeType.SilverArtist; break; case "ActiveArtistListener_Gold": badgeType = BadgeType.GoldArtist; break; case "ActiveForumsBadge_Bronze": badgeType = BadgeType.BronzeForums; break; case "ActiveForumsBadge_Silver": badgeType = BadgeType.SilverForums; break; case "ActiveForumsBadge_Gold": badgeType = BadgeType.GoldForums; break; case "ActiveReviewBadge_Bronze": badgeType = BadgeType.BronzeReview; break; case "ActiveReviewBadge_Silver": badgeType = BadgeType.SilverReview; break; case "ActiveReviewBadge_Gold": badgeType = BadgeType.GoldReview; break; } return(badgeType); }
public int GetSeriesUnlockProgress(BadgeType type) { int retVal = 0; if (SeriesBadgeUnlockProgress.ContainsKey(type)) { retVal = SeriesBadgeUnlockProgress[type]; } return(retVal); }
public async Task DeleteBadges(int nrOfBadges, BadgeType badgeType, Hero hero) { if (!HasBadgeByType(BadgeType.TierCategory5, hero)) { IEnumerable <HeroBadge> badgesToDelete = hero.Badges.Where(b => b.Badge.Tier == badgeType).Take(nrOfBadges); _context.RemoveRange(badgesToDelete); await _context.SaveChangesAsync(); } }
public Student(string firstName, string lastName, DateTime doB, CourseType classTaking, decimal balOwed, BadgeType typeofBadge, bool hasGrad) { FirstName = firstName; LastName = lastName; DateOfBirth = doB; ClassTaking = classTaking; BalanceOwed = balOwed; TypeofBadge = typeofBadge; HasGraduated = hasGrad; }
public IValidator Get(BadgeType type) { switch (type) { case BadgeType.ThreeCompletedChallenges: case BadgeType.FiveCompletedChallenges: case BadgeType.TenCompletedChallenges: case BadgeType.TwentyCompletedChallenges: case BadgeType.FiftyCompletedChallenges: return new NCompletedChallengesBadgeValidator(new ChallengeAcceptedData(new ChallengeAcceptedDbContext())); default: throw new InvalidEnumArgumentException(); } }
public ActionResult InitiatePreview(BadgeType previewType) { OAuthTokens tokens = new OAuthTokens(); string twitterLoginCallbackUrl = new Uri(Request.Url, string.Concat("/twitter/callback?previewType=", previewType)).ToString(); OAuthTokenResponse response = OAuthUtility.GetRequestToken(ConfigurationManager.AppSettings[CUSTOMER_KEY], ConfigurationManager.AppSettings[CUSTOMER_SECRET], twitterLoginCallbackUrl); Uri twitterLoginUrl = OAuthUtility.BuildAuthorizationUri(response.Token, false); if (User.Identity.IsAuthenticated) { FormsAuthentication.SignOut(); Session.Abandon(); } return Redirect(twitterLoginUrl.ToString()); }
public ActionResult Callback(string oAuth_Token, string oAuth_Verifier, BadgeType previewType) { if (string.IsNullOrEmpty(oAuth_Token) || string.IsNullOrEmpty(oAuth_Verifier)) { return new HttpNotFoundResult("todo"); } OAuthTokenResponse tokenResponse = OAuthUtility.GetAccessToken(ConfigurationManager.AppSettings[CUSTOMER_KEY], ConfigurationManager.AppSettings[CUSTOMER_SECRET], oAuth_Token, oAuth_Verifier); using (IDocumentSession session = MvcApplication.DocumentStore.OpenSession()) { Models.TwitterAccountModel user = GetTwitterAccountModel(session, tokenResponse.UserId.ToString()); if (user != null) { user.BadgeType = previewType; session.SaveChanges(); } else { user = new Models.TwitterAccountModel() { TwitterUserId = tokenResponse.UserId.ToString(), UserName = tokenResponse.ScreenName, TwitterAccessKey = tokenResponse.Token, TwitterAccessSecret = tokenResponse.TokenSecret, BadgeType = previewType }; OAuthTokens tokens = GetTwitterUserTokens(user); user.TwitterOriginalProfilePictureURL = GetBiggerProfilePictureURL(TwitterUser.Show(tokenResponse.UserId).ResponseObject.ProfileImageLocation); session.Store(user); session.SaveChanges(); } FormsAuthentication.SetAuthCookie(tokenResponse.UserId.ToString(), false); } return Redirect(new Uri(Request.Url, string.Concat("/twitter/preview?previewType=", previewType)).ToString()); }
public Badge(BadgeType badgeType, Texture2D sprite, Vector2 position, Case actualCase) : base(sprite, position, actualCase) { this.badgeType = badgeType; }
public FileContentResult PreviewImage(BadgeType previewType) { Models.TwitterAccountModel user = null; using (IDocumentSession session = MvcApplication.DocumentStore.OpenSession()) { user = GetTwitterAccountModel(session, User.Identity.Name); } if (user == null) return null; // TODO: ViewBag.UserName = user.UserName; TwitterUser twitterUser = TwitterUser.Show( GetTwitterUserTokens(user), decimal.Parse(user.TwitterUserId)).ResponseObject; string originalProfileImagePath = GetReasonablySmallProfilePictureURL(twitterUser.ProfileImageLocation); FileContentResult result = null; switch (previewType) { case BadgeType.BasicBlack: result = GetBasicBlackPreviewImageResult(originalProfileImagePath); break; case BadgeType.BasicRed: result = GetBasicRedPreviewImageResult(originalProfileImagePath); break; case BadgeType.ItsTime: result = new FileContentResult(System.IO.File.ReadAllBytes(Server.MapPath("~/Images/restore-full.jpg")), "image/jpg"); break; } Session[TWITTER_PREVIEW_IMAGE] = result.FileContents; return result; }
public static Badge GetBadgeByType(BadgeType type) { switch (type) { case BadgeType.Player: return Player; case BadgeType.Critic: return Critic; case BadgeType.Creator: return Contributor; case BadgeType.Riddler: return Riddler; case BadgeType.Supporter: return Supporter; case BadgeType.Popular: return PopularPuzzle; case BadgeType.Notable: return NotablePuzzle; case BadgeType.Famous: return FamousPuzzle; case BadgeType.Master: return Master; case BadgeType.Dominator: return Dominator; case BadgeType.Leader: return Leader; default: throw new ArgumentOutOfRangeException("type"); } }
public async Task<EquipBadgeResponse> EquipBadge(BadgeType type) { return await PostProtoPayload<Request, EquipBadgeResponse>(RequestType.EquipBadge, new EquipBadgeMessage() { BadgeType = type }); }
public bool SyncBadgeForUser(int userID, BadgeType badgeType, int reachedValue) { throw new NotImplementedException(); }
static extern int navigator_set_badge(BadgeType badge);
public ActionResult Preview(BadgeType previewType = BadgeType.BasicBlack) { if (User.Identity.IsAuthenticated) { using (IDocumentSession session = MvcApplication.DocumentStore.OpenSession()) { Models.TwitterAccountModel model = GetTwitterAccountModel(session, User.Identity.Name); ViewBag.UserName = model.UserName; TwitterUser twitterUser = TwitterUser.Show(GetTwitterUserTokens(model), decimal.Parse(model.TwitterUserId)).ResponseObject; string originalProfileImagePath = GetBiggerProfilePictureURL(twitterUser.ProfileImageLocation); ViewBag.OriginalProfileImageLocation = originalProfileImagePath; ViewBag.ImagePreviewType = previewType; } } return View(); }