[Package Index | Mudlib Index | Effect Index]

File /obj/handlers/room_rental.c

A Room Rental Handler

This keeps track of who rented what rooms where and for how much.

After including there are two options available for room inherits. ROOM_RENTAL_INHERIT_BASIC_ROOM includes the basic room inherit while ROOM_RENTAL_INHERIT_ROOM is for use in areas that have their own base room inherits.

The most important function is the one that checks that someone is allowed to enter.
int check_entry( object player, object room )
it returns: RENTAL_SUCCESS if the player rents the room successfully RENTAL_NO_SUCH_ROOM if the room isn't on the books RENTAL_ALREADY_RENTED if the room is rented to someone else RENTAL_AVAILABLE if the player doesn't rent the room but it is available

Written by goldenthread

Started 3 Sep y2k1

Includes

This class includes the following files /include/room/room_rental.h, /include/money.h, /include/shops/bank.h and /include/am_time.h

Method index

Public Functions

These are functions that everyone can access.

add_allowed
int add_allowed(string who,
                string room)

Adds someone as allowed to enter a rented room

Parameters:
who - name of the person to add
room - the room to allow them in


add_room
int add_room(string path,
             int cost,
             object office,
             int length)

Adds a room to the handler with a rental cost.

Parameters:
path - the path of the room to add to the handler
cost - the rental cost per day of this room
office - the current office

See also:
delete_room()

Example:
   add_room( "/w/goldenthread/workroom", 1000000 )

check_tenant
int check_tenant(object player_ob,
                 object room_ob)

Checks if a particular player is renting a particular room. returns: RENTAL_SUCCESS if the player rents the room successfully RENTAL_NO_SUCH_ROOM if the room isn't on the books RENTAL_ALREADY_RENTED if the room is rented to someone else RENTAL_AVAILABLE if the player doesn't rent the room but it is available

Parameters:
player_ob - the player object who you think might be renting the room
room_ob - the room object that you think the player might be renting

Returns:
value dependent on success of check. See below for details


clear_rooms
int clear_rooms(object office)

Clears the list of rooms available for rent.

Parameters:
office - the current office WARNING: This clears all rooms bookable from this office.


delete_room
int delete_room(string room,
                object office)

Deletes a room from the handler

Parameters:
room - the path of the room that will be deleted from the handler
office - the current office

Returns:
0 on success, 1 on failure

See also:
add_room()


do_eviction
int do_eviction(string room)

This handles evicting someone from a room and clearing the data associated with this room rental.

Parameters:
room - the room to evict from


do_rental
int do_rental(object player_ob,
              string room,
              object office)

Handles the actual renting of the room. If the prospective tenant is already renting the room, it extends the rental. returns: RENTAL_SUCCESSFUL if the rental is successful RENTAL_NO_SUCH_ROOM if the room isn't on the books RENTAL_ALREADY_RENTED if someone else is renting the room already RENTAL_NO_MONEY if the player hasn't enough money

Parameters:
player_ob - the player who is renting the room
room - the room that is to be rented
office - the current office

Returns:
value dependent on success of rental. See below for details

See also:
remove_rental()


evict_tenant
void evict_tenant(object room_ob)

Evicts the tenant ( and guests ).

Parameters:
room_ob - the room object


get_room_from_short
string get_room_from_short(string room_short)

Returns the path of a room identified from a given short

Parameters:
room_short - the short to query by

Returns:
the path of the room


is_allowed
int is_allowed(string who,
               string room)

Checks if someone is allowed to access a room

Parameters:
who - The person to add.
room - the room to check with

Returns:
1 if they are, 0 otherwise


query_current_renter
string query_current_renter(string room)
query_key_property
string query_key_property(string room)
query_rental_length
int query_rental_length(string room)
query_rental_length_string
string query_rental_length_string(string room)
query_rental_value
int query_rental_value(string room)

Returns the amount needed to pay for a rental

Parameters:
room - the room being queried

Returns:
rental amount


query_rooms
mapping query_rooms()
query_rooms_to_rent
string * query_rooms_to_rent(object office)

Returns a list of rooms available in a particular location.

Parameters:
office - the office

Returns:
a string ready for presentation to a player containing a list of all rooms available in that office.


query_time_left
int query_time_left(string room)

Returns the time left for a room rental

Parameters:
room - the room to check with

Returns:
-1 if no such room, 0 if no renter, the time left otherwise


query_time_string
string query_time_string(int time)
query_who_rents
string query_who_rents(string room)

Returns the name of whoever is renting the room specified.

Parameters:
room - the short of the room you want to check

Returns:
the short of the player who's renting the room


remove_allow
int remove_allow(string who,
                 string room)

Removes someone as allowed to enter a rented room

Parameters:
who - name of the person to add
room - the room to allow them in


remove_rental
int remove_rental(object room_ob)

Removes the rented status from a room. Should be called when the time limit of the rental is over.

Parameters:
room_ob - the room object that is currently rented

Returns:
0 on success, 1 on failure

See also:
do_rental()