// Start is called before the first frame update new void Start() { btnAttackArmy.onClick.AddListener(BtnAttackArmy); lblMessageForUser.text = ""; btnAttackArmy.interactable = false; ProtoMessage reply = GetArmyDetails(armyToViewID, tclient); if (reply.ResponseType == DisplayMessages.Success) { currentlyViewedArmy = (ProtoArmy)reply; DisplayArmyDetails(); // Can't attack if you don't have an army. if (!string.IsNullOrWhiteSpace(protoClient.activeChar.armyID)) { // Can't attack your own armies. if (!currentlyViewedArmy.ownerID.Equals(protoClient.playerChar.charID)) { if (currentlyViewedArmy.location.Equals(protoClient.playerChar.location)) { btnAttackArmy.interactable = true; } } } } else { DisplayMessageToUser("ERROR: Response type: " + reply.ResponseType.ToString()); } }
public static ProtoMessage GetArmyDetails(string armyID, TextTestClient client) { ProtoArmy request = new ProtoArmy { Message = armyID, ActionType = Actions.ViewArmy }; client.net.Send(request); return(GetActionReply(Actions.ViewArmy, client)); }
public ProtoGenericArray <ProtoArmyOverview> ArmyStatus(TextTestClient client) { ProtoArmy proto = new ProtoArmy(); proto.ownerID = "Char_158"; proto.ActionType = Actions.ListArmies; client.net.Send(proto); var reply = GetActionReply(Actions.ListArmies, client); var armies = (ProtoGenericArray <ProtoArmyOverview>)reply.Result; return(armies); }
public ProtoMessage changePillage(string aID, TextTestClient client) { ProtoArmy proto = new ProtoArmy(); proto.owner = client.charID; proto.Message = aID; proto.ActionType = Actions.ChangeAutoPillage; client.net.Send(proto); var armyReply = GetActionReply(Actions.ChangeAutoPillage, client); var armyResult = (ProtoMessage)armyReply.Result; return(armyResult); }
/// <summary>Test stub for MaintainArmy(String)</summary> public DisplayMessages MaintainArmyTest(TestClient target, string armyID) { Client client; if (!ValidClientState(target, out client)) { Assert.IsTrue(target.IsConnectedAndLoggedIn() == false); } int treasury = client.myPlayerCharacter.GetHomeFief().GetAvailableTreasury(true); uint armyMaintenanceCost = 0; bool isMaintained = false; DisplayMessages armyError; Army army = Utility_Methods.GetArmy(armyID, out armyError); if (army != null) { armyMaintenanceCost = army.getMaintenanceCost(); isMaintained = army.isMaintained; } target.MaintainArmy(armyID); var replyTask = target.GetReply(); if (!replyTask.Wait(5000)) { Assert.Fail("Timed out"); } var result = replyTask.Result; // if armyID is null or empty, or a bad format, get a MessageInvalid message if (string.IsNullOrWhiteSpace(armyID) || !Utility_Methods.ValidateArmyID(armyID)) { Assert.AreEqual(DisplayMessages.ErrorGenericMessageInvalid, result.ResponseType); return(result.ResponseType); } // If armyID is not a recognised army, get an ArmyUnidentified message if (!Globals_Game.armyMasterList.ContainsKey(armyID) || army == null) { Assert.AreEqual(DisplayMessages.ErrorGenericArmyUnidentified, result.ResponseType); return(result.ResponseType); } // If the player does not own the army, get an Unauthorised message if (army.GetOwner() != client.myPlayerCharacter) { Assert.AreEqual(DisplayMessages.ErrorGenericUnauthorised, result.ResponseType); return(result.ResponseType); } // If the army has already been maintained, expect a MaintainAlready message if (isMaintained) { Assert.AreEqual(DisplayMessages.ArmyMaintainedAlready, result.ResponseType); return(result.ResponseType); } // If don't have enough funds, if (treasury < armyMaintenanceCost) { Assert.AreEqual(DisplayMessages.ArmyMaintainInsufficientFunds, result.ResponseType); return(result.ResponseType); } // If all the checks pass, expect an army back ProtoArmy armyDetails = result as ProtoArmy; if (armyDetails == null) { Assert.Fail("Could not parse result to ProtoArmy"); } return(result.ResponseType); }