private Connection Build()
 {
     Connection conn = null;
     if( this.EndpointAContent != null && this.EndpointBContent != null )
         conn = new Connection(this.RelationName, EndpointALabel, EndpointAContent, EndpointBLabel, EndpointBContent );
     else if( this.EndpointAContent == null && this.EndpointBContent != null )
         conn = new Connection(this.RelationName, EndpointBLabel, EndpointBContent, EndpointALabel, EndpointAId);
     else if (this.EndpointAContent != null && this.EndpointBContent == null)
         conn = new Connection(this.RelationName, EndpointALabel, EndpointAContent, EndpointBLabel, EndpointBId);
     else 
         conn = new Connection(this.RelationName, EndpointALabel, EndpointAId, EndpointBLabel, EndpointBId);
     return conn;
 }
Exemple #2
0
 public bool SaveGamePlayerStatus(string gameId, Player player)
 {
     if (string.IsNullOrWhiteSpace(player.GameConnectionid))
     {
         var gameConnection = Connections.GetAsync(Relations.GamePlayer, gameId, player.Id).Result;
         player.GameConnectionid = gameConnection.Id;
     }
     Connection conn = new Connection(Relations.GamePlayer, player.GameConnectionid);
     conn.Set("points", player.Points);
     conn.Set("tiles", string.Join("|", player.Tiles));
     conn.Set("isactive", player.IsActive);
     conn.Set("tiles_remaining", player.TilesRemaining);
     conn.SaveAsync();
     return true;
 }
Exemple #3
0
 public bool SetPlayerTurn(string gameId, Player player)
 {
     if (string.IsNullOrWhiteSpace(player.GameConnectionid))
     {
         var gameConnection = Connections.GetAsync(Relations.GamePlayer, gameId, player.Id).Result;
         player.GameConnectionid = gameConnection.Id;
     }
     Connection conn = new Connection(Relations.GamePlayer, player.GameConnectionid);
     conn.Set("isactive", player.IsActive);
     conn.SaveAsync();
     return true;
 }
Exemple #4
0
 public static Player ToModelPlayer(this User user, Connection gameConnection)
 {
     if (user == null)
         return null;
     Player player = new Player(user.ToModelAccount(null))
     {
         Points = gameConnection.Get<int>("points"), // Game points
         IsActive = gameConnection.Get<bool>("isactive"),
         IsHost = gameConnection.Get<bool>("ishost"),
         Tiles = gameConnection.Get<string>("tiles").Split('|').ToList(),
         TilesRemaining = gameConnection.Get<int>("tiles_remaining"),
         GameConnectionid = gameConnection.Id
     };
     return player;
 }