Esempio n. 1
0
        private void ExecuteCommand(Command command)
        {
            switch (command.Action)
            {
            case ActionName.Attack:
                AttackOutcome attackOutcome = _warriorClient.Attack(command.Strength);
                WarriorLogger.AttackLogging(attackOutcome, command.Strength);
                break;

            case ActionName.Defend:
                DefenseOutcome defenseOutcome = _warriorClient.Defend(command.Time);
                WarriorLogger.DefenceLogging(defenseOutcome);
                break;

            case ActionName.Rest:
                RestOutcome restOutcome = _warriorClient.Rest(command.Time);
                WarriorLogger.RestLogging(restOutcome);
                break;

            case ActionName.Check:
                WarriorState warriorState = _warriorClient.Check();
                WarriorLogger.CheckLogging(warriorState);
                break;
            }
        }
        public WarriorState Check()
        {
            try
            {
                HttpResponseMessage responseMessage = _client.PostAsJsonAsync("Check/" + WarriorBrain.RoomGuid + "/" + _myGuid, "aaa").Result;
                responseMessage.EnsureSuccessStatusCode();

                WarriorState enemyState = responseMessage.Content.ReadAsAsync <WarriorState>().Result;

                return(enemyState);
            }
            catch (Exception exception)
            {
                WarriorLogger.UnableToConnect();
            }
            return(null);
        }