mirror of
https://github.com/oshima-studios/OshimaGameModule.git
synced 2025-04-22 20:09:35 +08:00
添加SC变动记录
This commit is contained in:
parent
e0d52167f1
commit
68b475c10b
@ -249,6 +249,9 @@ namespace Oshima.FunGame.OshimaServers
|
||||
case "sclist":
|
||||
msg = SCList(data);
|
||||
break;
|
||||
case "screcord":
|
||||
msg = SCRecord(data);
|
||||
break;
|
||||
case "att":
|
||||
break;
|
||||
default:
|
||||
@ -282,17 +285,26 @@ namespace Oshima.FunGame.OshimaServers
|
||||
sql.Parameters.Add("qq", qq);
|
||||
sql.Parameters.Add("group", groupid);
|
||||
sql.ExecuteDataSet();
|
||||
string content = Controller.JSON.GetObject<string>(data, "content") ?? "";
|
||||
string record = "";
|
||||
if (sql.Success)
|
||||
{
|
||||
sql.Script = "update saints set sc = sc + @sc where qq = @qq and `group` = @group";
|
||||
record = Convert.ToString(sql.DataSet.Tables[0].Rows[0]["record"]) ?? "";
|
||||
}
|
||||
record = $"{DateTime.Now:MM/dd HH:mm}:{content}({(sc < 0 ? "-" : "+") + Math.Abs(sc)})\r\n{record}";
|
||||
record = string.Join("\r\n", record.Split("\r\n", StringSplitOptions.RemoveEmptyEntries).Take(10));
|
||||
if (sql.Success)
|
||||
{
|
||||
sql.Script = "update saints set sc = sc + @sc, record = @record where qq = @qq and `group` = @group";
|
||||
}
|
||||
else
|
||||
{
|
||||
sql.Script = "insert into saints(qq, sc, `group`) values(@qq, @sc, @group)";
|
||||
sql.Script = "insert into saints(qq, sc, `group`, record) values(@qq, @sc, @group, @record)";
|
||||
}
|
||||
sql.Parameters.Add("sc", sc);
|
||||
sql.Parameters.Add("qq", qq);
|
||||
sql.Parameters.Add("group", groupid);
|
||||
sql.Parameters.Add("record", record);
|
||||
sql.Execute();
|
||||
if (sql.Success)
|
||||
{
|
||||
@ -371,12 +383,12 @@ namespace Oshima.FunGame.OshimaServers
|
||||
if (!reverse && userHas)
|
||||
{
|
||||
result += $"你的圣人点数为:{userSC} 分{(userRemark.Trim() != "" ? $"({userRemark})" : "")},排在第 {userTop} / {sql.DataSet.Tables[0].Rows.Count} 名。\r\n" +
|
||||
$"本排行榜仅供娱乐,不代表任何官方立场或真实情况";
|
||||
$"本排行榜仅供娱乐,不代表任何官方立场或真实情况。";
|
||||
}
|
||||
if (reverse && userHas)
|
||||
{
|
||||
result += $"你的出生点数为:{userSC} 分{(userRemark.Trim() != "" ? $"({userRemark})" : "")},排在出生榜第 {userTop} / {sql.DataSet.Tables[0].Rows.Count} 名。\r\n" +
|
||||
$"本排行榜仅供娱乐,不代表任何官方立场或真实情况";
|
||||
$"本排行榜仅供娱乐,不代表任何官方立场或真实情况。";
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -396,6 +408,48 @@ namespace Oshima.FunGame.OshimaServers
|
||||
return result.Trim();
|
||||
}
|
||||
|
||||
public string SCRecord(Dictionary<string, object> data)
|
||||
{
|
||||
string result = "";
|
||||
|
||||
SQLHelper? sql = Controller.SQLHelper;
|
||||
if (sql != null)
|
||||
{
|
||||
long userQQ = Controller.JSON.GetObject<long>(data, "qq");
|
||||
long groupid = Controller.JSON.GetObject<long>(data, "groupid");
|
||||
result = $"☆--- 圣人点数信息 ---☆\r\n统计时间:{DateTime.Now.ToString(General.GeneralDateTimeFormatChinese)}\r\n";
|
||||
sql.Script = "select * from saints where `group` = @group order by sc desc";
|
||||
sql.Parameters.Add("group", groupid);
|
||||
sql.Parameters.Add("qq", userQQ);
|
||||
sql.ExecuteDataSet();
|
||||
if (sql.Success && sql.DataSet.Tables.Count > 0)
|
||||
{
|
||||
Dictionary<int, DataRow> dict = sql.DataSet.Tables[0].AsEnumerable().Select((r, i) => new { Index = i + 1, Row = r }).ToDictionary(c => c.Index, c => c.Row);
|
||||
int index = dict.Where(kv => Convert.ToInt64(kv.Value["qq"]) == userQQ).Select(r => r.Key).FirstOrDefault();
|
||||
if (index != 0 && dict.TryGetValue(index, out DataRow? dr) && dr != null)
|
||||
{
|
||||
long qq = Convert.ToInt64(dr["qq"]);
|
||||
double sc = Convert.ToDouble(dr["sc"]);
|
||||
string remark = Convert.ToString(dr["remark"]) ?? "";
|
||||
string record = Convert.ToString(dr["record"]) ?? "";
|
||||
result += $"用户:{qq},圣人点数:{sc} 分{(remark.Trim() != "" ? $" ({remark})" : "")},排在圣人榜第 {index} / {sql.DataSet.Tables[0].Rows.Count} 名。\r\n" +
|
||||
$"{(record != "" ? "显示近期点数变动信息:\r\n" + record + "\r\n": "")}本系统仅供娱乐,不代表任何官方立场或真实情况。";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = "你在这个群没有任何历史记录。";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = "你在这个群没有任何历史记录。";
|
||||
}
|
||||
}
|
||||
else result = "无法调用此接口:SQL 服务不可用。";
|
||||
|
||||
return result.Trim();
|
||||
}
|
||||
|
||||
public override Task<Dictionary<string, object>> GamingMessageHandler(IServerModel model, GamingType type, Dictionary<string, object> data)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
Loading…
x
Reference in New Issue
Block a user