Ejemplo n.º 1
0
	def __init__(self, session):
		self.session = session
		# {instance: [list of icons]}
		self.icons = {}
		# Renderer used to render the icons
		self.renderer = self.session.view.renderer['GenericRenderer']

		AddStatusIcon.subscribe(self.on_add_icon_message)
		RemoveStatusIcon.subscribe(self.on_remove_icon_message)
		WorldObjectDeleted.subscribe(self.on_worldobject_deleted_message)
Ejemplo n.º 2
0
def test_decommissioned(session, player):
    settlement, island = settle(session)

    lj = Build(BUILDINGS.LUMBERJACK, 30, 30, island, settlement=settlement)(player)

    cb = mock.Mock()
    AddStatusIcon.subscribe(cb)

    assert not cb.called

    ToggleActive(lj.get_component(Producer))(player)

    assert_called_with_icon(cb, DecommissionedStatus)
Ejemplo n.º 3
0
def test_decommissioned(session, player):
	settlement, island = settle(session)

	lj = Build(BUILDINGS.LUMBERJACK, 30, 30, island, settlement=settlement)(player)

	cb = mock.Mock()
	AddStatusIcon.subscribe(cb)

	assert not cb.called

	ToggleActive(lj.get_component(Producer))(player)

	assert_called_with_icon(cb, DecommissionedStatus)
Ejemplo n.º 4
0
	def __init__(self, session):
		self.session = session
		# {instance: [list of icons]}
		self.icons = {}
		# Renderer used to render the icons
		self.renderer = self.session.view.renderer['GenericRenderer']

		self.tooltip_instance = None # no weakref:
		# we need to remove the tooltip always anyway, and along with it the entry here
		self.tooltip_icon = Icon(position=(1,1)) # 0, 0 is currently not supported by tooltips

		AddStatusIcon.subscribe(self.on_add_icon_message)
		HoverInstancesChanged.subscribe(self.on_hover_instances_changed)
		RemoveStatusIcon.subscribe(self.on_remove_icon_message)
		WorldObjectDeleted.subscribe(self.on_worldobject_deleted_message)
Ejemplo n.º 5
0
def test_productivity_low(session, player):
    settlement, island = settle(session)

    Build(BUILDINGS.CHARCOAL_BURNER, 30, 30, island, settlement=settlement)(player)

    cb = mock.Mock()
    AddStatusIcon.subscribe(cb)

    # Not yet low
    assert not cb.called

    session.run(seconds=60)

    # Now low
    assert_called_with_icon(cb, ProductivityLowStatus)
Ejemplo n.º 6
0
def test_productivity_low(session, player):
	settlement, island = settle(session)

	Build(BUILDINGS.CHARCOAL_BURNER, 30, 30, island, settlement=settlement)(player)

	cb = mock.Mock()
	AddStatusIcon.subscribe(cb)

	# Not yet low
	assert not cb.called

	session.run(seconds=60)

	# Now low
	assert_called_with_icon(cb, ProductivityLowStatus)
Ejemplo n.º 7
0
def test_settler_unhappy(session, player):
    settlement, island = settle(session)

    cb = mock.Mock()
    AddStatusIcon.subscribe(cb)

    settler = Build(BUILDINGS.RESIDENTIAL, 30, 30, island, settlement=settlement)(player)

    # certainly not unhappy
    assert settler.happiness > 0.45
    assert not cb.called

    # make it unhappy
    settler.get_component(StorageComponent).inventory.alter(RES.HAPPINESS, -settler.happiness)
    assert settler.happiness < 0.1
    assert_called_with_icon(cb, SettlerUnhappyStatus)
Ejemplo n.º 8
0
def test_settler_unhappy(session, player):
	settlement, island = settle(session)

	cb = mock.Mock()
	AddStatusIcon.subscribe(cb)

	settler = Build(BUILDINGS.RESIDENTIAL, 30, 30, island, settlement=settlement)(player)

	# certainly not unhappy
	assert settler.happiness > 0.45
	assert not cb.called

	# make it unhappy
	settler.get_component(StorageComponent).inventory.alter(RES.HAPPINESS, -settler.happiness)
	assert settler.happiness < 0.1
	assert_called_with_icon(cb, SettlerUnhappyStatus)
Ejemplo n.º 9
0
def test_inventory_full(session, player):
    settlement, island = settle(session)

    lj = Build(BUILDINGS.LUMBERJACK, 30, 30, island, settlement=settlement)(player)

    cb = mock.Mock()
    AddStatusIcon.subscribe(cb)

    # Not full
    assert not cb.called

    inv = lj.get_component(StorageComponent).inventory
    res = RES.BOARDS
    inv.alter(res, inv.get_free_space_for(res))

    session.run(seconds=1)

    # Full
    assert_called_with_icon(cb, InventoryFullStatus)
Ejemplo n.º 10
0
	def __init__(self, renderer, layer):
		"""
		@param renderer: Renderer used to render the icons
		@param layer: map layer, needed to place icon
		"""
		self.layer = layer
		self.renderer = renderer

		# {instance: [list of icons]}
		self.icons = {}

		self.tooltip_instance = None # no weakref:
		# we need to remove the tooltip always anyway, and along with it the entry here
		self.tooltip_icon = Icon(position=(1, 1)) # 0, 0 is currently not supported by tooltips

		AddStatusIcon.subscribe(self.on_add_icon_message)
		HoverInstancesChanged.subscribe(self.on_hover_instances_changed)
		RemoveStatusIcon.subscribe(self.on_remove_icon_message)
		WorldObjectDeleted.subscribe(self.on_worldobject_deleted_message)
Ejemplo n.º 11
0
def test_inventory_full(session, player):
	settlement, island = settle(session)

	lj = Build(BUILDINGS.LUMBERJACK, 30, 30, island, settlement=settlement)(player)

	cb = mock.Mock()
	AddStatusIcon.subscribe(cb)

	# Not full
	assert not cb.called

	inv = lj.get_component(StorageComponent).inventory
	res = RES.BOARDS
	inv.alter(res, inv.get_free_space_for( res ) )

	session.run(seconds=1)

	# Full
	assert_called_with_icon(cb, InventoryFullStatus)