mirror of
https://github.com/microsoft/ai-edu.git
synced 2026-09-01 14:50:53 +08:00
@@ -0,0 +1 @@
|
||||
userinfo.txt
|
||||
@@ -5,6 +5,8 @@ VisualStudioVersion = 15.0.28307.168
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BotDemo", "BotDemo\BotDemo.csproj", "{360FBD42-7FD5-42A7-B148-E33ED486510C}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GenerationClientCode", "GenerationClientCode\GenerationClientCode.csproj", "{A06392D5-4596-4AB3-84AB-86CFBCD13DD5}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -15,6 +17,10 @@ Global
|
||||
{360FBD42-7FD5-42A7-B148-E33ED486510C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{360FBD42-7FD5-42A7-B148-E33ED486510C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{360FBD42-7FD5-42A7-B148-E33ED486510C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A06392D5-4596-4AB3-84AB-86CFBCD13DD5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A06392D5-4596-4AB3-84AB-86CFBCD13DD5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A06392D5-4596-4AB3-84AB-86CFBCD13DD5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A06392D5-4596-4AB3-84AB-86CFBCD13DD5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
//----------------------
|
||||
// <auto-generated>
|
||||
// Generated using the NSwag toolchain v12.0.11.0 (NJsonSchema v9.13.13.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org)
|
||||
// Generated using the NSwag toolchain v12.0.15.0 (NJsonSchema v9.13.22.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org)
|
||||
// </auto-generated>
|
||||
//----------------------
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace GoldenNumber
|
||||
{
|
||||
#pragma warning disable
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCode("NSwag", "12.0.11.0 (NJsonSchema v9.13.13.0 (Newtonsoft.Json v9.0.0.0))")]
|
||||
[System.CodeDom.Compiler.GeneratedCode("NSwag", "12.0.15.0 (NJsonSchema v9.13.22.0 (Newtonsoft.Json v9.0.0.0))")]
|
||||
public partial class GoldenNumberService
|
||||
{
|
||||
private string _baseUrl = "https://goldennumber.aiedu.msra.cn";
|
||||
@@ -148,9 +148,9 @@ namespace GoldenNumber
|
||||
/// <param name="uid">User ID</param>
|
||||
/// <param name="nickName">User nickname, length greater than 20 will be truncated</param>
|
||||
/// <exception cref="SwaggerException">A server side error occurred.</exception>
|
||||
public System.Threading.Tasks.Task<UserRspModel> SetNickNameAsync(string uid, string nickName)
|
||||
public System.Threading.Tasks.Task<UserRspModel> NickNameAsync(string uid, string nickName)
|
||||
{
|
||||
return SetNickNameAsync(uid, nickName, System.Threading.CancellationToken.None);
|
||||
return NickNameAsync(uid, nickName, System.Threading.CancellationToken.None);
|
||||
}
|
||||
|
||||
/// <summary>Set nickname</summary>
|
||||
@@ -158,7 +158,7 @@ namespace GoldenNumber
|
||||
/// <param name="nickName">User nickname, length greater than 20 will be truncated</param>
|
||||
/// <exception cref="SwaggerException">A server side error occurred.</exception>
|
||||
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
|
||||
public async System.Threading.Tasks.Task<UserRspModel> SetNickNameAsync(string uid, string nickName, System.Threading.CancellationToken cancellationToken)
|
||||
public async System.Threading.Tasks.Task<UserRspModel> NickNameAsync(string uid, string nickName, System.Threading.CancellationToken cancellationToken)
|
||||
{
|
||||
var urlBuilder_ = new System.Text.StringBuilder();
|
||||
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/NickName?");
|
||||
@@ -495,9 +495,9 @@ namespace GoldenNumber
|
||||
/// <param name="roomid">Room ID
|
||||
/// If this parameter is empty, use the default room 0</param>
|
||||
/// <exception cref="SwaggerException">A server side error occurred.</exception>
|
||||
public System.Threading.Tasks.Task<StateRspModel> GetStateAsync(string uid, int? roomid)
|
||||
public System.Threading.Tasks.Task<StateRspModel> StateAsync(string uid, int? roomid)
|
||||
{
|
||||
return GetStateAsync(uid, roomid, System.Threading.CancellationToken.None);
|
||||
return StateAsync(uid, roomid, System.Threading.CancellationToken.None);
|
||||
}
|
||||
|
||||
/// <summary>Get game status</summary>
|
||||
@@ -506,7 +506,7 @@ namespace GoldenNumber
|
||||
/// If this parameter is empty, use the default room 0</param>
|
||||
/// <exception cref="SwaggerException">A server side error occurred.</exception>
|
||||
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
|
||||
public async System.Threading.Tasks.Task<StateRspModel> GetStateAsync(string uid, int? roomid, System.Threading.CancellationToken cancellationToken)
|
||||
public async System.Threading.Tasks.Task<StateRspModel> StateAsync(string uid, int? roomid, System.Threading.CancellationToken cancellationToken)
|
||||
{
|
||||
var urlBuilder_ = new System.Text.StringBuilder();
|
||||
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/State?");
|
||||
@@ -717,9 +717,9 @@ namespace GoldenNumber
|
||||
/// <param name="roomid">Room ID
|
||||
/// If this parameter is empty, use the default room 0</param>
|
||||
/// <exception cref="SwaggerException">A server side error occurred.</exception>
|
||||
public System.Threading.Tasks.Task<TodayGoldenListRspModel> GetTodayGoldenListAsync(int? roomid)
|
||||
public System.Threading.Tasks.Task<TodayGoldenListRspModel> TodayGoldenListAsync(int? roomid)
|
||||
{
|
||||
return GetTodayGoldenListAsync(roomid, System.Threading.CancellationToken.None);
|
||||
return TodayGoldenListAsync(roomid, System.Threading.CancellationToken.None);
|
||||
}
|
||||
|
||||
/// <summary>Get history of golden numbers</summary>
|
||||
@@ -727,7 +727,7 @@ namespace GoldenNumber
|
||||
/// If this parameter is empty, use the default room 0</param>
|
||||
/// <exception cref="SwaggerException">A server side error occurred.</exception>
|
||||
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
|
||||
public async System.Threading.Tasks.Task<TodayGoldenListRspModel> GetTodayGoldenListAsync(int? roomid, System.Threading.CancellationToken cancellationToken)
|
||||
public async System.Threading.Tasks.Task<TodayGoldenListRspModel> TodayGoldenListAsync(int? roomid, System.Threading.CancellationToken cancellationToken)
|
||||
{
|
||||
var urlBuilder_ = new System.Text.StringBuilder();
|
||||
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/TodayGoldenList?");
|
||||
@@ -817,9 +817,9 @@ namespace GoldenNumber
|
||||
/// <param name="roomid">Room ID
|
||||
/// If this parameter is empty, use the default room 0</param>
|
||||
/// <exception cref="SwaggerException">A server side error occurred.</exception>
|
||||
public System.Threading.Tasks.Task<TodayNumbersRspModel> GetTodayNumbersAsync(int? roomid)
|
||||
public System.Threading.Tasks.Task<TodayNumbersRspModel> TodayNumbersAsync(int? roomid)
|
||||
{
|
||||
return GetTodayNumbersAsync(roomid, System.Threading.CancellationToken.None);
|
||||
return TodayNumbersAsync(roomid, System.Threading.CancellationToken.None);
|
||||
}
|
||||
|
||||
/// <summary>Get history numbers submitted by players</summary>
|
||||
@@ -827,7 +827,7 @@ namespace GoldenNumber
|
||||
/// If this parameter is empty, use the default room 0</param>
|
||||
/// <exception cref="SwaggerException">A server side error occurred.</exception>
|
||||
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
|
||||
public async System.Threading.Tasks.Task<TodayNumbersRspModel> GetTodayNumbersAsync(int? roomid, System.Threading.CancellationToken cancellationToken)
|
||||
public async System.Threading.Tasks.Task<TodayNumbersRspModel> TodayNumbersAsync(int? roomid, System.Threading.CancellationToken cancellationToken)
|
||||
{
|
||||
var urlBuilder_ = new System.Text.StringBuilder();
|
||||
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/TodayNumbers?");
|
||||
@@ -917,9 +917,9 @@ namespace GoldenNumber
|
||||
/// <param name="roomid">Room ID
|
||||
/// If this parameter is empty, use the default room 0</param>
|
||||
/// <exception cref="SwaggerException">A server side error occurred.</exception>
|
||||
public System.Threading.Tasks.Task<TodayScoreRspModel> GetTodayScoreAsync(int? roomid)
|
||||
public System.Threading.Tasks.Task<TodayScoreRspModel> TodayScoreAsync(int? roomid)
|
||||
{
|
||||
return GetTodayScoreAsync(roomid, System.Threading.CancellationToken.None);
|
||||
return TodayScoreAsync(roomid, System.Threading.CancellationToken.None);
|
||||
}
|
||||
|
||||
/// <summary>Get players' score</summary>
|
||||
@@ -927,7 +927,7 @@ namespace GoldenNumber
|
||||
/// If this parameter is empty, use the default room 0</param>
|
||||
/// <exception cref="SwaggerException">A server side error occurred.</exception>
|
||||
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
|
||||
public async System.Threading.Tasks.Task<TodayScoreRspModel> GetTodayScoreAsync(int? roomid, System.Threading.CancellationToken cancellationToken)
|
||||
public async System.Threading.Tasks.Task<TodayScoreRspModel> TodayScoreAsync(int? roomid, System.Threading.CancellationToken cancellationToken)
|
||||
{
|
||||
var urlBuilder_ = new System.Text.StringBuilder();
|
||||
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/TodayScore?");
|
||||
@@ -1024,9 +1024,9 @@ namespace GoldenNumber
|
||||
/// The default value is 0, indicating that the old historical data is queried from the round startid.
|
||||
/// Another value is 1, indicating that the newer data is queried from the round startrid</param>
|
||||
/// <exception cref="SwaggerException">A server side error occurred.</exception>
|
||||
public System.Threading.Tasks.Task<HistoryRspModel> GetHistoryAsync(int? roomid, string startrid, int? count, int? direction)
|
||||
public System.Threading.Tasks.Task<HistoryRspModel> HistoryAsync(int? roomid, string startrid, int? count, int? direction)
|
||||
{
|
||||
return GetHistoryAsync(roomid, startrid, count, direction, System.Threading.CancellationToken.None);
|
||||
return HistoryAsync(roomid, startrid, count, direction, System.Threading.CancellationToken.None);
|
||||
}
|
||||
|
||||
/// <summary>Get pagination history data</summary>
|
||||
@@ -1041,7 +1041,7 @@ namespace GoldenNumber
|
||||
/// Another value is 1, indicating that the newer data is queried from the round startrid</param>
|
||||
/// <exception cref="SwaggerException">A server side error occurred.</exception>
|
||||
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
|
||||
public async System.Threading.Tasks.Task<HistoryRspModel> GetHistoryAsync(int? roomid, string startrid, int? count, int? direction, System.Threading.CancellationToken cancellationToken)
|
||||
public async System.Threading.Tasks.Task<HistoryRspModel> HistoryAsync(int? roomid, string startrid, int? count, int? direction, System.Threading.CancellationToken cancellationToken)
|
||||
{
|
||||
var urlBuilder_ = new System.Text.StringBuilder();
|
||||
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/History?");
|
||||
@@ -1177,7 +1177,7 @@ namespace GoldenNumber
|
||||
|
||||
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.13.0 (Newtonsoft.Json v9.0.0.0)")]
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.22.0 (Newtonsoft.Json v9.0.0.0)")]
|
||||
public partial class UserRspModel
|
||||
{
|
||||
/// <summary>User ID in the format of Guid</summary>
|
||||
@@ -1200,7 +1200,7 @@ namespace GoldenNumber
|
||||
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.13.0 (Newtonsoft.Json v9.0.0.0)")]
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.22.0 (Newtonsoft.Json v9.0.0.0)")]
|
||||
public partial class BadRequestRspModel
|
||||
{
|
||||
/// <summary>Error message</summary>
|
||||
@@ -1219,7 +1219,7 @@ namespace GoldenNumber
|
||||
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.13.0 (Newtonsoft.Json v9.0.0.0)")]
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.22.0 (Newtonsoft.Json v9.0.0.0)")]
|
||||
public partial class NewRoomRspModel
|
||||
{
|
||||
/// <summary>Room ID</summary>
|
||||
@@ -1238,7 +1238,7 @@ namespace GoldenNumber
|
||||
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.13.0 (Newtonsoft.Json v9.0.0.0)")]
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.22.0 (Newtonsoft.Json v9.0.0.0)")]
|
||||
public partial class BaseRspModel
|
||||
{
|
||||
/// <summary>The current round ID in the current room</summary>
|
||||
@@ -1267,7 +1267,7 @@ namespace GoldenNumber
|
||||
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.13.0 (Newtonsoft.Json v9.0.0.0)")]
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.22.0 (Newtonsoft.Json v9.0.0.0)")]
|
||||
public partial class StateRspModel : BaseRspModel
|
||||
{
|
||||
/// <summary>User ID</summary>
|
||||
@@ -1336,7 +1336,7 @@ namespace GoldenNumber
|
||||
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.13.0 (Newtonsoft.Json v9.0.0.0)")]
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.22.0 (Newtonsoft.Json v9.0.0.0)")]
|
||||
public partial class SubmitRspModel
|
||||
{
|
||||
public string ToJson()
|
||||
@@ -1351,7 +1351,7 @@ namespace GoldenNumber
|
||||
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.13.0 (Newtonsoft.Json v9.0.0.0)")]
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.22.0 (Newtonsoft.Json v9.0.0.0)")]
|
||||
public partial class TodayGoldenListRspModel
|
||||
{
|
||||
/// <summary>Room ID</summary>
|
||||
@@ -1374,7 +1374,7 @@ namespace GoldenNumber
|
||||
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.13.0 (Newtonsoft.Json v9.0.0.0)")]
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.22.0 (Newtonsoft.Json v9.0.0.0)")]
|
||||
public partial class TodayNumbersRspModel
|
||||
{
|
||||
/// <summary>Room ID</summary>
|
||||
@@ -1403,7 +1403,7 @@ namespace GoldenNumber
|
||||
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.13.0 (Newtonsoft.Json v9.0.0.0)")]
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.22.0 (Newtonsoft.Json v9.0.0.0)")]
|
||||
public partial class UserNumber
|
||||
{
|
||||
/// <summary>User index number, the same user index number indicates the number submitted by the same user in different rounds</summary>
|
||||
@@ -1434,13 +1434,18 @@ namespace GoldenNumber
|
||||
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.13.0 (Newtonsoft.Json v9.0.0.0)")]
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.22.0 (Newtonsoft.Json v9.0.0.0)")]
|
||||
public partial class TodayScoreRspModel
|
||||
{
|
||||
/// <summary>Player score list</summary>
|
||||
[Newtonsoft.Json.JsonProperty("scoreList", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
|
||||
public System.Collections.Generic.ICollection<UserScore> ScoreList { get; set; }
|
||||
|
||||
/// <summary>Date</summary>
|
||||
[Newtonsoft.Json.JsonProperty("date", Required = Newtonsoft.Json.Required.Always)]
|
||||
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
|
||||
public System.DateTimeOffset Date { get; set; }
|
||||
|
||||
public string ToJson()
|
||||
{
|
||||
return Newtonsoft.Json.JsonConvert.SerializeObject(this);
|
||||
@@ -1453,7 +1458,7 @@ namespace GoldenNumber
|
||||
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.13.0 (Newtonsoft.Json v9.0.0.0)")]
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.22.0 (Newtonsoft.Json v9.0.0.0)")]
|
||||
public partial class UserScore
|
||||
{
|
||||
/// <summary>User ID</summary>
|
||||
@@ -1484,7 +1489,7 @@ namespace GoldenNumber
|
||||
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.13.0 (Newtonsoft.Json v9.0.0.0)")]
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.22.0 (Newtonsoft.Json v9.0.0.0)")]
|
||||
public partial class HistoryRspModel
|
||||
{
|
||||
/// <summary>Array of rounds</summary>
|
||||
@@ -1508,7 +1513,7 @@ namespace GoldenNumber
|
||||
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.13.0 (Newtonsoft.Json v9.0.0.0)")]
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.22.0 (Newtonsoft.Json v9.0.0.0)")]
|
||||
public partial class RoundNumbers
|
||||
{
|
||||
/// <summary>Round ID</summary>
|
||||
@@ -1544,7 +1549,7 @@ namespace GoldenNumber
|
||||
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.13.0 (Newtonsoft.Json v9.0.0.0)")]
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.22.0 (Newtonsoft.Json v9.0.0.0)")]
|
||||
public partial class UserNumber2
|
||||
{
|
||||
/// <summary>User ID</summary>
|
||||
@@ -1575,7 +1580,7 @@ namespace GoldenNumber
|
||||
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCode("NSwag", "12.0.11.0 (NJsonSchema v9.13.13.0 (Newtonsoft.Json v9.0.0.0))")]
|
||||
[System.CodeDom.Compiler.GeneratedCode("NSwag", "12.0.15.0 (NJsonSchema v9.13.22.0 (Newtonsoft.Json v9.0.0.0))")]
|
||||
public partial class SwaggerException : System.Exception
|
||||
{
|
||||
public int StatusCode { get; private set; }
|
||||
@@ -1598,7 +1603,7 @@ namespace GoldenNumber
|
||||
}
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCode("NSwag", "12.0.11.0 (NJsonSchema v9.13.13.0 (Newtonsoft.Json v9.0.0.0))")]
|
||||
[System.CodeDom.Compiler.GeneratedCode("NSwag", "12.0.15.0 (NJsonSchema v9.13.22.0 (Newtonsoft.Json v9.0.0.0))")]
|
||||
public partial class SwaggerException<TResult> : SwaggerException
|
||||
{
|
||||
public TResult Result { get; private set; }
|
||||
|
||||
@@ -5,6 +5,7 @@ using GoldenNumber;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
@@ -16,12 +17,19 @@ namespace BotDemo
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Input room id: ");
|
||||
string inputRoomId = Console.ReadLine();
|
||||
int roomId = 0;
|
||||
if (!int.TryParse(inputRoomId, out roomId))
|
||||
|
||||
// Read roomid from args --room
|
||||
var index = args.ToList().FindIndex(item => item.Equals("--room", StringComparison.OrdinalIgnoreCase));
|
||||
if (index < 0 || args.Length <= index + 1 || !int.TryParse(args[index + 1], out roomId))
|
||||
{
|
||||
Console.WriteLine("Parse room id failed, default join in to room 0");
|
||||
// Input the roomid if there is no roomid in args
|
||||
Console.WriteLine("Input room id: ");
|
||||
string inputRoomId = Console.ReadLine();
|
||||
if (!int.TryParse(inputRoomId, out roomId))
|
||||
{
|
||||
Console.WriteLine("Parse room id failed, default join in to room 0");
|
||||
}
|
||||
}
|
||||
|
||||
RunBot(roomId).Wait();
|
||||
@@ -57,21 +65,40 @@ namespace BotDemo
|
||||
static async Task RunBot(int roomId)
|
||||
{
|
||||
GoldenNumberService service = new GoldenNumberService(new HttpClient());
|
||||
service.BaseUrl = "https://goldennumber.aiedu.msra.cn/";
|
||||
service.BaseUrl = "https://goldennumber.aiedu.msra.cn";
|
||||
|
||||
try
|
||||
{
|
||||
// Create a player
|
||||
var user = await service.NewUserAsync($"AI Player {new Random().Next() % 10000}");
|
||||
var userId = user.UserId;
|
||||
Console.WriteLine($"Player: {user.NickName} Id: {user.UserId}");
|
||||
var userInfoFile = "userinfo.txt";
|
||||
var userId = string.Empty;
|
||||
var nickName = string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
// Use an exist player
|
||||
var userInfo = File.ReadAllText(userInfoFile).Split(',');
|
||||
userId = userInfo[0];
|
||||
nickName = userInfo[1];
|
||||
|
||||
Console.WriteLine($"Use an exist player: {nickName} Id: {userId}");
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Create a new player
|
||||
var user = await service.NewUserAsync($"AI Player {new Random().Next() % 10000}");
|
||||
userId = user.UserId;
|
||||
nickName = user.NickName;
|
||||
Console.WriteLine($"Create a new player: {nickName} Id: {userId}");
|
||||
|
||||
File.WriteAllText(userInfoFile, $"{userId},{nickName}");
|
||||
}
|
||||
|
||||
Console.WriteLine($"Room id: {roomId}");
|
||||
|
||||
while (true)
|
||||
{
|
||||
// Get the room state
|
||||
var state = await service.GetStateAsync(userId, roomId);
|
||||
var state = await service.StateAsync(userId, roomId);
|
||||
|
||||
if (state.State == 2)
|
||||
{
|
||||
@@ -101,10 +128,10 @@ namespace BotDemo
|
||||
continue;
|
||||
}
|
||||
|
||||
Console.WriteLine($"This is round {state.FinishedRoundCount + 1}");
|
||||
Console.WriteLine($"\r\nThis is round {state.FinishedRoundCount + 1}");
|
||||
|
||||
// Get history of golden numbers
|
||||
var todayGoldenList = await service.GetTodayGoldenListAsync(roomId);
|
||||
var todayGoldenList = await service.TodayGoldenListAsync(roomId);
|
||||
|
||||
if (todayGoldenList.GoldenNumberList.Count != 0)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||
</startup>
|
||||
</configuration>
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{A06392D5-4596-4AB3-84AB-86CFBCD13DD5}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>GenerationClientCode</RootNamespace>
|
||||
<AssemblyName>GenerationClientCode</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="DotLiquid, Version=2.0.254.0, Culture=neutral, PublicKeyToken=82e46016ecf9f07c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\DotLiquid.2.0.254\lib\net45\DotLiquid.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NJsonSchema, Version=9.13.22.0, Culture=neutral, PublicKeyToken=c2f9c3bdfae56102, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NJsonSchema.9.13.22\lib\net45\NJsonSchema.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NJsonSchema.CodeGeneration, Version=9.13.22.0, Culture=neutral, PublicKeyToken=c2f9c3bdfae56102, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NJsonSchema.CodeGeneration.9.13.22\lib\net451\NJsonSchema.CodeGeneration.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NJsonSchema.CodeGeneration.CSharp, Version=9.13.22.0, Culture=neutral, PublicKeyToken=c2f9c3bdfae56102, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NJsonSchema.CodeGeneration.CSharp.9.13.22\lib\net451\NJsonSchema.CodeGeneration.CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NSwag.CodeGeneration, Version=12.0.15.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NSwag.CodeGeneration.12.0.15\lib\net451\NSwag.CodeGeneration.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NSwag.CodeGeneration.CSharp, Version=12.0.15.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NSwag.CodeGeneration.CSharp.12.0.15\lib\net451\NSwag.CodeGeneration.CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NSwag.Core, Version=12.0.15.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NSwag.Core.12.0.15\lib\net45\NSwag.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Net" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,43 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using NSwag;
|
||||
using NSwag.CodeGeneration.CSharp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GenerationClientCode
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Generate().Wait();
|
||||
}
|
||||
|
||||
static async Task Generate()
|
||||
{
|
||||
var document = await SwaggerDocument.FromUrlAsync("https://goldennumber.aiedu.msra.cn/swagger/v1%20-%20English/swagger.json");
|
||||
|
||||
var settings = new SwaggerToCSharpClientGeneratorSettings
|
||||
{
|
||||
ClassName = "GoldenNumberService",
|
||||
CSharpGeneratorSettings =
|
||||
{
|
||||
Namespace = "GoldenNumber"
|
||||
}
|
||||
};
|
||||
|
||||
var generator = new SwaggerToCSharpClientGenerator(document, settings);
|
||||
var code = generator.GenerateFile();
|
||||
|
||||
var copyright = "// Copyright (c) Microsoft. All rights reserved.\r\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\r\n\r\n";
|
||||
|
||||
File.WriteAllText("GoldenNumberService.cs", copyright + code.Replace("\r\n", "\n").Replace("\n", "\r\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("GenerationClientCode")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("GenerationClientCode")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2019")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("a06392d5-4596-4ab3-84ab-86cfbcd13dd5")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
|
||||
// 方法是按如下所示使用“*”: :
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="DotLiquid" version="2.0.254" targetFramework="net461" />
|
||||
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net461" />
|
||||
<package id="NJsonSchema" version="9.13.22" targetFramework="net461" />
|
||||
<package id="NJsonSchema.CodeGeneration" version="9.13.22" targetFramework="net461" />
|
||||
<package id="NJsonSchema.CodeGeneration.CSharp" version="9.13.22" targetFramework="net461" />
|
||||
<package id="NSwag.CodeGeneration" version="12.0.15" targetFramework="net461" />
|
||||
<package id="NSwag.CodeGeneration.CSharp" version="12.0.15" targetFramework="net461" />
|
||||
<package id="NSwag.Core" version="12.0.15" targetFramework="net461" />
|
||||
</packages>
|
||||
@@ -7,6 +7,7 @@ from pyswagger.contrib.client.requests import Client
|
||||
|
||||
import random
|
||||
import time
|
||||
import argparse
|
||||
|
||||
def GeneratePredictionNumbers(goldenNumberList, numberCount):
|
||||
number1 = 0.0
|
||||
@@ -26,34 +27,50 @@ def GeneratePredictionNumbers(goldenNumberList, numberCount):
|
||||
return number1, number2
|
||||
|
||||
|
||||
def main():
|
||||
def main(roomId):
|
||||
host = 'https://goldennumber.aiedu.msra.cn/'
|
||||
jsonpath = '/swagger/v1/swagger.json'
|
||||
|
||||
app = App._create_(host + jsonpath)
|
||||
client = Client()
|
||||
|
||||
roomId = input("Input room id: ")
|
||||
if not roomId:
|
||||
# Input the roomid if there is no roomid in args
|
||||
roomId = input("Input room id: ")
|
||||
try:
|
||||
roomId = int(roomId)
|
||||
except:
|
||||
roomId = 0
|
||||
print('Parse room id failed, default join in to room 0')
|
||||
|
||||
userInfoFile = "userinfo.txt"
|
||||
userId = None
|
||||
nickName = None
|
||||
try:
|
||||
roomId = int(roomId)
|
||||
# Use an exist player
|
||||
with open(userInfoFile) as f:
|
||||
userId, nickName = f.read().split(',')[:2]
|
||||
print('Use an exist player: ' + nickName + ' Id: ' + userId)
|
||||
except:
|
||||
roomId = 0
|
||||
print('Parse room id failed, default join in to room 0')
|
||||
# Create a new player
|
||||
userResp = client.request(
|
||||
app.op['NewUser'](
|
||||
nickName='AI Player ' + str(random.randint(0, 9999))
|
||||
))
|
||||
assert userResp.status == 200
|
||||
user = userResp.data
|
||||
userId = user.userId
|
||||
nickName = user.nickName
|
||||
print('Create a new player: ' + nickName + ' Id: ' + userId)
|
||||
|
||||
userResp = client.request(
|
||||
app.op['Default_NewUser'](
|
||||
nickName='AI Player ' + str(random.randint(0, 9999))
|
||||
))
|
||||
assert userResp.status == 200
|
||||
user = userResp.data
|
||||
userId = user.userId
|
||||
with open(userInfoFile, "w") as f:
|
||||
f.write("%s,%s" % (userId, nickName))
|
||||
|
||||
print('Player: ' + user.nickName + ' Id: ' + userId)
|
||||
print('Room id: ' + str(roomId))
|
||||
|
||||
while True:
|
||||
stateResp = client.request(
|
||||
app.op['Default_GetState'](
|
||||
app.op['State'](
|
||||
uid=userId,
|
||||
roomid=roomId
|
||||
))
|
||||
@@ -78,10 +95,10 @@ def main():
|
||||
time.sleep(1)
|
||||
continue
|
||||
|
||||
print('This is round ' + str(state.finishedRoundCount + 1))
|
||||
print('\r\nThis is round ' + str(state.finishedRoundCount + 1))
|
||||
|
||||
todayGoldenListResp = client.request(
|
||||
app.op['Default_GetTodayGoldenList'](
|
||||
app.op['TodayGoldenList'](
|
||||
roomid=roomId
|
||||
))
|
||||
assert todayGoldenListResp.status == 200
|
||||
@@ -93,7 +110,7 @@ def main():
|
||||
|
||||
if (state.numbers == 2):
|
||||
submitRsp = client.request(
|
||||
app.op['Default_Submit'](
|
||||
app.op['Submit'](
|
||||
uid=userId,
|
||||
rid=state.roundId,
|
||||
n1=str(number1),
|
||||
@@ -106,7 +123,7 @@ def main():
|
||||
|
||||
else:
|
||||
submitRsp = client.request(
|
||||
app.op['Default_Submit'](
|
||||
app.op['Submit'](
|
||||
uid=userId,
|
||||
rid=state.roundId,
|
||||
n1=str(number1)
|
||||
@@ -118,4 +135,9 @@ def main():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--room', type=int, help='Room ID', required=False)
|
||||
args = parser.parse_args()
|
||||
|
||||
main(args.room)
|
||||
Reference in New Issue
Block a user