Example #1
0
        public void Execute(CommodityVO commodity)
        {
            GossipModel model = AmbitionApp.Gossip;

            if (model.Quests.Count >= model.MaxQuests)
            {
                return;
            }

            FactionModel factions = AmbitionApp.GetModel <FactionModel>();
            QuestVO      quest    = new QuestVO();

            CommodityVO[] rewards;
            int           rewardTier = RNG.Generate(2) < 1 ? 0 : RNG.Generate(3) < 2 ? 1 : 2;

            if (!Enum.TryParse <FactionType>(commodity.ID, true, out quest.Faction))
            {
                List <FactionType> factionTypes = new List <FactionType>(factions.Factions.Keys);
                factionTypes.Remove(FactionType.None);
                quest.Faction = RNG.TakeRandom(factionTypes);
            }

            quest.Created = AmbitionApp.Calendar.Day;
            quest.Due     = commodity.Value >= 5
                ? quest.Created + commodity.Value
                : quest.Created + RNG.Generate(5) + RNG.Generate(4) + RNG.Generate(4) + 5;

            rewards      = model.RewardTiers[rewardTier].Rewards;
            quest.Reward = RNG.TakeRandom(rewards);
            AmbitionApp.Localization.SetCurrentQuest(quest);
            AmbitionApp.Gossip.Quests.Add(quest);
            AmbitionApp.Gossip.Broadcast();
        }
Example #2
0
        // TODO: Store them in order
        private string GetAllegianceString(int allegiance)
        {
            FactionModel fmod  = AmbitionApp.GetModel <FactionModel>();
            int          index = fmod.Allegiance.Length - 1;

            while (index >= 0 && allegiance >= fmod.Allegiance[index])
            {
                index--;
            }
            return(AmbitionApp.GetModel <LocalizationModel>().GetString("allegiance." + index.ToString()));
        }
Example #3
0
        public void Execute(CommodityVO reward)
        {
            FactionModel factions = AmbitionApp.GetModel <FactionModel>();

            if (reward.ID != null && factions.Factions.ContainsKey(reward.ID))
            {
                factions[reward.ID].Reputation += reward.Value;
                AmbitionApp.SendMessage(factions[reward.ID]);
            }
            else
            {
                AmbitionApp.GetModel <GameModel>().Reputation += reward.Value;
            }
        }
Example #4
0
        public void Execute(RoomVO room)
        {
            PartyModel   model = AmbitionApp.GetModel <PartyModel>();
            FactionModel fmod  = AmbitionApp.GetModel <FactionModel>();

            if (fmod[model.Party.Faction].Level >= 2)
            {
                AmbitionApp.SendMessage(PartyMessages.REFILL_DRINK);

                Dictionary <string, string> substitutions = new Dictionary <string, string>()
                {
                    { "$HOSTNAME", model.Party.Host }
                };
                AmbitionApp.OpenMessageDialog(DialogConsts.REPUTATION_WINE_DIALOG, substitutions);
            }
        }
Example #5
0
        public void Execute()
        {
            FactionModel       model = AmbitionApp.GetModel <FactionModel>();
            FactionStandingsVO standings;

            model.LastUpdated = AmbitionApp.Calendar.Day;
            model.Standings.Clear();
            foreach (FactionVO faction in model.Factions.Values)
            {
                standings            = new FactionStandingsVO();
                standings.Faction    = faction.Type;
                standings.Allegiance = faction.Allegiance;
                standings.Power      = faction.Power;
                model.Standings.Add(standings);
            }
        }
Example #6
0
        private void OnEnable()
        {
            FactionModel model = AmbitionApp.GetModel <FactionModel>();
            DateTime     date  = AmbitionApp.Calendar.StartDate.AddDays(model.LastUpdated);
            Dictionary <string, string> months = AmbitionApp.GetPhrases("month");
            Dictionary <string, string> subs   = new Dictionary <string, string>();

            months.TryGetValue(CalendarConsts.MONTH_LOC + (date.Month - 1), out string monthName);
            subs["%DAY%"]   = date.Day.ToString();
            subs["%MONTH%"] = monthName;
            subs["%YEAR%"]  = date.Year.ToString();
            string dateText = AmbitionApp.Localize(CalendarConsts.DATE, subs);

            subs.Clear();
            subs["$N"]    = (AmbitionApp.Calendar.Day - model.LastUpdated).ToString();
            subs["$DATE"] = dateText;
            Updated.text  = AmbitionApp.Localize(LAST_UPDATED_LOC, subs);
            Array.ForEach(List, i => i.Data = model.Standings.Find(f => f.Faction == i.Faction));
        }
Example #7
0
        public void Register(Core.ModelSvc modelSvc)
        {
            FactionModel       model = modelSvc.Register <FactionModel>();
            FactionStandingsVO standings;

            model.Factions.Clear();
            model.ResetValues.Clear();
            foreach (FactionVO faction in Factions)
            {
                model.Factions[faction.Type] = new FactionVO(faction);
                standings = new FactionStandingsVO()
                {
                    Faction    = faction.Type,
                    Power      = faction.Power,
                    Allegiance = faction.Allegiance
                };
                model.ResetValues.Add(standings);
            }
        }
Example #8
0
        // Use this for initialization
        void Start()
        {
            FactionModel fmod     = AmbitionApp.GetModel <FactionModel>();
            ServantModel servants = AmbitionApp.GetModel <ServantModel>();
            ServantVO    spymaster;

            availableSpymasterTestTheWaters = servants.Servants.TryGetValue(ServantConsts.SPYMASTER, out spymaster);
            availableTestTheWaters          = true;

            _allegianceTimers = new Dictionary <string, int>();
            _powerTimers      = new Dictionary <string, int>();
            foreach (string faction in fmod.Factions.Keys)
            {
                _powerTimers.Add(faction, 0);
                _allegianceTimers.Add(faction, 0);
            }

            IncrementKnowledgeTimers();
            UpdateInfo();
        }
Example #9
0
        public static bool Check(RequirementVO req)
        {
            //Debug.LogFormat("FactionAllegianceReq check");
            FactionModel factions   = AmbitionApp.GetModel <FactionModel>();
            int          allegiance = 0;

            if (Enum.TryParse(req.ID, ignoreCase: true, out FactionType factionID))
            {
                allegiance = factions.Factions.TryGetValue(factionID, out FactionVO faction)
                    ? faction.Allegiance : 0;

                //Debug.LogFormat("Faction {0} allegiance is {1}, checking {2} {3}",req.ID, allegiance, req.Operator, req.Value);
            }
            else
            {
                Debug.LogErrorFormat("Bad faction ID {0} in FactionAllegianceReq", req.ID);
            }

            return(RequirementsSvc.Check(req, allegiance));
        }
Example #10
0
        public static bool Check(RequirementVO req)
        {
            FactionModel model = AmbitionApp.GetModel <FactionModel>();

            char[]           sep      = new char[] { ',', ' ' };
            string[]         tokens   = req.ID.Split(sep);
            List <FactionVO> factions = new List <FactionVO>();
            FactionType      faction;

            foreach (string token in tokens)
            {
                if (Enum.TryParse(token, true, out faction))
                {
                    factions.Add(model.Factions[faction]);
                }
            }
            if (factions.Count > 1)
            {
                req.Value = factions[1].Power;
            }
            return(RequirementsSvc.Check(req, factions[0].Power));
        }
Example #11
0
        public void Execute(DateTime day)
        {
            FactionModel fmod = AmbitionApp.GetModel <FactionModel>();

            string victoriousPower;

            //Establish each Faction's final Power
            float crownFinalPower      = fmod["Crown"].Power * 100;
            float revolutionFinalPower = fmod["Third Estate"].Power * 100;

            if (fmod["Church"].Allegiance > 0)
            {
                crownFinalPower += (Math.Abs((float)(fmod["Church"].Allegiance / 2)) * fmod["Church"].Power);
            }
            else if (fmod["Church"].Allegiance < 0)
            {
                revolutionFinalPower += (Math.Abs((float)(fmod["Church"].Allegiance / 2)) * fmod["Church"].Power);
            }
            if (fmod["Military"].Allegiance > 0)
            {
                crownFinalPower += (Math.Abs((float)(fmod["Military"].Allegiance / 2)) * fmod["Military"].Power);
            }
            else if (fmod["Military"].Allegiance < 0)
            {
                revolutionFinalPower += (Math.Abs((float)(fmod["Military"].Allegiance / 2)) * fmod["Military"].Power);
            }
            if (fmod["Bourgeoisie"].Allegiance > 0)
            {
                crownFinalPower += (Math.Abs((float)(fmod["Bourgeoisie"].Allegiance / 2)) * fmod["Bourgeoisie"].Power);
            }
            else if (fmod["Bourgeoisie"].Allegiance < 0)
            {
                revolutionFinalPower += (Math.Abs((float)(fmod["Bourgeoisie"].Allegiance / 2)) * fmod["Bourgeoisie"].Power);
            }


            //Compare Final Powers (who won and by what degree?)
            victoriousPower = crownFinalPower >= revolutionFinalPower ? "Crown" : "Third Estate";
            //		isDecisive = Math.Abs(crownFinalPower - revolutionFinalPower) > 50;

            //Calculate Player Allegiance
            if (fmod["Crown"].Reputation > fmod["Third Estate"].Reputation)
            {
                GameData.Allegiance = "Crown";
            }
            else if (fmod["Third Estate"].Reputation > fmod["Crown"].Reputation)
            {
                GameData.Allegiance = "Third Estate";
            }
            else       // If it's equal then you get shuffled onto the losing team of History
            {
                GameData.Allegiance = "Unknown";
            }

            //Go to the End Screen

            if (GameData.Allegiance == victoriousPower)
            {
                GameData.playerVictoryStatus = "Political Victory";
            }
            else
            {
                GameData.playerVictoryStatus = "Political Loss";
            }
            AmbitionApp.SendMessage <string>(GameMessages.LOAD_SCENE, "Game_EndScreen");
        }
Example #12
0
        void UpdateInfo()
        {
            FactionModel model = AmbitionApp.GetModel <FactionModel>();

            //---- Crown Info ----
            if (model["Crown"].Level >= 8)
            {
                crownInfo.text = "- The Royalty and members of high ranking nobility alligned with them" +
                                 "\n- Like Expensive but Modest Clothes" +
                                 "\n- Power: " + GetPowerString(model["Crown"].Power) + " (Faction Benefit)";
            }
            else if (model["Crown"].Level >= 6)
            {
                crownInfo.text = "- The Royalty and members of high ranking nobility alligned with them" +
                                 "\n- Like Expensive but Modest Clothes" +
                                 "\n- Power: " + GetPowerString(model["Crown"].Power) + " (Faction Benefit)";
            }
            else
            {
                crownInfo.text = "- The Royalty and members of high ranking nobility alligned with them" +
                                 "\n- Like Expensive but Modest Clothes" +
                                 "\n- Power: " + model["Crown"].knownPower + " " + ConvertKnowledgeTimer(_powerTimers["Crown"]);
            }
            //---- Church Info ----
            if (model["Church"].Level >= 8)
            {
                churchInfo.text = "- The Clergy and those alligned with them" +
                                  "\n- Like Vintage and Modest Clothes" +
                                  "\n- Allegiance: " + GetAllegianceString(model["Church"].Allegiance) + " (Faction Benefit)" +
                                  "\n- Power: " + GetPowerString(model["Church"].Power) + " (Faction Benefit)";
            }
            else if (model["Church"].Level >= 6)
            {
                churchInfo.text = "- The Clergy and those alligned with them" +
                                  "\n- Like Vintage and Modest Clothes" +
                                  "\n- Allegiance: " + model["Church"].knownAllegiance + " " + ConvertKnowledgeTimer(_allegianceTimers["Church"]) +
                                  "\n- Power: " + GetPowerString(model["Church"].Power) + " (Faction Benefit)";
            }
            else
            {
                churchInfo.text = "- The Clergy and those alligned with them" +
                                  "\n- Like Vintage and Modest Clothes" +
                                  "\n- Allegiance: " + model["Church"].knownAllegiance + " " + ConvertKnowledgeTimer(_allegianceTimers["Church"]) +
                                  "\n- Power: " + model["Church"].knownPower + " " + ConvertKnowledgeTimer(_powerTimers["Church"]);
            }
            //---- Military Info ----
            if (model["Military"].Level >= 8)
            {
                militaryInfo.text = "- The Generals and Troops of the armed forces and those alligned with them" +
                                    "\n- Couldn't care less about your clothes" +
                                    "\n- Allegiance: " + GetAllegianceString(model["Military"].Allegiance) + " (Faction Benefit)" +
                                    "\n- Power: " + GetPowerString(model["Military"].Power) + " (Faction Benefit)";
            }
            else if (model["Military"].Level >= 6)
            {
                militaryInfo.text = "- The Generals and Troops of the armed forces and those alligned with them" +
                                    "\n- Couldn't care less about your clothes" +
                                    "\n- Allegiance: " + model["Military"].knownAllegiance + " " + ConvertKnowledgeTimer(_allegianceTimers["Military"]) +
                                    "\n- Power: " + GetPowerString(model["Military"].Power) + " (Faction Benefit)";
            }
            else
            {
                militaryInfo.text = "- The Generals and Troops of the armed forces and those alligned with them" +
                                    "\n- Couldn't care less about your clothes" +
                                    "\n- Allegiance: " + model["Military"].knownAllegiance + " " + ConvertKnowledgeTimer(_allegianceTimers["Military"]) +
                                    "\n- Power: " + model["Military"].knownPower + " " + ConvertKnowledgeTimer(_powerTimers["Military"]);
            }
            //---- Bourgeoisie Info ----
            if (model["Bourgeoisie"].Level >= 8)
            {
                bourgeoisieInfo.text = "- The newly wealthy Mercantile class" +
                                       "\n- Like clothes that are Luxurious and Racy" +
                                       "\n- Allegiance: " + GetAllegianceString(model["Bourgeoisie"].Allegiance) + " (Faction Benefit)" +
                                       "\n- Power: " + GetPowerString(model["Bourgeoisie"].Power) + " (Faction Benefit)";
            }
            else if (model["Bourgeoisie"].Level >= 6)
            {
                bourgeoisieInfo.text = "- The newly wealthy Mercantile class" +
                                       "\n- Like clothes that are Luxurious and Racy" +
                                       "\n- Allegiance: " + model["Bourgeoisie"].knownAllegiance + " " + ConvertKnowledgeTimer(_allegianceTimers["Bourgeoisie"]) +
                                       "\n- Power: " + GetPowerString(model["Bourgeoisie"].Power) + " (Faction Benefit)";
            }
            else
            {
                bourgeoisieInfo.text = "- The newly wealthy Mercantile class" +
                                       "\n- Like clothes that are Luxurious and Racy" +
                                       "\n- Allegiance: " + model["Bourgeoisie"].knownAllegiance + " " + ConvertKnowledgeTimer(_allegianceTimers["Bourgeoisie"]) +
                                       "\n- Power: " + model["Bourgeoisie"].knownPower + " " + ConvertKnowledgeTimer(_powerTimers["Bourgeoisie"]);
            }
            //---- Third Estate Info ----
            if (model["Third Estate"].Level >= 8)
            {
                revolutionInfo.text = "- The unhappy Common Man along with the Academics and Artists alligned with them" +
                                      "\n - Like clothes that are Vintage and Racy" +
                                      "\n- Power: " + GetPowerString(model["Third Estate"].Power) + " (Faction Benefit)";
            }
            else if (model["Third Estate"].Level >= 6)
            {
                revolutionInfo.text = "- The unhappy Common Man along with the Academics and Artists alligned with them" +
                                      "\n - Like clothes that are Vintage and Racy" +
                                      "\n- Power: " + GetPowerString(model["Third Estate"].Power) + " (Faction Benefit)";
            }
            else
            {
                revolutionInfo.text = "- The unhappy Common Man along with the Academics and Artists alligned with them" +
                                      "\n - Like clothes that are Vintage and Racy" +
                                      "\n- Power: " + model["Third Estate"].knownPower + " " + ConvertKnowledgeTimer(_powerTimers["Third Estate"]);
            }
        }
Example #13
0
        public bool CheckRequirements(CommodityVO[] requirments)
        {
            GameModel model = AmbitionApp.GetModel <GameModel>();

            foreach (CommodityVO req in requirments)
            {
                switch (req.Type)
                {
                case CommodityType.Item:
                    InventoryModel inventory = AmbitionApp.GetModel <InventoryModel>();
                    ItemVO         item      = inventory.Inventory.Find(i => i.Name == req.ID);
                    if (item == null || item.Quantity < req.Value)
                    {
                        return(false);
                    }
                    break;

                case CommodityType.Livre:
                    if (model.Livre < req.Value)
                    {
                        return(false);
                    }
                    break;

                case CommodityType.Location:
                    ParisModel paris = AmbitionApp.GetModel <ParisModel>();
                    if (!paris.Locations.Contains(req.ID))
                    {
                        return(false);
                    }
                    break;

                case CommodityType.Reputation:
                    FactionModel factions = AmbitionApp.GetModel <FactionModel>();
                    return((req.ID != null && factions.Factions.ContainsKey(req.ID))
                            ? factions[req.ID].Reputation >= req.Value
                            : model.Reputation >= req.Value);

                case CommodityType.Servant:
                    ServantModel servants = AmbitionApp.GetModel <ServantModel>();
                    if (!servants.Servants.ContainsKey(req.ID))
                    {
                        return(false);
                    }
                    break;

                case CommodityType.Date:
                    CalendarModel calendar = AmbitionApp.GetModel <CalendarModel>();
                    if (calendar.Today.Ticks < req.Value)
                    {
                        return(false);
                    }
                    break;

                case CommodityType.Mark:
                    MapModel map = AmbitionApp.GetModel <MapModel>();
                    return(Array.Exists(map.Map.Rooms, r => r.HostHere && r.Cleared));
                }
            }
            return(true);
        }