/// <summary>
        /// Recruit some troops for one of your armies
        /// </summary>
        /// <param name="armyID">ID of army to recruit for (will recruit from that army leader's location</param>
        /// <param name="numTroops">Number of troops to recruit</param>
        /// <param name="isConfirm">Boolean indicating that this message is confirming these details- will be changed once message sequences are established</param>
        public void RecruitTroops(string armyID, uint numTroops, bool isConfirm = false)
        {
            ProtoRecruit recruitDetails = new ProtoRecruit();

            recruitDetails.armyID     = armyID;
            recruitDetails.amount     = numTroops;
            recruitDetails.isConfirm  = isConfirm;
            recruitDetails.ActionType = Actions.RecruitTroops;
            net.Send(recruitDetails);
        }
    public static ProtoMessage HireTroops(int amount, TextTestClient client)
    {
        ProtoCharacter armyResult   = GetCharacterDetails("Char_158", client);
        ProtoRecruit   protoRecruit = new ProtoRecruit();

        protoRecruit.ActionType = Actions.RecruitTroops;
        if (amount > 0)
        {
            protoRecruit.amount = (uint)amount;
        }
        protoRecruit.armyID    = armyResult.armyID;
        protoRecruit.isConfirm = true;
        client.net.Send(protoRecruit);
        var reply = GetActionReply(Actions.RecruitTroops, client);

        return(reply);
    }
        public ProtoMessage HireNew(int amount, TextTestClient client)
        {
            ProtoPlayerCharacter protoMessage = new ProtoPlayerCharacter();

            protoMessage.Message    = client.charID;
            protoMessage.ActionType = Actions.ViewChar;
            client.net.Send(protoMessage);
            var          armyReply       = GetActionReply(Actions.ViewChar, client);
            var          armyResult      = (ProtoPlayerCharacter)armyReply.Result;
            ProtoRecruit protoRecruitNew = new ProtoRecruit();

            protoRecruitNew.ActionType = Actions.RecruitNew;
            if (amount > 0)
            {
                protoRecruitNew.amount = (uint)amount;
            }
            protoRecruitNew.isConfirm = true;
            client.net.Send(protoRecruitNew);
            var reply = GetActionReply(Actions.RecruitNew, client);

            return(reply.Result);
        }
    public ProtoMessage HireTroops(int amount, TextTestClient client)
    {
        ProtoPlayerCharacter protoMessage = new ProtoPlayerCharacter();

        protoMessage.Message    = "Char_158";
        protoMessage.ActionType = Actions.ViewChar;
        client.net.Send(protoMessage);
        var          armyReply    = GetActionReply(Actions.ViewChar, client);
        var          armyResult   = (ProtoPlayerCharacter)armyReply.Result;
        ProtoRecruit protoRecruit = new ProtoRecruit();

        protoRecruit.ActionType = Actions.RecruitTroops;
        if (amount > 0)
        {
            protoRecruit.amount = (uint)amount;
        }
        protoRecruit.armyID    = armyResult.armyID;
        protoRecruit.isConfirm = true;
        client.net.Send(protoRecruit);
        var reply = GetActionReply(Actions.RecruitTroops, client);

        return(reply.Result);
    }
Esempio n. 5
0
        /// <summary>Test stub for RecruitTroops(String, UInt32, Boolean)</summary>

        public void RecruitTroopsTest(
            TestClient target,
            string armyID,
            uint numTroops,
            bool isConfirm
            )
        {
            bool         ValidRecruit = true;
            Client       client       = Globals_Server.Clients[target.playerID];
            ProtoMessage ignoreMessage;

            ValidRecruit = client.myPlayerCharacter.ChecksBeforeRecruitment(out ignoreMessage);
            target.RecruitTroops(armyID, numTroops, isConfirm);
            Thread.Sleep(5000);
            Army army = null;
            Task <ProtoMessage> responseTask = target.GetReply();

            responseTask.Wait();
            ProtoMessage response = responseTask.Result;

            if (!string.IsNullOrWhiteSpace(armyID))
            {
                if (!Globals_Game.armyMasterList.ContainsKey(armyID))
                {
                    // Expect army unrecognised
                    Assert.AreEqual(DisplayMessages.ErrorGenericArmyUnidentified, response.ResponseType);
                    return;
                }
                else
                {
                    army = Globals_Game.armyMasterList[armyID];
                }
            }
            else
            {
                return;
            }
            if (army != null)
            {
                if (army.GetOwner() != client.myPlayerCharacter)
                {
                    Assert.AreEqual(DisplayMessages.ErrorGenericUnauthorised, response.ResponseType);
                }
                if (army.GetLocation().CalcMaxTroops() < numTroops)
                {
                    Assert.AreEqual(DisplayMessages.CharacterRecruitInsufficientFunds, response.ResponseType);
                }
            }
            if (!ValidRecruit)
            {
                Assert.IsFalse(response.ResponseType == DisplayMessages.CharacterRecruitInsufficientFunds || response.ResponseType == DisplayMessages.CharacterRecruitInsufficientFunds);
                Assert.IsFalse(response is ProtoRecruit);
                return;
            }
            ProtoRecruit recruitDetails = response as ProtoRecruit;

            if (recruitDetails == null)
            {
                Assert.Fail();
            }
        }