public MoveList(Game game) { var moves = game.GameActions.OfType<OccupyGameAction>(); Moves = moves.Select(x => new MoveItem(x.Move, x.Player)).ToList(); MoveCount = Moves.Count; StartPlayer = game.StartPlayer; }
protected GameAction(Game state, IPlayer player) { if (state == null) throw new ArgumentException("state cannot be null.", "state"); if (player == null) throw new ArgumentException("player cannot be null.", "player"); Game = state; Player = player; }
public GameViewModel() { Game = new Game(new HumanPlayer("Player 1"), new HumanPlayer("Player 2")); Player1Name = Game.Player1.Name; Player2Name = Game.Player2.Name; Game.PropertyChanged += GameOnPropertyChanged; GameBoardViewModel = new GameBoardViewModel(this); var t = new System.Timers.Timer(1000); t.Elapsed += (sender, args) => { }; t.Start(); }
public void Reset(IPlayer player1, IPlayer player2) { GameBoardViewModel.Dispose(); Game.PropertyChanged -= GameOnPropertyChanged; if(Game != null) Game.Dispose(); Game = new Game(player1, player2); Game.PropertyChanged += GameOnPropertyChanged; GameBoardViewModel = new GameBoardViewModel(this); Player1WinCount = 0; Player2WinCount = 0; TieCount = 0; }