Example #1
0
 public static void join(PopUnit pop)
 {
     if (pop.getMovement() == null)
     {
         var goal = pop.getMostImportantIssue();
         if (!goal.Equals(default(KeyValuePair <AbstractReform, AbstractReformValue>)))
         {
             //find reasonable goal and join
             var found = pop.Country.movements.Find(x => x.getGoal() == goal.Value);
             if (found == null)
             {
                 pop.setMovement(new Movement(goal.Key, goal.Value, pop, pop.Country));
             }
             else
             {
                 found.add(pop);
                 pop.setMovement(found);
             }
         }
     }
     else // change movement
     if (Game.Random.Next(Options.PopChangeMovementRate) == 1)
     {
         leave(pop);
         join(pop);
     }
 }
Example #2
0
 public static void join(PopUnit pop)
 {
     if (pop.getMovement() == null)
     {
         var goal = pop.getMostImportantIssue();// getIssues().MaxByRandom(x => x.Value);
         //todo if it's null it should throw exception early
         //if (!goal.Equals(default(KeyValuePair<AbstractReform, IReformValue>)))
         //if (!ReferenceEquals(goal, null))
         {
             //find reasonable goal and join
             var found = pop.Country.Politics.AllMovements.FirstOrDefault(x => x.getGoal() == goal.Value);
             if (found == null)
             {
                 pop.setMovement(new Movement(goal.Key, goal.Value, pop, pop.Country));
             }
             else
             {
                 found.add(pop);
                 pop.setMovement(found);
             }
         }
     }
     else // change movement
     if (Rand.Get.Next(Options.PopChangeMovementRate) == 1)
     {
         leave(pop);
         join(pop);
     }
 }
Example #3
0
        public static void leave(PopUnit pop)
        {
            if (pop.getMovement() != null)
            {
                pop.getMovement().demobilize(x => x.getPopUnit() == pop);
                pop.getMovement().members.Remove(pop);

                if (pop.getMovement().members.Count == 0)
                {
                    pop.getMovement().demobilize();
                    pop.Country.movements.Remove(pop.getMovement());
                }
                pop.setMovement(null);
            }
        }