Exemplo n.º 1
0
        //Static factory
        public static SquaresGameModel FromSave(GameStateWrapper state, ISquaresGameDataAccess dAccess)
        {
            SquaresGameModel instance = new SquaresGameModel(state.FieldSize, state.PlayerOne, state.PlayerTwo, dAccess);

            instance.ActivePlayer        = state.ActivePlayer;
            instance.lines               = state.Lines;
            instance.rectangles          = state.Rectangles;
            instance.registeredRectCount = state.RegisteredRectCount;

            return(instance);
        }
Exemplo n.º 2
0
        //============= CTORS ==============//
        public SquaresGameModel(int fieldSize, Player playerOne, Player playerTwo, ISquaresGameDataAccess dAccess)
        {
            //Field inits
            FieldSize  = (fieldSize > 1) ? fieldSize : throw new ArgumentOutOfRangeException("FieldSize", fieldSize, "value must be > 1");
            PlayerOne  = playerOne;
            PlayerTwo  = playerTwo;
            dataAccess = dAccess;

            ActivePlayer        = PlayerOne;
            GameEnded           = false;
            lines               = new List <Tuple <Point, Point, Player> >();
            linesToEnd          = CalcLinesToEnd();
            rectangles          = new List <Tuple <Point, Point, Player> >();
            registeredRectCount = 0;
        }
Exemplo n.º 3
0
 //===== UI Event handlers =====//
 private void GameWindow_Load(object sender, EventArgs e)
 {
     dataAccess = new SquaresGameDataAccess();
 }