Ejemplo n.º 1
0
 public void init(sendQQGroupMsgHandler _showScene, getQQNickHandler _getQQNick, BTCActor _btc, string _path)
 {
     outputMessage = _showScene;
     getQQNick     = _getQQNick;
     btc           = _btc;
     path          = _path;
     lock (matchMutex)
     {
         try
         {
             var lines = FileIOActor.readLines(path + userinfoFile);
             foreach (var line in lines)
             {
                 RHUser user = new RHUser(line);
                 users[user.userid] = user;
             }
             lines = FileIOActor.readLines(path + horseinfoFile);
             foreach (var line in lines)
             {
                 RHHorse horse = new RHHorse(line);
                 horses[horse.name] = horse;
             }
         }
         catch (Exception e)
         {
             FileIOActor.log(e.Message + "\r\n" + e.StackTrace);
         }
     }
 }
Ejemplo n.º 2
0
        /// <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}枚{BTCActor.unitName},共下注{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)}%");
        }
Ejemplo n.º 3
0
 /// <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))
             {
                 outputMessage(matchid, user.userid, res);
                 return(true);
             }
         }
     }catch (Exception ex)
     {
         FileIOActor.log(ex);
     }
     return(false);
 }
Ejemplo n.º 4
0
        public bool dealCmd(long uid, long group, string cmd)
        {
            try
            {
                //return true;


                //if (!matches.ContainsKey(group)) matches[group] = new RHMatch(this, group);
                if (!users.ContainsKey(uid))
                {
                    users[uid] = new RHUser(uid);
                }
                RHUser user = users[uid];

                if (cmd == "赛马介绍" || cmd == "赛马玩法" || cmd == "赛马说明")
                {
                    outputMessage(group, -1, getIntroduction());
                    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 == "胜率榜")
                {
                    outputMessage(group, -1, showBigWinner());
                    return(true);
                }
                else if (cmd == "败率榜")
                {
                    outputMessage(group, -1, showBigLoser());
                    return(true);
                }
                else if (cmd == "赌狗榜")
                {
                    outputMessage(group, -1, showMostPlayTime());
                    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)
                        {
                            FileIOActor.log(ex);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                FileIOActor.log(ex);
            }
            return(false);
        }
Ejemplo n.º 5
0
        /// <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 btcuser = ra.btc.getUser(user.userid);
                if (user == null)
                {
                    return("");
                }

                if (roadnum <= 0 || roadnum > this.roadnum)
                {
                    return($"在?没有第{roadnum}条赛道");
                }

                if (btcuser.Money <= 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 >= btcuser.Money)
                {
                    money = btcuser.Money;
                    res   = $"all in!把手上的{money}枚{BTCActor.unitName}都押了{roadnum}号马";
                }
                else
                {
                    res = $"成功在{roadnum}号马下注{money}枚{BTCActor.unitName}";
                }

                btcuser.addMoney(-1 * money);
                user.hrmoney += (ulong)money;
                if (!bets[user].ContainsKey(roadnum))
                {
                    bets[user][roadnum] = 0;
                }
                bets[user][roadnum] += money;

                res += $",账户余额{btcuser.Money}";
                return(res);
            }
            catch (Exception ex)
            {
                FileIOActor.log(ex);
                return($"ERROR:{ex.Message}");
            }
        }