/// <summary> /// Processes functions involved in lodging a new ownership (and kingship) challenge /// Returns ProtoMessage in case of error /// </summary> public ProtoMessage LodgeOwnershipChallenge(PlayerCharacter challenger) { bool proceed = true; ProtoMessage result = null; // ensure aren't current owner if (challenger == this.owner) { result = new ProtoMessage(); result.ResponseType = DisplayMessages.KingdomAlreadyKing; } else { // create and send new OwnershipChallenge OwnershipChallenge newChallenge = new OwnershipChallenge(Globals_Game.GetNextOwnChallengeID(), challenger.charID, "kingdom", this.id); proceed = Globals_Game.AddOwnershipChallenge(newChallenge, out result); } if (proceed) { // create and send journal entry // get interested parties PlayerCharacter currentOwner = this.owner; // ID uint entryID = Globals_Game.GetNextJournalEntryID(); // date uint year = Globals_Game.clock.currentYear; byte season = Globals_Game.clock.currentSeason; // location string entryLoc = this.id; // journal entry personae string allEntry = "all|all"; string currentOwnerEntry = currentOwner.charID + "|king"; string challengerEntry = challenger.charID + "|pretender"; string[] entryPersonae = new string[] { currentOwnerEntry, challengerEntry, allEntry }; // entry type string entryType = "depose_new"; // journal entry description string[] fields = new string[4]; fields[0] = this.name; fields[1] = this.id; fields[2] = challenger.firstName + " " + challenger.familyName; fields[3] = currentOwner.firstName + " " + currentOwner.familyName; ProtoMessage ownershipChallenge = new ProtoMessage(); ownershipChallenge.MessageFields = fields; ownershipChallenge.ResponseType = DisplayMessages.KingdomOwnershipChallenge; // create and send a proposal (journal entry) JournalEntry myEntry = new JournalEntry(entryID, year, season, entryPersonae, entryType, ownershipChallenge, loc: entryLoc); Globals_Game.AddPastEvent(myEntry); } return(result); }