public static string Start(long uid) { //检查是否创建 if (ps.Start == false) { return(CQApi.CQCode_At(uid) + "飞花令还未创建!回复【飞花令创建】创建一场比赛"); } //检查是否开始 if (ps.Flag != "") { return(CQApi.CQCode_At(uid) + "飞花令已经开始了!"); } //检查是否发起者 if (ps.CreateUid != uid) { return(CQApi.CQCode_At(uid) + "不是创建者无法开始飞花令!\n" + CQApi.CQCode_At(uid) + "如果觉得可以开始比赛了,请回复【飞花令开始】开始比赛!"); } if (ps.Players.Count < 2) { return(CQApi.CQCode_At(uid) + "人数不足!无法开始比赛!\n请选手们回复【飞花令加入】参与!"); } ps.Flag = PoemData.GetFlag(); return($"飞花令开始!\n系统出题,关键字为【{ps.Flag}】\n请回复带有【{ps.Flag}】的诗句!\n(直接回复诗句即可)\n" + $"现在请{CQApi.CQCode_At(ps.Players[0].Uid)}首先开始回复!\n(PS:如果暂时想不出来,请回复【飞花令跳过】)"); }
public static void DelData(PoemData _pd) { SQLiteConnection conn = new SQLiteConnection($"data source={Common.CQApi.AppDirectory}\\data.db;"); conn.Open(); //写入词库 SQLiteCommand sc = new SQLiteCommand(); sc.Connection = conn; sc.CommandText += $"DELETE FROM Poem WHERE PoemKey='{_pd.Key}' and Verse='{_pd.Verse}' and Info='{_pd.Info}'"; sc.ExecuteNonQuery(); sc.Dispose(); conn.Close(); conn.Dispose(); //缓存写入 pd.Remove(pd.Where(p => p.Info == _pd.Info && p.Verse == _pd.Verse && p.Key == _pd.Key).FirstOrDefault()); }
public static void AddData(PoemData _pd) { SQLiteConnection conn = new SQLiteConnection($"data source={Common.CQApi.AppDirectory}\\data.db;"); conn.Open(); //写入词库 SQLiteCommand sc = new SQLiteCommand(); sc.Connection = conn; sc.CommandText += $"INSERT INTO Poem VALUES('{_pd.Key}','" + $"{_pd.Verse}','" + $"{_pd.Info}');"; pd.Add(new PoemData { Info = _pd.Info, Key = _pd.Key, Verse = _pd.Verse }); sc.ExecuteNonQuery(); sc.Dispose(); conn.Close(); conn.Dispose(); }
public static string Reply(string msg, long uid) { //检查是否创建 if (ps.Start == false) { return(string.Empty); //return CQApi.CQCode_At(uid) + "飞花令还未创建!回复【飞花令创建】创建一场比赛"; } //检查是否开始 if (ps.Flag == "") { return(string.Empty); //return CQApi.CQCode_At(uid) + "飞花令还未开始!" + CQApi.CQCode_At(uid) + "如果觉得可以开始比赛了,请回复【飞花令开始】开始比赛!"; } //检查是否参加 bool isJoin = false; foreach (var tmp in ps.Players) { if (tmp.Uid == uid) { isJoin = true; break; } } if (isJoin == false) { return(string.Empty); //return CQApi.CQCode_At(uid) + "你未参加本次飞花令比赛!"; } //检查当前轮玩家 int index = ps.LastPlayerIndex + 1; if (index >= ps.Players.Count) { index = 0; } if (ps.Players[index].Uid != uid) { return(string.Empty); //return CQApi.CQCode_At(uid) + "还未轮到你回复!\n现在请" + CQApi.CQCode_At(ps.Players[index].Uid) + "回复"; } //判断语句是否包含关键字 msg = msg.Replace(" ", ""); string verse = msg.StartsWith("飞花令回复") ? StrongString.GetRight(msg, "飞花令回复") : msg; if (verse.Length < 4 || verse.Length > 8 || verse.Contains(ps.Flag) == false) { return(string.Empty); //return CQApi.CQCode_At(uid) + $"诗句不包含【{ps.Flag}】!"; } //检查语句是否重复; bool isRepeat = false; foreach (var tmp in ps.Verses) { if (tmp == verse) { isRepeat = true; break; } } if (isRepeat == true) { return(CQApi.CQCode_At(uid) + "该诗句已经有人说过了!"); } //检查是否正确诗句 PoemData pd = PoemData.VerseIsExist(verse); if (pd == null) { return(CQApi.CQCode_At(uid) + "诗句数据库不包含该诗句!"); } //加入回复 ps.Verses.Add(verse); ps.Players[index].AllVerse.Add(verse); ps.Players[index].Score++; ps.Players[index].Verse = verse; ps.LastPlayerIndex = index; int nextIndex = ps.LastPlayerIndex + 1; if (nextIndex >= ps.Players.Count) { nextIndex = 0; } return(CQApi.CQCode_At(uid) + $"回复成功!\n{CQApi.CQCode_At(uid)}积分+1,当前积分{ps.Players[ps.LastPlayerIndex].Score}\n“{verse}”出自{pd.Info}" + $"\n现在请{CQApi.CQCode_At(ps.Players[nextIndex].Uid)}回复\n(直接回复诗句即可)\n(PS:如果暂时想不出来,请回复【飞花令跳过】)"); }