コード例 #1
0
 def send_daily_profit_and_cost_update(self):
     if self.is_owner_household_active:
         profit_msg = Business_pb2.BusinessProfitUpdate()
         profit_msg.zone_id = self.business_zone_id
         profit_msg.net_profit = self.get_daily_net_profit(include_employee_wages=False)
         op = GenericProtocolBufferOp(DistributorOps_pb2.Operation.BUSINESS_PROFIT_UPDATE, profit_msg)
         Distributor.instance().add_op_with_no_owner(op)
         cost_msg = Business_pb2.BusinessDailyCostsUpdate()
         cost_msg.zone_id = self.business_zone_id
         cost_msg.daily_outgoing_costs = int(self.get_daily_outgoing_costs())
         op = GenericProtocolBufferOp(DistributorOps_pb2.Operation.BUSINESS_DAILY_OUTGOING_COSTS_UPDATE, cost_msg)
         Distributor.instance().add_op_with_no_owner(op)
コード例 #2
0
 def _on_remove_sim_from_situation(self, sim):
     if not services.current_zone().is_zone_running:
         super()._on_remove_sim_from_situation(sim)
         return
     sim_job = self.get_current_job_for_sim(sim)
     services.get_zone_situation_manager().add_sim_to_auto_fill_blacklist(
         sim.id, sim_job=sim_job)
     (pet_sim_info,
      pet_owner_sim_info) = self._get_pet_and_owner_sim_infos()
     pet_sim_info.remove_linked_sim(pet_owner_sim_info.sim_id)
     pet_owner_sim_info.remove_linked_sim(pet_sim_info.sim_id)
     pet_owner = self.get_pet_owner()
     is_pet_owner = False if pet_owner is None else sim is pet_owner
     super()._on_remove_sim_from_situation(sim)
     business_manager = services.business_service(
     ).get_business_manager_for_zone()
     if business_manager is not None and is_pet_owner:
         business_manager.remove_customer(
             sim, review_business=self._should_leave_review)
         customer_msg = Business_pb2.BusinessCustomerUpdate()
         customer_msg.sim_id = pet_owner_sim_info.sim_id
         op = GenericProtocolBufferOp(
             DistributorOps_pb2.Operation.BUSINESS_CUSTOMER_REMOVE,
             customer_msg)
         Distributor.instance().add_op_with_no_owner(op)
コード例 #3
0
 def send_business_funds_update(self):
     if self.is_owner_household_active:
         funds_msg = Business_pb2.BusinessFundsUpdate()
         funds_msg.available_funds = self.funds.money
         funds_msg.zone_id = self.business_zone_id
         op = GenericProtocolBufferOp(DistributorOps_pb2.Operation.BUSINESS_FUNDS_UPDATE, funds_msg)
         Distributor.instance().add_op_with_no_owner(op)
コード例 #4
0
 def _distribute_business_open_status(self, is_open=True, open_time=0):
     open_msg = Business_pb2.BusinessIsOpenUpdate()
     open_msg.is_open = is_open
     open_msg.time_opened = open_time
     open_msg.zone_id = self.business_zone_id
     op = GenericProtocolBufferOp(DistributorOps_pb2.Operation.BUSINESS_OPEN_UPDATE, open_msg)
     Distributor.instance().add_op_with_no_owner(op)
コード例 #5
0
 def _send_daily_items_sold_update(self):
     if self.is_active_household_and_zone():
         items_sold_msg = Business_pb2.BusinessDailyItemsSoldUpdate()
         items_sold_msg.zone_id = self.business_zone_id
         items_sold_msg.daily_items_sold = self.daily_items_sold
         op = GenericProtocolBufferOp(DistributorOps_pb2.Operation.BUSINESS_DAILY_ITEMS_SOLD_UPDATE, items_sold_msg)
         Distributor.instance().add_op_with_no_owner(op)
コード例 #6
0
 def _build_vet_clinic_data_message(self):
     msg = Business_pb2.VetClinicBusinessDataUpdate()
     msg.zone_id = self.business_zone_id
     if self._advertising_manager._advertising_type != BusinessAdvertisingType.INVALID:
         msg.advertising_chosen = self._advertising_manager._advertising_type
     msg.quality_chosen = self._quality_setting
     msg.is_quality_unlocked = self._quality_unlocked
     return msg
コード例 #7
0
 def _send_advertisement_update_message(self):
     msg = Business_pb2.BusinessAdvertisementUpdate()
     msg.zone_id = self._business_manager.business_zone_id
     msg.advertisement_chosen = self._advertising_type
     op = GenericProtocolBufferOp(
         DistributorOps_pb2.Operation.BUSINESS_ADVERTISEMENT_DATA_UPDATE,
         msg)
     Distributor.instance().add_op_with_no_owner(op)
コード例 #8
0
def show_employee_management_dialog(opt_sim: OptionalSimInfoParam = None,
                                    _connection=None):
    sim_info = get_optional_target(opt_sim,
                                   target_type=OptionalSimInfoParam,
                                   _connection=_connection)
    if sim_info is None:
        return False
    business_services = services.business_service()
    business_manager = business_services.get_business_manager_for_zone()
    if business_manager is None:
        return False
    business_tracker = business_services.get_business_tracker_for_household(
        sim_info.household_id, business_manager.business_type)
    msg = Business_pb2.ManageEmployeesDialog()
    msg.hiring_sim_id = sim_info.sim_id

    def get_sim_filter_gsi_name():
        return 'Business Command: Get New Possible Employees'

    for (business_employee_type, business_employee_data
         ) in business_manager.tuning_data.employee_data_map.items():
        with ProtocolBufferRollback(msg.jobs) as employee_job_msg:
            total_unlocked_slots = business_employee_data.employee_count_default + business_tracker.get_additional_employee_slots(
                business_employee_type)
            employee_job_msg.open_slots = total_unlocked_slots - business_manager.get_employee_count(
                business_employee_type)
            employee_job_msg.locked_slots = business_employee_data.employee_count_max - total_unlocked_slots
            employee_job_msg.job_type = int(business_employee_type)
            employee_job_msg.job_name = business_employee_data.job_name
            employee_job_msg.job_icon = create_icon_info_msg(
                IconInfoData(business_employee_data.job_icon))
            current_employees = business_manager.get_employees_by_type(
                business_employee_type)
            sim_info_manager = services.sim_info_manager()
            for employee_sim_id in current_employees:
                employee_sim_info = sim_info_manager.get(employee_sim_id)
                with ProtocolBufferRollback(
                        employee_job_msg.employees) as employee_msg:
                    business_manager.populate_employee_msg(
                        employee_sim_info, employee_msg,
                        business_employee_type, business_employee_data)
            results = services.sim_filter_service().submit_matching_filter(
                number_of_sims_to_find=business_employee_data.
                potential_employee_pool_size,
                sim_filter=business_employee_data.
                potential_employee_pool_filter,
                requesting_sim_info=sim_info,
                allow_yielding=False,
                gsi_source_fn=get_sim_filter_gsi_name)
            for result in results:
                with ProtocolBufferRollback(
                        employee_job_msg.available_sims) as employee_msg:
                    business_manager.populate_employee_msg(
                        result.sim_info, employee_msg, business_employee_type,
                        business_employee_data)
    op = shared_messages.create_message_op(
        msg, Consts_pb2.MSG_MANAGE_EMPLOYEES_DIALOG)
    Distributor.instance().add_op_with_no_owner(op)
コード例 #9
0
 def send_data_to_client(self):
     zone = services.get_zone(self._zone_id, allow_uninstantiated_zones=True)
     if zone is None:
         logger.error('Trying to send the business data to client but the business manager {} has an invalid zone id.', self)
         return
     business_data_msg = Business_pb2.SetBusinessData()
     self.construct_business_message(business_data_msg)
     business_data_op = GenericProtocolBufferOp(DistributorOps_pb2.Operation.SET_BUSINESS_DATA, business_data_msg)
     Distributor.instance().add_op_with_no_owner(business_data_op)
コード例 #10
0
 def save_data(self, business_save_data):
     super().save_data(business_save_data)
     business_save_data.vet_clinic_save_data = Business_pb2.VetClinicSaveData(
     )
     business_save_data.vet_clinic_save_data.advertising_type = self._advertising_manager._advertising_type
     business_save_data.vet_clinic_save_data.quality_type = self.quality_setting
     business_save_data.vet_clinic_save_data.profit_per_treatment_queue.extend(
         int(profit) for profit in self._profits_per_treatment)
     business_save_data.vet_clinic_save_data.exam_table_count = self._exam_table_count
コード例 #11
0
 def _send_customer_review_event_message(self,
                                         buff_bucket,
                                         is_positive=True):
     event_msg = Business_pb2.BusinessCustomerReviewEvent()
     buff_bucket_data = self._business_manager.tuning_data.customer_star_rating_buff_bucket_data[
         buff_bucket]
     event_msg.sim_id = self._sim_id
     event_msg.event_name = buff_bucket_data.bucket_positive_text(
     ) if is_positive else buff_bucket_data.bucket_negative_text()
     event_msg.event_icon = ResourceKey_pb2.ResourceKey()
     event_msg.event_icon.instance = buff_bucket_data.bucket_icon.instance
     event_msg.event_icon.group = buff_bucket_data.bucket_icon.group
     event_msg.event_icon.type = buff_bucket_data.bucket_icon.type
     event_msg.is_event_positive = is_positive
     op = GenericProtocolBufferOp(
         DistributorOps_pb2.Operation.BUSINESS_CUSTOMER_REVIEW_EVENT,
         event_msg)
     Distributor.instance().add_op_with_no_owner(op)
コード例 #12
0
 def construct_business_message(self, msg):
     msg.zone_id = self.business_zone_id
     persistence = services.get_persistence_service()
     zone_data = persistence.get_zone_proto_buff(self.business_zone_id)
     if zone_data is not None:
         msg.name = zone_data.name
     msg.is_open = self.is_open
     if self._open_time is not None:
         msg.time_opened = self._open_time.absolute_ticks()
     msg.daily_items_sold = self._daily_items_sold
     msg.daily_outgoing_costs = self.get_daily_outgoing_costs(include_employee_wages=False)
     msg.funds = self.funds.money
     msg.daily_customers_served = self._customer_manager.session_customers_served
     msg.net_profit = self.get_daily_net_profit(include_employee_wages=False)
     msg.markup_chosen = self.markup_multiplier
     msg.daily_revenue = int(self._daily_revenue)
     icon_tuning = self.tuning_data.business_icon
     msg.icon = ResourceKey_pb2.ResourceKey()
     msg.icon.instance = icon_tuning.instance
     msg.icon.group = icon_tuning.group
     msg.icon.type = icon_tuning.type
     msg.review_data = Business_pb2.ReviewDataUpdate()
     self._populate_review_update_message(msg.review_data)
     msg.minimum_employee_requirements_met = self.meets_minimum_employee_requirment()
コード例 #13
0
 def _send_review_update_message(self):
     review_msg = Business_pb2.ReviewDataUpdate()
     self._populate_review_update_message(review_msg)
     op = GenericProtocolBufferOp(DistributorOps_pb2.Operation.REVIEW_DATA_UPDATE, review_msg)
     Distributor.instance().add_op_with_no_owner(op)
コード例 #14
0
 def _add_business_data(self):
     self._report_msg.business_data = Business_pb2.SetBusinessData()
     self._business_manager.construct_business_message(
         self._report_msg.business_data)
コード例 #15
0
 def construct_business_message(self, msg):
     super().construct_business_message(msg)
     msg.retail_data = Business_pb2.RetailBusinessDataUpdate()
コード例 #16
0
 def _send_daily_customers_served_update(self):
     customers_msg = Business_pb2.BusinessDailyCustomersServedUpdate()
     customers_msg.zone_id = self._business_manager.business_zone_id
     customers_msg.daily_customers_served = self.session_customers_served
     op = GenericProtocolBufferOp(DistributorOps_pb2.Operation.BUSINESS_DAILY_CUSTOMERS_SERVED_UPDATE, customers_msg)
     Distributor.instance().add_op_with_no_owner(op)
コード例 #17
0
 def send_min_employee_req_met_update_message(self):
     update_message = Business_pb2.MinEmployeeReqMetUpdate()
     update_message.zone_id = self.business_zone_id
     update_message.minimum_employee_requirements_met = self.meets_minimum_employee_requirment()
     op = GenericProtocolBufferOp(DistributorOps_pb2.Operation.BUSINESS_EMPLOYEE_MIN_REQUIREMENT_UPDATE, update_message)
     Distributor.instance().add_op_with_no_owner(op)
コード例 #18
0
 def _distribute_markup_multiplier_update(self):
     markup_msg = Business_pb2.BusinessMarkupUpdate()
     markup_msg.zone_id = self.business_zone_id
     markup_msg.markup_chosen = self.markup_multiplier
     op = GenericProtocolBufferOp(DistributorOps_pb2.Operation.BUSINESS_MARKUP_DATA_UPDATE, markup_msg)
     Distributor.instance().add_op_with_no_owner(op)
コード例 #19
0
 def __init__(self, business_manager):
     self._business_manager = business_manager
     self._business_tuning = business_manager.tuning_data
     self._report_msg = Business_pb2.BusinessSummaryDialog()