A rhythm game net ranking service built on ATproto.
at main 98 lines 2.1 kB view raw
1using Godot; 2using System; 3using System.Threading.Tasks; 4 5public partial class Main : Control { 6 [Export] 7 public LineEdit NameField; 8 [Export] 9 public OAuth OAuth; 10 [Export] 11 public Label TokenLabel; 12 13 // Called when the node enters the scene tree for the first time. 14 public override void _Ready() { 15 if (OAuth.Authorized) { 16 TokenLabel.Text = OAuth.Token; 17 } 18 } 19 20 // Called every frame. 'delta' is the elapsed time since the previous frame. 21 public override void _Process(double delta) { 22 } 23 24 public void _OnLoginPressed() { 25 string handle = NameField.Text; 26 OAuth.Authorize(handle); 27 } 28 29 public void _OnTokenReceived() { 30 TokenLabel.Text = OAuth.Token; 31 } 32 33 public void _OnDoThingPressed() { 34 DoThisPlease(); 35 } 36 37 public async Task DoThisPlease() { 38 HttpRequest request = new(); 39 AddChild(request); 40 // string requestUrl = "http://127.0.0.1:8080/admin/graphql"; 41 string requestUrl = "http://127.0.0.1:8080/graphql"; 42 string[] headers = [ 43 $"Authorization: Bearer {OAuth.Token}", 44 "Accept: application/json", 45 "Content-Type: application/json" 46 ]; 47 string req = """ 48 mutation { 49 createDevTsunagiteScore( 50 rkey: "3mc4n5cne422d" 51 input: { 52 game: "at://lemmaeof.gay/dev.tsunagite.game/testGame", 53 song: "at://lemmaeof.gay/dev.tsunagite.song/mirinTestSong", 54 chart: "at://lemmaeof.gay/dev.tsunagite.chart/mirinTestSong-expert", 55 judgments: { 56 critPerfect: { 57 total: 32 58 } 59 perfect: { 60 total: 16 61 early: 9 62 late: 7 63 } 64 great: { 65 total: 8 66 early: 5 67 late: 3 68 } 69 good: { 70 total: 4 71 early: 3 72 late: 1 73 } 74 miss: { 75 total: 2 76 } 77 }, 78 scoreComponents: { 79 lamp: { 80 value: "pass" 81 } 82 points: { 83 value: 18000 84 } 85 accuracy: { 86 value: "85.1485" 87 } 88 } 89 } 90 ) 91 } 92 """; 93 GD.Print(QDGQL.WrapQuery(req)); 94 Error err = request.Request(requestUrl, headers, HttpClient.Method.Post, QDGQL.WrapQuery(req)); 95 HttpResult res = new(await ToSignal(request, HttpRequest.SignalName.RequestCompleted)); 96 GD.Print($"{res.Body}"); 97 } 98}