/// <summary> /// Initializes a new instance of the <see cref="BTLibrary.PackageSeme"/> class. /// </summary> /// <param name="bs">Bytes array representing the seme.</param> /// <exception cref="System.Exception">Thrown when the byte sequence doesen't represent a seme.</exception> public PackageSeme(byte [] bs) : base(EnPackageType.SEME) { if (bs [0] != (byte)type) { throw new Exception("Wrong byte's sequence"); } player = (Player)bs [1]; seme = (EnSemi)bs [2]; }
/// <summary> /// Initializes a new instance of the <see cref="ChiamataLibrary.Card"/> class. /// </summary> /// <param name="number">The card's number.</param> /// <param name="seme">The card's seme.</param> /// <param name="iniziale">The player who initially owns the card.</param> internal Card(EnNumbers number, EnSemi seme, Player initial) { if (!Board.Instance.IsCreationPhase) { throw new WrongPhaseException("A player must be instantiated during the creation time", "Creation"); } this.seme = seme; //set the seme this.number = number; //set the number this.initialPlayer = initial; //set the initial player }
public void packageSemeAckTest() { EnSemi s = EnSemi.COPE; PackageSeme pkgs = new PackageSeme(Board.Instance.Me, s); byte [] bs = pkgs.getAckMessage(); PackageSeme pkgsRec = new PackageSeme(PackageBase.getMessageFromAck(bs)); Assert.AreEqual(EnPackageType.SEME, pkgsRec.type); Assert.AreSame(Board.Instance.Me, pkgsRec.player); Assert.AreEqual(s, pkgsRec.seme); }
/// <summary> /// Initializes a new instance of the <see cref="BTLibrary.PackageCard"/> class. /// </summary> /// <param name="bs">Byte array representing the move.</param> /// <exception cref="System.Exception">Thrown when the byte sequence doesen't represent a move.</exception> public PackageCard(byte [] bs) : base(EnPackageType.MOVE) { if (bs [0] != (byte)type) { throw new Exception("Wrong byte's sequence"); } EnSemi s = (EnSemi)(bs [2] / Board.Instance.nNumber); EnNumbers n = (EnNumbers)(bs [2] % Board.Instance.nNumber); card = Board.Instance.GetCard(s, n); player = (Player)bs [1]; time = (int)bs [3]; }
public List <Card> GetHand(EnSemi seme, bool complete = false) { List <Card> hand = new List <Card> (); for (int n = 0; n < Board.Instance.nNumber; ++n) { Card c = Board.Instance._cardGrid [(int)seme, n]; if (c.initialPlayer == this && (complete || c.IsPlayable)) { hand.Add(c); } } return(hand); }
// <summary> /// Getter for the card. Must provide SEME and NUMBER as arguments. /// </summary> /// <returns>The instance of <see cref="ChiamataLibrary.Card"/>.</returns> /// <param name="seme">Seme.</param> /// <param name="number">Number.</param> public Card GetCard(EnSemi seme, EnNumbers number) { return(_cardGrid [(int)seme, (int)number]); }
/// <summary> /// Notifies the AI that the auction is starting and sets up the seme and bid choosers. /// </summary> private void StartAuction() { _seme = _semeChooser.ChooseSeme(me); _bidChooser.Setup(me, _seme); }
/// <summary> /// Initializes this instance. /// </summary> /// <param name="me">The <see cref="ChiamataLibrary.Player"/> instance representing the AI.</param> /// <param name="seme">The seme that will be chosen by the AI if it wins the auction.</param> public void Setup(Player me, EnSemi seme) { this._me = me; this._seme = seme; _lastBid = SetLastBid(); }
/// <summary> /// Initializes a new instance of the <see cref="BTLibrary.PackageSeme"/> class. /// </summary> /// <param name="player">The player that choose the seme.</param> /// <param name="seme">Seme.</param> public PackageSeme(Player player, EnSemi seme) : base(EnPackageType.SEME) { this.player = player; this.seme = seme; }
/// <summary> /// Initializes this instance. /// </summary> /// <param name="me">The <see cref="ChiamataLibrary.Player"/> instance representing the AI.</param> /// <param name="seme">The seme that will be chosen if this AI wins the auction.</param> public void Setup(Player me, EnSemi seme) { }