Example #1
0
    def test_guild_restrict(self):
        initialize_settlement(self.settlement)
        turn_processor = TurnProcessor(self.settlement.tile.world)
        turn_processor.do_settlement_job_updates(self.settlement)
        guild = self.settlement.building_set.get(type=Building.GUILD)
        for worker in list(self.settlement.get_residents().filter(
                workplace__type=Building.GRAIN_FIELD))[:30]:
            worker.workplace = guild
            worker.save()
        self.assertEqual(
            self.settlement.get_residents().filter(
                workplace__type=Building.GUILD).count(), 30)

        self.settlement.guilds_setting = Settlement.GUILDS_RESTRICT
        self.settlement.save()
        turn_processor.do_settlement_job_updates(self.settlement)
        self.assertTrue(
            self.settlement.get_residents().filter(
                workplace__type=Building.GRAIN_FIELD).exists())
        self.assertTrue(
            self.settlement.get_residents().filter(
                workplace__type=Building.GUILD).exists())
        self.assertTrue(
            0 <
            self.settlement.get_residents().filter(
                workplace__type=Building.GUILD).count() <= 20)
Example #2
0
 def test_guild_default(self):
     initialize_settlement(self.settlement)
     turn_processor = TurnProcessor(self.settlement.tile.world)
     turn_processor.do_settlement_job_updates(self.settlement)
     self.assertEqual(
         self.settlement.guilds_setting, Settlement.GUILDS_KEEP)
     self.assertTrue(
         self.settlement.get_residents().filter(
             workplace__type=Building.GRAIN_FIELD).exists())
     self.assertFalse(
         self.settlement.get_residents().filter(
             workplace__type=Building.GUILD).exists())
Example #3
0
 def test_guild_promote(self):
     self.settlement.guilds_setting = Settlement.GUILDS_PROMOTE
     self.settlement.save()
     initialize_settlement(self.settlement)
     turn_processor = TurnProcessor(self.settlement.tile.world)
     turn_processor.do_settlement_job_updates(self.settlement)
     self.assertTrue(
         self.settlement.get_residents().filter(
             workplace__type=Building.GRAIN_FIELD).exists())
     self.assertTrue(
         self.settlement.get_residents().filter(
             workplace__type=Building.GUILD).exists())
     self.assertEqual(
         self.settlement.get_residents().filter(
             workplace__type=Building.GUILD).count(), 10)