protected override void InitSource() { lock (matchMutex) { try { money = BOT.getMoneyManager(); var lines = FileHelper.readLines(PluginPath + userinfoFile); foreach (var line in lines) { RHUser user = new RHUser(); user.parse(line); users[user.id] = user; } lines = FileHelper.readLines(PluginPath + horseinfoFile); foreach (var line in lines) { RHHorse horse = new RHHorse(line); horses[horse.name] = horse; } } catch (Exception e) { FileHelper.Log(e.Message + "\r\n" + e.StackTrace); } } }
/// <summary> /// 个人赌马记录 /// </summary> /// <param name="userqq"></param> /// <returns></returns> public string getRHInfo(long userqq) { if (!users.ContainsKey(userqq)) { users[userqq] = new RHUser(userqq); } var u = users[userqq]; return($"您在赌马上消费过{u.hrmoney}枚{moneyName()},共下注{u.losetime + u.wintime}场,赢{u.wintime}场,胜率{Math.Round(u.getWinPercent(), 2)}%"); //outputMessage(group, userqq, $"您在赌马上消费过{u.hrmoney}枚{BTCActor.unitName},共下注{u.losetime+u.wintime}场,赢{u.wintime}场,胜率{Math.Round(u.getWinPercent(), 2)}%"); }
/// <summary> /// 下注 /// </summary> /// <param name="matchid"></param> /// <param name="user"></param> /// <param name="road"></param> /// <param name="money"></param> public bool addBet(long matchid, RHUser user, int road, long money) { try { if (matches.ContainsKey(matchid)) { string res = matches[matchid].bet(user, road, money); if (!string.IsNullOrWhiteSpace(res)) { showMessage(matchid, user.id, res); return(true); } } } catch (Exception ex) { FileHelper.Log(ex); } return(false); }
/// <summary> /// 下注 /// </summary> /// <param name="user"></param> /// <param name="roadnum"></param> /// <param name="money"></param> /// <returns></returns> public string bet(RHUser user, int roadnum, long money) { try { int maxbet = 2; if (status != RHStatus.Bet || money <= 0) { return(""); } var betuser = context.getUser(user.id); //ra.btc.getUser(user.userid); if (user == null) { return(""); } if (roadnum <= 0 || roadnum > this.roadnum) { return($"在?没有第{roadnum}条赛道"); } if (context.getMoney(betuser) <= 0) { return($"一分钱都没有,下你🐎的注呢?"); } if (!bets.ContainsKey(user)) { bets[user] = new Dictionary <int, long>(); } if (bets[user].Keys.Count >= maxbet && !bets[user].ContainsKey(roadnum)) { return($"最多押{maxbet}匹,你已经押了{string.Join("、", bets[user].Keys)}。"); } string res = ""; if (money >= context.getMoney(betuser)) { money = context.getMoney(betuser); res = $"all in!把手上的{money}枚{context.moneyName()}都押了{roadnum}号马"; } else { res = $"成功在{roadnum}号马下注{money}枚{context.moneyName()}"; } context.changeMoney(betuser, -1 * money); user.hrmoney += (ulong)money; if (!bets[user].ContainsKey(roadnum)) { bets[user][roadnum] = 0; } bets[user][roadnum] += money; res += $",账户余额{context.getMoney(betuser)}"; return(res); } catch (Exception ex) { FileHelper.Log(ex); return($"ERROR:{ex.Message}"); } }
public string getNickName(RHUser user) { return(money.getUser(user.id).UserName); }
public override bool HandleMessage(Message msg) { try { string cmd = BOT.getAskCmd(msg); if (string.IsNullOrWhiteSpace(cmd)) { return(false); } bool isGroup = msg.fromGroup > 0 ? true : false; //string uid = msg.from.ToString(); long group = msg.fromGroup; if (!users.ContainsKey(msg.from)) { users[msg.from] = new RHUser(msg.from); } RHUser user = users[msg.from]; //BOT.log("赛马 "+cmd); if (cmd == "赛马介绍" || cmd == "赛马玩法" || cmd == "赛马说明") { msg.str = getIntroduction(); BOT.sendBack(msg); return(true); } if (cmd == "富豪榜" || cmd == "富人榜") { string res = BOT.getMoneyManager().showRichest(); if (!string.IsNullOrWhiteSpace(res)) { msg.str = res; BOT.sendBack(msg); return(true); } } if (cmd == "穷人榜") { string res = BOT.getMoneyManager().showPoorest(); if (!string.IsNullOrWhiteSpace(res)) { msg.str = res; BOT.sendBack(msg); return(true); } } if (cmd == "个人信息") { string res = $"{money.getUserInfo(msg.from)}\r\n{getRHInfo(msg.from)}"; if (!string.IsNullOrWhiteSpace(res)) { msg.str = res; BOT.sendBack(msg); return(true); } } else if (cmd == "赛马") { int num = 5; if (!matches.ContainsKey(group)) { matches[group] = new RHMatch(group, this); } matches[group].begin(num, 100); return(true); } else if (cmd == "胜率榜") { msg.str = showBigWinner(); BOT.sendBack(msg); return(true); } else if (cmd == "败率榜") { msg.str = showBigLoser(); BOT.sendBack(msg); return(true); } else if (cmd == "赌狗榜") { msg.str = showMostPlayTime(); BOT.sendBack(msg); return(true); } else { var trygetbet = Regex.Match(cmd, @"(\d+)号\s*(\d+)"); if (trygetbet.Success) { try { int roadnum = int.Parse(trygetbet.Groups[1].ToString()); int money = int.Parse(trygetbet.Groups[2].ToString()); addBet(group, user, roadnum, money); return(true); } catch (Exception ex) { FileHelper.Log(ex); } } } } catch (Exception ex) { FileHelper.Log(ex); } return(false); }
public long getMoney(RHUser user) { return(money.getUser(user.id).Money); }
public long changeMoney(RHUser user, long num) { return(money.getUser(user.id).addMoney(num)); }