Compare commits
No commits in common. "52f02a6c8c4a352dc4e23f33d9d057ba3f9df6e8" and "037ef53a70490240fc3785c67a2a95cbf2bcad31" have entirely different histories.
52f02a6c8c
...
037ef53a70
@ -1,7 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using qtc_api.Services.CurrencyGamesService;
|
||||
using System.Security.Claims;
|
||||
using static qtc_api.Services.CurrencyGamesService.CurrencyGamesService;
|
||||
|
||||
namespace qtc_api.Controllers
|
||||
{
|
||||
@ -17,8 +16,6 @@ namespace qtc_api.Controllers
|
||||
_currencyGamesService = currencyGamesService;
|
||||
}
|
||||
|
||||
// Stock Market
|
||||
|
||||
[HttpGet("stock-market/current-price")]
|
||||
public ActionResult<ServiceResponse<int>> GetCurrentPricePerStock()
|
||||
{
|
||||
@ -94,21 +91,5 @@ namespace qtc_api.Controllers
|
||||
}
|
||||
else return Ok(new ServiceResponse<UserStockActionResultDto> { Success = false, Message = "No Identity" });
|
||||
}
|
||||
|
||||
// Number Guess
|
||||
|
||||
[HttpGet("number-guess/get-number")]
|
||||
[Authorize]
|
||||
public ActionResult<ServiceResponse<int>> GetRandomNumber()
|
||||
{
|
||||
return Ok(_currencyGamesService.GetRandomNumber());
|
||||
}
|
||||
|
||||
[HttpGet("number-guess/guess-number")]
|
||||
[Authorize]
|
||||
public ActionResult<ServiceResponse<NumberGuessResult>> GuessNumber(int original, int guess)
|
||||
{
|
||||
return Ok(_currencyGamesService.GuessRandomNumber(original, guess));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -86,39 +86,11 @@ namespace qtc_api.Services.CurrencyGamesService
|
||||
}
|
||||
}
|
||||
|
||||
// Number Guess
|
||||
|
||||
public ServiceResponse<int> GetRandomNumber()
|
||||
{
|
||||
Random rnd = new Random();
|
||||
return new ServiceResponse<int> { Success = true, Data = rnd.Next(1, 500) };
|
||||
}
|
||||
|
||||
public ServiceResponse<NumberGuessResult> GuessRandomNumber(int original, int guess)
|
||||
{
|
||||
var response = new ServiceResponse<NumberGuessResult> { Success = true };
|
||||
|
||||
if (original - guess == 10) response.Data = NumberGuessResult.Lower;
|
||||
else if (guess - original == 10) response.Data = NumberGuessResult.Higher;
|
||||
else if (guess == original) response.Data = NumberGuessResult.Correct;
|
||||
else response.Data = NumberGuessResult.Incorrect;
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
private void Timer_Elapsed(object? state)
|
||||
{
|
||||
Random rnd = new Random();
|
||||
CurrentPricePerStock = rnd.Next(5, 200);
|
||||
logger.LogInformation($"Current Price Per Stock - {CurrentPricePerStock}");
|
||||
}
|
||||
|
||||
public enum NumberGuessResult
|
||||
{
|
||||
Higher,
|
||||
Lower,
|
||||
Correct,
|
||||
Incorrect
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user