private void DoAction() { bool bSuccess = false; string OutMessage = ""; Engine.Action SelectedAction = null; // Update FromObj and FromLoc // Look into getting rid of this code - I don't think FromObj and FromLoc // are used anymore. /* FromObj = false; * if (i != null) * { * if (i.oContainerObject != null) * { * FromLoc = false; * FromObj = true; * } * } */ // Still a bit kludgy. // There are some old and nonstandard actions that need to be checked for and run in // their own way. if (lbAction.SelectedItem == _Report_hiOwner) { richTextBox1.AppendText("Owner of " + i.sName + " is " + i.hiOwner.sName + "\n"); } else // OK so by this point we've weeded out all the nonstandard actions. // Time for the SelectedAction.DoAction polymorphism I've been wanting to do ever // since this project started! // (This project started 13 Aug 2016 (ish) and writing this comment 29 Aug 2016) { SelectedAction = (Engine.Action)lbAction.SelectedItem; OutMessage = ""; SelectedAction.DoAction(i, i2, false, ref OutMessage, ref bSuccess); richTextBox1.AppendText(OutMessage); } }
private void InitialiseValues() { // A lot of things are initialised by the World static class (see the Engine namespace) // The UI needs to know what an action is if it's a nonstandard action. // report hiOwner is a reporting action used in debugging // Create player _player = World._player; // Define actions _Report_hiOwner = World._Report_hiOwner; // UI - put the beginning text in, and get the UI ready for use if ((World._BeginningText != "") && (World._BeginningText != null)) { richTextBox1.AppendText(World._BeginningText + "\n"); } _player.DetermineActions(ref ActionList); UpdateUIAfterTurn(); }