private void ExecuteAdd(object obj) { if (_selected != null) { if (!Chosen.Contains(_selected)) { String query = "Select distinct Läsperiod from Läsperioder Where Kurskod LIKE '%" + _selected.Kurskod.Trim() + "%';"; foreach (string v in PerformDatabaseStringAccess(query)) { StudyPeriods.Add(v); } if (StudyPeriods.Count == 1) { Chosen.Add(_selected.returnNewCourse(StudyPeriods.First())); Messenger.Default.Send <ObservableCollection <Course> >(Chosen); MessageQueue.Enqueue(_selected.ToString() + " tillagd i specialiseringen"); StudyPeriods.Clear(); } else { OpenDialog = true; } } else { MessageBox.Show("The course has already been chosen for your future specialization"); } } }
public async Task <IActionResult> Otclick(string id) { ViewBag.Ban1 = db.Banners.FirstOrDefault(p => p.NameBanner == "banner1"); ViewBag.Ban2 = db.Banners.FirstOrDefault(p => p.NameBanner == "banner2"); ViewBag.Ban3 = db.Banners.FirstOrDefault(p => p.NameBanner == "banner3"); ViewBag.Ban4 = db.Banners.FirstOrDefault(p => p.NameBanner == "banner4"); ViewBag.Ban5 = db.Banners.FirstOrDefault(p => p.NameBanner == "banner5"); var user = await _userManager.GetUserAsync(User); if (user != null) { var userservice = await db.UserServices.FirstOrDefaultAsync(p => p.UserId == id); if (userservice != null) { Chosen chosen = new Chosen { UserId = user.Id, UserServiceId = userservice.Id }; if (chosen != null) { await db.Chosens.AddAsync(chosen); await db.SaveChangesAsync(); return(RedirectToAction("Favorite", "CustomManage")); } } } return(View()); }
private void DealwithStraight(kindsOfCombination combination, int CardPlayer) { for (int i = 0; i < Hand.Count; i++) { if (Chosen.Count == 0) { if (Hand[i].rank > (Rank)combination.index) { Chosen.Add(Hand[i]); } } else if (Hand[i].rank == Chosen.Last().rank + 1 && Hand[i].rank < (Rank)15) { Chosen.Add(Hand[i]); } else if (Hand[i].rank > Chosen.Last().rank + 1) { Chosen.Clear(); } if (Chosen.Count == combination.assist) { break; } } if (Chosen.Count != combination.assist) { Chosen.Clear(); } if (Chosen.Count == 0 && combination.assist >= 7) //use bomb { DealwithBomb(combination, CardPlayer); } }
/* * public void DiscardCard(Card card) * { * Hand.Remove(card); * if (HasWon && OnPlayerHasWon != null) * OnPlayerHasWon(this, new PlayerEventArgs { Player = this, State = PlayerState.Winner }); * if (OnCardDiscarded != null) * OnCardDiscarded(this, new CardEventArgs { Card = card }); * } */ public void play(kindsOfCombination k) { kindsOfCombination result = validCards(); if (result == null) { return; } if (!result.biggerThan(k)) { return; } for (int i = 0; i < Chosen.Count; i++) { Hand.Remove(Chosen[i]); } CardEventArgs args = new CardEventArgs(); args.Card = new Card((Suit)1, (Rank)3); args.Cards = (Cards)Chosen.Clone(); args.index = Index; args.CurrentCombination = result; OnCardPlayed(this, args); Chosen.Clear(); if (HasWon && OnPlayerHasWon != null) { OnPlayerHasWon(this, new PlayerEventArgs { Player = this, State = PlayerState.Winner }); } }
protected virtual void OnChosen() { if (Chosen != null) { Chosen.Invoke(); } }
private void ChooseStudyPeriod(string obj) { Chosen.Add(_selected.returnNewCourse(obj)); Messenger.Default.Send <ObservableCollection <Course> >(Chosen); OpenDialog = false; MessageQueue.Enqueue(_selected.ToString() + " tillagd i specialiseringen"); StudyPeriods.Clear(); }
private void DealwithSingle(kindsOfCombination combination, int CardPlayer) { foreach (Card c in Hand) { if (c.rank > (Rank)combination.index) { Chosen.Add(c); break; } } }
public void ChooseCard(Card card) { if (Chosen.Contains(card)) { Chosen.Remove(card); } else { Chosen.Add(card); } }
public void pass(int CardsPlayer) { if (Index == CardsPlayer) { return; } Chosen.Clear(); this._state = PlayerState.Pass; OnCardPlayed(this, new CardEventArgs { Cards = new Cards() }); }
public ExploreInstancesPageViewModel() { Chosen.Subscribe((vm) => { SignInAsync(vm); }); Close.Subscribe(() => Root.Navigation.PopModalAsync()); Reload.Subscribe(() => FetchInstances()); FetchInstances(); }
private void DealwithPair(kindsOfCombination combination, int CardPlayer) { for (int i = 0; i < Hand.Count - 1; i++) { if (Hand[i].rank == Hand[i + 1].rank && Hand[i].rank > (Rank)combination.index) { Chosen.Add(Hand[i]); Chosen.Add(Hand[i + 1]); break; } } }
private void DealwithThree(kindsOfCombination combination, int CardPlayer) { for (int i = 0; i < Hand.Count - 2; i++) { if (Hand[i].rank == Hand[i + 1].rank && Hand[i].rank == Hand[i + 2].rank && Hand[i].rank > (Rank)combination.index) { Chosen.Add(Hand[i]); Chosen.Add(Hand[i + 1]); Chosen.Add(Hand[i + 2]); break; } } if (combination.assist == 1) { for (int i = 0; i < Hand.Count; i++) { if (!Chosen.Contains(Hand[i])) { Chosen.Add(Hand[i]); break; } } if (Chosen.Count != 4) { Chosen.Clear(); } } else if (combination.assist == 2) { for (int i = 0; i < Hand.Count - 1; i++) { if (!Chosen.Contains(Hand[i]) && !Chosen.Contains(Hand[i + 1])) { Chosen.Add(Hand[i]); Chosen.Add(Hand[i + 1]); break; } } if (Chosen.Count != 5) { Chosen.Clear(); } } if (Chosen.Count == 0 && combination.index >= 10) //use bomb { DealwithBomb(combination, CardPlayer); } }
/* * public void PerformDiscard(Deck deck) * { * switch (Skill) * { * case ComputerSkillLevel.Easy: * int discardIndex = _random.Next(Hand.Count); * DiscardCard(Hand[discardIndex]); * break; * default: * DiscardWorstCard(); * break; * } * } */ private void decision(kindsOfCombination combination, int CardPlayer) { if (Index == CardPlayer) { combination = null; } if (combination == null) //free to play { Chosen.Add(Hand[0]); } else { if (combination.kind == Kind.Single) { DealwithSingle(combination, CardPlayer); } else if (combination.kind == Kind.Pair) { DealwithPair(combination, CardPlayer); } else if (combination.kind == Kind.Three) { DealwithThree(combination, CardPlayer); } else if (combination.kind == Kind.Bomb) { DealwithBomb(combination, CardPlayer); } else if (combination.kind == Kind.Straight) { DealwithStraight(combination, CardPlayer); } else if (combination.kind == Kind.StraightPair) { DealwithStraightPair(combination, CardPlayer); } } if (Chosen.Count > 0) { play(null); } else { pass(CardPlayer); } }
private void DealwithStraightPair(kindsOfCombination combination, int CardPlayer) { bool chooseFirst = true; for (int i = 0; i < Hand.Count - 3; i++) { if (Chosen.Count == 0) { if (Hand[i].rank > (Rank)combination.index) { Chosen.Add(Hand[i]); } } else if (chooseFirst && Hand[i].rank == Chosen.Last().rank&& Hand[i].rank < (Rank)15) { chooseFirst = false; Chosen.Add(Hand[i]); } else if (chooseFirst && Hand[i].rank > Chosen.Last().rank&& Hand[i].rank < (Rank)15) { Chosen.Clear(); } else if (!chooseFirst && Hand[i].rank == Chosen.Last().rank + 1 && Hand[i].rank < (Rank)15) { chooseFirst = true; Chosen.Add(Hand[i]); } else if (!chooseFirst && Hand[i].rank > Chosen.Last().rank + 1) { Chosen.Clear(); } if (Chosen.Count == combination.assist) { break; } } if (Chosen.Count != combination.assist * 2) { Chosen.Clear(); } if (Chosen.Count == 0 && combination.assist >= 4) //use bomb { DealwithBomb(combination, CardPlayer); } }
private void DealwithBomb(kindsOfCombination combination, int CardPlayer) { for (int i = 0; i < Hand.Count - 3; i++) { if (Hand[i].rank == Hand[i + 1].rank && Hand[i].rank == Hand[i + 2].rank && Hand[i].rank == Hand[i + 3].rank && Hand[i].rank > (Rank)combination.index) { Chosen.Add(Hand[i]); Chosen.Add(Hand[i + 1]); Chosen.Add(Hand[i + 2]); Chosen.Add(Hand[i + 3]); break; } } if (Chosen.Count != 4 && Hand.Count >= 2 && Hand[Hand.Count - 1].rank == Rank.Joker && Hand[Hand.Count - 2].rank == Rank.joker) { Chosen.Add(Hand[Hand.Count - 1]); Chosen.Add(Hand[Hand.Count - 2]); } }
private void AssignSeat(IContext ctx, Context context, Seating seating, Guest guest1, Guest guest2, Count count) { int rightSeat = seating.RightSeatId; int seatId = seating.Id; int cnt = count.Value; var newSeating = new Seating(cnt, seatId, false, rightSeat, seating.RightGuestName, rightSeat + 1, guest2.Name); ctx.Insert(newSeating); var path = new Path(cnt, rightSeat + 1, guest2.Name); ctx.Insert(path); var chosen = new Chosen(seatId, guest2.Name, guest1.Hobby); ctx.Insert(chosen); count.Increment(); ctx.Update(count); context.SetState(ContextState.MakePath); ctx.Update(context); }
private void HandleInput(IMenuItemInfo[] options, ref int selected) { var key = Console.ReadKey(true).Key; switch (key) { case ConsoleKey.UpArrow: if (selected <= 0) { selected = options.GetUpperBound(0); } else { selected--; } break; case ConsoleKey.DownArrow: if (selected >= options.GetUpperBound(0)) { selected = 0; } else { selected++; } break; case ConsoleKey.Backspace: case ConsoleKey.Escape: Back?.Invoke(this, EventArgs.Empty); selected = -1; break; case ConsoleKey.Enter: Chosen?.Invoke(this, new MenuItemInfoEventArgs(options[selected])); selected = -1; break; } }
private void RemoveFromCourseList(Course action) { NumCourses = Chosen.Count() + ""; }
public kindsOfCombination validCards() { if (Chosen.Count == 0) { return(null); } if (Chosen.Count == 1) //single card { return(new kindsOfCombination(Kind.Single, 0, (int)Chosen[0].rank)); } Chosen.Sort(); if (Chosen.Count == 2) { if (Chosen[0].rank == (Rank)16 && Chosen[1].rank == (Rank)17) { return(new kindsOfCombination(Kind.Bomb, 0, (int)Chosen[0].rank)); //a kind } if (Chosen[0].rank == Chosen[1].rank) { return(new kindsOfCombination(Kind.Pair, 0, (int)Chosen[0].rank)); //pair } return(null); } if (Chosen.Count == 3) { if (Chosen[0].rank == Chosen[1].rank && Chosen[0].rank == Chosen[2].rank) { return(new kindsOfCombination(Kind.Three, 0, (int)Chosen[0].rank)); //3 a kind } return(null); } if (Chosen.Count == 4) { if (Chosen[0].rank == Chosen[1].rank && Chosen[0].rank == Chosen[2].rank && Chosen[0].rank == Chosen[3].rank) { return(new kindsOfCombination(Kind.Bomb, 0, (int)Chosen[0].rank)); //a kind } if (Chosen[0].rank == Chosen[1].rank && Chosen[0].rank == Chosen[2].rank) { return(new kindsOfCombination(Kind.Three, 1, (int)Chosen[0].rank)); //3 a kind } if (Chosen[1].rank == Chosen[2].rank && Chosen[1].rank == Chosen[3].rank) { return(new kindsOfCombination(Kind.Three, 1, (int)Chosen[1].rank)); //3 a kind } return(null); } if (Chosen.Count == 5) { if (Chosen[0].rank == Chosen[1].rank && Chosen[0].rank == Chosen[2].rank && Chosen[3].rank == Chosen[4].rank) { return(new kindsOfCombination(Kind.Three, 2, (int)Chosen[0].rank)); //full house } if (Chosen[0].rank == Chosen[1].rank && Chosen[2].rank == Chosen[3].rank && Chosen[2].rank == Chosen[4].rank) { return(new kindsOfCombination(Kind.Three, 2, (int)Chosen[2].rank)); //full house } } if (Chosen.Count >= 6 && Chosen.Count % 2 == 0) { bool straightPair = true; if (Chosen[0].rank != Chosen[1].rank) { straightPair = false; } for (int i = 2; i < Chosen.Count % 2; i += 2) { if (Chosen[i].rank != (Chosen[i - 1].rank + 1) || Chosen[i].rank != Chosen[i + 1].rank) { straightPair = false; break; } } if (straightPair && Chosen[Chosen.Count - 1].rank <= (Rank)14) { return(new kindsOfCombination(Kind.StraightPair, Chosen.Count % 2, (int)Chosen[0].rank)); //StraightPair } } bool straight = true; for (int i = 1; i < Chosen.Count; i++) { if (Chosen[i].rank != Chosen[i - 1].rank + 1) { straight = false; break; } } if (straight && Chosen[Chosen.Count - 1].rank <= (Rank)14) { return(new kindsOfCombination(Kind.Straight, Chosen.Count, (int)Chosen[0].rank)); //Straight } return(null); }
private void UpdateCourseList(ObservableCollection <Course> action) { NumCourses = Chosen.Count().ToString(); }
public Cards GetChosenCards() { return(Chosen.Clone() as Cards); }
private EventHandler InitializeButtonClickHandler(string choice) => (sender, args) => Chosen?.Invoke(null, choice);
internal void OnChosen() { Chosen?.Invoke(this); }
protected virtual void OnChosen(MenuItem i_MenuItem) { Chosen?.Invoke(i_MenuItem); }