public void SetCurrentRuler(Kingdom ruler)
 {
     if (ruler != null)
     {
         currentRuler = ruler;
     }
 }
Exemple #2
0
 //Method that gets a Kingdom Object and sets it as an Ally of the Current Kingdom (object)
 private void SetAlly(Kingdom ally)
 {
     if (ally != null)
     {
         numberOfAllies++;
         allies.Add(ally);
     }
 }
Exemple #3
0
 //Method that recieves the Incoming Message and sends it off for Processing
 private void ReceiveMessage(Kingdom sender, string msg, Kingdom receiver)
 {
     if (msg != "")
     {
         incomingMessage = msg;
         MessageProcessor.Instance.StartMessageProcessing(sender, msg, receiver);
     }
 }
Exemple #4
0
        public void StartMessageProcessing(Kingdom sender, string msg, Kingdom receiver)
        {
            Sender   = sender;
            Receiver = receiver;

            var found = emblemFinder.ProcessMessageForKingdom(msg, receiver);

            if (found)
            {
                //Transmit confirmation to the Receiver that its Emblem was found in the Incoming Message, and let it decide if it wants to be an Ally or not
                receiver.ProcessAllegiance(found, Sender);
            }
        }
Exemple #5
0
 //Method that is used to process allegiance for the Kingdom that Receives a Message. We can do all sorts of checks here before the Kingdom registers itself as an Ally of another Kingdom (Message Sender)
 //The 'ruler' object is the Kingdom that sent the message
 public void ProcessAllegiance(bool flag, Kingdom ruler)
 {
     //The Flag is sent in by the Message Processor, confirming that the Kingdom's emblem was found in the Incoming Message
     if (flag)
     {
         //The Kingdom can only be an Ally if it is not already an Ally of another kingdom AND is not competing for rulership of Southeros
         if (!isAlly && !isCompetingForRulership)
         {
             isAlly   = true;
             isAllyOf = ruler.GetKingdomName();
             //If everything is satisfactory, the Kingdom which is processing the allegiance registers itself as an Ally of the 'ruler' kingdom
             ruler.SetAlly(this);
         }
     }
 }
Exemple #6
0
        public bool ProcessMessageForKingdom(string msg, Kingdom receiver)
        {
            var found = receiver.GetEmblem().ToCharArray().Select(c => char.ToUpper(c)).Distinct().All(c => msg.ToUpper().Contains(c));

            return(found);
        }