#region 超时处理 if (vEastTick > 1000 || vWestTick > 1000)
{
if (vEastTick > 1000)
Console.WriteLine("{0}出拳严重超时", typeof(T1).Name);
if (vWestTick > 1000)
Console.WriteLine("{0}出拳严重超时", typeof(T2).Name);
return;
}
if (vEastTick > 100)
{
vEastResult = Result.Overtime;
eastOvertime++;
}
if (vWestTick > 100)
{
vWestResult = Result.Overtime;
westOvertime++;
}
#endregion 超时处理 #region 判断谁犯规 if (vEastResult == Result.Unknown)
if (vEastSum < 0 || vEastSum > 10 ||
vEastFinger < 0 || vEastFinger > 5 ||
vEastSum - 5 > vEastFinger || vEastFinger > vEastSum)
vEastResult = Result.Foul;
if (vWestResult == Result.Unknown)
if (vWestSum < 0 || vWestSum > 10 ||
vWestFinger < 0 || vWestFinger > 5 ||
vWestSum - 5 > vWestFinger || vWestFinger > vWestSum)
vWestResult = Result.Foul;
#endregion 判断谁犯规 #region 有一个人犯规 if (vEastResult == Result.Foul ^ vWestResult == Result.Foul)
{
#region 如犯规判则对方赢 if (vEastResult == Result.Foul)
vWestResult = Result.Win;
else if (vWestResult == Result.Foul)
vEastResult = Result.Win;
#endregion 如犯规判则对方赢
}
#endregion 有一个人犯规 #region 划拳比较 if (vEastResult == Result.Unknown)
if (vEastFinger + vWestFinger == vEastSum)
vEastResult = Result.Win;
if (vWestResult == Result.Unknown)
if (vEastFinger + vWestFinger == vWestSum)
vWestResult = Result.Win;
#endregion 划拳比较 #region 平局 if (vEastResult == vWestResult)
{
vEastResult = Result.Dogfall;
vWestResult = Result.Dogfall;
}
#endregion 平局 #region 出现胜负 if (vEastResult == Result.Win || vWestResult == Result.Win)
{
if (vEastResult == Result.Win)
{
eastTotal++;
vWestResult = Result.Lost;
}
else if (vWestResult == Result.Win)
{
westTotal++;
vEastResult = Result.Lost;
}
}
#endregion 出现胜负 #region 通知划拳的结果
vEastTick = Environment.TickCount;
vEastCatch = false;
try
{
eastPlayer.Outcome(vWestFinger, vWestSum, vWestResult,
vEastFinger, vEastSum, vEastResult);
}
catch
{
vEastCatch = true;
}
vEastTick = Environment.TickCount - vEastTick;
vWestTick = Environment.TickCount;
vWestCatch = false;
try
{
westPlayer.Outcome(vEastFinger, vEastSum, vEastResult,
vWestFinger, vWestSum, vWestResult);
}
catch
{
vWestCatch = true;
}
vWestTick = Environment.TickCount - vWestTick;
#endregion 通知划拳的结果 #region 出现异常 if (vEastCatch || vWestCatch)
{
if (vEastCatch)
{
eastTotal -= catchPenalty;
westTotal++;
}
if (vWestCatch)
{
westTotal -= catchPenalty;
eastTotal++;
}
break;
}
#endregion 出现异常 #region 超时处理 if (vEastTick > 1000 || vWestTick > 1000)
{
if (vEastTick > 1000)
Console.WriteLine("{0}接收结果严重超时", typeof(T1).Name);
if (vWestTick > 1000)
Console.WriteLine("{0}接收结果严重超时", typeof(T2).Name);
return;
}
if (vEastTick > 100)
{
eastTotal -= overtimePenalty;
eastOvertime++;
}
if (vWestTick > 100)
{
westTotal -= overtimePenalty;
westOvertime++;
}
if (eastOvertime > 10 || westOvertime > 10)
{
if (eastOvertime > 10)
Console.WriteLine("{0}超时十次以上", typeof(T1).Name);
if (westOvertime > 10)
Console.WriteLine("{0}超时十次以上", typeof(T2).Name);
return;
}
#endregion 超时处理 #region 出现胜负 if (vEastResult == Result.Win || vWestResult == Result.Win)
break;
#endregion 出现胜负
}
}
#endregion 猜拳过程 #region 输出结果
Console.WriteLine("{0}得分:{1}, {2}得分:{3}",
typeof(T1).Name, eastTotal,
typeof(T2).Name, westTotal);
Console.ReadLine();
#endregion 输出结果
}
}
class Program
{
static void Main(string[] args)
{
new Drunkery<Zswang一号, Zswang二号>().Play();
}
}
}
|
||||||||||||

【