Пример #1
0
        public override bool castable(Map map, Hex hex)
        {
            if (hex.location == null)
            {
                return(false);
            }
            if (hex.location.soc == null)
            {
                return(false);
            }
            if (map.overmind.enthralled == null)
            {
                return(false);
            }
            if (hex.location.soc != map.overmind.enthralled.society)
            {
                return(false);
            }



            Society soc = (Society)hex.location.soc;

            if (soc.voteSession == null)
            {
                return(false);
            }

            double sumLiking = 0;

            foreach (Person p in soc.people)
            {
                if (p == map.overmind.enthralled)
                {
                    continue;
                }
                sumLiking += p.getRelation(map.overmind.enthralled).getLiking(p, map.overmind.enthralled);
            }

            return(sumLiking > 0);
        }
        public override void castInner(Map map, Unit u)
        {
            Property.addProperty(map, u.location, "Red Death");
            u.location.map.world.prefabStore.popImgMsg("The first victim of this wave of the Red Death is in " + u.location.getName() + "."
                                                       + " The disease will spread between cities (unless quarantined or immune), and will decrease the city's population by 1 per turn.",
                                                       u.location.map.world.wordStore.lookup("ABILITY_RED_DEATH_ORIGIN"), 5);

            if (u.location.soc != null && u.location.soc is Society)
            {
                Society soc = (Society)u.location.soc;
                soc.crisisPlague     = "Plagues have appeared in our lands";
                soc.crisisPlagueLong = "Diseases are spreading throughout our lands, carried by some unknown ghastly apparition";
            }

            double   amount = map.param.unit_majorEvidence;
            Evidence e2     = new Evidence(map.turn);

            e2.pointsTo = u;
            e2.weight   = amount;
            u.location.evidence.Add(e2);
        }
Пример #3
0
        public override bool castable(Map map, Person person)
        {
            if (map.overmind.enthralled == null)
            {
                return(false);
            }
            if (person == map.overmind.enthralled)
            {
                return(false);
            }
            if (person.getRelation(map.overmind.enthralled).getLiking() < World.staticMap.param.ability_switchVoteLikingCost)
            {
                return(false);
            }

            if (map.overmind.enthralled.society == null)
            {
                throw new Exception("Enthralled didn't have a society?");
            }
            Society soc = map.overmind.enthralled.society;

            if (soc.voteSession == null)
            {
                return(false);
            }
            if (soc.voteSession.issue == null)
            {
                throw new Exception("Vote session didn't have an issue? Why?");
            }

            //Check the enthralled was actually voting one way or the other
            foreach (VoteOption opt in soc.voteSession.issue.options)
            {
                if (opt.votesFor.Contains(map.overmind.enthralled))
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #4
0
        public override void castInner(Map map, Person other)
        {
            int nTouched = 0;

            foreach (SocialGroup sg in map.socialGroups)
            {
                if (sg is Society)
                {
                    Society soc = (Society)sg;
                    foreach (Person p in soc.people)
                    {
                        bool affected = false;
                        foreach (Person p2 in soc.people)
                        {
                            if (p2 == p)
                            {
                                continue;
                            }
                            double delta = p.shadow - p2.shadow;//How much more shadow we have than they do
                            if (delta <= 0)
                            {
                                continue;
                            }

                            affected = true;
                            delta   *= -map.param.ability_hateTheLightMult;
                            p.getRelation(p2).addLiking(delta, "Hate the Light", map.turn);
                        }
                        if (affected)
                        {
                            nTouched += 1;
                        }
                    }
                }
            }

            map.world.prefabStore.popImgMsg("The enshadowed of the world grow to hate those not touched by your shadow. " + nTouched + " nobles have gained dislike for the non-enshadowed of their nations.",
                                            map.world.wordStore.lookup("ABILITY_HATE_THE_LIGHT"));
        }
Пример #5
0
 private void computeSuspicionGain()
 {
     foreach (SocialGroup sg in map.socialGroups)
     {
         if (sg is Society == false)
         {
             continue;
         }
         Society soc = (Society)sg;
         foreach (Person p in soc.people)
         {
             if (p == this)
             {
                 continue;
             }
             double infoAvail    = map.getInformationAvailability(this.getLocation(), sg);
             RelObj rel          = getRelation(p);
             double evidenceMult = Math.Pow(p.evidence, map.param.person_evidenceExponent);//Make low evidence a bit slower to cause suspicion
             rel.suspicion += infoAvail * evidenceMult * map.param.person_suspicionPerEvidence;
         }
     }
 }
        public override void castInner(Map map, Unit u)
        {
            if (u.location.soc != null && u.location.soc is Society)
            {
                Society soc = (Society)u.location.soc;
                soc.crisisPlague     = "Plagues have appeared in our landsare increasing in ferocity";
                soc.crisisPlagueLong = "The diseases in our land have increased in intensity, and are devastating our populations";
            }

            double   amount = map.param.unit_majorEvidence;
            Evidence e2     = new Evidence(map.turn);

            e2.pointsTo = u;
            e2.weight   = amount;
            u.location.evidence.Add(e2);

            u.task = new Task_LethalStrain();

            u.location.map.world.prefabStore.popImgMsg(u.getName() + " begins increasing the diseases in and around " + u.location.getName() + "."
                                                       + " Every turn they spend will drop the human population in this location and all connected which have a disease.",
                                                       u.location.map.world.wordStore.lookup("ABILITY_RED_LETHAL_STRAIN"), 5);
        }
Пример #7
0
        public override void castInner(Map map, Person other)
        {
            Society soc = map.overmind.enthralled.society;

            soc.voteSession.assignVoters();
            VoteOption enthOpt  = null;
            VoteOption otherOpt = null;

            foreach (VoteOption opt in soc.voteSession.issue.options)
            {
                if (opt.votesFor.Contains(map.overmind.enthralled))
                {
                    enthOpt = opt;
                }
                if (opt.votesFor.Contains(other))
                {
                    otherOpt = opt;
                }
            }
            if (enthOpt == null)
            {
                throw new Exception("Enthralled wasn't voting for some reason");
            }

            if (soc.voteSession.issue.computeUtility(other, enthOpt, new System.Collections.Generic.List <ReasonMsg>()) < -50)
            {
                map.world.prefabStore.popMsg(other.getFullName() + " refuses to change their vote, as they are too opposed to voting for " + enthOpt.info() + ".");
                return;
            }

            other.forcedVoteSession = soc.voteSession;
            other.forcedVoteOption  = enthOpt;
            other.getRelation(map.overmind.enthralled).addLiking(-World.staticMap.param.ability_switchVoteLikingCost, "Asked to change vote", map.turn);


            map.world.prefabStore.popImgMsg(
                other.getFullName() + " is now voting for " + enthOpt.info(soc.voteSession.issue),
                map.world.wordStore.lookup("SOC_CHANGE_VOTE"));
        }
        public override void castInner(Map map, Person person)
        {
            Society soc = person.society;

            int nAffected = 0;

            foreach (Person p in soc.people)
            {
                bool       affected = false;
                ThreatItem t        = p.getGreatestThreat();
                if (t.threat >= map.param.person_fearLevel_terrified)
                {
                    foreach (Person p2 in soc.people)
                    {
                        if (p2 == p)
                        {
                            continue;
                        }
                        if (p2.state == Person.personState.enthralled)
                        {
                            continue;
                        }
                        if (p2.getMilitarism() < 0)
                        {
                            p.getRelation(p2).addLiking(map.param.ability_denouncePacisfistsLiking, "Pacifists expose us to danger", map.turn);
                        }
                    }
                    if (affected)
                    {
                        nAffected += 1;
                    }
                }
            }

            map.world.prefabStore.popImgMsg(
                "You call on the nobles of " + soc.getName() + " to reject the pacifists in their midst, explaining that these people are exposing you all to danger by refusing to take up arms against your many foes.\n" +
                nAffected + " nobles are affected.",
                map.world.wordStore.lookup("ABILITY_DENOUNCE_PACIFISTS"));
        }
        public override bool castable(Map map, Hex hex)
        {
            if (hex.location == null)
            {
                return(false);
            }
            if (hex.location.soc == null)
            {
                return(false);
            }
            if (hex.location.soc is Society == false)
            {
                return(false);
            }

            Society soc = (Society)hex.location.soc;

            if (soc.voteSession == null)
            {
                return(false);
            }
            return(true);
        }
Пример #10
0
        public void setToSociety(Society soc)
        {
            state = uiState.SOCIETY;

            uiMainMenu.gameObject.SetActive(false);
            uiLeftPrimary.gameObject.SetActive(true);
            uiScrollables.gameObject.SetActive(true);
            uiMidTop.gameObject.SetActive(true);
            uiVoting.gameObject.SetActive(false);
            hexSelector.SetActive(false);

            uiScrollables.viewSocButtonText.text = "View World";

            GraphicalSociety.purge();
            GraphicalMap.purge();

            GraphicalSociety.setup(soc);

            uiLeftPrimary.maskTitle.text = "Neighbor Liking View";
            GraphicalSociety.refreshNeighbor(GraphicalSociety.focus);

            checkData();
        }
        public Unit_Investigator(Location loc, Society soc) : base(loc, soc)
        {
            maxHp = 5;
            hp    = 2;
            abilities.Add(new Abu_Inv_FalseAccusation());
            abilities.Add(new Abu_Inv_ProduceFalseEvidence());
            abilities.Add(new Abu_Inv_Incriminate());
            abilities.Add(new Abu_Base_Infiltrate());
            abilities.Add(new Abu_Base_SocialiseAtCourt());
            abilities.Add(new Abu_Base_PleadCase());
            abilities.Add(new Abu_Base_Recruit());
            abilities.Add(new Abu_Base_ChangeIdentity());
            //abilities.Add(new Abu_Base_Disrupt());
            //if (loc.map.simplified == false)
            //{
            //    abilities.Add(new Abu_Base_EnthrallNoble());
            //}
            abilities.Add(new Abu_Base_SpreadShadow());
            abilities.Add(new Abu_Base_SetLoose());
            abilities.Add(new Abu_Base_Apoptosis());

            turnLastChangedRole = loc.map.turn;
        }
        public override void implement(VoteOption option)
        {
            base.implement(option);
            if (option.index == 1)
            {
                bool            canVassalise = false;
                Society         receiever    = (Society)target;
                List <Location> trans        = new List <Location>();
                foreach (Location loc in society.map.locations)
                {
                    if (loc.soc == society)
                    {
                        trans.Add(loc);
                    }
                    if (loc.soc == target && loc.settlement != null)
                    {
                        canVassalise = true;
                    }
                }
                if (canVassalise)
                {
                    World.log(society.getName() + " VASSALISES UNDER " + target.getName());
                    society.map.turnMessages.Add(new MsgEvent(society.getName() + " vassalises under " + target.getName() + ", transferring all lands and landed nobles.", MsgEvent.LEVEL_RED, true, society.getCapitalHex()));

                    foreach (Location loc in trans)
                    {
                        receiever.map.takeLocationFromOther(receiever, society, loc);
                        if (loc.settlement != null && loc.settlement.embeddedUnit != null)
                        {
                            loc.settlement.embeddedUnit.society = target;
                        }
                    }
                    receiever.addHistory("#GRN_We absorbed " + society.getName() + ", as they vassalised under us. Took " + trans.Count + " locations.");
                }
            }
        }
Пример #13
0
        public void populate(Society soc, Person agent)
        {
            this.agent               = agent;
            societyName.text         = soc.getName();
            textVotingIssue.text     = soc.voteSession.issue.ToString();
            textVotingIssueDesc.text = soc.voteSession.issue.getLargeDesc();
            textProposer.text        = "Proposed by: " + soc.voteSession.issue.proposer.getFullName();
            if (soc.voteSession.issue.proposer != null)
            {
                World.log("Proposer: " + soc.voteSession.issue.proposer.getFullName());
                World.log("Text " + textProposerVote);
                textProposerVote.text = "Voting For: " + soc.voteSession.issue.proposer.getVote(soc.voteSession).info(soc.voteSession.issue);
                proposerBack.sprite   = soc.voteSession.issue.proposer.getImageBack();
                proposerMid.sprite    = soc.voteSession.issue.proposer.getImageMid();
                proposerFore.sprite   = soc.voteSession.issue.proposer.getImageFore();
                proposerBorder.sprite = soc.voteSession.issue.proposer.getImageBorder();
            }
            else
            {
                Person arbitrary = soc.getSovereign();
                if (arbitrary == null)
                {
                    arbitrary = soc.people[0];
                }
                if (arbitrary != null)
                {
                    textProposerVote.text = "";
                    proposerBack.sprite   = arbitrary.getImageBack();
                    proposerMid.sprite    = arbitrary.getImageMid();
                    proposerFore.sprite   = arbitrary.getImageFore();
                    proposerBorder.sprite = arbitrary.getImageBorder();
                }
            }
            foreach (Person p in soc.people)
            {
                PopVoterBar bar = world.prefabStore.getVoterBar(p);
                //bar.gameObject.transform.parent = this.gameObject.transform;
                voterBars.Add(bar);
            }
            foreach (VoteOption opt in soc.voteSession.issue.options)
            {
                PopOptBar bar = world.prefabStore.getVoteOptBar(opt, soc.voteSession);
                //bar.gameObject.transform.parent = this.gameObject.transform;
                voteOptBars.Add(bar);
            }
            viewSelf.gameObject.SetActive(false);
            if (agent != null)
            {
                textAgentName.text = "Interacting with:\n" + agent.getFullName();
                agentBack.sprite   = agent.getImageBack();
                agentBorder.sprite = agent.getImageBorder();
                agentFore.sprite   = agent.getImageFore();
                agentMid.sprite    = agent.getImageMid();
                textAgentDesc.text = "You may use the voter's liking for " + agent.getFullName() + " to sway their votes one way or another, spending this liking as political capital.";
            }
            else
            {
                agentBack.sprite   = world.textureStore.icon_mask;
                agentMid.sprite    = world.textureStore.icon_mask;
                agentBorder.sprite = world.textureStore.slotCount;
                agentFore.sprite   = world.textureStore.icon_mask;
                textAgentName.text = "Interacting without character";
                textAgentDesc.text = "If you interact with a society with an enthralled noble, or use an agent, you can spend the liking the voters have towards them to sway their votes.";
            }


            if (World.staticMap.param.option_useAdvancedGraphics == 1 && agent != null)
            {
                Person p = agent;
                if (p.isMale)
                {
                    agentMid.sprite   = p.map.world.textureStore.cultures[p.culture.graphicsIndex].m_faces[p.imgAdvFace];
                    agentEyes.sprite  = p.map.world.textureStore.cultures[p.culture.graphicsIndex].m_eyes[p.imgAdvEyes];
                    agentMouth.sprite = p.map.world.textureStore.cultures[p.culture.graphicsIndex].m_mouths[p.imgAdvMouth];
                    agentHair.sprite  = p.map.world.textureStore.cultures[p.culture.graphicsIndex].m_hair[p.imgAdvHair];
                    agentJewel.sprite = p.map.world.textureStore.cultures[p.culture.graphicsIndex].m_jewels[p.imgAdvJewel];
                }
                else
                {
                    agentMid.sprite   = p.map.world.textureStore.cultures[p.culture.graphicsIndex].f_faces[p.imgAdvFace];
                    agentEyes.sprite  = p.map.world.textureStore.cultures[p.culture.graphicsIndex].f_eyes[p.imgAdvEyes];
                    agentMouth.sprite = p.map.world.textureStore.cultures[p.culture.graphicsIndex].f_mouths[p.imgAdvMouth];
                    agentHair.sprite  = p.map.world.textureStore.cultures[p.culture.graphicsIndex].f_hair[p.imgAdvHair];
                    agentJewel.sprite = p.map.world.textureStore.cultures[p.culture.graphicsIndex].f_jewels[p.imgAdvJewel];
                }
                agentFore.sprite = p.getImageFore();
            }
            else
            {
                agentEyes.sprite  = World.self.textureStore.person_advClear;
                agentMouth.sprite = World.self.textureStore.person_advClear;
                agentHair.sprite  = World.self.textureStore.person_advClear;
                agentJewel.sprite = World.self.textureStore.person_advClear;
            }
            lastPos = World.self.ui.uiInputs.scrollwheelTracking;

            sess = soc.voteSession;
            checkData();

            if (agent != null && agent == soc.map.overmind.enthralled)
            {
                bGoToSelf();
                viewSelf.gameObject.SetActive(true);
            }
        }
 public Title_Sovreign(Society soc) : base(soc)
 {
     nameM = "King";
     nameF = "Queen";
 }
Пример #15
0
 public VoteIssue_MilitaryStance(Society soc, Person proposer) : base(soc, proposer)
 {
 }
 public VoteIssue(Society society, Person proposer)
 {
     this.society  = society;
     this.proposer = proposer;
 }
        public override double computeUtility(Person voter, VoteOption option, List <ReasonMsg> msgs)
        {
            double u = option.getBaseUtility(voter);

            //Option 0 is "Don't vassalise"
            //Multiply values based on this, as they should be symmetric for most parts
            double parityMult = 1;

            if (option.index == 0)
            {
                parityMult = -1;
            }


            double localU = 0;

            localU = voter.map.param.utility_vassaliseReluctance * parityMult;
            msgs.Add(new ReasonMsg("Inherent reluctance", localU));
            u += localU;

            Society socTarget = (Society)target;

            foreach (KillOrder order in socTarget.killOrders)
            {
                if (order.person == voter)
                {
                    localU = -1000 * parityMult;
                    msgs.Add(new ReasonMsg("Kill order against " + voter.getFullName(), localU));
                    u += localU;
                }
            }

            if (voter.society.defensiveTarget == null)
            {
                return(u);
            }

            double threatV = 0;

            foreach (ThreatItem threat in voter.threatEvaluations)
            {
                if (threat.group == voter.society.defensiveTarget)
                {
                    threatV = threat.threat;
                    break;
                }
            }

            /*
             * double ourStrength = society.currentMilitary;
             * double theirStrength = society.defensiveTarget.currentMilitary;
             * if (ourStrength + theirStrength == 0) { ourStrength += 0.001; }
             * //-1 if we're 100% of the balance, +1 if they are
             * double relativeStrength = (theirStrength - ourStrength) / (ourStrength + theirStrength);
             *
             * double relMilU = society.map.param.utility_vassaliseMilMult*relativeStrength * parityMult;
             * msgs.Add(new ReasonMsg("Military strength vs defensive target", relMilU));
             * u += relMilU;
             */

            double relThreatU = society.map.param.utility_vassaliseThreatMult * threatV * parityMult;

            msgs.Add(new ReasonMsg("Threat from defensive target", relThreatU));
            u += relThreatU;


            return(u);
        }
 public VoteIssue_Vassalise(Society soc, Society target, Person proposer) : base(soc, proposer)
 {
     this.target = target;
 }
        public List <VoteIssue> econIssues(Map map, Person p, Society society)
        {
            List <VoteIssue>    reply = new List <VoteIssue>();
            HashSet <EconTrait> all   = new HashSet <EconTrait>();
            HashSet <EconTrait> mine  = new HashSet <EconTrait>();

            foreach (EconTrait trait in p.title_land.settlement.econTraits())
            {
                mine.Add(trait);
            }
            foreach (Location loc in map.locations)
            {
                if (loc.soc == society && loc.settlement != null)
                {
                    foreach (EconTrait trait in loc.settlement.econTraits())
                    {
                        all.Add(trait);
                    }
                }
            }

            foreach (EconTrait econ_from in all)
            {
                if (mine.Contains(econ_from))
                {
                    continue;
                }                                          //Don't take from yourself
                foreach (EconTrait econ_to in mine)
                {
                    VoteIssue issue = new VoteIssue_EconomicRebalancing(society, p, econ_from, econ_to);
                    //Allow them to spam econ votes
                    //if (lastProposedIssue != null && lastProposedIssue.GetType() == issue.GetType()) { break; }//Already seen this proposal, most likely. Make another or skip

                    bool present = false;
                    foreach (EconEffect effect in society.econEffects)
                    {
                        if (effect.from == econ_from && effect.to == econ_to)
                        {
                            present = true;
                        }
                        if (effect.to == econ_from && effect.from == econ_to)
                        {
                            present = true;
                        }
                    }
                    if (present)
                    {
                        continue;
                    }

                    //We have our two options (one way or the other)
                    VoteOption opt1 = new VoteOption();
                    opt1.econ_from = econ_from;
                    opt1.econ_to   = econ_to;
                    issue.options.Add(opt1);
                    VoteOption opt2 = new VoteOption();
                    opt2.econ_from = econ_to;
                    opt2.econ_to   = econ_from;
                    issue.options.Add(opt2);

                    reply.Add(issue);
                }
            }
            return(reply);
        }
Пример #20
0
        public static void takeCommand(Map map, string command)
        {
            World.log("cheat command registered: " + command);


            try
            {
                if (command == "power")
                {
                    map.overmind.power = 100;
                }
                if (command == "testsave")
                {
                    map.world.save("testSave.sv");
                }
                if (command == "testload")
                {
                    map.world.load("testSave.sv");
                }
                if (command == "shadow")
                {
                    GraphicalMap.selectedHex.location.person().shadow = 1;
                }
                if (command == "aware")
                {
                    GraphicalMap.selectedHex.location.person().awareness = 1;
                }
                if (command == "testproperty")
                {
                    Property.addProperty(map, GraphicalMap.selectedHex.location, "Military Aid");
                    World.staticMap.world.ui.checkData();
                }
                if (command == "playback")
                {
                    World.staticMap.world.ui.addBlocker(World.staticMap.world.prefabStore.getPlayback(World.staticMap.world, World.staticMap).gameObject);
                }
                if (command == "uivoting")
                {
                    World.staticMap.world.ui.uiVoting.populate((Society)GraphicalMap.selectedHex.location.soc, GraphicalMap.selectedHex.location.person());
                    World.staticMap.world.ui.setToVoting();
                }
                if (command == "100")
                {
                    World.staticMap.world.b100Turns();
                }
                if (command == "enthrall")
                {
                    if (GraphicalMap.selectedHex.location.person() == null)
                    {
                        int    c      = 0;
                        Person choice = null;
                        foreach (Person p in ((Society)GraphicalMap.selectedHex.location.soc).people)
                        {
                            if (p.getLocation() == GraphicalMap.selectedHex.location)
                            {
                                c += 1;
                                if (Eleven.random.Next(c) == 0)
                                {
                                    choice = p;
                                }
                            }
                        }
                        choice.state            = Person.personState.enthralled;
                        map.overmind.enthralled = choice;
                    }
                    else
                    {
                        map.overmind.enthralled       = GraphicalMap.selectedHex.location.person();
                        map.overmind.enthralled.state = Person.personState.enthralled;
                    }
                }
                if (command == "love")
                {
                    foreach (Person p in map.overmind.enthralled.society.people)
                    {
                        p.getRelation(map.overmind.enthralled).addLiking(100, "Cheat love", map.turn);
                    }
                }
                if (command == "insanity")
                {
                    GraphicalMap.selectedHex.location.person().goInsane();
                }
                if (command == "hot")
                {
                    for (int i = 0; i < map.tempMap.Length; i++)
                    {
                        for (int j = 0; j < map.tempMap[0].Length; j++)
                        {
                            map.tempMap[i][j] += 0.1f;
                            if (map.tempMap[i][j] > 1)
                            {
                                map.tempMap[i][j] = 1;
                            }
                        }
                    }
                    map.assignTerrainFromClimate();
                    map.world.ui.checkData();
                }
                if (command == "cold")
                {
                    for (int i = 0; i < map.tempMap.Length; i++)
                    {
                        for (int j = 0; j < map.tempMap[0].Length; j++)
                        {
                            map.tempMap[i][j] -= 0.1f;
                            if (map.tempMap[i][j] < 0)
                            {
                                map.tempMap[i][j] = 0;
                            }
                        }
                    }
                    map.assignTerrainFromClimate();
                    map.world.ui.checkData();
                }
                if (command == "min sanity")
                {
                    GraphicalMap.selectedHex.location.person().sanity = 0.01;
                }
                if (command == "die")
                {
                    GraphicalMap.selectedHex.location.person().die("Killed by console");
                }
                if (command == "evidence")
                {
                    GraphicalMap.selectedHex.location.person().evidence = 1;
                }
                if (command == "10 evidence")
                {
                    GraphicalMap.selectedHex.location.person().evidence += 0.1;
                    if (GraphicalMap.selectedHex.location.person().evidence > 1)
                    {
                        GraphicalMap.selectedHex.location.person().evidence = 1;
                    }
                }
                if (command == "refresh")
                {
                    World.staticMap.overmind.hasTakenAction = false;
                }
                if (command == "unit")
                {
                    Unit u = new Unit_Investigator(GraphicalMap.selectedHex.location, (Society)GraphicalMap.selectedHex.location.soc);
                    map.units.Add(u);
                    GraphicalMap.selectedHex.location.units.Add(u);
                }
                if (command == "victory")
                {
                    World.staticMap.overmind.victory();
                }
                if (command == "placeevidence")
                {
                    GraphicalMap.selectedHex.location.evidence.Add(new Evidence(map.turn));
                    World.log("Placing evidence");
                }
                if (command == "vote")
                {
                    Society soc = map.overmind.enthralled.society;
                    if (soc.voteSession != null)
                    {
                        soc.voteSession.assignVoters();
                        World.log("Attempting to build blocker");
                        map.world.ui.addBlocker(map.world.prefabStore.getScrollSet(soc.voteSession, soc.voteSession.issue.options).gameObject);
                    }
                }
                map.world.ui.checkData();
            }
            catch (Exception e)
            {
                World.log(e.Message);
            }
        }
Пример #21
0
        public void checkData()
        {
            title.text = "";

            // FIXME: check if this needs to be done?
            foreach (Transform t in listContent)
            {
                GameObject.Destroy(t.gameObject);
            }

            activeSociety = getSociety(GraphicalMap.selectedHex);
            if (currentTab == Tab.Messages)
            {
                title.text = "EVENT MESSAGES";
                fillMessagesTab();
                return;
            }

            if (activeSociety == null)
            {
                return;
            }

            //title.text = soc.getName();
            switch (currentTab)
            {
            case Tab.People:
            {
                foreach (Person p in activeSociety.people)
                {
                    GameObject pp = Instantiate(portraitPrefab, listContent);
                    pp.GetComponent <Portrait>().SetInfo(p);
                }

                break;
            }

            case Tab.Places:
            {
                foreach (Settlement s in getSettlements(activeSociety))
                {
                    GameObject sp = Instantiate(portraitPrefab, listContent);
                    sp.GetComponent <Portrait>().SetInfo(s);
                }

                break;
            }

            case Tab.Votes:
            {
                if (activeSociety.voteSession != null)
                {
                    title.text = activeSociety.voteSession.issue.ToString();

                    Person p = null;
                    if (master.state == UIMaster.uiState.SOCIETY && GraphicalSociety.focus != null)
                    {
                        p = GraphicalSociety.focus;
                    }

                    Hex hex = GraphicalMap.selectedHex;
                    if (hex != null && hex.settlement != null && hex.settlement.title != null && hex.settlement.title.heldBy != null)
                    {
                        p = hex.settlement.title.heldBy;
                    }

                    activeSociety.voteSession.assignVoters();
                    foreach (VoteOption v in activeSociety.voteSession.issue.options)
                    {
                        GameObject vp = Instantiate(portraitPrefab, listContent);
                        vp.GetComponent <Portrait>().SetInfo(activeSociety.voteSession.issue, v, p);
                    }
                }

                break;
            }
            }
        }
Пример #22
0
 public void Start()
 {
     currentTab    = Tab.Messages;
     activeSociety = null;
 }
Пример #23
0
 public LogBox(Society p)
 {
     path = "logging" + World.separator + "societies" + World.separator + p.getName() + ".log";
     System.IO.File.WriteAllLines(path, new string[] { "Log for " + p.getName() });
 }
        public override void cast(Map map, Hex hex)
        {
            //base.cast(map, hex);

            Society soc = map.overmind.enthralled.society;

            Person    proposer = map.overmind.enthralled;
            VoteIssue issue    = null;

            List <VoteIssue> potentialIssues = new List <VoteIssue>();

            if (soc.posture == Society.militaryPosture.offensive && soc.offensiveTarget != null && (soc.isAtWar() == false))
            {
                issue = new VoteIssue_DeclareWar(soc, soc.offensiveTarget, proposer);
                potentialIssues.Add(issue);
                VoteOption option_0 = new VoteOption();
                option_0.index = 0;
                issue.options.Add(option_0);
                VoteOption option_1 = new VoteOption();
                option_1.index = 1;
                issue.options.Add(option_1);
            }


            if (proposer.title_land != null)
            {
                potentialIssues.AddRange(econIssues(map, proposer, soc));
            }

            //Remove unlanded nobles
            List <Person> removables = new List <Person>();

            foreach (Person p in soc.people)
            {
                if (p.title_land == null)
                {
                    removables.Add(p);
                }
            }
            if (removables.Count != 0)
            {
                issue = new VoteIssue_DismissFromCourt(soc, proposer);
                foreach (Person p in removables)
                {
                    VoteOption option = new VoteOption();
                    option.person = p;
                    issue.options.Add(option);
                }
                potentialIssues.Add(issue);
            }

            issue = new VoteIssue_MilitaryStance(soc, proposer);
            potentialIssues.Add(issue);
            for (int i = 0; i < 3; i++)
            {
                VoteOption opt = new VoteOption();
                opt.index = i;
                issue.options.Add(opt);
            }

            //Check to see if you want to alter offensive military targetting
            issue = new VoteIssue_SetOffensiveTarget(soc, proposer);
            foreach (SocialGroup neighbour in map.getExtendedNeighbours(soc))
            {
                VoteOption option = new VoteOption();
                option.group = neighbour;
                issue.options.Add(option);
            }
            potentialIssues.Add(issue);

            //Check to see if you want to alter defensive military targetting
            issue = new VoteIssue_SetDefensiveTarget(soc, proposer);
            foreach (ThreatItem item in proposer.threatEvaluations)
            {
                if (item.group == null)
                {
                    continue;
                }
                VoteOption option = new VoteOption();
                option.group = item.group;
                issue.options.Add(option);
            }

            //Check if you want to vassalise yourself
            if (soc.offensiveTarget != null && soc.posture == Society.militaryPosture.defensive && (soc.isAtWar() == false))
            {
                foreach (SocialGroup sg in soc.getNeighbours())
                {
                    if (sg is Society == false)
                    {
                        continue;
                    }
                    if (sg == soc)
                    {
                        continue;
                    }
                    Society other = (Society)sg;
                    if (other.defensiveTarget == soc.defensiveTarget)
                    {
                        issue = new VoteIssue_Vassalise(soc, other, proposer);
                        VoteOption option_0 = new VoteOption();
                        option_0.index = 0;
                        issue.options.Add(option_0);

                        VoteOption option_1 = new VoteOption();
                        option_1.index = 1;
                        issue.options.Add(option_1);

                        potentialIssues.Add(issue);
                    }
                }
            }


            //Check if you want to execute someone
            if (soc.posture == Society.militaryPosture.introverted)
            {
                foreach (Person p in soc.people)
                {
                    if (p == proposer)
                    {
                        continue;
                    }
                    issue = new VoteIssue_JudgeSuspect(soc, p, proposer);
                    VoteOption option_0 = new VoteOption();
                    option_0.index = 0;
                    issue.options.Add(option_0);

                    VoteOption option_1 = new VoteOption();
                    option_1.index = 1;
                    issue.options.Add(option_1);

                    potentialIssues.Add(issue);
                }
            }

            foreach (Title t in soc.titles)
            {
                if (t.turnLastAssigned - map.turn > map.param.society_minTimeBetweenTitleReassignments)
                {
                    issue = new VoteIssue_AssignTitle(soc, proposer, t);
                    potentialIssues.Add(issue);
                    //Everyone is eligible
                    foreach (Person p in soc.people)
                    {
                        VoteOption opt = new VoteOption();
                        opt.person = p;
                        issue.options.Add(opt);
                    }
                }
            }
            foreach (Location loc in map.locations)
            {
                if (loc.soc == soc && loc.settlement != null && loc.settlement.title != null)
                {
                    issue = new VoteIssue_AssignLandedTitle(soc, proposer, loc.settlement.title);
                    potentialIssues.Add(issue);
                    //Everyone is eligible
                    foreach (Person p in soc.people)
                    {
                        VoteOption opt = new VoteOption();
                        opt.person = p;
                        issue.options.Add(opt);
                    }
                }
            }

            map.world.ui.addBlocker(map.world.prefabStore.getScrollSet(this, soc, potentialIssues).gameObject);
            map.overmind.hasTakenAction = false;
        }
Пример #25
0
 public VoteIssue_EconomicRebalancing(Society soc, Person proposer, EconTrait from, EconTrait to) : base(soc, proposer)
 {
     this.econFrom = from;
     this.econTo   = to;
 }
Пример #26
0
 public VoteIssue_Crisis_EnshadowedNobles(Society soc, Person proposer, List <Evidence> evidence) : base(soc, proposer)
 {
     foundEvidence = evidence;
 }
Пример #27
0
        public override void turnTick(Unit unit)
        {
            if (unit.person == null)
            {
                unit.task = null; return;
            }
            if (unit.location.settlement == null)
            {
                unit.task = null; return;
            }
            if (unit.location.settlement.title == null)
            {
                unit.task = null; return;
            }
            if (unit.location.settlement.title.heldBy == null)
            {
                unit.task = null; return;
            }
            if (unit.location.soc is Society == false)
            {
                unit.task = null; return;
            }

            dur += 1;
            if (dur >= unit.location.map.param.unit_socialiseAtCourtTime)
            {
                Society soc         = (Society)unit.location.soc;
                double  maxPrestige = 0;
                foreach (Person p in soc.people)
                {
                    if (p.prestige > maxPrestige)
                    {
                        maxPrestige = p.prestige;
                    }
                }
                double prestige = unit.location.person().prestige;
                double scale    = 0;
                if (maxPrestige > 0)
                {
                    scale  = prestige / maxPrestige;
                    scale  = 1 - scale;//0 to 1, 1 if prestige is 0, 0 if prestige is MAX
                    scale *= 0.75;
                    scale += 0.25;
                }

                RelObj rel     = unit.location.settlement.title.heldBy.getRelation(unit.person);
                double maxGain = World.staticMap.param.unit_socialiseAtCourtGain;
                double delta   = maxGain * scale;
                delta = Math.Min(delta, 100 - rel.getLiking());
                if (delta < 0)
                {
                    delta = 0;
                }
                int iDelta = (int)(delta);

                rel.addLiking(iDelta, "Socialised at court", unit.location.map.turn);
                if (unit.isEnthralled())
                {
                    unit.location.map.world.prefabStore.popImgMsg(unit.getName() + " finishes socialising at court. " + unit.location.settlement.title.heldBy.getFullName() + "'s liking "
                                                                  + "for them increases by " + iDelta + " and is now " + ((int)rel.getLiking()), unit.location.map.world.wordStore.lookup("ABILITY_UNIT_SOCIALISE_AT_COURT"));
                }
                unit.task = null;
            }
        }
Пример #28
0
        public void bViewRelationships()
        {
            if (GraphicalMap.selectedSelectable is Unit == false)
            {
                return;
            }
            Unit u = (Unit)GraphicalMap.selectedSelectable;

            if (u.person == null)
            {
                return;
            }
            if (u.person.state == Person.personState.enthralledAgent)
            {
                List <RelObj> rels = new List <RelObj>();
                foreach (Unit u2 in u.location.map.units)
                {
                    if (u2 == u)
                    {
                        continue;
                    }
                    if (u2.person != null)
                    {
                        RelObj rel = u2.person.getRelation(u.person);
                        if (Math.Abs(rel.getLiking()) > 10 && rel.suspicion > 0)
                        {
                            rels.Add(rel);
                        }
                    }
                }
                foreach (SocialGroup sg in u.location.map.socialGroups)
                {
                    if (sg is Society)
                    {
                        Society soc = (Society)sg;
                        foreach (Person p in soc.people)
                        {
                            RelObj rel = p.getRelation(u.person);
                            if (Math.Abs(rel.getLiking()) > 10 && rel.suspicion > 0)
                            {
                                rels.Add(rel);
                            }
                        }
                    }
                }
                rels.Sort(this);

                world.ui.addBlocker(world.prefabStore.getScrollSetRelationsReflexive(rels).gameObject);
                return;
            }
            if (u.person.state == Person.personState.enthralled)
            {
                return;
            }
            {
                List <RelObj> rels = new List <RelObj>();
                foreach (RelObj rel in u.person.relations.Values)
                {
                    if (Math.Abs(rel.getLiking()) > 10)
                    {
                        rels.Add(rel);
                    }
                }
                rels.Sort(this);

                world.ui.addBlocker(world.prefabStore.getScrollSetRelations(rels).gameObject);
            }
        }
 public Title_ProvinceRuler(Society soc, Province province) : base(soc)
 {
     nameM         = "Duke";
     nameF         = "Duchess";
     this.province = province;
 }
Пример #30
0
        public void checkData_old()
        {
            Hex hex = GraphicalMap.selectedHex;

            if (hex == null)
            {
                title.text = "";
                //body.text = "";
            }
            else
            {
                title.text = GraphicalMap.selectedHex.getName();
                string bodyText = "Body text for hex " + GraphicalMap.selectedHex.getName();

                bodyText += "\nAttachedTo " + GraphicalMap.selectedHex.territoryOf.hex.getName();
                bodyText += "\nProvince: " + hex.province.name;
                if (hex.location != null)
                {
                    if (hex.location.settlement != null)
                    {
                        if (hex.location.settlement.title != null)
                        {
                            if (hex.location.settlement.title.heldBy != null)
                            {
                                bodyText += "\nTitle held by: " + hex.location.settlement.title.heldBy.getFullName();
                            }
                            else
                            {
                                bodyText += "\nTitle currently unheld";
                            }
                        }
                    }

                    if (hex.location.soc != null)
                    {
                        bodyText += "\nSocial group: " + hex.location.soc.getName();
                        if (hex.location.soc is Society)
                        {
                            Society locSoc = (Society)hex.location.soc;

                            foreach (EconEffect effect in locSoc.econEffects)
                            {
                                bodyText += "\nEcon from " + effect.from.name + " to " + effect.to.name;
                            }

                            foreach (Person p in locSoc.people)
                            {
                                bodyText += "\n   -" + p.getFullName();
                            }

                            if (locSoc.offensiveTarget != null)
                            {
                                bodyText += "\nOffensive: " + locSoc.offensiveTarget.getName();
                            }
                            else
                            {
                                bodyText += "\nOffensive: None";
                            }
                        }
                    }
                }
                foreach (EconTrait t in hex.province.econTraits)
                {
                    bodyText += "\n  Industry: " + t.name;
                }
                //body.text = bodyText;
            }
        }