//================================================================================================================= // Created buttons to select different player views during the game private void createPlayerButtons() { Canvas g = (Canvas)parent.Children[1]; List <PlayerState> ps = game.getPlayers(); int startLeft = 1200; int startTop = 20; int numP = ps.Count; for (int i = 0; i < 7; i++) { Button P1 = new Button(); if (i < ps.Count) { P1.Content = ps[i].getName(); } else { P1.Content = "P" + (i + 1); } P1.Name = "P" + (i + 1); P1.Width = 50; P1.Height = 30; P1.Click += new RoutedEventHandler(playerButton_Click); Canvas.SetTop(P1, startTop); Canvas.SetLeft(P1, startLeft); startTop += 30; if (i >= numP) { P1.Visibility = Visibility.Hidden; } g.Children.Add(P1); } }
public Score(GameState g) { finalScore = new int[g.getPlayers().Count,7]; for(int i = 0; i < g.getPlayers().Count; i++){ if (g.players[i].getPlayedCards().Count < 10) { g.players[i].setScore(0, 0); g.players[i].setScore(0, 1); g.players[i].setScore(0, 2); g.players[i].setScore(0, 3); g.players[i].setScore(0, 4); g.players[i].setScore(0, 5); g.players[i].setScore(0, 6); } else { g.players[i].setScore(militaryScore(g.getPlayerNum(i)), 0); g.players[i].setScore(treasuryScore(g.getPlayerNum(i)), 1); g.players[i].setScore(WonderScore(g.getPlayerNum(i)), 2); g.players[i].setScore(civScore(g.getPlayerNum(i)), 3); g.players[i].setScore(sciScore(g.getPlayerNum(i)), 4); g.players[i].setScore(comScore(g.getPlayerNum(i)), 5); g.players[i].setScore(0, 6); //g.players[i].setScore(,7); } } }
//private int[] coinTransactions; //private Logger _logger; //Constructor private ResourceManager(GameState g) { gameState = g; baseResources = new Dictionary<string,List<int>>(); SResources = new Dictionary<string, List<ResourceCard>>(); TempResources = new Dictionary<string, List<int>>(); //_logger = Logger.GetInstance(this, g); //_logger.SetLogging(true); //_logger.LogPlayer(1); List<PlayerState> players = gameState.getPlayers(); for (int i = 0; i < players.Count; i++) { List<int> boardResources = new List<int>(); List<int> empty = new List<int>(); List<ResourceCard> rclist = new List<ResourceCard>(); for (int j = 0; j < 7; j++) { boardResources.Add(players[i].getBoard().getResources()[j]); empty.Add(0); } baseResources.Add(players[i].getName(), boardResources); SResources.Add(players[i].getName(), rclist); TempResources.Add(players[i].getName(), empty); } }
//CoinTransaction public void coinExchange(PlayerState p) { gameState.getLeftPlayer(p).updateCoins(coinTransactions[0]); gameState.getRightPlayer(p).updateCoins(coinTransactions[1]); gameState.getPlayers()[p.getSeatNumber()].updateCoins(0 - coinTransactions[0] - coinTransactions[1]); System.Console.WriteLine("Coins Exchanged! Left: " + coinTransactions[0] + " Right: " + coinTransactions[1] + " You: " + (0 - coinTransactions[0] - coinTransactions[1])); }
//Resources resources; //private Logger _logger; //Constructor public ResourceManager(GameState g) { gameState = g; //resources = GetCombinedResources(); baseResources = new Dictionary <string, List <int> >(); SResources = new Dictionary <string, List <ResourceCard> >(); TempResources = new Dictionary <string, List <int> >(); ComCards = new Dictionary <string, List <CommerceCard> >(); //_logger = Logger.GetInstance(this, g); //_logger.SetLogging(true); //_logger.LogPlayer(1); List <PlayerState> players = gameState.getPlayers(); for (int i = 0; i < players.Count; i++) { List <int> boardResources = new List <int>(); List <int> empty = new List <int>(); List <ResourceCard> rclist = new List <ResourceCard>(); List <CommerceCard> cclist = new List <CommerceCard>(); for (int j = 0; j < 7; j++) { boardResources.Add(players[i].getBoard().getResources()[j]); empty.Add(0); } baseResources.Add(players[i].getName(), boardResources); SResources.Add(players[i].getName(), rclist); ComCards.Add(players[i].getName(), cclist); TempResources.Add(players[i].getName(), empty); } }
private void startGameButton_Click(object sender, RoutedEventArgs e) { parent.Children.Remove(parent.Children[1]); //hostCanvas List <TextBox> tbList = new List <TextBox>(7); List <ComboBox> cbList = new List <ComboBox>(7); List <Player> players = new List <Player>(); input = this.tb.Text; UIElementCollection c = waitingCanvas.Children; //System.Console.WriteLine("\n\n\n"); for (int i = 0; i < c.Count; i++) { UIElement el = c[i]; if (c[i].GetType() == typeof(System.Windows.Controls.ComboBox)) { cbList.Add((ComboBox)c[i]); } if (c[i].GetType() == typeof(System.Windows.Controls.TextBox)) { tbList.Add((TextBox)c[i]); } } for (int i = 0; i < tbList.Count; i++) { ComboBox cb = null; TextBox tb = tbList[i]; if (tb.Text.Length != 0 && tb.Text != " ") { cb = this.getComboBox(cbList, tb.Name.Substring(4, 1)); players.Add(new Player(i, cb.SelectedIndex)); } } if (players.Count < 3) { System.Windows.MessageBox.Show("C'mon you need at least three players!"); WaitingToStartCanvasHost wait = new WaitingToStartCanvasHost(parent); } else { StartGame start = new StartGame(players); //TODO NETWORKING need a text field input of how many players are connected //Just read the text fields?...Accumulate GameState game = start.getGame(); List <PlayerState> ps = game.getPlayers(); PlayerGameBoard play = new PlayerGameBoard(parent, ps[0], game);//this creates the canvas that shows. //TODO need to make child 0 player and child 1 current view. } }
private void addPlayers(Grid g) { for (int i = 0; i < game.getPlayers().Count; i++) { Label l = new Label(); PlayerState player = game.getPlayers()[i]; List <int> scores = player.getScores(game); l.FontSize = 24; l.Content = player.getName();//"P" + (i+1);//TODO change so name shows AI geoffry Grid.SetColumn(l, (i + 2)); Grid.SetRow(l, 1); g.Children.Add(l); int sum = 0; for (int j = 0; j < 7; j++) { sum += scores[j]; Label v = new Label(); v.FontSize = 24; v.Content = scores[j]; Grid.SetRow(v, (j + 2)); Grid.SetColumn(v, (i + 2)); g.Children.Add(v); } Label s = new Label(); s.FontSize = 24; s.Content = sum; Grid.SetRow(s, (9)); Grid.SetColumn(s, (i + 2)); g.Children.Add(s); } }
//private Logger _logger; private ResourceManager(GameState g) { gameState = g; hashtable = new Dictionary<string,List<int>>(); //_logger = Logger.GetInstance(this, g); //_logger.SetLogging(true); //_logger.LogPlayer(1); List<PlayerState> players = gameState.getPlayers(); for (int i = 0; i < players.Count; i++) { List<int> list = new List<int>(); for (int j = 0; j < 7; j++) list.Add(0); hashtable.Add(players[i].getName(), list); } }
private Logger(Object o, GameState g) { _class = o; _gameState = g; players = _gameState.getPlayers(); }
public void LogPlayer(int index) { player = _gameState.getPlayers()[index]; _playerName = player.getName(); }