18 lines
1.7 KiB
Python
18 lines
1.7 KiB
Python
from pathlib import Path
|
|
def block(s,marker):
|
|
start=s.index(marker);a=s.index('{',start);n=1;b=a+1
|
|
while n:n+=(s[b]=='{')-(s[b]=='}');b+=1
|
|
return s[start:b]
|
|
s=Path('Client/Assets/Scripts/Services/ClubService.cs').read_text(encoding='utf-8-sig');m=Path('Client/Assets/Scripts/Services/ClubModel.cs').read_text(encoding='utf-8-sig')
|
|
code='using System;using System.Collections.Generic;using System.ComponentModel;using System.Threading.Tasks;using Newtonsoft.Json.Linq;\n'
|
|
code+=block(m,'public enum EMemberRole')+'\n'+'\n'.join(block(m,'public class '+x+'\n') for x in ['ClubInfo','ClubSettingData','GetSelfClubRequest','GetSelfClubResp','ClubPlayerProfile'])
|
|
code+='''
|
|
public class Subject {public User userService=new();public Server customServerMgr=new();public Chat chatService=new();public ClubInfo myClubInfo=new(){id=9};public EMemberRole memberRole=EMemberRole.Owner;public Dictionary<long,string> internalIdToPlayerId=new();public int Effects;void SetClubPlayerProfile(List<ClubPlayerProfile> p){Effects++;}void SetClubRed(){Effects++;}void MyClubInfoChange(){Effects++;}
|
|
'''+block(s,'public async void GetSelfClub()')+'\n}\n'
|
|
code+='''
|
|
public class User {public bool IsAuthorized=true;public string ApiPlayerId="101";}
|
|
public class Server {public int SessionVersion,Calls;public string Response;public GetSelfClubRequest Request;public TaskCompletionSource<string> Gate;public Task<string> ClubRequest(string path,object data){Calls++;Request=(GetSelfClubRequest)data;return Gate?.Task??Task.FromResult(Response);}}
|
|
public class Chat{public int Calls;public void GetConversationList(long id){Calls++;}}
|
|
'''
|
|
Path('CodexOutput/upserver/HomeLoginTests/Generated.cs').write_text(code)
|