@@ -14,9 +14,10 @@ public partial struct ExampleData
1414 [ SpacetimeDB . Index . BTree ]
1515 public uint Indexed ;
1616 }
17-
17+
1818 [ SpacetimeDB . Table ( Name = "Player" , Public = true ) ]
19- public partial struct Player {
19+ public partial struct Player
20+ {
2021 [ SpacetimeDB . PrimaryKey ]
2122 [ SpacetimeDB . AutoInc ]
2223 public ulong Id ;
@@ -28,16 +29,18 @@ public partial struct Player {
2829 }
2930
3031 [ SpacetimeDB . Table ( Name = "PlayerLevel" , Public = true ) ]
31- public partial struct PlayerLevel {
32+ public partial struct PlayerLevel
33+ {
3234 [ SpacetimeDB . Unique ]
3335 public ulong PlayerId ;
3436
3537 [ SpacetimeDB . Index . BTree ]
3638 public ulong Level ;
3739 }
38-
40+
3941 [ Type ]
40- public partial struct TransportData {
42+ public partial struct TransportData
43+ {
4144 public int TroopCount ;
4245 }
4346
@@ -56,7 +59,7 @@ public partial struct PlayerAndLevel
5659 {
5760 return ctx . Db . Player . Identity . Find ( ctx . Sender ) as Player ? ;
5861 }
59-
62+
6063 // Multiple rows: return a list
6164 [ SpacetimeDB . View ( Name = "PlayersForLevel" , Public = true ) ]
6265 public static List < PlayerAndLevel > PlayersForLevel ( AnonymousViewContext ctx )
@@ -96,7 +99,7 @@ public static void ThrowError(ReducerContext ctx, string error)
9699 {
97100 throw new Exception ( error ) ;
98101 }
99-
102+
100103 [ Reducer ( ReducerKind . ClientConnected ) ]
101104 public static void ClientConnected ( ReducerContext ctx )
102105 {
@@ -109,9 +112,9 @@ public static void ClientConnected(ReducerContext ctx)
109112 else
110113 {
111114 // Lets setup a new player with a level of 1
112- ctx . Db . Player . Insert ( new Player { Identity = ctx . Sender , Name = "NewPlayer" } ) ;
115+ ctx . Db . Player . Insert ( new Player { Identity = ctx . Sender , Name = "NewPlayer" } ) ;
113116 var playerId = ( ctx . Db . Player . Identity . Find ( ctx . Sender ) ! ) . Value . Id ;
114- ctx . Db . PlayerLevel . Insert ( new PlayerLevel { PlayerId = playerId , Level = 1 } ) ;
117+ ctx . Db . PlayerLevel . Insert ( new PlayerLevel { PlayerId = playerId , Level = 1 } ) ;
115118 }
116119 }
117120}
0 commit comments