//refresh the entire page public async void RoundRefreshPage() //REFRESH After Round { if (_viewModel.battleInstance.ListCharacters.Count <= 0) { _viewModel.battleInstance.EndGame(); var data = new ScoreDetailViewModel(_viewModel.battleInstance.score); Debug.WriteLine("here is experience sent to page" + data.Data.ExperienceGainedTotal); Debug.WriteLine("here is the turns sent to page" + data.Data.Turn); await Navigation.PushModalAsync(new EndGamePage(data)); } //clear battlepage ClearBattlePage(); // reload map SetBackground(); //Updated Message OutputMonster.Text = _viewModel.checkMonsterMessage(); OutputCharacter.Text = _viewModel.checkCharacterMessage(); //new 6 monster rewspawn _viewModel.refreshMonster(); //reload current players in DatasetCharacter populateGrid(); //load new monsters insertMonster(); insertGrid(); //calls for ew loading of monster turns _viewModel.battleInstance.LoadTurnOrder(); _viewModel.battleInstance.numberMonsterDead = 0; _viewModel.battleInstance.checkTurns(); //Update Rest of UI RoundNum.Text = _viewModel.getRound(); Debug.WriteLine("Round " + _viewModel.getRound()); }
public ActionResult ScoreJudgeViewFormPartial(int?ScoreId) { if (ScoreId != null) { var item = db.Scores.FirstOrDefault(i => i.Id == ScoreId); var schedule = db.Schedules.FirstOrDefault(i => i.Id == item.ScheduleId); item.Schedule = schedule; var model = new ScoreDetailViewModel(); model.Score = item; model.ScoreDetails = item.ScoreDetail.ToList(); //这里需要EventCriterias与scoredetail leftjoin,暂时先只列出scoredetail //var criterias = db.EventCriterias.Where(c => c.EventId == schedule.EventId); //foreach (EventCriteria criteria in criterias) //{ // ScoreDetail detail = new ScoreDetail(); // detail.EventCriteriaId = criteria.Id; // detail.EventCriteria = criteria; // model.ScoreDetails.Add(detail); //} return(PartialView("_ScoreJudgeViewFormPartial", model ?? new ScoreDetailViewModel())); } return(PartialView("_ScoreJudgeViewFormPartial", new ScoreDetailViewModel())); }
//-------------AUTOBATTLE--------------------------------- //If player clicks auto battle private async void AutoBattle_Clicked(object sender, EventArgs e) { if (GlobalVariables.auto_battle_reset == true) { _viewModel.resetAutoBattleView(); } else if (_viewModel == BattleViewModel.Instance) { _viewModel.resetAutoBattleView(); } _viewModel = BattleViewModel.AutoInstance; _viewModel.LoadDataCommand.Execute(null); await Task.Delay(5000); string result = await _viewModel.FightClickedAutoAsync(); if (result == "endgame") { var data = new ScoreDetailViewModel(_viewModel.battleInstance.score); await Navigation.PushModalAsync(new EndGamePage(data)); } if (GlobalVariables.auto_battle_reset == false) { GlobalVariables.auto_battle_reset = true; } }
private ScoreDetailViewModel GetNewScoreDetailViewModel(int ScheduleId, string SetName) { var model = new ScoreDetailViewModel(); //在属性里加了默认值,这里就不需要了 //model.Score = new Score(); //model.ScoreDetails = new List<ScoreDetail>(); var schedule = db.Schedules.Find(ScheduleId); model.Score.ScheduleId = ScheduleId; model.Score.Schedule = schedule; var judgeStaffid = User.Identity.Name; var judge = db.Judges.Where(j => j.StaffId == judgeStaffid).FirstOrDefault(); model.Score.JudgeId = judge.Id; model.Score.Judge = judge; model.SetName = SetName; var criterias = db.EventCriterias.Where(c => c.EventId == schedule.EventId);; if (!string.IsNullOrEmpty(SetName)) { criterias = criterias.Where(c => c.SetName == SetName); } foreach (EventCriteria criteria in criterias) { ScoreDetail detail = new ScoreDetail(); detail.EventCriteriaId = criteria.Id; detail.EventCriteria = criteria; detail.Note = criteria.Note; model.ScoreDetails.Add(detail); } return(model); }
public ActionResult ScoreJudgeEditFormPartial(int?ScheduleId, string SetName) { if (ScheduleId != null) { if (string.IsNullOrEmpty(SetName)) { var schedule = db.Schedules.Find(ScheduleId); ScoreDetailViewModel model = new ScoreDetailViewModel(); if (schedule.Event.MultiScoreDetailSet) { var setNameList = db.EventCriterias.Where(c => c.EventId == schedule.EventId).GroupBy(g => g.SetName).Select(s => s.Key); ViewBag.setNameList = setNameList; model = GetNewScoreDetailViewModel(ScheduleId.Value, schedule.Event.EventCriterias.FirstOrDefault().SetName); } else { model = GetNewScoreDetailViewModel(ScheduleId.Value, ""); } return(PartialView("_ScoreJudgeEditFormPartial", model ?? new ScoreDetailViewModel())); } else { var schedule = db.Schedules.Find(ScheduleId); var setNameList = db.EventCriterias.Where(c => c.EventId == schedule.EventId).GroupBy(g => g.SetName).Select(s => s.Key); ViewBag.setNameList = setNameList; ScoreDetailViewModel model = GetNewScoreDetailViewModel(ScheduleId.Value, SetName); return(PartialView("_ScoreJudgeEditFormPartial", model ?? new ScoreDetailViewModel())); } } return(PartialView("_ScoreJudgeEditFormPartial", new ScoreDetailViewModel())); }
public ScoreDetailPage(ScoreDetailViewModel viewModel) { InitializeComponent(); // Set the data binding for the page BindingContext = _viewModel = viewModel; }
// The constructor takes a View Model public ScoreDetailPage(ScoreDetailViewModel viewModel) { InitializeComponent(); Data = viewModel.Data; //Establish Binding Context BindingContext = _viewModel = viewModel; }
public void ViewModel_ScoreViewModel_Instantiate_Should_Pass() { MockForms.Init(); var Actual = new ScoreDetailViewModel(); Assert.AreEqual(null, Actual.Title, TestContext.CurrentContext.Test.Name); }
// Score Detail View model initialized public ScoreDetailPage() { InitializeComponent(); var data = new Score(); _viewModel = new ScoreDetailViewModel(data); BindingContext = _viewModel; }
public ActionResult ScoreJudgeEditFormPartial(ScoreDetailViewModel item) { if (ModelState.IsValid) { var judgeStaffid = User.Identity.Name; var judge = db.Judges.Where(j => j.StaffId == judgeStaffid).FirstOrDefault(); var schedule = db.Schedules.Find(item.Score.ScheduleId); if (db.Scores.Where(s => s.JudgeId == judge.Id && s.ScheduleId == item.Score.ScheduleId).Count() == 0) { item.Score.JudgeId = judge.Id; item.Score.JudgeTime = DateTime.Now; item.Score.ModifyTime = DateTime.Now; item.Score.Mark = item.ScoreDetails.Sum(s => s.Mark); int timelimit = Convert.ToInt32(schedule.Event.TimeLimit.TotalSeconds); int min = item.Score.TimeConsume_minute.Value; int sec = item.Score.TimeConsume_second.Value; if (schedule.Event.HasTimeScore) { double timescore = Math.Floor((double)(timelimit - 60 * min - sec) / 30) * 0.5; if (timescore > 5) { timescore = 5; } if (timescore < 0) { timescore = 0; } item.Score.Mark += timescore; } if (db.Scores.Where(s => s.ScheduleId == item.Score.ScheduleId).Count() >= 1) //如果对应的赛程已经有一个以上的分数,那么再加上当前的分数,就表示有2个以上的裁判打分了,就把赛程设置为完成。 { schedule.Status = SchedulStatus.Complete; } if (item.Score.Mark < 0) { item.Score.Mark = 0; } db.Scores.Add(item.Score); db.SaveChanges(); foreach (var detail in item.ScoreDetails) { detail.ScoreId = item.Score.Id; db.ScoreDetails.Add(detail); } db.SaveChanges(); return(RedirectToAction("Index")); } else { ViewBag.Error = "请勿重复提交"; return(PartialView("_ScoreJudgeEditFormPartial", GetNewScoreDetailViewModel(item.Score.ScheduleId, ""))); } } ViewBag.Error = ModelState.Values; return(PartialView("_ScoreJudgeEditFormPartial", GetNewScoreDetailViewModel(item.Score.ScheduleId, ""))); }
public DeleteScorePage(ScoreDetailViewModel viewModel) { // Save off the item Data = viewModel.Data; InitializeComponent(); // Set the data binding for the page BindingContext = _viewModel = viewModel; }
// Fancy version of the score display after a battle public ScoreResults(ScoreDetailViewModel viewModel) { InitializeComponent(); // Bind the data for the score, characters at death, monsters killed, and items dropped BindingContext = _viewModel = viewModel; CharacterList.ItemsSource = _viewModel.Data.CharacterList; MonsterList.ItemsSource = _viewModel.Data.MonsterList; ItemList.ItemsSource = _viewModel.Data.ItemList; ScoreList.ItemsSource = _viewModel.Data.BattleText; }
//constructor public EditScorePage(ScoreDetailViewModel viewModel) { // Save off the item Data = viewModel.Data; viewModel.Title = "Edit " + viewModel.Title; InitializeComponent(); // Set the data binding for the page BindingContext = _viewModel = viewModel; }
public ScoreDetailPage() { InitializeComponent(); var data = new Score { Name = "Score name", ScoreTotal = 0 }; _viewModel = new ScoreDetailViewModel(data); BindingContext = _viewModel; }
//___________________________________________________________ public EndRoundPage() //end roung page { InitializeComponent(); var data = new Score { Name = "Score name", ScoreTotal = 0 }; _viewModel = new ScoreDetailViewModel(data); BindingContext = _viewModel; }
public void ViewModel_ScoreViewModel_Instantiate_With_Data_Should_Pass() { MockForms.Init(); var myData = DefaultModels.ScoreDefault(); var value = "hi"; myData.Name = value; var Actual = new ScoreDetailViewModel(myData); Assert.AreEqual(value, Actual.Title, TestContext.CurrentContext.Test.Name); }
public ScoreDetailPage() { InitializeComponent(); var data = new Score { Id = Guid.NewGuid().ToString(), Name = "Score Name", ScoreTotal = 0 }; _viewModel = new ScoreDetailViewModel(data); BindingContext = _viewModel; }
// Initializing page public ScoreDetailPage() { InitializeComponent(); // Default var data = new Score { Name = "Score name", ScoreTotal = 0 }; _viewModel = new ScoreDetailViewModel(data); BindingContext = _viewModel; setBindingsForLists(); }
public void ViewModel_ScoreViewModel_GetData_With_Data_Should_Pass() { MockForms.Init(); var myData = DefaultModels.ScoreDefault(); var value = "hi"; myData.Name = value; var myViewModel = new ScoreDetailViewModel(myData); var Actual = myViewModel.Data; var Expected = myData; Assert.AreEqual(Expected.Name, Actual.Name, TestContext.CurrentContext.Test.Name); }
//---------------sets scores from battle------------------------------- public EndGamePage(ScoreDetailViewModel viewModel) { Data = new Score(); Data = viewModel.Data; Data.Id = Guid.NewGuid().ToString(); InitializeComponent(); //Binders to the VM BindingContext = _viewModel = viewModel; BindingContext = _viewModel; Data.ScoreTotal = _viewModel.Data.ExperienceGainedTotal; Data.GameDate = _viewModel.Data.GameDate; // Set to be now by default. Data.AutoBattle = _viewModel.Data.AutoBattle; //assume user battle Data.ItemsDroppedList = _viewModel.Data.ItemsDroppedList; Data.MonstersKilledList = _viewModel.Data.MonstersKilledList; Data.ExperienceGainedTotal = _viewModel.Data.ExperienceGainedTotal; Data.Round = _viewModel.Data.Round; Data.Turn = _viewModel.Data.Turn; Data.CharacterAtDeathList = _viewModel.Data.CharacterAtDeathList; }
public ScoreDetailPage() { InitializeComponent(); Data = new Score { Name = "Player name", Id = Guid.NewGuid().ToString(), FinalScore = 0, Round = 1, Date = DateTime.Now, TotalXP = 10, Turns = 10, Auto = true, }; _viewModel = new ScoreDetailViewModel(Data); BindingContext = _viewModel; }
// Initialize with data from viewModel public ScoreDetailPage(ScoreDetailViewModel viewModel) { InitializeComponent(); BindingContext = _viewModel = viewModel; foreach (var name in _viewModel.Data.CharacterAtDeathList.Split(',')) { characterAtDeath.Add(name); } foreach (var name in _viewModel.Data.MonstersKilledList.Split(',')) { monstersDead.Add(name); } foreach (var name in _viewModel.Data.ItemsDroppedList.Split(',')) { itemsDropped.Add(name); } }
//____________________SELECTED ITEMS_______________________________________________________ //Fight button click public async void OnFight_Clicked(object sender, SelectedItemChangedEventArgs args) { message = _viewModel.FightClicked(); if (message == "EndGame") { _viewModel.battleInstance.EndGame(); var data = new ScoreDetailViewModel(_viewModel.battleInstance.score); await Navigation.PushModalAsync(new EndGamePage(data)); } else if (message == "EndRound") //finish round { var data = new ScoreDetailViewModel(_viewModel.battleInstance.score); await Navigation.PushModalAsync(new EndRoundPage(data)); //or send to items page return; } else if (message == "reload") //reload { reloadEntities(); } OutputCharacter.Text = _viewModel.checkCharacterMessage(); //check if monster or character message appeared OutputMonster.Text = _viewModel.checkMonsterMessage(); string checker = _viewModel.entityCheck(); if (checker == "EndGame") //endgame case { var data = new ScoreDetailViewModel(_viewModel.battleInstance.score); await Navigation.PushModalAsync(new EndGamePage(data)); } else if (checker == "refresh") //reload round { await Navigation.PushModalAsync(new ItemDropPage(_viewModel.Pool)); RoundRefreshPage(); } }
//if no view model provided, creates a new score to display and creates a new view model public ScoreDetailPage() { InitializeComponent(); var data = new Score { Name = "Score name", ScoreTotal = 0, Id = Guid.NewGuid().ToString(), GameDate = DateTime.Now, AutoBattle = false, TurnNumber = 1, MonsterSlainNumber = 0, ExperienceGainedTotal = 0, CharacterAtDeathList = "Characters dead", MonstersKilledList = "Monsters killed", ItemsDroppedList = "Items dropped" }; _viewModel = new ScoreDetailViewModel(data); BindingContext = _viewModel; }
public ScoreDetailPage(ScoreDetailViewModel viewModel) { InitializeComponent(); BindingContext = _viewModel = viewModel; }