Esempio n. 1
0
        private void UpdateShowman()
        {
            if (_showman == null)
            {
                return;
            }

            if (_showman.AccountType == AccountTypes.Human)
            {
                if (!_model.NetworkGame || _model.Role == GameRole.Showman)
                {
                    _showman.SelectionList   = new List <Account>(new Account[] { Human });
                    _showman.SelectedAccount = Human;
                }
                else
                {
                    var oneAccount = new HumanAccount {
                        Name = Constants.FreePlace, IsHuman = true
                    };
                    _showman.SelectionList   = new Account[] { oneAccount };
                    _showman.SelectedAccount = oneAccount;
                }
            }
            else if (_showman.SelectionList != _computerShowmans)
            {
                _showman.SelectionList   = _computerShowmans;
                _showman.SelectedAccount = _computerShowmans[0];
            }
        }
Esempio n. 2
0
 public ReconnectManager(SlaveServer server, Client client, IViewerClient host, HumanAccount human, GameRole role, string credentials, bool upgrade)
 {
     _server      = server;
     _client      = client;
     _host        = host;
     _human       = human;
     _role        = role;
     _credentials = credentials;
     _upgrade     = upgrade;
 }
Esempio n. 3
0
        private void UpdatePlayer(GameAccount player, bool force = false)
        {
            if (player == null)
            {
                return;
            }

            if (player.AccountType == AccountTypes.Human)
            {
                if (!_model.NetworkGame || _model.Role == GameRole.Player && _model.PlayerNumber > -1 &&
                    _model.PlayerNumber < Players.Count && Players[_model.PlayerNumber] == player)
                {
                    player.SelectionList   = new List <Account>(new Account[] { Human });
                    player.SelectedAccount = Human;
                }
                else
                {
                    var oneAccount = new HumanAccount {
                        Name = Constants.FreePlace, IsHuman = true
                    };
                    player.SelectionList   = new Account[] { oneAccount };
                    player.SelectedAccount = oneAccount;
                }
            }
            else if (force || player.SelectionList != _computerPlayers)
            {
                var visited = new List <int>();

                for (int i = 0; i < Players.Count; i++)
                {
                    if (Players[i] != player && Players[i].AccountType == AccountTypes.Computer)
                    {
                        visited.Add(Array.IndexOf(_computerPlayers, (ComputerAccount)Players[i].SelectedAccount));
                    }
                }

                var index = Random.Next(_computerPlayers.Length - visited.Count - 1);
                while (visited.Contains(index))
                {
                    index++;
                }

                if (!force)
                {
                    player.SelectionList = _computerPlayers;
                }

                player.SelectedAccount = _computerPlayers[index];
            }
        }
Esempio n. 4
0
        private void InitializeCore()
        {
            EditAccount   = new CustomCommand(EditAccount_Executed);
            RemoveAccount = new CustomCommand(RemoveAccount_Executed);

            UpdateHumanPlayers();

            SetHumanPlayer();

            if (_humanPlayer == null)
            {
                _humanPlayer           = _commonSettings.Humans2.FirstOrDefault() ?? _newHumanAccount;
                _model.HumanPlayerName = _humanPlayer.Name;
            }

            OnHumanPlayerChanged();
        }
Esempio n. 5
0
 private void SetHumanPlayer()
 {
     _humanPlayer = HumanPlayers.FirstOrDefault(acc => acc.Name == _model.HumanPlayerName);
 }
Esempio n. 6
0
        internal void PrepareForGame()
        {
            Viewers.Clear();
            if (Role == GameRole.Viewer)
            {
                Viewers.Add(new SimpleAccount <HumanAccount> {
                    SelectedAccount = Human
                });
            }

            Players.Clear();

            var playersCount = PlayersCount;

            var anyAccount = new HumanAccount {
                Name = Constants.FreePlace, CanBeDeleted = false
            };

            var playerTypes = Model.PlayersTypes;

            for (int i = 0; i < playersCount; i++) // Рандомные игроки
            {
                if (Role == GameRole.Player && i == PlayerNumber)
                {
                    Players.Add(new GameAccount(this)
                    {
                        AccountType = AccountTypes.Human, SelectedAccount = Human
                    });
                }
                else if (!NetworkGame || playerTypes == null ||
                         i >= playerTypes.Length || playerTypes[i] == AccountTypes.Computer)
                {
                    Players.Add(new GameAccount(this)
                    {
                        AccountType = AccountTypes.Computer
                    });
                }
                else
                {
                    Players.Add(new GameAccount(this)
                    {
                        AccountType = AccountTypes.Human, SelectedAccount = anyAccount
                    });
                }
            }

            if (Showman == null)
            {
                if (Role == GameRole.Showman)
                {
                    Showman = new GameAccount(this)
                    {
                        AccountType = AccountTypes.Human, SelectedAccount = Human
                    }
                }
                ;
                else if (!NetworkGame || _model.ShowmanType == AccountTypes.Computer)
                {
                    Showman = new GameAccount(this)
                    {
                        AccountType = AccountTypes.Computer, SelectedAccount = _computerShowmans[0]
                    }
                }
                ;
                else
                {
                    Showman = new GameAccount(this)
                    {
                        AccountType = AccountTypes.Human, SelectedAccount = anyAccount
                    }
                };
            }
        }
    }
Esempio n. 7
0
 public HumanAccount(HumanAccount account)
     : base(account)
 {
     IsHuman    = true;
     _birthDate = account._birthDate;
 }