示例#1
0
    public static void NorthWestClickEvent(object obj, EventArgs args)
    {
        ProtoFief move = playerOps.Move(PlayerOperations.MoveDirections.Nw, client);

        FiefClickEvent(obj, args);
        ProfileClickEvent(obj, args);
    }
        public void TravelTest(TestClient target, string charID, string targetFief, string[] travelInstructions)
        {
            DisplayMessages fiefError, charError;
            Character       character = Utility_Methods.GetCharacter(charID, out charError);
            Client          client    = Globals_Server.Clients[target.playerID];
            Fief            oldFief   = null;

            if (character != null)
            {
                oldFief = character.location;
            }
            target.Move(charID, targetFief, travelInstructions);
            Task <ProtoMessage> responseTask = target.GetReply();

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

            // Travelling will be done either by series of instructions or by choosing fief- ensure at least one is being used!
            if (string.IsNullOrWhiteSpace(targetFief))
            {
                if (travelInstructions == null)
                {
                    Assert.AreEqual(DisplayMessages.ErrorGenericFiefUnidentified, reply.ResponseType);
                    return;
                }
            }
            Fief f = Utility_Methods.GetFief(targetFief, out fiefError);

            if (!string.IsNullOrWhiteSpace(targetFief) && f == null)
            {
                Assert.AreEqual(fiefError, reply.ResponseType);
                return;
            }

            // Note- if the travel instructions are invalid the server will still move the client up until the first invalid instruction, and will then send an update stating that there was a problem with the movement instructions


            if (character == null)
            {
                Assert.AreEqual(charError, reply.ResponseType);
                return;
            }
            if (character.GetPlayerCharacter() != client.myPlayerCharacter)
            {
                Assert.AreEqual(DisplayMessages.ErrorGenericUnauthorised, reply.ResponseType);
                return;
            }
            if (f != null && character.days < oldFief.getTravelCost(f))
            {
                Assert.AreEqual(DisplayMessages.CharacterDaysJourney, reply.ResponseType);
                return;
            }
            ProtoFief fiefDetails = reply as ProtoFief;

            Assert.IsNotNull(fiefDetails);
        }
    public static ProtoMessage GetFiefDetails(string fiefID, TextTestClient client)
    {
        ProtoFief request = new ProtoFief {
            Message    = fiefID,
            ActionType = Actions.ViewFief
        };

        client.net.Send(request);
        return(GetActionReply(Actions.ViewFief, client));
    }
示例#4
0
        public void DisplayFief(ProtoFief fiefProtoBuf)
        {
            var armys = fiefProtoBuf.armies;

            Console.WriteLine("-----------------------------");
            Console.WriteLine("Fief Report");
            Console.WriteLine("-----------------------------");
            Console.WriteLine("Fief ID: " + fiefProtoBuf.fiefID);
            Console.WriteLine("Owner: " + fiefProtoBuf.owner);
            Console.WriteLine("Owner ID: " + fiefProtoBuf.ownerID);
            Console.WriteLine("Industry Level: " + fiefProtoBuf.industry);
            Console.WriteLine("Terrain type: " + fiefProtoBuf.terrain);
            var characters = fiefProtoBuf.charactersInFief;

            Console.WriteLine("Characters in Fief: ");
            foreach (var character in characters)
            {
                Console.WriteLine("-----------------------------");
                Console.WriteLine("ID: " + character.charID);
                Console.WriteLine("Name :" + character.charName);
                Console.WriteLine("Role: " + character.role);
            }
            Console.WriteLine("-----------------------------");
            if (armys != null)
            {
                Console.WriteLine("Armies in Fief: ");
                foreach (var army in armys)
                {
                    Console.WriteLine("-----------------------------");
                    Console.WriteLine("ID: " + army.armyID);
                    Console.WriteLine("Size :" + army.armySize); // for some reason displays different number than when checking armies
                    Console.WriteLine("Leader: " + army.leaderName);
                    Console.WriteLine("Owner: " + army.ownerName);
                }
                Console.WriteLine("-----------------------------");
            }
            var keep = fiefProtoBuf.keepLevel;

            Console.WriteLine("Keep Level: " + keep);
            Console.WriteLine("-----------------------------");
            var militia = fiefProtoBuf.militia;

            Console.WriteLine("Number of recruits available: " + militia);
            Console.WriteLine("Number of troops in fief: " + fiefProtoBuf.troops);
            Console.WriteLine("-----------------------------");
        }
示例#5
0
    public ProtoFief FiefDetails(TextTestClient client)
    {
        ProtoPlayerCharacter protoMessage = new ProtoPlayerCharacter();

        protoMessage.Message    = "Char_158";
        protoMessage.ActionType = Actions.ViewChar;
        client.net.Send(protoMessage);
        var       locReply  = GetActionReply(Actions.ViewChar, client);
        var       locResult = (ProtoPlayerCharacter)locReply;
        ProtoFief protoFief = new ProtoFief();

        protoFief.Message    = locResult.location;
        protoFief.ActionType = Actions.ViewFief;
        client.net.Send(protoFief);
        var reply = GetActionReply(Actions.ViewFief, client);

        return((ProtoFief)reply);
    }
示例#6
0
    public static void FiefClickEvent(object obj, EventArgs args, uint ArmySize)
    {
        ProtoFief fief = playerOps.FiefDetails(client);

        if (fiefTable == null)
        {
            fiefTable = new FiefTable(fief.fiefID, fief.owner, Convert.ToString(fief.industry),
                                      fief.charactersInFief, fief.armies, Convert.ToString(fief.militia));
        }
        else
        {
            fiefTable.destroyTable();

            fiefTable = new FiefTable(fief.fiefID, fief.owner, Convert.ToString(fief.industry),
                                      fief.charactersInFief, fief.armies, Convert.ToString(fief.militia));
        }
        tableLayout.Attach(fiefTable.getProfileTable(), 0, 1, 4, 5);
        myWin.ShowAll();
    }
示例#7
0
    protected void LoginButton()
    {
        m_MyText.text += "1";
        string username = inputUsername.text;
        string password = inputPassword.text;

        tclient.LogInAndConnect("helen", "potato", "localhost");

        while (!tclient.IsConnectedAndLoggedIn())
        {
            Thread.Sleep(0);
        }

        buttonText.text = "loading";
        if (tclient.IsConnectedAndLoggedIn())
        {
            mf = FiefDetails(tclient);

            SceneManager.LoadScene(1);
            // FiefControl f = new FiefControl(tclient);
        }
    }
示例#8
0
    // Start is called before the first frame update
    new void Start()
    {
        btnAdjustExpenditure.onClick.AddListener(BtnAdjustExpenditure);
        //btnAutoAdjustExpenditure.onClick.AddListener(BtnAutoAdjustExpenditures);
        btnAppointBailiff.onClick.AddListener(BtnViewPossibleBailiffs);
        btnRemoveBailiff.onClick.AddListener(BtnRemoveBailiff);
        btnViewArmies.onClick.AddListener(BtnViewArmies);
        btnListCharsInMeetingPlace.onClick.AddListener(BtnListCharsInMeetingPlace);
        btnTransferFunds.onClick.AddListener(BtnTransferFunds);
        btnTravelTo.onClick.AddListener(BtnTravelTo);
        lblMessageForUser.text                  = "";
        btnAdjustExpenditure.interactable       = false;
        btnAppointBailiff.interactable          = false;
        btnRemoveBailiff.interactable           = false;
        btnViewArmies.interactable              = false;
        btnListCharsInMeetingPlace.interactable = false;
        btnTransferFunds.interactable           = false;

        txtTaxRate.interactable        = false;
        txtOfficials.interactable      = false;
        txtGarrison.interactable       = false;
        txtInfrastructure.interactable = false;
        txtKeep.interactable           = false;
        txtTransferFunds.interactable  = false;

        ddMeetingPlaceType.interactable = false;


        ProtoMessage reply = GetFiefDetails(fiefToViewID, tclient);

        if (reply.ResponseType == DisplayMessages.Success)
        {
            currentlyViewedFief        = (ProtoFief)reply;
            btnViewArmies.interactable = true;
        }
        else if (reply.ResponseType == DisplayMessages.ErrorGenericTooFarFromFief)
        {
            lblMessageForUser.text = "You have no information on this fief.";
            currentlyViewedFief    = null;
            return;
        }
        else
        {
            DisplayMessageToUser("ERROR: Response type: " + reply.ResponseType.ToString());
            currentlyViewedFief = null;
            return;
        }

        if (currentlyViewedFief.ownerID.Equals(protoClient.playerChar.charID))  // If player's own fief.
        {
            txtTaxRate.interactable           = true;
            txtOfficials.interactable         = true;
            txtGarrison.interactable          = true;
            txtInfrastructure.interactable    = true;
            txtKeep.interactable              = true;
            btnAdjustExpenditure.interactable = true;
            txtTransferFunds.interactable     = true;
            btnTransferFunds.interactable     = true;

            if (currentlyViewedFief.bailiff == null)
            {
                btnAppointBailiff.interactable = true;
            }
            else
            {
                btnRemoveBailiff.interactable = true;
            }
        }

        if (protoClient.activeChar.location.Equals(fiefToViewID))
        {
            ddMeetingPlaceType.interactable         = true;
            btnListCharsInMeetingPlace.interactable = true;
        }

        lblPageTitle.text = fiefNames[fiefToViewID];

        if (currentlyViewedFief != null)
        {
            DisplayFiefDetails();
        }

        if (userMessageOnSceneLoad != null)
        {
            DisplayMessageToUser(userMessageOnSceneLoad);
            userMessageOnSceneLoad = null;
        }

        //lblDetails2.text += "\n" + protoClient.activeChar.days.ToString();
    }
示例#9
0
    private void BtnAdjustExpenditure()
    {
        string[] inputValues = new string[5];
        inputValues[0] = txtTaxRate.text;
        inputValues[1] = txtOfficials.text;
        inputValues[2] = txtGarrison.text;
        inputValues[3] = txtInfrastructure.text;
        inputValues[4] = txtKeep.text;
        double[]     adjustedValues;
        bool         autoAdjust = true;
        ProtoMessage response;

        foreach (var value in inputValues)
        {
            if (!value.Equals(""))
            {
                autoAdjust = false;
                break;
            }
        }
        if (autoAdjust)
        {
            // Blank values trigger auto-adjust.
            //adjustedValues = null;
            //response = AdjustExpenditure(currentlyViewedFief.fiefID, adjustedValues, tclient);

            return; // Auto-adjust has issues server-side which cause it to never work (it always thinks there's no money to spend).
        }
        else
        {
            adjustedValues = new double[5];
            for (int i = 0; i < 5; i++)
            {
                double newValue = 0.0f;
                try {
                    newValue = Convert.ToDouble(inputValues[i]);
                }
                catch (FormatException) {
                    // If invalid entry, use the finances original value.
                    newValue = currentlyViewedFief.keyStatsNext[i + 2];
                }
                finally {
                    adjustedValues[i] = newValue;
                }
            }
            response = AdjustExpenditure(currentlyViewedFief.fiefID, adjustedValues, tclient);
        }

        if (response.ResponseType == DisplayMessages.FiefExpenditureAdjusted)
        {
            currentlyViewedFief = (ProtoFief)response;
            DisplayFiefDetails();
            DisplayMessageToUser("Finances " + response.Message + ".");
            txtTaxRate.text        = "";
            txtOfficials.text      = "";
            txtGarrison.text       = "";
            txtInfrastructure.text = "";
            txtKeep.text           = "";
        }
        else if (response.ResponseType == DisplayMessages.FiefExpenditureAdjustment)
        {
            DisplayMessageToUser("The fief treasury is short by " + response.MessageFields[1] + " to cover this budget.");
        }
        else
        {
            DisplayMessageToUser("Error: " + response.ResponseType.ToString());
        }
    }
示例#10
0
 public void DisplayMove(ProtoFief moveProtoFief)
 {
     Console.WriteLine("New Fief ID: " + moveProtoFief.fiefID);
 }