Esempio n. 1
0
 public Player(string name, int wins, IPlayerLogic playerLogic)
 {
     Hand        = new Hand();
     Name        = name;
     Wins        = wins;
     PlayerLogic = playerLogic;
 }
Esempio n. 2
0
 public Player(int id, Color color, IPlayerLogic playerLogic)
 {
     this.id          = id;
     this.fields      = 0;
     this.color       = color;
     this.PlayerLogic = playerLogic;
 }
Esempio n. 3
0
        public MainViewModel(IPlayerLogic logic)
        {
            this.logic = logic;

            Team = new ObservableCollection <Player>();

            if (IsInDesignMode)
            {
                Player p2 = new Player()
                {
                    Name = "Wild Bill 2"
                };
                Player p3 = new Player()
                {
                    Name = "Wild Bill 3", Status = StatusType.Injured
                };
                Team.Add(p2);
                Team.Add(p3);
            }

            // MUST USE commandWpf!
            // MUST USE this.logic
            AddCmd = new RelayCommand(() => this.logic.AddPlayer(Team));
            ModCmd = new RelayCommand(() => this.logic.ModPlayer(TeamSelected));
            DelCmd = new RelayCommand(() => this.logic.DelPlayer(Team, TeamSelected));
        }
Esempio n. 4
0
 public HomeController(IUserLogic userLogic, IGameLogic gameLogic, IGameBetsLogic gameBetsLogic, IPlayerLogic playerLogic, ILogger <HomeController> logger)
 {
     _userLogic     = userLogic;
     _gameLogic     = gameLogic;
     _gameBetsLogic = gameBetsLogic;
     _playerLogic   = playerLogic;
     _logger        = logger;
 }
Esempio n. 5
0
 public HomeController(
     IConfiguration configuration,
     IPlayerLogic playerLogic,
     ITemplateLogic templateLogic)
 {
     _configuration = configuration;
     _playerLogic   = playerLogic;
     _templateLogic = templateLogic;
 }
Esempio n. 6
0
        public Connection(string ipAddress, int port, string gameName, string[] args, object testPlaceholder)
        {
            _logic    = new PlayerLogic(this);
            _address  = ipAddress;
            _port     = port;
            _gameName = gameName;

            _keepAliveInterval = ARBITRATYKEEPALIVEINTERVAL;;
            uint.TryParse(args[0], out _retryJoinGameInterval);
            Enum.TryParse(args[1], out _team);
            Enum.TryParse(args[2], out _role);
        }
Esempio n. 7
0
 public Connection(string ipAddress, int port, string gameName, Messages.ParametersReader inputParameters)
 {
     _logic    = new PlayerLogic(this);
     _address  = ipAddress;
     _port     = port;
     _gameName = gameName;
     if (inputParameters != null)
     {
         _keepAliveInterval = (int)inputParameters.ReadPlayerSettings.KeepAliveInterval;
     }
     else
     {
         _keepAliveInterval = ARBITRATYKEEPALIVEINTERVAL;
     }
     _retryJoinGameInterval = inputParameters.ReadPlayerSettings.RetryJoinGameInterval;
     Enum.TryParse(inputParameters.Team, out _team);
     Enum.TryParse(inputParameters.Role, out _role);
 }
Esempio n. 8
0
        public float mCastSpellDistance; //攻击距离

        public bool InitState()
        {
            BaseGameLogic <IPlayerLogic> bgLogic = (BaseGameLogic <IPlayerLogic>)GameLogicManager.Instance.GetGameLogic(eGameLogicType.PlayerLogic, (short)ePlayerLogicType.Robot);

            if (null == bgLogic)
            {
                return(false);
            }

            mLogic = bgLogic.Logic;

            if (IsDie)
            {
                mState = ePlayerState.None;
            }
            else
            {
                mState = ePlayerState.Idle;
            }

            return(true);
        }
Esempio n. 9
0
        static async Task Main(string[] args)
        {
            var configuration = new ConfigurationBuilder()
                                .SetBasePath(Directory.GetCurrentDirectory())
                                .AddJsonFile("appsettings.json")
                                .Build();

            Log.Logger = new LoggerConfiguration()
                         .ReadFrom.Configuration(configuration)
                         .CreateLogger();
            if (args.Any(s => s == "?" || s == "help"))
            {
                Console.WriteLine("Valid arguments:");
                Console.WriteLine("\t--playerName joe");
                Console.WriteLine("\t--serverAddress http://localhost:5000");
                Console.WriteLine("\t--useAlternate true");
                Console.WriteLine("\t--sleep random");
                return;
            }

            using IHost host = CreateHostBuilder(args).Build();
            config           = host.Services.GetService(typeof(IConfiguration)) as IConfiguration ?? throw new Exception("Unable to load configuration");

            Console.WriteLine("What is your player name?");
            var playerName = config["playerName"] switch
            {
                null => Console.ReadLine(),
                string name => name
            };

            Console.WriteLine("Hello {0}!", playerName);


            var serverAddress = config["serverAddress"] ?? "http://localhost:5000";

            Console.WriteLine($"Talking to the server at {serverAddress}");
            Log.Information("Connected to server at: " + serverAddress);

            hubConnection = new HubConnectionBuilder()
                            .WithUrl($"{serverAddress}/riskhub")
                            .Build();

            hubConnection.On <IEnumerable <BoardTerritory> >(MessageTypes.YourTurnToDeploy, async(board) =>
            {
                Log.Information("Deploy request received");
                var deployLocation = playerLogic.WhereDoYouWantToDeploy(board);
                Console.WriteLine("Deploying to {0}", deployLocation);
                Log.Information("Deploy response sent to" + deployLocation.Column + "," + deployLocation.Row);
                await DeployAsync(deployLocation);
            });

            hubConnection.On <IEnumerable <BoardTerritory> >(MessageTypes.YourTurnToAttack, async(board) =>
            {
                Log.Information("Attack request received.");
                try
                {
                    (var from, var to) = playerLogic.WhereDoYouWantToAttack(board);

                    Console.WriteLine("Attacking from {0} ({1}) to {2} ({3})", from, board.First(c => c.Location == from).OwnerName, to, board.First(c => c.Location == to).OwnerName);
                    Log.Information("Attack response successful from (" + from.Column + "," + from.Row + ") to (" + to.Column + "," + to.Row + ").");
                    await AttackAsync(from, to);
                }
                catch (Exception ex)
                {
                    Log.Error("Exception caught: " + ex.Message);
                    Console.WriteLine("Yielding turn (nowhere left to attack)");
                    await AttackCompleteAsync();
                }
            });

            hubConnection.On <string, string>(MessageTypes.SendMessage, (from, message) =>
            {
                Console.WriteLine("From {0}: {1}", from, message);
                Log.Information("Message received from " + from + ": " + message);
            });

            hubConnection.On <string>(MessageTypes.JoinConfirmation, validatedName =>
            {
                if (config["useAlternate"] == "true")
                {
                    playerLogic = new AlternateSampleLogic(validatedName);
                }
                else
                {
                    var shouldSleep = config["sleep"] == "random";
                    playerLogic     = new PlayerLogic(validatedName, shouldSleep);
                }
                Console.Title = validatedName;
                Console.WriteLine($"Successfully joined server. Assigned Name is {validatedName}");
                Log.Information("Joining game as: " + validatedName);
            });

            await hubConnection.StartAsync();

            Console.WriteLine("My connection id is {0}.  Waiting for game to start...", hubConnection.ConnectionId);
            await SignupAsync(playerName);

            Console.ReadLine();

            Console.WriteLine("Disconnecting from server.  Game over.");
        }
Esempio n. 10
0
 public HomeController(IPlayerLogic playerLogic, ApplicationIdentityUserManager userManager)
 {
     _playerLogic = playerLogic;
     _userManager = userManager;
 }
Esempio n. 11
0
 public PlayerController(IPlayerLogic client)
 {
     _client = client;
 }
Esempio n. 12
0
 public SyndicateLogic(TauDbContext dbContext, IPlayerLogic playerLogic)
 {
     _dbContext   = dbContext;
     _playerLogic = playerLogic;
 }
Esempio n. 13
0
        static async Task Main(string[] args)
        {
            if (args.Any(s => s == "?" || s == "help"))
            {
                Console.WriteLine("Valid arguments:");
                Console.WriteLine("\t--playerName joe");
                Console.WriteLine("\t--serverAddress http://localhost:5000");
                Console.WriteLine("\t--useAlternate true");
                Console.WriteLine("\t--sleep random");
                return;
            }

            using IHost host = CreateHostBuilder(args).Build();
            config           = host.Services.GetService(typeof(IConfiguration)) as IConfiguration ?? throw new Exception("Unable to load configuration");

            Console.WriteLine("What is your player name?");
            var playerName = config["playerName"] switch
            {
                null => Console.ReadLine(),
                string name => name
            };

            Console.WriteLine("Hello {0}!", playerName);


            var serverAddress = config["serverAddress"] ?? "http://localhost:5000";

            Console.WriteLine($"Talking to the server at {serverAddress}");

            hubConnection = new HubConnectionBuilder()
                            .WithUrl($"{serverAddress}/riskhub")
                            .Build();

            hubConnection.On <IEnumerable <BoardTerritory> >(MessageTypes.YourTurnToDeploy, async(board) =>
            {
                var deployLocation = playerLogic.WhereDoYouWantToDeploy(board);
                Console.WriteLine("Deploying to {0}", deployLocation);
                await DeployAsync(deployLocation);
            });

            hubConnection.On <IEnumerable <BoardTerritory> >(MessageTypes.YourTurnToAttack, async(board) =>
            {
                try
                {
                    (var from, var to) = playerLogic.WhereDoYouWantToAttack(board);
                    Console.WriteLine("Attacking from {0} ({1}) to {2} ({3})", from, board.First(c => c.Location == from).OwnerName, to, board.First(c => c.Location == to).OwnerName);
                    await AttackAsync(from, to);
                }
                catch
                {
                    Console.WriteLine("Yielding turn (nowhere left to attack)");
                    await AttackCompleteAsync();
                }
            });

            hubConnection.On <string, string>(MessageTypes.SendMessage, (from, message) => Console.WriteLine("From {0}: {1}", from, message));

            hubConnection.On <string>(MessageTypes.JoinConfirmation, validatedName =>
            {
                if (config["useAlternate"] == "true")
                {
                    playerLogic = new AlternateSampleLogic(validatedName);
                }
                else
                {
                    var shouldSleep = config["sleep"] == "random";
                    playerLogic     = new PlayerLogic(validatedName, shouldSleep);
                }
                Console.Title = validatedName;
                Console.WriteLine($"Successfully joined server. Assigned Name is {validatedName}");
            });

            await hubConnection.StartAsync();

            Console.WriteLine("My connection id is {0}.  Waiting for game to start...", hubConnection.ConnectionId);
            await SignupAsync(playerName);

            Console.ReadLine();

            Console.WriteLine("Disconnecting from server.  Game over.");
        }
Esempio n. 14
0
 public InternalPlayer(IPlayerLogic player)
     : base(player)
 {
     this.Cards = new List <Card>();
 }
 public SyndicateManagementController(IPlayerLogic logic, ISyndicateLogic syndicateLogic, ApplicationIdentityUserManager userManager) :
     base(syndicateLogic, userManager)
 {
     _playerLogic = logic;
 }
Esempio n. 16
0
 public PlayerController(IPlayerLogic playerLogic, IPortfolioLogic portfolioLogic)
 {
     this.playerLogic    = playerLogic;
     this.portfolioLogic = portfolioLogic;
 }
Esempio n. 17
0
 protected PlayerDecorator(IPlayerLogic player)
 {
     this.Player = player;
 }
Esempio n. 18
0
 public GameBetsRepository(EntityContext entityContext, IPlayerLogic playerLogic)
 {
     _entityContext = entityContext;
     _playerLogic   = playerLogic;
 }
Esempio n. 19
0
 public GameRepository(EntityContext entityContext, ITransactionLogic transactionLogic, IPlayerLogic playerLogic)
 {
     _entityContext    = entityContext;
     _transactionLogic = transactionLogic;
     _playerLogic      = playerLogic;
 }
 public PlayersController(IPlayerLogic playerLogic)
 {
     _playerLogic = playerLogic;
 }
Esempio n. 21
0
 public SettingsController(IPlayerLogic playerLogic, ApplicationIdentityUserManager userManager, ISyndicateLogic syndicateLogic) : base(syndicateLogic, userManager)
 {
     _playerLogic = playerLogic;
 }
Esempio n. 22
0
 public HomeController(IPlayerLogic playerLogic)
 {
     _playerLogic = playerLogic;
 }