public PropertyTheftWindow( Player victim, Player thief, int actionId ) { AssetsOfVictim = new ObservableCollection<Card>(); this.victim = victim; this.thief = thief; this.type = (TheftType)actionId; this.showMonopoliesOnly = (TheftType.Dealbreaker == this.type); InitializeComponent(); // Update the label for the victim's assets. this.VictimAssetsLabel.Content = victim.Name + "'s Assets"; // Create a property hierarchy for the victim's properties. This view will be used regardless of the type of theft. propertyViewVictim = new PropertyHierarchyView(victim, showMonopoliesOnly); Grid.SetRow(propertyViewVictim, 1); Grid.SetColumn(propertyViewVictim, 0); WindowGrid.Children.Add(propertyViewVictim); propertyViewVictim.SelectedItemChanged += new RoutedPropertyChangedEventHandler<object>(SelectedItemChanged); // If this is a ForcedDeal, create a tree view of the thief's properties. if (TheftType.ForcedDeal == type) { propertyViewThief = new PropertyHierarchyView(thief, false, true); Grid.SetRow(propertyViewThief, 1); Grid.SetColumn(propertyViewThief, 1); WindowGrid.Children.Add(propertyViewThief); propertyViewThief.SelectedItemChanged += new RoutedPropertyChangedEventHandler<object>(SelectedItemChanged); } // Otherwise, display only the victim's properties. else { // Center the victim's properties in the window. Grid.SetColumnSpan(propertyViewVictim, 2); Grid.SetColumnSpan(VictimAssetsLabel, 2); // Hide the thief assets label. ThiefAssetsLabel.Visibility = System.Windows.Visibility.Hidden; } // Update the window title to reflect the player receiving rent. this.Title = "Stealing Property from " + victim.Name; // Set the data context of the window. this.DataContext = this; }
public RentWindow( Player rentee, string renterName, int rentAmount, bool rentDoubled ) { Payment = new ObservableCollection<Card>(); Assets = new ObservableCollection<Card>(); InitializeComponent(); amountOwed = rentAmount * ((rentDoubled) ? (2) : (1)); // Update the window to display the amount owed. AmountOwedLabel.Content = AmountOwedLabel.Content.ToString() + rentAmount + ((rentDoubled) ? (" x 2") : ("")); // Add all the rentee's cards in play to the Assets listview. foreach ( List<Card> cardList in rentee.CardsInPlay ) { foreach ( Card card in cardList ) { Assets.Add(card); } } // Update the window title to reflect the player receiving rent. this.Title = "Rental Payment to " + renterName; // Set the data context of the window. this.DataContext = this; this.ContentRendered += ( sender, args ) => { // If the user has a "Just Say No", give him the option to use it. bool hasNo = rentee.CardsInHand.Any(card => 2 == card.ActionID); if ( hasNo ) { if ( MessageBoxResult.Yes == MessageBox.Show("Would you like to use your \"Just Say No\" card to reject " + renterName + "'s rent request?", "Rent Rejection", MessageBoxButton.YesNo) ) { // Mark the result of the dialog as false and close it. this.dialogResult = false; this.CloseWindow = true; } } }; }
// Return a list of all the card groups in the player's CardsInPlay that are monopolies. public static List<List<Card>> FindMonopolies( Player player ) { List<List<Card>> monopolies = new List<List<Card>>(); // Iterate through the card lists. Always skip the first one, since it is reserved for money. for ( int i = 1; i < player.CardsInPlay.Count; ++i ) { if ( ClientUtilities.IsCardListMonopoly(player.CardsInPlay[i]) ) { monopolies.Add(player.CardsInPlay[i]); } } return monopolies; }
public void InitGame(IRace selectedPlayerRace) { var mapLoader = new MapLoader(); mapLoader.Load(selectedPlayerRace); this.Player = mapLoader.Player; this.Friend = mapLoader.Friend; this.Friend.AddFrined(this.Player); this.Enemies = mapLoader.Enemies; this.ItemsToCollect = mapLoader.ItemToCollect; this.Maze = mapLoader.Maze; Hud.Instance.PopulateElements(this.Player, this.Friend); this.Bullets = new List<Bullet>(); }
public MoneyListView(Player player) { InitializeComponent(); this.DataContext = player; }
private void SelectPlayer_Click( object sender, RoutedEventArgs e ) { SelectedPlayer = (Player)PlayerListBox.SelectedItem; this.DialogResult = true; this.Close(); }
public PropertyHierarchyView( Player player, bool onlyMonopoliesSelectable, bool isThiefAssets = false ) { // Instantiate member variables. this.player = player; this.showMonopoliesOnly = onlyMonopoliesSelectable; List<List<Card>> cardGroups; if ( isThiefAssets ) { cardGroups = new List<List<Card>>(player.CardsInPlay.Skip(1)); } else { cardGroups = onlyMonopoliesSelectable ? (ClientUtilities.FindMonopolies(player)) : new List<List<Card>>(player.CardsInPlay.Skip(1).Where(cardList => !ClientUtilities.IsCardListMonopoly(cardList))); } // Populate the tree with cards from the player's cards in play. foreach ( List<Card> cardList in cardGroups) { // Each parent item will represent a potential monopoly, TreeViewItem potentialMonopoly = new TreeViewItem(); potentialMonopoly.Tag = cardList; potentialMonopoly.Header = ClientUtilities.GetCardListColor(cardList).ToString() + " Group"; this.Items.Add(potentialMonopoly); // Display the properties from the group under the group label. foreach ( Card property in cardList ) { TreeViewItem propertyItem = new TreeViewItem(); propertyItem.Header = property.Name; propertyItem.Tag = property; propertyItem.IsEnabled = !onlyMonopoliesSelectable; potentialMonopoly.Items.Add(propertyItem); } this.ExpandSubtree(potentialMonopoly); } }