Exemple #1
0
        public override void turnTick(Unit unit)
        {
            if (unit is Unit_Merchant == false)
            {
                unit.task = null; return;
            }
            if (unit.society is Society == false)
            {
                unit.task = null; return;
            }
            if (unit.location.settlement == null)
            {
                unit.task = null; return;
            }
            if (unit.location.soc == null)
            {
                unit.task = null; return;
            }

            Unit_Merchant merchant = (Unit_Merchant)unit;

            if (merchant.cash <= 0)
            {
                unit.task = null; return;
            }

            merchant.cash -= 10;

            Person noble = merchant.location.person();

            if (noble != null)
            {
                noble.getRelation(merchant.person).addLiking(10, "Spent Wealth", unit.location.map.turn, RelObj.STACK_ADD);
                noble.prestige += 1.5;
            }
            if (unit.location.soc.currentMilitary < unit.location.soc.maxMilitary)
            {
                unit.location.soc.currentMilitary += 1;
                if (unit.location.soc.currentMilitary > unit.location.soc.maxMilitary)
                {
                    unit.location.soc.currentMilitary = unit.location.soc.maxMilitary;
                }
            }

            if (merchant.cash <= 0)
            {
                merchant.cash = 0;
                merchant.task = null;
                if (merchant.isEnthralled())
                {
                    merchant.location.map.world.prefabStore.popMsg(unit.getName() + " has spent their last wealth, and must now return home to collect more cargo to sell.");
                }
            }
        }
Exemple #2
0
        public override void castInner(Map map, Unit u)
        {
            u.task = new Task_LoadCargo();

            Unit_Merchant merchant = (Unit_Merchant)u;

            merchant.hasLoadedCargo = true;

            u.location.map.world.prefabStore.popImgMsg(u.getName() + " begins loading cargo, ready to be sold for profit in distant towns.",
                                                       u.location.map.world.wordStore.lookup("ABILITY_UNIT_LOAD_CARGO"), 1);
        }
        public override void turnTick(Unit unit)
        {
            if (unit is Unit_Merchant == false)
            {
                unit.task = null; return;
            }
            if (unit.society is Society == false)
            {
                unit.task = null; return;
            }
            if (unit.location.settlement == null)
            {
                unit.task = null; return;
            }


            float         profit   = getSaleValue(unit.society, unit.location);
            Unit_Merchant merchant = (Unit_Merchant)unit;

            int sold = Math.Min(merchant.cargo, 10);

            merchant.cargo -= sold;
            if (merchant.cargo <= 0)
            {
                merchant.cargo = 0;
            }
            int gain = (int)(0.5f + (profit * sold));

            merchant.cash += gain;


            if (merchant.cash >= 100)
            {
                merchant.task = null;
                if (merchant.isEnthralled())
                {
                    merchant.location.map.world.prefabStore.popMsg(unit.getName() + " has generated as much wealth as they can transport, their strong-boxes brim with gold. They must spend before they can sell again.");
                }
            }
            if (merchant.cargo <= 0)
            {
                merchant.task = null;
                if (merchant.isEnthralled())
                {
                    merchant.location.map.world.prefabStore.popMsg(unit.getName() + " has sold all their cargo. They may now spend their profits or gather further cargo from home.");
                }
            }
        }
        public override void castInner(Map map, Unit u)
        {
            Task_SellCargo task = new Task_SellCargo();

            u.task = task;

            Unit_Merchant merchant = (Unit_Merchant)u;

            merchant.hasSoldCargo = true;

            float profit = task.getSaleValue(u.society, u.location);

            u.location.map.world.prefabStore.popImgMsg(u.getName() + " begins selling cargo, generating wealth. Every turn they will sell 10% of their cargo, with a proft of " + ((int)(100 * profit))
                                                       + "%. Metropoles, cities and towns give greater profit, and selling in your home nation generates less than selling in foreign lands."
                                                       , u.location.map.world.wordStore.lookup("ABILITY_UNIT_SELL_CARGO"), 1);
        }
Exemple #5
0
        public override void castInner(Map map, Unit u)
        {
            Task_SpendWealth task = new Task_SpendWealth();

            u.task = task;

            Unit_Merchant merchant = (Unit_Merchant)u;

            merchant.hasSpendWealth = true;
            if (merchant.hasSpendWealth && merchant.hasSoldCargo && merchant.hasLoadedCargo)
            {
                AchievementManager.unlockAchievement(SteamManager.achievement_key.MERCANTILISM);
            }

            u.location.map.world.prefabStore.popImgMsg(u.getName() + " begins spending their wealth, in lavish banquets, gifts and fine silks. They enjoy the company of the local noble, who" +
                                                       " benefits from increased taxes and excellent festivals. The economy booms, to be spent on swords or favours."
                                                       , u.location.map.world.wordStore.lookup("ABILITY_UNIT_SPEND_WEALTH"), 1);
        }
        public void checkMerchants()
        {
            int n = 0;

            foreach (Unit u in map.units)
            {
                if (u is Unit_Merchant)
                {
                    n += 1;
                }
            }
            if (n < map.data_nSocietyLocations * map.param.unit_merchantsPerCity)
            {
                int      c      = 0;
                Location chosen = null;
                if (chosen == null)
                {
                    foreach (Province p in map.provinces)
                    {
                        foreach (int locI in p.locations)
                        {
                            Location loc = map.locations[locI];
                            if (loc.soc is Society && loc.settlement != null && loc.settlement.isHuman)
                            {
                                c += 1;
                                if (Eleven.random.Next(c) == 0)
                                {
                                    chosen = loc;
                                }
                            }
                        }
                    }
                }
                if (chosen != null)
                {
                    Unit_Merchant u = new Unit_Merchant(chosen, (Society)chosen.soc);
                    u.person      = new Person((Society)chosen.soc);
                    u.person.unit = u;
                    u.person.traits.Clear();//Can't see traits, best to have them removed
                    map.units.Add(u);
                    u.parentLocation = chosen;
                }
            }
        }
Exemple #7
0
        public override void turnTick(Unit unit)
        {
            if (unit is Unit_Merchant == false)
            {
                unit.task = null; return;
            }
            if (unit.society != unit.location.soc)
            {
                unit.task = null; return;
            }
            if (unit.location.settlement == null)
            {
                unit.task = null; return;
            }


            Unit_Merchant merchant = (Unit_Merchant)unit;

            if (unit.location.settlement is Set_City)
            {
                merchant.cargo += 30;
            }
            else
            {
                merchant.cargo += 15;
            }
            if (merchant.cargo >= 100)
            {
                merchant.cargo = 100;
                merchant.task  = null;
                if (merchant.isEnthralled())
                {
                    merchant.location.map.world.prefabStore.popMsg(unit.getName() + " has finished loading cargo");
                }
            }
        }