def _set_taxes_and_permissions(self, sailor_taxes, pioneer_taxes,
                                settler_taxes, citizen_taxes,
                                sailor_upgrades, pioneer_upgrades,
                                settler_upgrades):
     """Set new tax settings and building permissions."""
     if abs(self.settlement.tax_settings[TIER.SAILORS] -
            sailor_taxes) > 1e-9:
         self.log.info("%s set sailors' taxes from %.1f to %.1f", self,
                       self.settlement.tax_settings[TIER.SAILORS],
                       sailor_taxes)
         SetTaxSetting(self.settlement, TIER.SAILORS,
                       sailor_taxes).execute(self.land_manager.session)
     if abs(self.settlement.tax_settings[TIER.PIONEERS] -
            pioneer_taxes) > 1e-9:
         self.log.info("%s set pioneers' taxes from %.1f to %.1f", self,
                       self.settlement.tax_settings[TIER.PIONEERS],
                       pioneer_taxes)
         SetTaxSetting(self.settlement, TIER.PIONEERS,
                       pioneer_taxes).execute(self.land_manager.session)
     if abs(self.settlement.tax_settings[TIER.SETTLERS] -
            settler_taxes) > 1e-9:
         self.log.info("%s set settlers' taxes from %.1f to %.1f", self,
                       self.settlement.tax_settings[TIER.SETTLERS],
                       settler_taxes)
         SetTaxSetting(self.settlement, TIER.SETTLERS,
                       settler_taxes).execute(self.land_manager.session)
     if abs(self.settlement.tax_settings[TIER.CITIZENS] -
            citizen_taxes) > 1e-9:
         self.log.info("%s set citizens' taxes from %.1f to %.1f", self,
                       self.settlement.tax_settings[TIER.CITIZENS],
                       citizen_taxes)
         SetTaxSetting(self.settlement, TIER.CITIZENS,
                       citizen_taxes).execute(self.land_manager.session)
     if self.settlement.upgrade_permissions[
             TIER.SAILORS] != sailor_upgrades:
         self.log.info('%s set sailor upgrade permissions to %s', self,
                       sailor_upgrades)
         SetSettlementUpgradePermissions(self.settlement, TIER.SAILORS,
                                         sailor_upgrades).execute(
                                             self.land_manager.session)
     if self.settlement.upgrade_permissions[
             TIER.PIONEERS] != pioneer_upgrades:
         self.log.info('%s set pioneer upgrade permissions to %s', self,
                       pioneer_upgrades)
         SetSettlementUpgradePermissions(self.settlement, TIER.PIONEERS,
                                         pioneer_upgrades).execute(
                                             self.land_manager.session)
     if self.settlement.upgrade_permissions[
             TIER.SETTLERS] != settler_upgrades:
         self.log.info('%s set settler upgrade permissions to %s', self,
                       settler_upgrades)
         SetSettlementUpgradePermissions(self.settlement, TIER.SETTLERS,
                                         settler_upgrades).execute(
                                             self.land_manager.session)
def test_deny_upgrade_permissions_special(s, p):
    """
	Verify that denying upgrade permissions works even though the settler
	leveled down after starting the upgrade process.
	"""
    settlement, island = settle(s)

    settler = Build(BUILDINGS.RESIDENTIAL,
                    22,
                    22,
                    island,
                    settlement=settlement)(p)

    # make it happy
    inv = settler.get_component(StorageComponent).inventory
    to_give = inv.get_free_space_for(RES.HAPPINESS)
    inv.alter(RES.HAPPINESS, to_give)

    s.run(seconds=GAME.INGAME_TICK_INTERVAL)

    # give upgrade res
    inv.alter(RES.BOARDS, 100)

    s.run(seconds=GAME.INGAME_TICK_INTERVAL)

    # should have leveled up
    assert settler.level == TIER.PIONEERS
    assert settler._upgrade_production is None

    # Start leveling up again
    settler._add_upgrade_production_line()
    assert settler._upgrade_production is not None

    s.run(seconds=1)

    # Force the settler to level down, even though it is currently
    # trying to upgrade
    settler.level_down()

    # Make sure this worked!
    assert settler._upgrade_production is None

    # Make sure forbidding upgrades works
    SetSettlementUpgradePermissions(settlement, TIER.SAILORS, False).execute(s)
    assert settler.level == TIER.SAILORS
Exemple #3
0
 def toggle_upgrades(self):
     SetSettlementUpgradePermissions(
         self.settlement, self.__class__.LEVEL,
         not self.settlement.upgrade_permissions[self.__class__.LEVEL]
     ).execute(self.settlement.session)