Internet and Mobile: Functions, variables and values in the code
netuttki editó esta página hace 1 año

internet_mobile.qsrc

A new location that holds internet and mobile subscription related the list of valid internet and mobile plan values, and how to use them.

Valid Plans and Subscriptions

Plan Names

Plan name Description
'free' A subscription that is freely available, libraries, friends and lovers apartment, etc. that has a computer. The value of this plan is always 1 and the subscription_date is 0.
'mobile': Mobile internet used by the phone and the laptop if taken somewhere else. If at a location where subscription['free'] is used, she has to ask first to be able to use her own laptop with the local internet, otherwise it will still use the mobile subscription - if there is none, it won't work.
'metered_mobile' Cheaper option for broke Svetas. When subscription['mobile'] = 0 check for this and if subscription['metered_mobile'] > 0 then use this.
'<home name>' This is a monthly subscription that can be used in a specific home owned/rented by Sveta.
This is tracking the internet subscription per home. So if Sveta owns several places, she has a separate subscription for each of them. For allowed values see homes_properties.
'monthly_calls' A monthly mobile subscription giving unlimited call minutes and text message
'metered_calls' A mobile plan that gives a set amount of minutes that can be used.

Variables used

Variable Possible values
subscription[<plan name>-date] The day the subscription was bought for the home (or mobile), this will be the renewal day. Automatically set to day
subscription[<plan name>] The subscription itself that will be checked to see if Sveta can access the internet
subscription[<plan name>-price] The monthly fee of the subscription.
subscription[<plan_name>-discount] The discount applied to the subscription. If the discount was more than the monthly cost of the subscription, then the initial purchase cost 0 rubels, and the remaining discount will be used first to pay the monthly balances until it reaches 0.
subscription[<plan_name>-type] Defines the type of the subscription.

Functions (well, $ARGS[0]-s)

top_up_metered

Used to purchase minutes/credits for metered plans.

Parameteres
$ARGS[1]: string  the plan name, the values used are 'meteredmobile' for mobile net
          or 'meteredcalls' for phone calls and text messages
ARGS[2]:  integer  the number of units purchased (minutes, calls, etc.) 
          right now relevant for metered mobile internet and calls/texts only
Outcome

The function sets the following values:

subscription[$ARGS[1]] += ARGS[2]
subscription[$ARGS[1]+':type'] = 2
Example
$ARGS[1] = 'metered_calls', ARGS{2] = 60, subscription['metered_calls'] = 21

subscription['metered_call'] = 81
subscription['metered_call-type'] = 2
buy_subscription

To purchase the monthly subscriptions.

Paremeters
$ARGS[1]: string The plan name - see on top, generally the name of a property or a mobile plan. 
ARGS[2]: integer Subscription fee - the price to be paid every month
ARGS[3]: integer Discount value
Outcome
subscription[$ARGS[1]] = 1
subscription[$ARGS[1]+'-date'] = day
subscription[$ARGS[1]+'-price'] = ARGS[2]
subscription[$ARGS[1]+'-discount'] = ARGS[3]
subscription[$ARGS[1]+'-type'] = 1
Example
$ARGS[1] = 'mobile', ARGS[2] = 1200, ARGS[3] = 0, day = 12

subscription['mobile'] = 1
subscription['mobile-date'] = 12
subscription['mobile-price'] = 1200
subscription['mobile-discount'] = 0
subscription['mobile-type'] = 1

In theory the top_up_metered and the buy_subscription could be one function, especially if we decide to ignore the discount value. The subscription is treated as inactive if it is 0 and active if it is not zero. However, I feel like keeping them separate makes things less confusing. The $ARGS[0] tells exactly what the goal is, no ambiguity.

cancel_subscription

Called when the payment fails and the subscription is closed, or if the player decides to cancel it.

Paremeters

*$ARGS[1]: string* The name of the subscription

Outcome

subscription[$ARGS[1]] = 0

Example
$ARGS[1] = 'mobile', subscription['mobile'] = 1

subscription['mobile'] = 0
transfer_subscription

Used to transfer an existing subscription from one home to another.

Paremeters
$ARGS[1]: string* The name of the original home - this is the same as the name of the plan
$ARGS[2]: string* The name of the new home - this is the same as the name of the new plan
Outcome
subscription[$ARGS[2]] = subscription[$ARGS[1]]
subscription_date[$ARGS[2]+'-date'] = subscription[$ARGS[1]+'-date']*<br/>
subscription[$ARGS[2]+'-price'] = subscription[$ARGS[1]+'-price']*<br/>
subscription[$ARGS[2]+'-discount'] = subscription[$ARGS[1]+'-discount']*<br/>
subscription[$ARGS[2]+'-type'] = subscription[$ARGS[1]+'-type']*<br/>
subscription[$ARGS[1]] is deleted*<br/>
check_allowed_location

This is not really for public use, but could be useful in certain cases. The transfer_subscription functions uses it to decide if the two locations that were passed as parameters are:

  1. Actually homes, i.e. one of the locations that can be set as the current home of the player
  2. If they are homes, their internet_enabled value is 1 - see Homes, properties, locations

The result of the check is stored in result thus this can be used as:
if func('internet_mobile', 'check_allowed_location', $ARGS[1): .....

Paremeters

$ARGS[0]: string* The location name

Outcome
result = 0 (false) if the location is either 'none' or 'internet_enabled' = 0<br/>
result = -1 (true) if the location is an existing property and it 'internet_enabled' = 1