예제 #1
0
 public InitLoginViewModel(
     ICommonDataManager commonDataManager,
     IServiceCallInvoker serviceCallInvoker,
     IMessageBoxDialogService messageBoxDialogService) : base(commonDataManager, serviceCallInvoker)
 {
     _messageBoxDialogService = messageBoxDialogService;
 }
        public WaitGameStartFlowViewModel(
            ICommonDataManager commonDataManager,
            IServiceCallInvoker serviceCallInvoker,
            IMessageBoxDialogService messageBoxDialogService)
            : base(commonDataManager, serviceCallInvoker)
        {
            _messageBoxDialogService = messageBoxDialogService;

            CommonDataManager.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "Challenge")
                {
                    ChallengeString = CommonDataManager.Challenge;
                }

                if (args.PropertyName == "PlayerId")
                {
                    PlayerId = CommonDataManager.PlayerId;
                }
            };

            ChallengeString = CommonDataManager.Challenge;
            PlayerId        = CommonDataManager.PlayerId;

            _isExecuting = false;
        }
 public CreatePlayerViewModel(
     ICommonDataManager commonDataManager,
     IServiceCallInvoker serviceCallInvoker,
     IMessageBoxDialogService messageBoxDialogService)
     : base(commonDataManager, serviceCallInvoker)
 {
     _messageBoxDialogService = messageBoxDialogService;
 }
예제 #4
0
        public LoggerViewModel(IServiceCallInvoker serviceCallInvoker)
        {
            serviceCallInvoker.InvokeBegan += (sender, args) => { Request = args.Request; };

            serviceCallInvoker.InvokeFinished += (sender, args) =>
            {
                Response      = args.Response;
                OperationTime = args.OperationTime;
            };
        }
 public CreatePlayerFlowViewModel(
     ICommonDataManager commonDataManager,
     IServiceCallInvoker serviceCallInvoker,
     IMessageBoxDialogService messageBoxDialogService,
     ISessionIdGenerator sessionIdGenerator)
     : base(commonDataManager, serviceCallInvoker)
 {
     _messageBoxDialogService = messageBoxDialogService;
     _sessionIdGenerator      = sessionIdGenerator;
 }
        protected ServiceCallViewModel(ICommonDataManager commonDataManager, IServiceCallInvoker serviceCallInvoker)
        {
            CommonDataManager  = commonDataManager;
            ServiceCallInvoker = serviceCallInvoker;

            ServiceUrl     = CommonDataManager.ServerUrl;
            Username       = CommonDataManager.Username;
            TeamName       = CommonDataManager.TeamName;
            Password       = CommonDataManager.Password;
            SessionId      = CommonDataManager.SessionId;
            SequenceNumber = CommonDataManager.SequenceNumber;

            CalculateAuthCode();

            CommonDataManager.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "ServerUrl")
                {
                    ServiceUrl = CommonDataManager.ServerUrl;
                }
                else if (args.PropertyName == "Username")
                {
                    Username = CommonDataManager.Username;
                }
                else if (args.PropertyName == "TeamName")
                {
                    TeamName = CommonDataManager.TeamName;
                }
                else if (args.PropertyName == "Password")
                {
                    Password = CommonDataManager.Password;
                }
                else if (args.PropertyName == "SessionId")
                {
                    SessionId = CommonDataManager.SessionId;
                }
                else if (args.PropertyName == "SequenceNumber")
                {
                    SequenceNumber = CommonDataManager.SequenceNumber;
                }
            };

            this.PropertyChanged += (sender, args) =>
            {
                string[] authcodeProps = new string[] { "TeamName", "Username", "SessionId", "SequenceNumber", "Password" };
                if (Array.IndexOf(authcodeProps, args.PropertyName) >= 0)
                {
                    CalculateAuthCode();
                }
            };
        }
예제 #7
0
        protected ServiceCallViewModel(ICommonDataManager commonDataManager, IServiceCallInvoker serviceCallInvoker)
        {
            CommonDataManager  = commonDataManager;
            ServiceCallInvoker = serviceCallInvoker;

            PropertyChanged += OnPropertyChanged;

            CommonDataManager.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "ServerUrl")
                {
                    ServiceUrl = CommonDataManager.ServerUrl;
                }

                if (args.PropertyName == "Username")
                {
                    Username = CommonDataManager.Username;
                }

                if (args.PropertyName == "TeamName")
                {
                    TeamName = CommonDataManager.TeamName;
                }

                if (args.PropertyName == "Password")
                {
                    Password = CommonDataManager.Password;
                }

                if (args.PropertyName == "SessionId")
                {
                    SessionId = CommonDataManager.SessionId;
                }

                if (args.PropertyName == "SequenceNumber")
                {
                    SequenceNumber = CommonDataManager.SequenceNumber;
                }
            };

            ServiceUrl     = CommonDataManager.ServerUrl;
            Username       = CommonDataManager.Username;
            TeamName       = CommonDataManager.TeamName;
            Password       = CommonDataManager.Password;
            SessionId      = CommonDataManager.SessionId;
            SequenceNumber = CommonDataManager.SequenceNumber;
        }
예제 #8
0
        public LeaveGameViewModel(
            ICommonDataManager commonDataManager,
            IServiceCallInvoker serviceCallInvoker,
            IMessageBoxDialogService messageBoxDialogService)
            : base(commonDataManager, serviceCallInvoker)
        {
            _messageBoxDialogService           = messageBoxDialogService;
            CommonDataManager.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "PlayerId")
                {
                    PlayerId = CommonDataManager.PlayerId;
                }
            };

            PlayerId = CommonDataManager.PlayerId;
        }
예제 #9
0
        public CompleteLoginViewModel(
            ICommonDataManager commonDataManager,
            IServiceCallInvoker serviceCallInvoker,
            IMessageBoxDialogService messageBoxDialogService)
            : base(commonDataManager, serviceCallInvoker)
        {
            _messageBoxDialogService = messageBoxDialogService;

            CommonDataManager.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "Challenge")
                {
                    ChallengeString = CommonDataManager.Challenge;
                }
            };

            ChallengeString = CommonDataManager.Challenge;
        }
예제 #10
0
        public CreatePlayerFlowViewModel(
            ICommonDataManager commonDataManager,
            IServiceCallInvoker serviceCallInvoker,
            IMessageBoxDialogService messageBoxDialogService)
            : base(commonDataManager, serviceCallInvoker)
        {
            _messageBoxDialogService = messageBoxDialogService;

            CommonDataManager.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "Challenge")
                {
                    ChallengeString = CommonDataManager.Challenge;
                }
            };

            ChallengeString = CommonDataManager.Challenge;
            SessionId       = CommonDataManager.SessionId;
        }
예제 #11
0
        public GetTurnResultViewModel(
            ICommonDataManager commonDataManager,
            IServiceCallInvoker serviceCallInvoker,
            IMapService mapService,
            IMessageBoxDialogService messageBoxDialogService)
            : base(commonDataManager, serviceCallInvoker)
        {
            CommonDataManager.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "PlayerId")
                {
                    PlayerId = CommonDataManager.PlayerId;
                }
            };

            _mapService = mapService;
            _messageBoxDialogService = messageBoxDialogService;
            PlayerId = CommonDataManager.PlayerId;
        }
예제 #12
0
        static void Main(string[] args)
        {
            Console.Title      = $"Game Demo Bot - ver. {Assembly.GetExecutingAssembly().GetName().Version}";
            ServiceCallInvoker = new ServiceCallInvoker(new Logger(), new JsonWebServiceClient());
            ReadParams(args);

            var gameFlowWrapper = new GameFlowWrapper();

            if (gameFlowWrapper.CreatePlayer())
            {
                while (true)
                {
                    Settings.Turn = 0;

                    while (true)
                    {
                        if (!gameFlowWrapper.WaitNextTurn())
                        {
                            break;
                        }

                        if (!gameFlowWrapper.GetPlayerView())
                        {
                            break;
                        }

                        //DumpBoard();

                        if (!gameFlowWrapper.PerformMove())
                        {
                            break;
                        }

                        //Console.ReadKey();
                    }
                }
            }

            Console.WriteLine("DemoClient Terminated");
            Console.ReadKey(true);
        }
예제 #13
0
        public WaitNextTurnViewModel(
            ICommonDataManager commonDataManager,
            IServiceCallInvoker serviceCallInvoker,
            IMessageBoxDialogService messageBoxDialogService)
            : base(commonDataManager, serviceCallInvoker)
        {
            _messageBoxDialogService = messageBoxDialogService;
            PlayerId = CommonDataManager.PlayerId;
            Turn     = CommonDataManager.Turn;

            CommonDataManager.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "Turn")
                {
                    Turn = CommonDataManager.Turn;
                }
                if (args.PropertyName == "PlayerId")
                {
                    PlayerId = CommonDataManager.PlayerId;
                }
            };
        }
        public PlayerModeFlowViewModel(
            ICommonDataManager commonDataManager,
            IServiceCallInvoker serviceCallInvoker,
            IMapService mapService,
            IMessageBoxDialogService messageBoxDialogService)
            : base(commonDataManager, serviceCallInvoker)
        {
            _mapService = mapService;
            _messageBoxDialogService = messageBoxDialogService;

            PlayerId = CommonDataManager.PlayerId;
            Turn     = CommonDataManager.Turn;

            CommonDataManager.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "Turn")
                {
                    Turn = CommonDataManager.Turn;
                }

                if (args.PropertyName == "PlayerId")
                {
                    PlayerId = CommonDataManager.PlayerId;
                }
            };

            _mapService.MapChanged += (sender, args) =>
            {
                var cellViewModels = new List <CellViewModel>();

                for (int i = 0; i < _mapService.Map.Length; i++)
                {
                    for (int j = 0; j < _mapService.Map[i].Length; j++)
                    {
                        cellViewModels.Add(new CellViewModel {
                            X = j, Y = i, State = Convert.ToString(_mapService.Map[i][j]),
                        });
                    }
                }

                CellCollection   = new ObservableCollection <CellViewModel>(cellViewModels);
                PlayerCollection = new ObservableCollection <PlayerViewModel>(_mapService.Players.Select(p => new PlayerViewModel
                {
                    Condition = p.Condition,
                    Index     = p.Index,
                }));
            };

            _mapService.CellChanged += (sender, args) =>
            {
                int index = args.Y * _mapService.Map.First().Length + args.X;

                CellCollection[index].State = args.State;

                PlayerCollection = new ObservableCollection <PlayerViewModel>(_mapService.Players.Select(p => new PlayerViewModel
                {
                    Condition = p.Condition,
                    Index     = p.Index,
                }));
            };

            if (_mapService.Map != null)
            {
                var cellViewModels = new List <CellViewModel>();

                for (int i = 0; i < _mapService.Map.Length; i++)
                {
                    for (int j = 0; j < _mapService.Map[i].Length; j++)
                    {
                        cellViewModels.Add(new CellViewModel {
                            X = j, Y = i, State = Convert.ToString(_mapService.Map[i][j]),
                        });
                    }
                }

                CellCollection   = new ObservableCollection <CellViewModel>(cellViewModels);
                PlayerCollection = new ObservableCollection <PlayerViewModel>(_mapService.Players.Select(p => new PlayerViewModel
                {
                    Condition = p.Condition,
                    Index     = p.Index,
                }));
            }
            else
            {
                CellCollection   = new ObservableCollection <CellViewModel>();
                PlayerCollection = new ObservableCollection <PlayerViewModel>();
            }

            _isExecuting = false;
        }
        public PerformMoveViewModel(
            ICommonDataManager commonDataManager,
            IServiceCallInvoker serviceCallInvoker,
            IMapService mapService,
            IMessageBoxDialogService messageBoxDialogService)
            : base(commonDataManager, serviceCallInvoker)
        {
            CommonDataManager.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "PlayerId")
                {
                    PlayerId = CommonDataManager.PlayerId;
                }
            };

            _mapService = mapService;
            _messageBoxDialogService = messageBoxDialogService;
            PlayerId = CommonDataManager.PlayerId;

            _mapService.MapChanged += (sender, args) =>
            {
                var cellViewModels = new List <CellViewModel>();

                for (int row = 0; row < _mapService.Height; row++)
                {
                    for (int col = 0; col < _mapService.Width; col++)
                    {
                        cellViewModels.Add(new CellViewModel
                        {
                            X     = col,
                            Y     = row,
                            State = _mapService.Map[row, col]
                        });
                    }
                }

                CellCollection = new ObservableCollection <CellViewModel>(cellViewModels);
                MoveCollection = new ObservableCollection <PlayerMoveModel>(_mapService.Actors.Select(a => new PlayerMoveModel
                {
                    Index    = a.Index,
                    Name     = a.Name,
                    Move     = a.Position,
                    IsTecman = a.IsTecman
                }));
            };

            _mapService.CellChanged += (sender, args) =>
            {
                var index = args.Y * _mapService.Width + args.X;
                CellCollection[index].State = args.State;
            };

            if (_mapService.Map != null)
            {
                var cellViewModels = new List <CellViewModel>();

                for (int row = 0; row < _mapService.Height; row++)
                {
                    for (int col = 0; col < _mapService.Width; col++)
                    {
                        cellViewModels.Add(new CellViewModel
                        {
                            X     = col,
                            Y     = row,
                            State = _mapService.Map[row, col]
                        });
                    }
                }

                CellCollection = new ObservableCollection <CellViewModel>(cellViewModels);
                MoveCollection = new ObservableCollection <PlayerMoveModel>(_mapService.Actors.Select(a => new PlayerMoveModel
                {
                    Index    = a.Index,
                    Name     = a.Name,
                    Move     = a.Position,
                    IsTecman = a.IsTecman
                }));
            }
            else
            {
                CellCollection = new ObservableCollection <CellViewModel>();
                MoveCollection = new ObservableCollection <PlayerMoveModel>();
            }

            this.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "SelectedCell")
                {
                    if (SelectedCell != null && SelectedActor != null)
                    {
                        SelectedActor.Move = new Point(SelectedCell.Y, SelectedCell.X);
                        Positions          = string.Concat(MoveCollection.Select(m => $"{m.Move.Row},{m.Move.Col},"));
                    }
                }
            };
        }