Commit 665f58a3 authored by mercury233's avatar mercury233

add hand param

parent cb1e5433
......@@ -40,6 +40,11 @@ namespace WindBot.Game.AI
Enemy = Duel.Fields[1];
}
public virtual int OnRockPaperScissors()
{
return Program.Rand.Next(1, 4);
}
public virtual bool OnSelectHand()
{
return Program.Rand.Next(2) > 0;
......
......@@ -52,10 +52,19 @@ namespace WindBot.Game
_dialogs.SendDuelStart();
}
/// <summary>
/// Called when the AI do the rock-paper-scissors.
/// </summary>
/// <returns>1 for Scissors, 2 for Rock, 3 for Paper.</returns>
public int OnRockPaperScissors()
{
return Executor.OnRockPaperScissors();
}
/// <summary>
/// Called when the AI won the rock-paper-scissors.
/// </summary>
/// <returns>True if the AI should begin, false otherwise.</returns>
/// <returns>True if the AI should begin first, false otherwise.</returns>
public bool OnSelectHand()
{
return Executor.OnSelectHand();
......
......@@ -24,11 +24,13 @@ namespace WindBot.Game
private Room _room;
private Duel _duel;
private int _hand;
public GameBehavior(GameClient game)
{
Game = game;
Connection = game.Connection;
_hand = game.Hand;
_packets = new Dictionary<StocMessage, Action<BinaryReader>>();
_messages = new Dictionary<GameMessage, Action<BinaryReader>>();
......@@ -207,7 +209,12 @@ namespace WindBot.Game
private void OnSelectHand(BinaryReader packet)
{
Connection.Send(CtosMessage.HandResult, (byte)Program.Rand.Next(1, 4));
int result;
if (_hand > 0)
result = _hand;
else
result = _ai.OnRockPaperScissors();
Connection.Send(CtosMessage.HandResult, (byte)result);
}
private void OnSelectTp(BinaryReader packet)
......
......@@ -13,6 +13,7 @@ namespace WindBot.Game
public string Username;
public string Deck;
public string Dialog;
public int Hand;
private string _serverHost;
private int _serverPort;
......@@ -27,6 +28,7 @@ namespace WindBot.Game
Username = Info.Name;
Deck = Info.Deck;
Dialog = Info.Dialog;
Hand = Info.Hand;
_serverHost = Info.Host;
_serverPort = Info.Port;
_roomInfo = Info.HostInfo;
......
......@@ -162,6 +162,9 @@ namespace WindBot
string password = HttpUtility.ParseQueryString(RawUrl).Get("password");
if (password != null)
Info.HostInfo = password;
string hand = HttpUtility.ParseQueryString(RawUrl).Get("hand");
if (hand != null)
Info.Hand = Int32.Parse(hand);
if (Info.Name == null || Info.Host == null || port == null)
{
......
......@@ -11,6 +11,7 @@ namespace WindBot
public int Port { get; set; }
public string HostInfo { get; set; }
public int Version { get; set; }
public int Hand { get; set; }
public WindBotInfo()
{
......@@ -21,6 +22,7 @@ namespace WindBot
Port = 7911;
HostInfo = "";
Version = 0x233C;
Hand = 0;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment