Eiffel Media API
Overview Cluster Class Classes Index      Previous Next      Top Features

em.highscore

Class EM_HIGHSCORE


Direct ancestors

EM_LOCAL_HIGHSCORE, EM_SHARED_SUBSYSTEMS

Creation

Features

Invariants

indexing

description

Extension to local highscore which can send local highscore to the server
and receive a remote highscore.

date

$Date: 2005/10/28 16:47:31 $

revision

$Revision: 1.36 $

class

EM_HIGHSCORE

inherit

EM_LOCAL_HIGHSCORE

create

make

-- create highscore

-- (From EM_LOCAL_HIGHSCORE)

require
application_id_set: application_id.item /= void
make_extended (the_other_keys: ARRAY [STRING])

-- create highscore with additional keys

-- (From EM_LOCAL_HIGHSCORE)

require
no_keywords: not has_keywords(the_other_keys)
the_other_keys /= void application_id_set: application_id.item /= void

feature -- Initialization

make

-- create highscore

-- (From EM_LOCAL_HIGHSCORE)

require
application_id_set: application_id.item /= void
make_extended (the_other_keys: ARRAY [STRING])

-- create highscore with additional keys

-- (From EM_LOCAL_HIGHSCORE)

require
no_keywords: not has_keywords(the_other_keys)
the_other_keys /= void application_id_set: application_id.item /= void

feature -- Access

network_subsystem: EM_NETWORK_SUBSYSTEM

-- EiffelMedia network subsystem is

-- (From EM_SHARED_SUBSYSTEMS)

ensure
network_subsystem_not_void: Result /= void
highscore_file: PLAIN_TEXT_FILE

-- (From EM_LOCAL_HIGHSCORE)

local_highscore: DS_LINKED_LIST[like highscore_entries]

-- data structure with local highscore in it

-- (From EM_LOCAL_HIGHSCORE)

num_of_local_entries: INTEGER

-- desired number of entries in local highscore

-- (From EM_LOCAL_HIGHSCORE)

num_of_remote_entries: INTEGER

-- desired number of entries in remote highscore

remote_highscore: DS_LINKED_LIST[like highscore_entries]

-- data structure with remote highscore in it

url: STRING

-- url to synchronize highscore with

feature -- Element change

set_local_file (a_directory: STRING; a_filename: STRING)

-- set path for highscore file

-- (From EM_LOCAL_HIGHSCORE)

require
a_filename /= voida_directory.item (a_directory.count) = '/'
set_num_of_local_entries (a_num_of_local_entries: like num_of_local_entries)

-- Set num_of_local_entries to a_num_of_local_entries.

-- (From EM_LOCAL_HIGHSCORE)

ensure
num_of_local_entries_assigned: num_of_local_entries = a_num_of_local_entries
set_num_of_remote_entries (a_num_of_remote_entries: like num_of_remote_entries)

-- Set num_of_remote_entries to a_num_of_remote_entries.

ensure
num_of_remote_entries_assigned: num_of_remote_entries = a_num_of_remote_entries
set_url (an_url: STRING)

-- set url to synchronize highscore

require
url_not_void: an_url /= void

feature -- Crop

crop_remote (nb_elements: INTEGER)

-- crop remote highscore to 'nb_elements'

require
positive: nb_elements > 0

feature -- Sorting

sort_remote_by_key (a_key: STRING; sort_reverse: BOOLEAN)

-- sort remote highscore by key (sorting alphabetically)

sort_remote_by_name (sort_reverse: BOOLEAN)

-- sort remote highscore by name

sort_remote_by_score (sort_reverse: BOOLEAN)

-- sort remote highscore by score

feature -- Network

cancel_connection

-- cancel the connection to server

require
network_enabled: network_subsystem.is_enabled
connection_closed_event: EM_EVENT_TYPE [TUPLE []]

-- Event to indicate that the connection closed

connection_established_event: EM_EVENT_TYPE [TUPLE []]

-- Event to indicate that the connection is established

connection_failed_event: EM_EVENT_TYPE [TUPLE []]

-- Event to indicate that the connection failed

receive_remote

-- receive remote highscore

require
network_enabled: network_subsystem.is_enabled
send_local

-- send local highscore to server

require
network_enabled: network_subsystem.is_enabled
synchronize_with_server

-- send local highscore to server, receive remote highscore

require
network_enabled: network_subsystem.is_enabled

feature -- Checksum

set_checksum_generator (a_generator: like checksum_generator)

-- set the checksum generator
-- (if you want to use your own checksum generator)

-- (From EM_LOCAL_HIGHSCORE)

feature -- Sort and Crop

crop_local (nb_elements: INTEGER)

-- crop local highscore to 'nb_elements'

-- (From EM_LOCAL_HIGHSCORE)

require
positive: nb_elements > 0
sort_local_by_key (a_key: STRING; sort_reverse: BOOLEAN)

-- sort local highscore by a key (alphabetical sorting)

-- (From EM_LOCAL_HIGHSCORE)

sort_local_by_name (sort_reverse: BOOLEAN)

-- sort local highscore by name

-- (From EM_LOCAL_HIGHSCORE)

sort_local_by_score (sort_reverse: BOOLEAN)

-- sort local highscore by score

-- (From EM_LOCAL_HIGHSCORE)

feature -- Add/Update entries

add_entry (a_name: STRING; a_score: INTEGER)

-- add entry to local highscore

-- (From EM_LOCAL_HIGHSCORE)

require
name_valid: is_valid_string (a_name)
add_entry_extended (a_name: STRING; a_score: INTEGER; other_values: ARRAY[STRING])

-- add extended entry to local highscore

-- (From EM_LOCAL_HIGHSCORE)

require
name_valid: is_valid_string (a_name)
right_number_of_values: other_values.count = other_keys.count
add_or_update_entry (a_name: STRING; a_score: INTEGER)

-- add or update entry depending on if it's already present or not

-- (From EM_LOCAL_HIGHSCORE)

require
name_valid: is_valid_string (a_name)
add_or_update_entry_extended (a_name: STRING; a_score: INTEGER; other_values: ARRAY[STRING])

-- add or update extended entry depending of it's already present or not

-- (From EM_LOCAL_HIGHSCORE)

require
name_valid: is_valid_string (a_name)
right_number_of_values: other_values.count = other_keys.count
has_entry (a_name: STRING): BOOLEAN

-- check if name is in local highscore

-- (From EM_LOCAL_HIGHSCORE)

require
name_not_void: a_name /= Void
is_better (a_name: STRING; a_score: INTEGER): BOOLEAN

-- check if 'a_score' of 'a_name' is better than the one already in highscore

-- (From EM_LOCAL_HIGHSCORE)

require
has_entry (a_name)
is_valid_character (a_char: CHARACTER): BOOLEAN

-- check if character is valid (isn't special character)

-- (From EM_LOCAL_HIGHSCORE)

is_valid_string (a_string: STRING): BOOLEAN

-- check if string is valid (doesn't contain special characters

-- (From EM_LOCAL_HIGHSCORE)

update_entry (the_name: STRING; the_score: INTEGER)

-- update entry in local highscore

-- (From EM_LOCAL_HIGHSCORE)

require
name_valid: is_valid_string (the_name)
update_entry_extended (the_name: STRING; a_score: INTEGER; other_values: ARRAY[STRING])

-- update extended in local highscore

-- (From EM_LOCAL_HIGHSCORE)

require
name_valid: is_valid_string (the_name)
right_number_of_values: other_values.count = other_keys.count

feature -- Read/Write

read_local

-- read highscore from a local file

-- (From EM_LOCAL_HIGHSCORE)

require
file_set: highscore_file /= void
write_local

-- write local highscore to disc

-- (From EM_LOCAL_HIGHSCORE)

require
highscore_file_set: highscore_file /= void

feature -- Keys

has_keywords (the_keys: ARRAY[STRING]): BOOLEAN

-- check if an array has a keyword

-- (From EM_LOCAL_HIGHSCORE)

require
the_keys /= void
key_valid (the_key: STRING): BOOLEAN

-- check if a key is valid

-- (From EM_LOCAL_HIGHSCORE)

require
key_not_void: the_key /= void
other_keys: ARRAY[STRING]

-- (From EM_LOCAL_HIGHSCORE)

feature -- Application ID singleton

application_id: EM_APPLICATION_ID

-- Application ID singleton.

-- (From EM_SHARED_APPLICATION_ID)

invariant


-- From ANY
reflexive_equality: standard_is_equal (Current)
reflexive_conformance: conforms_to (Current)

end