internal GameAPI(long group, long qqID, MiraiHttpSession Session) { this.Session = Session; groupPath = "com.coc.groupadmin\\" + group; MemberFile = "com.coc.groupadmin\\" + group + "\\" + qqID + ".bin"; if (!Directory.Exists(groupPath)) { Directory.CreateDirectory(groupPath); } if (!File.Exists(MemberFile)) { var Member = new GroupMemberInfo() { GroupId = group, QQId = qqID, Card = Session.GetGroupMemberInfoAsync(qqID, group).Result.Name }; GameMember gameMember; gameMember = new GameMember { Member = Member, Cash = 100, Exp = 100, Work = Work.给野蛮人刷背, Checked = DateTime.MinValue, Combo = 0, CurrentHP = 100, weapon = new None(), Robbed = DateTime.MinValue, PlayTime = DateTime.MinValue }; var writer = new XmlSerializer(typeof(GameMember)); using StreamWriter stream = new StreamWriter(MemberFile); writer.Serialize(stream, gameMember); } else { //Weird error if (File.ReadAllText(MemberFile).Contains("</GameMember>d>")) { File.WriteAllText(MemberFile, File.ReadAllText(MemberFile).Replace("</GameMember>d>", "")); } } try { XmlSerializer reader = new XmlSerializer(typeof(GameMember)); using (FileStream stream = new FileStream(MemberFile, FileMode.Open)) { this.Member = (GameMember)reader.Deserialize(stream); } foreach (Type type in Assembly.GetAssembly(typeof(Element)).GetTypes().Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(Element)))) { elements.Add((Element)Activator.CreateInstance(type)); } } catch (Exception ex) { Session.SendGroupMessage(group, new PlainMessage(qqID + "资料损毁,错误资料:" + ex.Message)); } }