📄 horse_start.cs
字号:
using System;
using System.Threading;
using System.Collections;
using System.Data;
using System.Data.OleDb;
namespace xajh
{
public class horse_start
{
private Thread MyThread;
private int horsespan = var.public_horsespan * 1000;
private System.Web.HttpContext xajh = System.Web.HttpContext.Current;
public horse_start()
{
this.MyThread = new Thread(new ThreadStart(ThreadProc));
this.MyThread.Name = "bet_house";
this.MyThread.Start();
}
internal void ThreadProc()
{
string[] aword;
ArrayList roomlist = var.public_roomlist;
while(true)
{
aword = new string[9];
aword[0] = "ran";
aword[1] = "";
aword[2] = "";
aword[3] = "sys.gif";
aword[4] = "";
aword[5] = "";
aword[6] = "赛马(第<font class=\\\"byts\\\">" + var.public_horseID + "</font>场)开始接受下注啦,走过路过不要错过呀!(<a href=\\\"javascript:parent.h0.byts_horse('bet')\\\">立即下注</a>)";
aword[7] = "赛马";
aword[8] = DateTime.Now.ToLongTimeString();
this.xajh.Application.Lock();
var.public_horselist.Clear();
var.public_canbet = "";
for (int i = 0; i < roomlist.Count; i ++)
{
ArrayList words = (ArrayList) this.xajh.Application["byts_xajh_chat_words_" + roomlist[i]];
words.Add(aword);
words.RemoveAt(0);
this.xajh.Application["byts_xajh_chat_line_" + roomlist[i]] = (int) this.xajh.Application["byts_xajh_chat_line_" + roomlist[i]] + 1;
}
this.xajh.Application.UnLock();
Thread.Sleep(this.horsespan);
if (var.public_horselist.Count == 0)
{
aword = new string[9];
aword[0] = "ran";
aword[1] = "";
aword[2] = "";
aword[3] = "sys.gif";
aword[4] = "";
aword[5] = "";
aword[6] = "赛马(第<font class=\\\"byts\\\">" + var.public_horseID + "</font>场)没有任何人下注,比赛取消,请等待下一场比赛!";
aword[7] = "赛马";
aword[8] = DateTime.Now.ToLongTimeString();
this.xajh.Application.Lock();
var.public_canbet = "正是休息时间,请等到下一场开始再下注!";
for (int i = 0; i < roomlist.Count; i ++)
{
ArrayList words = (ArrayList) this.xajh.Application["byts_xajh_chat_words_" + roomlist[i]];
words.Add(aword);
words.RemoveAt(0);
this.xajh.Application["byts_xajh_chat_line_" + roomlist[i]] = (int) this.xajh.Application["byts_xajh_chat_line_" + roomlist[i]] + 1;
}
var.public_horseID ++;
this.xajh.Application.UnLock();
}
else
{
aword = new string[9];
aword[0] = "ran";
aword[1] = "";
aword[2] = "";
aword[3] = "sys.gif";
aword[4] = "";
aword[5] = "";
aword[6] = "赛马(第<font class=\\\"byts\\\">" + var.public_horseID + "</font>场)正式开始跑马,停止下注!";
aword[7] = "赛马";
aword[8] = DateTime.Now.ToLongTimeString();
this.xajh.Application.Lock();
var.public_canbet = "跑马已经正式开始,不能下注!";
for (int i = 0; i < roomlist.Count; i ++)
{
ArrayList words = (ArrayList) this.xajh.Application["byts_xajh_chat_words_" + roomlist[i]];
words.Add(aword);
words.RemoveAt(0);
this.xajh.Application["byts_xajh_chat_line_" + roomlist[i]] = (int) this.xajh.Application["byts_xajh_chat_line_" + roomlist[i]] + 1;
}
this.xajh.Application.UnLock();
Thread.Sleep(5000);
try
{
System.Random MyRan = new System.Random();
DataRow dr = var.public_horseinfo.Rows[MyRan.Next(0, var.public_horseinfo.Rows.Count)];
string winname = dr["马匹名称"].ToString();
int winb = (int) dr["赔率"];
OleDbConnection MyConn = new OleDbConnection(var.public_conn);
MyConn.Open();
OleDbCommand MyComm = new OleDbCommand(@"update [马匹列表] set [夺魁次数]=[夺魁次数]+1 where [id]=" + dr["id"], MyConn);
MyComm.ExecuteNonQuery();
string winmsg = "";
foreach (string tinfo in var.public_horselist.Values)
{
if (tinfo.IndexOf("|" + winname + ":") != -1)
{
string[] tinfos = tinfo.Split('|');
for (int i = 2; i < tinfos.Length; i ++)
{
string[] ms = tinfos[i].Split(':');
if (ms[0] == winname)
{
string winmoney = (int.Parse(ms[1]) * winb).ToString();
winmsg += tinfos[1] + ":赢" + winmoney + "两\\\\t";
MyComm.CommandText = @"update [注册用户] set [银两]=[银两]+" + winmoney + " where [id]=" + tinfos[0];
MyComm.ExecuteNonQuery();
break;
}
}
}
}
MyComm.Dispose();
MyConn.Close();
MyConn.Dispose();
if (winmsg == "")
{
winmsg = "没有任何人在本场赛马中投中注!";
}
aword = new string[9];
aword[0] = "ran";
aword[1] = "";
aword[2] = "";
aword[3] = "sys.gif";
aword[4] = "";
aword[5] = "";
aword[6] = "赛马(第<font class=\\\"byts\\\">" + var.public_horseID + "</font>场)跑马结束,<font class=\\\"byts\\\">" + winname + "</font>不负众望,勇猛夺魁!(<a href=\\\"javascript:parent.HHCtrl.TextPopup('" + winmsg + "','宋体,10',9,9,-1,-1)\\\">详细结果</a>)";
aword[7] = "赛马";
aword[8] = DateTime.Now.ToLongTimeString();
this.xajh.Application.Lock();
dr.BeginEdit();
dr["夺魁次数"] = (int) dr["夺魁次数"] + 1;
dr.EndEdit();
var.public_canbet = "正是休息时间,请等到下一场开始再下注!";
for (int i = 0; i < roomlist.Count; i ++)
{
ArrayList words = (ArrayList) this.xajh.Application["byts_xajh_chat_words_" + roomlist[i]];
words.Add(aword);
words.RemoveAt(0);
this.xajh.Application["byts_xajh_chat_line_" + roomlist[i]] = (int) this.xajh.Application["byts_xajh_chat_line_" + roomlist[i]] + 1;
}
var.public_horseID ++;
this.xajh.Application.UnLock();
}
catch
{
aword = new string[9];
aword[0] = "ran";
aword[1] = "";
aword[2] = "";
aword[3] = "sys.gif";
aword[4] = "";
aword[5] = "";
aword[6] = "赛马(第<font class=\\\"byts\\\">" + var.public_horseID + "</font>场)发生意外,程序内部线程出错,请等待下一场比赛!";
aword[7] = "系统";
aword[8] = DateTime.Now.ToLongTimeString();
this.xajh.Application.Lock();
var.public_canbet = "正是休息时间,请等到下一场开始再下注!";
for (int i = 0; i < roomlist.Count; i ++)
{
ArrayList words = (ArrayList) this.xajh.Application["byts_xajh_chat_words_" + roomlist[i]];
words.Add(aword);
words.RemoveAt(0);
this.xajh.Application["byts_xajh_chat_line_" + roomlist[i]] = (int) this.xajh.Application["byts_xajh_chat_line_" + roomlist[i]] + 1;
}
var.public_horseID ++;
this.xajh.Application.UnLock();
}
}
Thread.Sleep(5000);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -