private void AntiblockCardSelected() { ListBoxItems.Show(); ButtonUseCard.Show(); ButtonDiscardCard.Show(); PlayerSet myPlayer = Game.Players.Where(player => player.Name == Game.Player.Name).First(); if (myPlayer.Blocks.HasValue) { if (Game.Player.SelectedCard.BlockType.Value.HasFlag(BlockType.Cart)) { if (myPlayer.Blocks.Value.HasFlag(BlockType.Cart)) { ListBoxItems.Items.Add(BlockType.Cart); } } if (Game.Player.SelectedCard.BlockType.Value.HasFlag(BlockType.Lantern)) { if (myPlayer.Blocks.Value.HasFlag(BlockType.Lantern)) { ListBoxItems.Items.Add(BlockType.Lantern); } } if (Game.Player.SelectedCard.BlockType.Value.HasFlag(BlockType.Pickaxe)) { if (myPlayer.Blocks.Value.HasFlag(BlockType.Pickaxe)) { ListBoxItems.Items.Add(BlockType.Pickaxe); } } } }
private void ButtonUseCard_Click(object sender, EventArgs e) { if (Game.Player.SelectedCard.Type == CardType.Block) { if (ListBoxItems.SelectedItem != null) { if (((PlayerSet)ListBoxItems.SelectedItem).Blocks.HasValue) { ((PlayerSet)ListBoxItems.SelectedItem).Blocks = ((PlayerSet)ListBoxItems.SelectedItem).Blocks | Game.Player.SelectedCard.BlockType; } else { ((PlayerSet)ListBoxItems.SelectedItem).Blocks = Game.Player.SelectedCard.BlockType; } EndTurn(); } } if (Game.Player.SelectedCard.Type == CardType.AntiBlock) { if (ListBoxItems.SelectedItem != null) { PlayerSet blockedPlayer = Game.Players.Where(player => player.Name == Game.Player.Name).First(); blockedPlayer.Blocks = blockedPlayer.Blocks ^ (BlockType)ListBoxItems.SelectedItem; EndTurn(); } } }
public static void AssignRandomCard(string playerName) { PlayerSet player = Players.Find(playerName); CardSet[] cards = Cards.Where(card => card.Owner == "Deck").ToArray(); cards[RandNumGen.Next(0, cards.Count() - 1)].Owner = playerName; SqlWorker.SaveData(); }
private static PlayerSet CratePlayer(string name) { PlayerSet deck = new PlayerSet(); deck.Name = name; deck.IsTurn = false; deck.IsSabateur = false; deck.Score = 0; return(deck); }
public bool IsTurn() { if (Connection.State == System.Data.ConnectionState.Closed) { Connection.Open(); PlayerSet curPlayer = db.PlayerSet.Find(Game.Player.Name); if (curPlayer != null && curPlayer.IsTurn == true) { Connection.Close(); Game.Player.IsTurn = true; return(true); } else { Connection.Close(); return(false); } } else { return(false); } }