private void declarePeace(DipRel rel)
        {
            World.log("Peace breaks out between " + rel.a.getName() + " and " + rel.b.getName());

            turnMessages.Add(new MsgEvent("The war between " + rel.war.att.getName() + " and " + rel.war.def.getName() + " winds down", MsgEvent.LEVEL_YELLOW, false));

            rel.war   = null;
            rel.state = DipRel.dipState.none;
        }
示例#2
0
 internal void set(SocialGroup key, DipRel value)
 {
     for (int i = 0; i < keys.Count; i++)
     {
         if (keys[i].Equals(key.randID))
         {
             values[i] = value;
             return;
         }
     }
     add(key, value);
 }
        //public double permanentThreat;

        public SocialGroup(Map map)
        {
            this.map = map;
            color    = getViableColor();
            color2   = getViableColor();
            name     = "SocialGroup";
            randID   = Eleven.random.NextDouble();

            //Self-diplomacy
            DipRel rel = new DipRel(map, this, this);

            selfRel = rel;
            relations.Add(this, rel);

            addHistory("We came into existence");
        }
        public DipRel getRel(SocialGroup soc)
        {
            if (relations.ContainsKey(soc))
            {
                return(relations.lookup(soc));
            }
            if (soc.relations.ContainsKey(this))
            {
                relations.Add(soc, soc.relations.lookup(this));
                return(relations.lookup(soc));
            }
            DipRel rel = new DipRel(map, this, soc);

            relations.Add(soc, rel);
            soc.relations.Add(this, rel);

            return(rel);
        }
示例#5
0
        public SocialGroup(Map map)
        {
            this.map = map;
            color    = new Color(
                (float)Eleven.random.NextDouble(),
                (float)Eleven.random.NextDouble(),
                (float)Eleven.random.NextDouble());
            color2 = new Color(
                (float)Eleven.random.NextDouble(),
                (float)Eleven.random.NextDouble(),
                (float)Eleven.random.NextDouble());
            name = "SocialGroup";

            //Self-diplomacy
            DipRel rel = new DipRel(map, this, this);

            selfRel = rel;
            relations.Add(this, rel);
        }
示例#6
0
        private void declarePeace(DipRel rel)
        {
            World.log("Peace breaks out between " + rel.nameA + " and " + rel.nameB);

            turnMessages.Add(new MsgEvent("The war between " + rel.war.att.getName() + " and " + rel.war.def.getName() + " winds down", MsgEvent.LEVEL_YELLOW, false));

            rel.war   = null;
            rel.state = DipRel.dipState.none;

            SocialGroup a = rel.getA();
            SocialGroup b = rel.getB();

            if (a != null)
            {
                a.addHistory("Now at peace with " + rel.nameB);
            }
            if (b != null)
            {
                b.addHistory("Now at peace with " + rel.nameA);
            }
        }
示例#7
0
 public void add(SocialGroup key, DipRel value)
 {
     keys.Add(key.randID);
     values.Add(value);
 }
示例#8
0
 public void Add(SocialGroup key, DipRel value)
 {
     add(key, value);
 }
示例#9
0
        public override void castInner(Map map, Unit u)
        {
            Society soc = (Society)u.location.soc;

            SocialGroup enemy = null;

            foreach (SocialGroup sg in map.socialGroups)
            {
                if (sg.getRel(u.location.soc).state == DipRel.dipState.war)
                {
                    bool controlled = false;
                    if (sg is Society)
                    {
                        Society sgSoc = (Society)sg;
                        if (sgSoc.isDarkEmpire)
                        {
                            controlled = true;
                        }
                    }
                    else
                    {
                        controlled = sg.isDark();
                    }
                    if (controlled && sg.currentMilitary > u.location.soc.currentMilitary)
                    {
                        enemy = sg;
                    }
                }
            }
            if (enemy == null)
            {
                map.world.prefabStore.popMsg(soc.getName() + " is not at war with a superior military you control."); return;
            }

            HashSet <Person> targets = new HashSet <Person>();

            foreach (Person p in soc.people)
            {
                targets.Add(p);
            }
            int nSaved = 0;

            foreach (Location loc in map.locations)
            {
                if (loc.soc == soc)
                {
                    foreach (Location l2 in loc.getNeighbours())
                    {
                        if (l2.soc != soc)
                        {
                            if (l2.person() != null)
                            {
                                targets.Add(l2.person());
                            }
                        }
                    }
                    nSaved += 1;
                }
            }
            if (nSaved >= 10)
            {
                AchievementManager.unlockAchievement(SteamManager.achievement_key.SAVIOUR);
            }

            foreach (Person p in targets)
            {
                double boost = 100;
                //Let's not overcomplicate this one
                //foreach (ThreatItem item in p.threatEvaluations)
                //{
                //    if (item.group == enemy)
                //    {
                //        boost = item.threat;
                //    }
                //}
                //if (boost > 150) { boost = 150; }
                //if (boost < 25) { boost = 25; }
                p.getRelation(u.person).addLiking(boost, "Our Saviour!", map.turn, RelObj.STACK_REPLACE, true);
            }

            DipRel rel = soc.getRel(enemy);

            if (rel.war != null)
            {
                rel.war.startTurn = map.turn;
            }
            List <Unit> rems = new List <Unit>();

            foreach (Unit u2 in map.units)
            {
                if (u2.society == enemy && u2.isMilitary)
                {
                    rems.Add(u2);
                }
                else if (u2.society == soc && u2 is Unit_Army)
                {
                    u2.task = null;//Retask, to drop the 'defend the homeland' defensive task and go on the offensive
                }
            }
            foreach (Unit u2 in rems)
            {
                u2.die(map, "Killed by The Saviour");
            }
            soc.posture = Society.militaryPosture.offensive;//Flip to assault mode to ruin the dark forces

            Evidence e2 = new Evidence(map.turn);

            e2.pointsTo = u;
            e2.weight   = u.location.map.param.unit_majorEvidence;
            u.location.evidence.Add(e2);

            u.location.map.world.prefabStore.popImgMsg(u.getName() + " saves " + soc.getName() + " from invasion by " + enemy.getName() + "."
                                                       + "\nNobles within the nation, and those adjacent to it gain liking for " + soc.getName() + ". " + targets.Count + " nobles affected. " + rems.Count + " units killed."
                                                       + soc.getName() + " will now wage this war with renewed vigour, driving back their dark enemy",
                                                       u.location.map.world.wordStore.lookup("ABILITY_SAVIOUR_INVASION"), 7);
        }