public ServerResponseInfo <bool, Exception, CellContent[][]> PostRadarActivatedAsync([FromBody] string i_info) { List <string> deserialized = i_info.DeserializeObject <List <string> >(); IGameManagerActor actor = ActorProxy.Create <IGameManagerActor>(new ActorId(deserialized[0])); return(actor.RadarActivatedAsync(deserialized[1]).Result); }
public ServerResponseInfo <bool, Exception> PostPlayerAttacksAsync([FromBody] string i_info) { List <string> deserialized = i_info.DeserializeObject <List <string> >(); IGameManagerActor actor = ActorProxy.Create <IGameManagerActor>(new ActorId(deserialized[0])); return(actor.PlayerAttacksAsync(deserialized[1]).Result); }
public void PostPlayerStillConnectedAsync([FromBody] string i_info) { List <string> deserialized = i_info.DeserializeObject <List <string> >(); IGameManagerActor actor = ActorProxy.Create <IGameManagerActor>(new ActorId(deserialized[0])); actor.PlayerStillConnectedAsync(deserialized[1]).Wait(); }
/// <summary> /// Creates a new game session on the server /// </summary> /// <param name="i_gameDef">Game session definition</param> /// <returns>True if game session was able to be created, false otherwise</returns> public async Task <ServerResponseInfo <bool, Exception> > CreateGameAsync(string i_gameId, int i_maxPlayers) { ServerResponseInfo <bool, Exception> res = new ServerResponseInfo <bool, Exception>(); try { //Connects to the SQL Server and close when exiting using (SqlConnection connection = new SqlConnection(builder.ConnectionString)) { //Opens SQL connection connection.Open(); //Creates query string string query = "INSERT INTO Games VALUES('" + i_gameId + "'," + i_maxPlayers + "," + 0 + ")"; //Creates SQL Command using query and connection using (SqlCommand command = new SqlCommand(query, connection)) { //Executes command command.ExecuteNonQuery(); } } //Creates game actor IGameManagerActor actor = ActorProxy.Create <IGameManagerActor>(new ActorId(i_gameId)); //Initializes game actor await actor.InitializeGameAsync(i_maxPlayers); //Returns true res.info = true; return(res); } //If exception caught catch (Exception e) { //REMOVE GAME //Returns false with exception res.info = false; res.exception = e; return(res); } }
public void PostUpdateLobbyInfoAsync([FromBody] string i_gameId) { IGameManagerActor actor = ActorProxy.Create <IGameManagerActor>(new ActorId(i_gameId)); actor.UpdateLobbyInfoAsync().Wait(); }