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 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"); }