Exemplo n.º 1
0
        public override void UpdateValues(Database db)
        {
            Planet destination, nextStop, orbiting;

            if (kDestination != "" &&
                db.Planets.TryGetValue(kDestination, out destination))
            {
                Destination = destination;
            }
            else if (Destination != null)
            {
                Destination = null;
            }
            if (kNextStop != "" &&
                db.Planets.TryGetValue(kNextStop, out nextStop))
            {
                NextStop = nextStop;
            }
            else if (NextStop != null)
            {
                NextStop = null;
            }
            if (kOrbiting != "" &&
                db.Planets.TryGetValue(kOrbiting, out orbiting))
            {
                Orbiting = orbiting;
                Position = Orbiting.Position;
            }
            else if (Orbiting != null)
            {
                Orbiting = null;
            }
            Military = db.Militaries[kMilitary];
        }
Exemplo n.º 2
0
 public Military()
 {
     ID             = "";
     Name           = "";
     kSuperMilitary = kGovernment = "";
     Branches       = new HashSet <Military>();
     Fleets         = new HashSet <Fleet>();
     _superMilitary = null;
     _government    = null;
 }
Exemplo n.º 3
0
 public Fleet()
 {
     ID           = "";
     Name         = "";
     kDestination = kNextStop = kOrbiting = "";
     Destination  = NextStop = Orbiting = null;
     Military     = null;
     Position     = new Coordinate(0, 0, 0);
     Ships        = new List <Ship>();
     Speed        = 1f;
 }
Exemplo n.º 4
0
 public Government()
 {
     ID                = "";
     Name              = Description = "";
     kSuperGovernment  = kMilitary = "";
     ExecutivePower    = LegislativePower = JudicialPower = ResidentialTax = CommercialTax = 0f;
     MemberPlanets     = new HashSet <Planet>();
     Relationships     = new JDictionary <string, Relationship>();
     Relationships[ID] = Relationship.Ally;
     Budget            = new Budget();
     Military          = null;
     SuperGovernment   = null;
     SubGovernments    = new HashSet <Government>();
 }
Exemplo n.º 5
0
        private int Match(Military comparison, string query, bool fromSub, bool fromSuper)
        {
            int rank = -1;

            if (Match(comparison.Name, query))
            {
                return(0);
            }
            if (!fromSuper)
            {
                if (comparison.Government != null)
                {
                    rank = BestRank(rank,
                                    Match(comparison.Government, query, true, false),
                                    2);
                }
                else if (comparison.SuperMilitary != null)
                {
                    rank = BestRank(rank,
                                    Match(comparison.SuperMilitary, query, true, false),
                                    1);
                }
            }
            if (!fromSub)
            {
                foreach (Fleet f in comparison.Fleets)
                {
                    rank = BestRank(rank,
                                    Match(f, query, false, true),
                                    2);
                }
                foreach (Military m in comparison.Branches)
                {
                    rank = BestRank(rank,
                                    Match(m, query, false, true),
                                    2);
                }
            }
            return(rank);
        }
Exemplo n.º 6
0
        public override void UpdateValues(Database db)
        {
            Government government;
            Military   military;

            if (db.Governments.TryGetValue(kSuperGovernment, out government))
            {
                SuperGovernment = government;
            }
            if (db.Militaries.TryGetValue(kMilitary, out military))
            {
                Military = military;
            }
            foreach (string k in Relationships.Keys)
            {
                if (!db.Governments.ContainsKey(k))
                {
                    Relationships.Remove(k);
                }
            }
            Relationships[ID] = Relationship.Ally;
        }