public void RevealSecretCard(int creatureId, string cardId) { if (!Hands.ContainsKey(creatureId) && creatureId != IntAllPlayersId) { return; } if (creatureId == IntAllPlayersId) { bool haveRevealedAnything = false; foreach (StreamlootsHand hand in Hands.Values) { if (hand.RevealSecretCard(cardId)) { haveRevealedAnything = true; } } if (haveRevealedAnything) { SendCardCommand("Reveal Secret Cards"); } } else { StreamlootsHand hand = Hands[creatureId]; if (hand.RevealSecretCard(cardId)) { SendCardCommand("Reveal Secret Cards"); } } }
public void PlaySelectedCard(int creatureId, Creature creature) { if (!Hands.ContainsKey(creatureId)) { return; } StreamlootsHand hand = Hands[creatureId]; if (!hand.IsShown) { hand.IsShown = true; } if (hand.SelectedCard == null) { SelectFirstAvailableCard(hand); UpdateLastInteraction(creatureId); StateHasChanged(); return; } UpdateLastInteraction(creatureId); hand.PlaySelectedCard(creature); SendCardCommand("Play Cards"); hand.SelectedCardsHaveBeenPlayed(); }
private void SelectCard(int creatureId, CardDirection direction) { if (!Hands.ContainsKey(creatureId)) { return; } StreamlootsHand hand = Hands[creatureId]; if (hand.Cards.Count == 0) { return; } if (!hand.IsShown) { hand.IsShown = true; } UpdateLastInteraction(creatureId); int selectedCardIndex = hand.GetSelectedCardIndex(); if (selectedCardIndex == -1) { hand.SelectedCard = null; StreamlootsCard firstCard; if (direction == CardDirection.Next) { firstCard = hand.Cards.First(); SelectFirstAvailableCard(hand); } else { firstCard = hand.Cards.Last(); SelectLastAvailableCard(hand); } if (hand.SelectedCard == null) // Only secret cards in the hand. { hand.SelectedCard = firstCard; } } else { if (direction == CardDirection.Next) { selectedCardIndex = GetNextCardIndex(hand, selectedCardIndex); } else { selectedCardIndex = SelectPreviousCardIndex(hand, selectedCardIndex); } hand.SelectedCard = hand.Cards[selectedCardIndex]; } StateHasChanged(); }
private static void SelectLastAvailableCard(StreamlootsHand hand) { for (int i = hand.Cards.Count - 1; i >= 0; i--) { StreamlootsCard card = hand.Cards[i]; if (!card.IsSecret) { hand.SelectedCard = card; break; } } }
private static int SelectPreviousCardIndex(StreamlootsHand hand, int selectedCardIndex) { if (selectedCardIndex > 0) { selectedCardIndex--; } else { selectedCardIndex = hand.Count - 1; } return(selectedCardIndex); }
private static int GetNextCardIndex(StreamlootsHand hand, int selectedCardIndex) { if (selectedCardIndex < hand.Count - 1) { selectedCardIndex++; } else { selectedCardIndex = 0; } return(selectedCardIndex); }
public void AddCard(int creatureId, StreamlootsCard card) { if (!Hands.TryGetValue(creatureId, out StreamlootsHand existingHand)) { existingHand = new StreamlootsHand(); existingHand.CharacterId = creatureId; existingHand.HueShift = GetHueShift(creatureId); Hands.Add(creatureId, existingHand); } existingHand.SelectedCard = null; existingHand.AddCard(card); ShowHand(creatureId); StateHasChanged(); }
public void PlaySelectedCard(int creatureId) { if (!Hands.ContainsKey(creatureId)) { return; } StreamlootsHand hand = Hands[creatureId]; if (hand.SelectedCard == null) { return; } hand.PlaySelectedCard(); SendCardCommand("Play Cards"); hand.SelectedCardsHaveBeenPlayed(); }
public void SelectPreviousCard(int creatureId) { if (!Hands.ContainsKey(creatureId)) { return; } StreamlootsHand hand = Hands[creatureId]; if (hand.Cards.Count == 0) { return; } int selectedCardIndex = hand.GetSelectedCardIndex(); if (selectedCardIndex == -1) { hand.SelectedCard = null; for (int i = hand.Cards.Count - 1; i >= 0; i--) { StreamlootsCard card = hand.Cards[i]; if (!card.IsSecret) { hand.SelectedCard = card; break; } } if (hand.SelectedCard == null) { hand.SelectedCard = hand.Cards[hand.Cards.Count - 1]; } } else { if (selectedCardIndex > 0) { selectedCardIndex--; } else { selectedCardIndex = hand.Count - 1; } hand.SelectedCard = hand.Cards[selectedCardIndex]; } StateHasChanged(); }
public void SelectNextCard(int creatureId) { if (!Hands.ContainsKey(creatureId)) { return; } StreamlootsHand hand = Hands[creatureId]; if (hand.Cards.Count == 0) { return; } int selectedCardIndex = hand.GetSelectedCardIndex(); if (selectedCardIndex == -1) { hand.SelectedCard = null; foreach (StreamlootsCard card in hand.Cards) { if (!card.IsSecret) { hand.SelectedCard = card; break; } } if (hand.SelectedCard == null) { hand.SelectedCard = hand.Cards[0]; } } else { if (selectedCardIndex < hand.Count - 1) { selectedCardIndex++; } else { selectedCardIndex = 0; } hand.SelectedCard = hand.Cards[selectedCardIndex]; } StateHasChanged(); }