protected void TryCaptureOrRecharge(Portal portal, AchievementModel achievement) { if (portal.Model.Faction == Faction.None) { GameProvider.CapturePortal(portal, SelfFaction); achievement.Capture(portal.Model); if (ShouldSound) { SoundManager.GetInstance().PortalCapturedSound.Play(); } } else if (portal.Model.Faction == SelfFaction) { if (portal.Energy < 100 && rechargeTimer.IsTimeout()) { portal.RechargeEnergy(10); rechargeTimer.Start(); achievement.Recharge(); if (ShouldSound) { SoundManager.GetInstance().PortalRechargedSound.Play(); } } } }
private void dealWithAchievement() { List <AchievementTrendTable> list_AchievementTrends = new List <AchievementTrendTable>(); foreach (int i in list_FriendId) { // TimeSpan span=24*nowTime.Subtract(DateTime.Parse(c.Time)).Days+nowTime.Subtract(DateTime.Parse(c.Time)).Hours; foreach (AchievementTrendTable trends in db.AchievementTrends) { int days = nowTime.Subtract(DateTime.Parse(trends.Time)).Duration().Days; int hour = nowTime.Subtract(DateTime.Parse(trends.Time)).Duration().Hours; DateTime d = DateTime.Parse(trends.Time); int hours = 24 * nowTime.Subtract(DateTime.Parse(trends.Time)).Duration().Days + nowTime.Subtract(DateTime.Parse(trends.Time)).Duration().Hours; // if (trends.UserId == i && hours <= 200) list_AchievementTrends.Add(trends); } } foreach (AchievementTrendTable trend in db.AchievementTrends) { // UserTable user = db.Users.First(c => c.Id == trend.UserId); AchievementModel achievement = new AchievementModel() { UserId = trend.UserId, Name = trend.Name, ImageUri = trend.ImageUri, Describe = trend.Achievement, Time = trend.Time, Category = trend.Category }; list_AchievementModel.Add(achievement); } }
public async Task <IActionResult> CreateAchievement(AchievementModel model, ApplicationDbContext context) { context.AchievementModel.Add(model); await context.SaveChangesAsync(); return(null); }
public void FillNotify(AchievementModel fillInfo) { iconImage.sprite = achievementIcon; titleText.text = fillInfo.Title; descriptionText.text = fillInfo.Description; pointsText.text = fillInfo.Points.ToString(); reachPointsText.text = fillInfo.ReachPoints.ToString(); }
public Burst Init(Faction faction, Vector2 position, AchievementModel ownerAchievement, float velocity) { Faction = faction; OwnerAchievement = ownerAchievement; transform.position = transform.position.Set2D(position); Velocity = velocity; return(this); }
public MedalHelper(AchievementModel achievement) { DecideMedalType(MedalRow.AchievementType.Liberator, achievement.Liberator, 20, 40, 60, 80, 100); DecideMedalType(MedalRow.AchievementType.Connector, achievement.Connector, 20, 40, 60, 80, 100); DecideMedalType(MedalRow.AchievementType.MindController, achievement.MindController, 10, 15, 20, 30, 50); DecideMedalType(MedalRow.AchievementType.Illuminator, achievement.Illuminator, 100, 200, 400, 800, 1600); DecideMedalType(MedalRow.AchievementType.Explorer, achievement.Explorer, 30, 34, 38, 42, 43); DecideMedalType(MedalRow.AchievementType.Pioneer, achievement.Pioneer, 20, 25, 30, 40, 43); DecideMedalType(MedalRow.AchievementType.Hacker, achievement.Hacker, 100, 150, 300, 450, 800); }
public static AchievementViewModel ToAchievementViewModel(this AchievementModel model) { return(new AchievementViewModel { Id = model.Id, Title = model.Title, Description = model.Description, GeneralTimeSpent = model.GeneralTimeSpent }); }
public AchievementDataGridModel(AchievementModel model) { Id = model.Id; TypeName = model.Type.Description; Location = model.Location.Description; RecordedBy = model.RecordedBy.GetDisplayName(true); CreatedDate = model.CreatedDate; Comments = model.Comments; Points = model.Points; }
public void AddPlayer(string name, int score, string desc) { AchievementModel model = new AchievementModel { Name = name, Score = score, Description = desc }; _context.Achievements.Add(model); _context.SaveChanges(); MessageBox.Show("Added!"); }
public void Save(AchievementModel achievement) { if (achievement.Id != 0) { _db.InsertOrReplaceWithChildren(achievement); } else { _db.InsertWithChildren(achievement); } }
private void DoGameOver() { isGameing = false; stopWatchTextBlockProxy.StopStopWatch(); AchievementModel achievement = new AchievementModel(moveCount, (int)stopWatchTextBlockProxy.TotalSeconds()); App.AchievementDao.TrySaveAchievement(achievement); DoClear(); }
public async Task StoreAchievement(AchievementModel achievement) { if (await connection.FindAsync <AchievementModel>((int)achievement.Id) != null) { Console.WriteLine("Attemped to store an existing achievement with id: {0}", achievement.Id); } else { await connection.InsertAsync(achievement); } }
public static AchievementViewModel ToAchievementViewModel(this AchievementModel model) { return(new AchievementViewModel { Id = model.Id, AchievementNotes = model.AchievementNotes.ToAchievementNoteViewModels(), Title = model.Title, GeneralDescription = model.GeneralDescription, GeneralTimeSpent = model.GeneralTimeSpent, ImageContent = model.ImageContent }); }
public AchievementGroupModel(XmlNode node, Database db) : base(node, db) { m_pAchievementList = new List <AchievementModel>(); XmlNodeList nodelist = node.SelectNodes(@"achievement"); foreach (XmlNode tmp in nodelist) { AchievementModel m = new AchievementModel(tmp, db); m_pAchievementList.Add(m); } }
public void Show(AchievementScriptable achievement, bool showDescription = false) { AchievementModel fillInfo = achievement.Data; if (!showDescription) { fillInfo.Description = string.Empty; } achievementIcon = achievement.Icon; Initialize(); AchievementSystem.ShowNotification(this, fillInfo); }
private async Task CreateAchievement() { var model = new AchievementModel { Title = Title, Description = Description, UserId = Settings.CurrentUserId }; App.AchievementRepository.Value.Save(model); MessagingCenter.Send(this, ConstantsHelper.AchievementCreated); await NavigateBack(); }
public AchievementSummaryModel(AchievementModel model) { if (model.Id.HasValue) { Id = model.Id.Value; } TypeName = model.Type.Description; Location = model.Location.Description; RecordedBy = model.CreatedBy.GetDisplayName(NameFormat.FullNameAbbreviated); CreatedDate = model.CreatedDate; Comments = model.Comments; Points = model.Points; }
public async Task <IActionResult> Create([FromBody] CreateAchievementModel model) { return(await ProcessAsync(async() => { var user = await UserService.GetUserByPrincipal(User); var request = new AchievementModel(model, user.Id); await _achievementService.Create(request); return Ok("Achievement created."); }, Permissions.Behaviour.Achievements.EditAchievements)); }
public async Task GenerateAchievementsTestData() { AchievementModel firstTen = new AchievementModel { Id = (int)Achievement.FirstTen, TimeAchieved = DateTime.Now, HasBeenAchieved = true }; await StoreAchievement(firstTen); AchievementModel changedGoal = new AchievementModel { Id = (int)Achievement.SetHarderGoal, TimeAchieved = DateTime.Now.AddDays(-1), HasBeenAchieved = true }; await StoreAchievement(changedGoal); }
public async Task <IActionResult> Post([FromBody] AchievementModel model) { try { await _context.Achievements.AddAsync(model); await _context.SaveChangesAsync(); return(Ok(model)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public void ClaimAchievement(AchievementModel achievement, Action <List <AchievementRewardModel> > onAchievementClaimed = null) { if (!achievement.isClaimed) { //print("Claiming achievement with hash: " + achievement.GetHashCode()); ach.MarkAchievementAsClaimed(achievement.ID); if (onAchievementClaimed != null) { onAchievementClaimed(achievement.listReward); Mio.Utils.AnalyticsHelper.Instance.LogClaimedAchievement(achievement.title); } MessageBus.Annouce(msgAchievementDataChanged); } }
public AdminViewModel() { var tmpPl = new PlayerModel(); var tmpAc = new AchievementModel(); var tmpLe = new LeagueModel(); var tmpEv = new EventModel(); EventsList = new List <EventModel>(); PlayerList = new List <PlayerModel>(); AchievementList = new List <AchievementModel>(); LeagueList = new List <LeagueModel>(); PlayerList.Add(tmpPl); AchievementList.Add(tmpAc); LeagueList.Add(tmpLe); EventsList.Add(tmpEv); }
public async Task <IActionResult> CreateAchievementDay([FromBody] CreateDayAchievementDto requestDto) { if (requestDto.Date.Date > DateTime.Now.Date) { return(Failed(Common.ErrorCode.UserData, "只能上传今日及过去的数据")); } if (requestDto.DayGoal <= 0) { return(Failed(Common.ErrorCode.UserData, "目标值必须大于0")); } CreateMonthAchievementDto request = new CreateMonthAchievementDto { Date = requestDto.Date }; //校验月份是否存在 var achievementMonthModel = new AchievementMonthBiz().GetAchievementMonthGoalModel(request, UserID).Result; if (achievementMonthModel == null) { return(Failed(Common.ErrorCode.UserData, "此月份的业绩目标不存在")); } //校验当天业绩数据是否上传过 var achievementModel = await new AchievementBiz().GetAchievementModel(requestDto.Date, achievementMonthModel.GoalGuid); if (achievementModel != null) { return(Failed(Common.ErrorCode.UserData, "当天的业绩目标已存在")); } var model = new AchievementModel(); model.AchievementGuid = Guid.NewGuid().ToString("N"); model.GoalGuid = achievementMonthModel.GoalGuid; model.AchievementDate = requestDto.Date; model.TodayGoal = requestDto.DayGoal; model.TodayComplete = requestDto.DayCompleteGoal; model.CreationDate = DateTime.Now; model.LastUpdatedDate = DateTime.Now; model.LastUpdatedBy = UserID; model.CreatedBy = UserID; model.OrgGuid = string.Empty; var result = await new AchievementBiz().InsertAsync(model); if (result) { MQNotice(); } return(result ? Success() : Failed(ErrorCode.DataBaseError, "添加日业绩目标失败")); }
public async Task <IActionResult> EditAchievement(AchievementModel model, ApplicationDbContext context) { var original = context.AchievementModel.Find(model.Id); if (model.Points != original.Points && model.Points != 0) { original.Points = model.Points; } if (model.Description != original.Description && model.Description != null) { original.Description = model.Description; } context.AchievementModel.Update(original); await context.SaveChangesAsync(); return(null); }
public Boolean GetAward() { if (Progress < Target) { return(false); } Int32 delta = Award; AchievementModel m = m_pModel.GetLastAchievement; m.SetDone(); PocketModule pocket = m_pDb.GetPocketModel(); pocket.Point.UpdatePoint(delta); return(true); }
/// <summary> /// 排序,确保宅王成就放在第一位 /// </summary> /// <returns></returns> List <AchievementModel> ReSort() { List <AchievementModel> achievements = new List <AchievementModel>(); achievements = FindAchievementsByName(); for (int i = 0; i < achievements.Count; i++) { ///这个有点问题,TODO if (achievements[i].Name.StartsWith("宅")) { AchievementModel aTemp = new AchievementModel(); aTemp = achievements[i]; achievements.Remove(achievements[i]); achievements.Insert(0, aTemp); } } return(achievements); }
/// <summary> /// Checks if a user has completed an achievement and stores the result in the database /// </summary> /// <param name="model">AchievementModel which holds the achievement data</param> public void checkIfAchievementCompleted(AchievementModel model) { switch (model.Name) { case "10 Doge": if (DataBaseAccess.GetCoinAmount("dogecoin", App.UserID) >= 10) { model.IsCompleted = true; DataBaseAccess.CompleteAchievement(App.UserID, "10 Doge"); } break; case "10 litecoin": if (DataBaseAccess.GetCoinAmount("litecoin", App.UserID) >= 10) { model.IsCompleted = true; DataBaseAccess.CompleteAchievement(App.UserID, "10 litecoin"); } break; case "10 bit": if (DataBaseAccess.GetCoinAmount("bitcoin", App.UserID) >= 10) { model.IsCompleted = true; DataBaseAccess.CompleteAchievement(App.UserID, "10 bit"); } break; case "10k CLUB": if (DataBaseAccess.GetEuroAmount() >= 10000) { model.IsCompleted = true; DataBaseAccess.CompleteAchievement(App.UserID, "10k CLUB"); } break; } }
public async Task <ActionResult> Put(Guid id, [FromBody] AchievementModel model) { AchievementModel original = await _context.Achievements.AsNoTracking().FirstOrDefaultAsync(x => x.Id == id); if (original == null) { return(NotFound($"Model with Id {id} not found.")); } try { _context.Achievements.Update(model); await _context.SaveChangesAsync(); return(Ok(model)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public async Task <IActionResult> Delete(Guid id) { AchievementModel model = await _context.Achievements.FirstOrDefaultAsync(x => x.Id == id); if (model == null) { return(NotFound($"Model with Id {id} not found.")); } try { _context.Achievements.Remove(model); await _context.SaveChangesAsync(); return(Ok(model)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
/// <summary> /// 单日医院业绩占比 /// </summary> /// <returns></returns> public async Task <(List <GetDayWeChatDetailResponseDto>, string date)> GetDayWeChatAchievementAsync() { var achievementDate = string.Empty; List <GetDayWeChatDetailResponseDto> result = null; var sql = $@"SELECT c.hos_name AS HospitalName, c.hospital_guid AS HospitalGuid, a.today_complete AS TotalMoney FROM t_achievement_month_goal b inner JOIN t_achievement a ON b.goal_guid = a.goal_guid AND a.`enable` = 1 and a.achievement_date = @AchievementDate Right JOIN t_doctor_hospital c ON c.hospital_guid = b.hospital_guid WHERE c.is_hospital=1 and c.`enable`=1 GROUP BY c.hospital_guid, c.hos_name, a.today_complete" ; using (var conn = MySqlHelper.GetConnection()) { //查找最大的时间 var maxResult = await conn.QueryFirstOrDefaultAsync <AchievementModel>("SELECT * from t_achievement WHERE `enable`=1 ORDER BY achievement_date desc LIMIT 0,1"); //if (maxResult == null) //{ maxResult = new AchievementModel { AchievementDate = DateTime.Now.AddDays(-1) }; //} result = new List <GetDayWeChatDetailResponseDto>(); result = (await conn.QueryAsync <GetDayWeChatDetailResponseDto>(sql, new { AchievementDate = maxResult.AchievementDate.ToString("yyyy-MM-dd") }))?.ToList(); achievementDate = maxResult.AchievementDate.ToString("yyyy-MM-dd"); return(result, achievementDate); } }