public Board(Player[] plist, Game game) { playerList = plist; first = null; last = null; theGame = game; }
public MainWindow(PreGameScreen pregs) { InitializeComponent(); this.Visibility = Visibility.Hidden; TheGame = new Game(this); dice.MouseLeftButtonUp += Button_Click; rollButton.IsEnabled = false; pgs = pregs; }
public void pawnToSpawn(Pawn p , Game g) { bool placed = false; for (int i = 0; i < _spawns.Length; i++) { if (!placed) { if (_spawns[i].pawn == null) { _spawns[i].pawn = p; p.currentField = _spawns[i]; placed = true; p.onSpawn = true; g.sendFieldCode(_spawns[i]); } } } }
public void move(int steps , Game g) { //The actual move bool direction = true; Field temp = currentField; //TESTCODE currentField.pawn = null; if (_onSpawn) { //_currentField = _currentField.nextF; _onSpawn = false; } for (int i = 1; i <= steps; i++) { if (_currentField.nextF == null) { direction = false; } if (direction) { if (_currentField.switchF != null) { if (_currentField.switchF.player == this._player) { _currentField = _currentField.switchF; _player.pawnsInGoal++; } else { //check if last move & is filled *not a switch* if (i == steps) { if (_currentField.nextF.pawn != null) { _currentField.nextF.pawn.player.pawnToSpawn(_currentField.nextF.pawn , g); _currentField = _currentField.nextF; _currentField.pawn = this; } else { _currentField = _currentField.nextF; _currentField.pawn = this; } } else { //normal move _currentField = _currentField.nextF; } } } else { //check if last move & is filled *no switch* if (i == steps) { if (_currentField.nextF.pawn != null) { _currentField.nextF.pawn.player.pawnToSpawn(_currentField.nextF.pawn, g); _currentField = _currentField.nextF; _currentField.pawn = this; } else { _currentField = _currentField.nextF; _currentField.pawn = this; } } else { //normal move _currentField = _currentField.nextF; } } } else { //check if last move & is filled *going backwards* if (i == steps) { if (_currentField.previousF.pawn != null) { _currentField.previousF.pawn.player.pawnToSpawn(_currentField.previousF.pawn , g); _currentField = _currentField.previousF; _currentField.pawn = this; } else { _currentField = _currentField.previousF; _currentField.pawn = this; } } else { //normal move _currentField = _currentField.previousF; } if (_currentField.switchF != null) { if (_currentField.switchF.player == _player) { _player.pawnsInGoal--; } } } // end if else //Drawing step by step if (direction) { if (_currentField.pawn == null) { _currentField.pawn = this; } if (_currentField.previousF.pawn == this) { _currentField.previousF.pawn = null; g.sendFieldCode(_currentField.previousF); } } else { if (_currentField.pawn == null) { _currentField.pawn = this; } if (_currentField.nextF.pawn == this) { _currentField.nextF.pawn = null; g.sendFieldCode(_currentField.nextF); } if (_currentField.switchF != null) { if (_currentField.switchF.pawn != null) { if (_currentField.switchF.pawn == this) { _currentField.switchF.pawn = null; g.sendFieldCode(_currentField.switchF); } } } } //no clue why, but wont work without V. maybe it delays something g.colorSpawns(); //refresh if (temp != currentField) { //Does not draw steps individually g.sendFieldCode(currentField); } }//endfor g.colorSpawns(); }