Esempio n. 1
0
        public void takeLocationFromOther(SocialGroup att, SocialGroup def, Location taken)
        {
            World.log(att.getName() + " takes " + taken.getName() + " from " + def.getName());
            int  priority = MsgEvent.LEVEL_YELLOW;
            bool benefit  = !def.hasEnthralled();

            if (att.hasEnthralled())
            {
                priority = MsgEvent.LEVEL_GREEN;
            }
            else if (def.hasEnthralled())
            {
                priority = MsgEvent.LEVEL_RED;
            }
            else
            {
                priority = MsgEvent.LEVEL_YELLOW;
            }


            addMessage(new MsgEvent(att.getName() + " takes " + taken.getName() + " from " + def.getName(), priority, benefit));

            if (taken.settlement != null)
            {
                if (taken.settlement.isHuman == false)
                {
                    taken.settlement = null;//Burn it down
                }
                else if (taken.settlement.title != null && taken.settlement.title.heldBy != null)
                {
                    Person lord = taken.settlement.title.heldBy;
                    if (att is Society)
                    {
                        Society socAtt = (Society)att;
                        lord.prestige *= param.combat_prestigeLossFromConquest;
                        foreach (Title t in lord.titles)
                        {
                            t.heldBy = null;
                        }
                        lord.titles.Clear();


                        movePerson(lord, socAtt);
                    }
                    else
                    {
                        lord.die("Killed by " + att.getName() + " when " + taken.getName() + " fell");
                    }
                }
            }

            taken.soc = att;
            att.takeLocationFromOther(def, taken);
        }
        public void declareWar(SocialGroup att, SocialGroup def)
        {
            World.log(att.getName() + " declares war on " + def.getName());
            int  priority = MsgEvent.LEVEL_ORANGE;
            bool good     = false;

            if (att.hasEnthralled())
            {
                good = true; priority = MsgEvent.LEVEL_GREEN;
            }
            if (def.hasEnthralled())
            {
                priority = MsgEvent.LEVEL_RED;
            }
            turnMessages.Add(new MsgEvent(att.getName() + " launches an offensive against " + def.getName(), priority, good));

            att.getRel(def).state = DipRel.dipState.war;
            att.getRel(def).war   = new War(this, att, def);
        }
        public void takeLocationFromOther(SocialGroup att, SocialGroup def, Location taken)
        {
            World.log(att.getName() + " takes " + taken.getName() + " from " + def.getName());
            int  priority = MsgEvent.LEVEL_YELLOW;
            bool benefit  = !def.hasEnthralled();

            if (att.hasEnthralled())
            {
                priority = MsgEvent.LEVEL_GREEN;
            }
            else if (def.hasEnthralled())
            {
                priority = MsgEvent.LEVEL_RED;
            }
            else
            {
                priority = MsgEvent.LEVEL_YELLOW;
            }


            turnMessages.Add(new MsgEvent(att.getName() + " takes " + taken.getName() + " from " + def.getName(), priority, benefit));

            if (taken.settlement != null)
            {
                if (taken.settlement.isHuman == false)
                {
                    taken.settlement = null;//Burn it down
                }
                else if (taken.settlement.title != null && taken.settlement.title.heldBy != null)
                {
                    Person lord = taken.settlement.title.heldBy;
                    if (att is Society)
                    {
                        Society socAtt = (Society)att;
                        lord.prestige *= param.combat_prestigeLossFromConquest;
                        if (socAtt.getSovreign() != null)
                        {
                            lord.getRelation(socAtt.getSovreign()).addLiking(param.person_likingFromBeingInvaded, "Their nation invaded mine", turn);
                        }
                        foreach (Title t in lord.titles)
                        {
                            t.heldBy = null;
                        }
                        lord.titles.Clear();


                        movePerson(lord, socAtt);
                    }
                    else
                    {
                        lord.die("Killed by " + att.getName() + " when " + taken.getName() + " fell");
                    }
                }
            }

            taken.soc = att;
            att.takeLocationFromOther(def, taken);

            bool hasRemainingTerritory = false;

            foreach (Location loc in locations)
            {
                if (loc.soc == def)
                {
                    hasRemainingTerritory = true;
                    break;
                }
            }
            if (!hasRemainingTerritory)
            {
                World.log("Last territory taken");
                addMessage(def.getName() + " has lost its last holdings to " + att.getName());

                /*
                 * if (att is Society && def is Society)
                 * {
                 *  Society sAtt = (Society)att;
                 *  Society sDef = (Society)def;
                 *  List<Person> toMove = new List<Person>();
                 *  foreach (Person p in sDef.people)
                 *  {
                 *      if (p.title_land == null)
                 *      {
                 *          toMove.Add(p);
                 *      }
                 *  }
                 *  foreach (Person p in toMove)
                 *  {
                 *      movePerson(p, sAtt);
                 *      addMessage(p.getFullName() + " is now part of the court of " + att.getName(), MsgEvent.LEVEL_GRAY, false);
                 *  }
                 * }
                 */
            }
        }
Esempio n. 4
0
        public void declareWar(SocialGroup att, SocialGroup def)
        {
            World.log(att.getName() + " declares war on " + def.getName());
            int  priority = MsgEvent.LEVEL_ORANGE;
            bool good     = false;

            if (att.hasEnthralled())
            {
                good = true; priority = MsgEvent.LEVEL_GREEN;
            }
            if (def.hasEnthralled())
            {
                priority = MsgEvent.LEVEL_RED;
            }
            Location attLoc = null;

            foreach (Location loc in locations)
            {
                if (loc.soc == att)
                {
                    attLoc = loc;
                }
            }
            Hex focusHex = null;

            if (attLoc != null)
            {
                focusHex = attLoc.hex;
            }
            turnMessages.Add(new MsgEvent(att.getName() + " launches an offensive against " + def.getName(), priority, good, focusHex));

            att.getRel(def).state = DipRel.dipState.war;
            att.getRel(def).war   = new War(this, att, def);

            if (def.getRel(att).state != DipRel.dipState.war)
            {
                throw new Exception("Asymmetric war");
            }

            foreach (Location loc in locations)
            {
                if (loc.soc == att || loc.soc == def)
                {
                    if (loc.settlement != null && loc.settlement.embeddedUnit != null)
                    {
                        loc.units.Add(loc.settlement.embeddedUnit);
                        units.Add(loc.settlement.embeddedUnit);
                        loc.settlement.embeddedUnit = null;
                    }
                }
            }

            if (att is Society)
            {
                Society sAtt = (Society)att;
                sAtt.crisisWarLong  = "We are at war, attacking " + def.getName() + ". We can discuss how to deploy our forces.";
                sAtt.crisisWarShort = "Crisis: At War";
                //Get the agents moving early, or they'll stick around doing whatever nonsense they previously were
                foreach (Unit u in units)
                {
                    if (u.society == def &&
                        u is Unit_Investigator &&
                        (((Unit_Investigator)u).state == Unit_Investigator.unitState.basic || ((Unit_Investigator)u).state == Unit_Investigator.unitState.knight) &&
                        (u.task is Task_Disrupted == false))
                    {
                        u.task = new Task_DefendHomeland();
                    }
                }
            }
            att.addHistory("We declared war on " + def.getName());
            if (def is Society)
            {
                Society sDef = (Society)def;
                sDef.crisisWarLong  = att.getName() + " has attacked us, and we are at war. We must respond to this crisis.";
                sDef.crisisWarShort = "Crisis: At War";
                //Get the agents moving early, or they'll stick around doing whatever nonsense they previously were
                foreach (Unit u in units)
                {
                    if (u.society == def &&
                        u is Unit_Investigator &&
                        (((Unit_Investigator)u).state == Unit_Investigator.unitState.basic || ((Unit_Investigator)u).state == Unit_Investigator.unitState.knight) &&
                        (u.task is Task_Disrupted == false))
                    {
                        u.task = new Task_DefendHomeland();
                    }
                }
            }
            def.addHistory(att.getName() + " declared war on us");
        }