public DiscordCommandResult EvalLuaAsync( [Name("Code String"), Description("The code to execute"), OverrideTypeParser(typeof(CodeBlockTypeParser)), Remainder] string codeString) { var evalResult = EvalService.EvalLuaCode(codeString); return(Response(evalResult)); }
/// <summary> /// discard cards by player /// </summary> /// <param name="player"></param> /// <param name="discards"></param> public void Discard(Player player, List <Card> discards) { if (player != null) { if (discards != null) { if (discards.Count > 0) { //keep the discarded cards player.Discard = discards; //build a new hand minus the discarded cards List <Card> newhand = new List <Card>(); foreach (Card card in player.Hand) { if (!card.Discard) { newhand.Add(card); } } player.Hand = newhand; //eval the hand EvalService eval = new EvalService(); player.HandRank = eval.Evaluate(player.Hand); } } } }
/// <summary> /// you only need to run this host, and will have access to the service via console interface. /// no need to first start the servcelibrary before running this project, because this is a host, /// not a client (which is a consumer and needs to have an upp and running servcie somewhere so taht /// the client can consume it). /// </summary> /// <param name="args"></param> static void Main(string[] args) { ServiceHost host = new ServiceHost(typeof(EvalService)); // CONFIGURATION in program instead off in the app.config //host.AddServiceEndpoint(typeof(IEvalService), new BasicHttpBinding(), "Http://localhost:8080/evals/basic"); try { host.Open(); EvalService service = new EvalService(); Eval eone = new Eval(); eone.Submitter = "ivan prgomet"; eone.Comments = "really cool | sweet | neat"; eone.TimeSent = DateTime.Now; service.SubmitEval(eone); List <Eval> evals = service.GetEvals(); PrintEvals(evals); host.Close(); } catch (Exception) { host.Abort(); throw; } }
static void Main(string[] args) { ServiceHost host = new ServiceHost(typeof(EvalService)); //configure host before opening host.AddServiceEndpoint(typeof(IEvalService), new BasicHttpBinding(), "Http://localhost:8080/evals/basic"); host.AddServiceEndpoint(typeof(IEvalService), new WSHttpBinding(), "Http://localhost:8080/evals/ws"); host.AddServiceEndpoint(typeof(IEvalService), new NetTcpBinding(), "net.tcp://localhost:8081/evals"); try { host.Open(); #region service info Console.WriteLine($"{host.Description.ServiceType} is up and running with these endpoints:\n"); foreach (ServiceEndpoint se in host.Description.Endpoints) { Console.WriteLine(se.Address); } Console.WriteLine(); #endregion EvalService evalService = new EvalService(); Eval eval = new Eval() { Submitter = "ivan prgomet", TimeSent = DateTime.Now, Comments = "Hello World", }; Eval eval2 = new Eval() { Submitter = "jon jonsson", TimeSent = DateTime.Now, Comments = "Hello Universe", }; evalService.SubmitEval(eval); evalService.SubmitEval(eval2); List <Eval> myEvals = evalService.GetEvals(); foreach (var e in myEvals) { Console.WriteLine("Submitter: " + e.Submitter); Console.WriteLine("Comment: " + e.Comments); Console.WriteLine("TimeSent: " + e.TimeSent + "\n"); } host.Close(); } catch (Exception e) { Console.WriteLine(e.Message); host.Abort(); } }
public HomeController(IServiceProvider serviceProvider) { _timeTrackerService = serviceProvider.GetRequiredService <StudentTimeTrackerService>(); _courseService = serviceProvider.GetRequiredService <CourseService>(); _evalService = serviceProvider.GetRequiredService <EvalService>(); _groupService = serviceProvider.GetRequiredService <GroupService>(); _projectService = serviceProvider.GetRequiredService <ProjectService>(); _timeService = serviceProvider.GetRequiredService <TimeService>(); _userService = serviceProvider.GetRequiredService <UserService>(); }
public async Task Eval([Remainder] string input) { var pattern = new Regex("```(?i)(cs)?(?s)(.*)```"); string evalString = pattern.Match(input).Groups[2].Value; if (evalString == null) { return; } await EvalService.EvaluateAsync(evalString, Context); } // end Eval
/// <summary> /// draw cards /// </summary> /// <param name="player"></param> /// <param name="cards"></param> public void Draw(Player player, List <Card> cards) { if (player != null) { //keep the draw player.Draw = cards; //add to hand also player.Hand.AddRange(cards); //eval the hand EvalService eval = new EvalService(); player.HandRank = eval.Evaluate(player.Hand); } }
static void Main(string[] args) { var host = new ServiceHost(typeof(EvalService)); host.AddServiceEndpoint(typeof(IEvalService), new BasicHttpBinding(), "http://localhost:8080/Evals/basic"); host.AddServiceEndpoint(typeof(IEvalService), new WSHttpBinding(), "http://localhost:8080/Evals/ws"); host.AddServiceEndpoint(typeof(IEvalService), new NetTcpBinding(), "net.tcp://localhost:8081/Evals/"); try { host.Open(); PrintServiceInfo(host); var evalService = new EvalService(); var eval = new Eval() { Submitter = "Chuck Norris", TimeSent = DateTime.Now, Comment = "It Works!" }; evalService.SubmitEval(eval); var evalList = new List <Eval>(); evalList = evalService.GetEvals(); if (evalList != null) { foreach (var e in evalList) { Console.WriteLine("Submitted Evaluations"); Console.WriteLine("---------------------------------------------"); Console.WriteLine($"Submitter: {e.Submitter} Time: {e.TimeSent}"); Console.WriteLine($"Comment: {e.Comment}"); Console.WriteLine("---------------------------------------------"); } } host.Close(); } catch (Exception e) { Console.Write(e.Message); host.Abort(); } Console.ReadLine(); }
static void Main(string[] args) { ServiceHost host = new ServiceHost(typeof(EvalService)); TimeSpan timeout = new TimeSpan(0, 0, 2); host.AddServiceEndpoint(typeof(IEvalService), new BasicHttpBinding { SendTimeout = timeout }, "http://localhost:8080/evals/basic"); host.AddServiceEndpoint(typeof(IEvalService), new WSHttpBinding(), "http://localhost:8080/evals/ws"); host.AddServiceEndpoint(typeof(IEvalService), new NetTcpBinding(), "net.tcp://localhost:8088/evals"); try { host.Open(); EvalService evalService = new EvalService(); Eval eval = new Eval { Comments = "Kommentar", Submitter = "Submitter", Timesent = DateTime.Now }; evalService.SubmitEval(eval); List <Eval> evals = evalService.GetEvals(); foreach (Eval item in evals) { Console.WriteLine($"{item.Submitter} {item.Comments} {item.Timesent}"); } Console.ReadKey(); host.Close(); } catch (Exception e) { Console.WriteLine(e); Console.ReadKey(); host.Abort(); } }
/// <summary> /// deal cards to all players /// </summary> /// <param name="deck"></param> /// <param name="cardCount"></param> public void Deal(ref List <Card> deck, short cardCount) { DeckService ds = new DeckService(); //deal hands to all the players for (short i = 0; i < cardCount; i++) { //each player gets 1 card foreach (Player p in Players) { Deal(p, ds.DealCards(ref deck, BPConstants.OneCard)); } } //eval the hand EvalService eval = new EvalService(); //each player gets 1 card foreach (Player p in Players) { p.HandRank = eval.Evaluate(p.Hand); } }
public BotOwners(EvalService evalService, LoggingService logger) { _evalService = evalService; _logger = logger; }
public EvalCommand(IClient client, EvalService eval) : base(client) { _eval = eval; }