DiscoverTenerife
|
Class that stores the current user data. More...
Public Member Functions | |
UserData (Firebase.Auth.FirebaseUser newFireBaseUserData, List< Dictionary< string, string > > oldVisitedPlaces=null, Dictionary< string, string > baseCordsData=null, List< string > friendList=null, List< string > friendsInvitationsList=null, List< string > friendsInvitationsAcceptedList=null, List< string > deletedFriendsList=null, List< Dictionary< string, string > > challengesData=null, string userScore=null, string earnedScore=null, List< Dictionary< string, string > > rangeStory=null) | |
Constructor. It initialices all the properties taking aware if they have been given with a real value or they are null. More... | |
string | ToJson () |
This method converts all the properties of the current object in a string that follows the JSON format. More... | |
bool | hasVisitPlace (string type, int id) |
This method return true if the current user has visited the place that has the given type and the given id. It returns false in any other case. More... | |
int | countOfVisitedPlaces () |
int | countOfVisitedPlacesOfZone (string zone) |
returns the quantity of places of the given type that the user has visited. Zones of the map are defined on mapRulesHandler class. More... | |
int | countOfAccumulatedVisits () |
returns the accumulated sum of number of visit of all the places that the current user has visited. More... | |
string | mostVisitedPlace () |
it returns a string that contains the name of the place that the current user has visited more times. More... | |
string | mostVisitedZone () |
it returns a string that contains the most visited zone of the current user. Zones of the map are defined on mapRulesHandler class. More... | |
string | mostVisitedType () |
it returns a string that contains the most visited zone of the current user. Type of the sites are defined on mapRulesHandler class. More... | |
int | countVisitedPlacesOfZone (string zone) |
it returns the sum of all visits to places that are on the given zone. Zones of the map are defined on mapRulesHandler class. More... | |
void | newVisitAt (string type, int id, long visitTime) |
This method register a visit of the current user to the place that has the given type and id. It registers the visit at the given timestamp. If the user havent visit a place with the given type and id this method adds a new VisitedPlace object to the visitedPlaces_ array. It also adds to the user a bonus of score. The obtained score depends on: if its the first time that the user visit that place and the proportion of visits that place has compared to the most visited place. It is calculated using getScoreForVisitingAPlace method of gameRules class. It also checks if one of the challenges was visit that place, if that is the case it use the calculateChallengeScore method of gameRules class. More... | |
void | setBase (double latitude, double longitude) |
this method should be called once per user. It stablished the user base on the given coords and set the baseEstablished_ attribute to true. More... | |
double | getBaseLongitude () |
Getter of the baseLongitude_ attribute. More... | |
double | getBaseLatitude () |
Getter of the baseLatitude_ attribute. More... | |
bool | baseEstablished () |
Getter of the baseEstablished_ attribute, true if the base of the current user has been already established, false in other case. More... | |
long | getTimestampByName (string name) |
It returns the timestamp of the last visit to the place that has the given name, if the user hadn't visited a place with that name it returns 0. More... | |
int | countOffriendsInvitations () |
It returns an int with how many new friendship invitations the current user has. More... | |
string | getFriendInvitation (int index) |
It returns the user id of the friendship invitation that is on the given position on the list of all friendship invitations. If the index is bigger than the list or the index is negative it will raise an exception. More... | |
void | deleteInvitationByName (string name) |
this method removes the frienship invitation of the user that has the given user id. More... | |
int | countOfFriends () |
string | getFriend (int index) |
Returns the user id of the friend index-th of the current user's friend list. If the given index is bigger than the size of the current user's friend list or its negative it will raise an exception. More... | |
int | countOfFriendData () |
FriendData | getFriendData (int index) |
Returns the friendData of the friend that is on the index-th position. If the given index is bigger than the size of the friendDataList_ list or its negative it will raise an exception. More... | |
void | addFriendData (FriendData friendData) |
bool | friendDataIsComplete () |
int | countOfNewFriends () |
string | getNewFriend (int index) |
It returns the user id of the index-th invitation of the friendsInvitationsList_ attribute. If the index is bigger than the list's size or its negative it will raise an exception. More... | |
int | countOfNewFriendData () |
newFriendData | getNewFriendData (int index) |
It returns the user id of the index-th friendship invitation data of the friendDataList_ attribute. If the index is bigger than the list's size or its negative it will raise an exception. More... | |
void | addNewFriendData (newFriendData friendData) |
bool | newFriendDataIsComplete () |
void | acceptFriend (string uid) |
This method add the given user id to the friend list and removes the friendship invitation and the friendship invitation data of the attributes of the current user. More... | |
void | deleteFriend (string uid) |
This method remove either the given user id of the friend list and the correspondent data from the properties of the current user. More... | |
VisitedPlace | getStoryPlaceData (int index) |
This method returns the VisitedPlace that is stored on the given position. If the given position is bigger than the visitedPlaces_ size or the given index is negative it will raise an exception. More... | |
string | getUid () |
getter of the user id. More... | |
bool | isAFriendByDisplayName (string displayName) |
This method checks if on the current user's friend list exists any user with the given display name. More... | |
FriendData | getFriendDataByUID (string uid) |
This method returns the FriendData object that contains the information of the current user's friend that has the given id. More... | |
void | destroyChallengeByChallengerId (string uid) |
This method deletes the challenge that has been sended by the user that has the given user id. More... | |
int | getQuantityOfChallenges () |
This method returns the cuantity of active challenges that the current user has. More... | |
challengeData | getChallenge (int index) |
This method returns the challengeData object that is on the given index-th position. More... | |
int | lastChallengeScore () |
getter of the lastChallengeScore_ property. More... | |
int | lastVisitScore () |
getter of the lastVisitScore_ property. More... | |
bool | hasToBeNotified (string uid) |
true if the user with the given user id is on the acceptedFriendsToNotify_ list, false in another case. More... | |
string | nextFriendToBeNotified () |
void | hasBeenNotified (string uid) |
This method removes the given user id of the acceptedFriendsToNotify_ list. More... | |
bool | anyUserHasToBeNotified () |
This method returns true if the acceptedFriendsToNotify_ isnt empty, false in any other case. More... | |
int | getScore () |
Getter of the score_ property. More... | |
string | getDisplayName () |
Getter of the displayName_ property. More... | |
int | getRangeStoryCount () |
Getter of the rangeStory_.Count property. More... | |
Dictionary< string, string > | getRangeStory (int index) |
Getter of the elements rangeStory_ property. More... | |
void | addRangeElementOnRangeStory (Dictionary< string, string > toAdd) |
This method adds the given dictionary to the rangeStory_ property. The rangeStory_ expects dictionaries with at least range_ and date_ entries. More... | |
string | getJSONof (string property) |
this method returns the json conversion of the property of this user that has the given name More... | |
bool | IsAnonymous () |
Public Attributes | |
Firebase.Auth.FirebaseUser | firebaseUserData_ |
Reference to the current user firebase data. More... | |
List< VisitedPlace > | visitedPlaces_ |
List of the places that the current user has visited. More... | |
List< string > | friendsInvitationsDeletedList_ |
List<string> that stores all the friends invitations that the user accepts or denies in order to prevent the database incongruences. More... | |
List< string > | deletedFriends_ |
List<string> that stores all the friends that the user deletes in order to prevent the database incongruences. More... | |
List< challengeData > | deletedChallenges_ |
List<challengeData> that stores all the challenges that the user completes or removes in order to prevent the database incongruences. More... | |
List< string > | acceptedFriends_ |
List<string> that stores all the friends invitations that the other user has accepted. More... | |
int | earnedScoreBeforeAdding_ |
int that stores the score that this user had before adding the score that is on the database version. This has to be done on this way because other users can add score to this user so the database version could be different of the local score version More... | |
Static Public Attributes | |
static List< string > | safeProperties_ |
static List<string> that store the names of the properties that are considered safe to write on the database because they only can be modified by the user that own them More... | |
static List< string > | unsafeProperties_ |
static List<string> that store the names of the properties that are considered unsafe to write on the database because they could be modified by the user that own them and other users. More... | |
Private Attributes | |
string | displayName_ |
String that contains the display name of the current user. More... | |
double | baseLatitude_ |
double that contains the latitude of the base of the current user. More... | |
double | baseLongitude_ |
double that contains the longitude of the base of the current user. More... | |
bool | baseEstablished_ |
bool true if the user has already stablished his base, false in other case. More... | |
List< string > | friendList_ |
list of strings that contains all the user ids of the friends of the current user. More... | |
List< FriendData > | friendDataList_ |
list that contains all the data of the friends of the current user. More... | |
List< string > | friendsInvitationsList_ |
list that contains strings with the user ids of all the user that has sended a friendship invitation to the current user and the current user hasnt accepted or denied. More... | |
List< newFriendData > | newFriendDataList_ |
list that stores all the necessary information of the users those that the current user has a new friendship invitation. More... | |
List< challengeData > | challenges_ |
List that stores all the data of the challenges that this user has. More... | |
int | score_ |
Int that stores the score of the current user. More... | |
int | lastVisitScore_ |
int that stores the score obtained by the last visit done. More... | |
int | lastChallengeScore_ |
int that stores the score obtained by the last challenge done. More... | |
List< string > | acceptedFriendsToNotify_ |
List<string> that stores the user ids that have to been notified that this user accepted the friendship invitation. More... | |
List< Dictionary< string, string > > | rangeStory_ |
List<Dictionary<string,string>> that stores all the user range story. It has an element for each time the user has reached a new range. Each element stores the range that is reached and the date of the achievement. The rangeStory_ expects dictionaries with at least range_ and date_ entries. More... | |
Class that stores the current user data.
UserData.UserData | ( | Firebase.Auth.FirebaseUser | newFireBaseUserData, |
List< Dictionary< string, string > > | oldVisitedPlaces = null , |
||
Dictionary< string, string > | baseCordsData = null , |
||
List< string > | friendList = null , |
||
List< string > | friendsInvitationsList = null , |
||
List< string > | friendsInvitationsAcceptedList = null , |
||
List< string > | deletedFriendsList = null , |
||
List< Dictionary< string, string > > | challengesData = null , |
||
string | userScore = null , |
||
string | earnedScore = null , |
||
List< Dictionary< string, string > > | rangeStory = null |
||
) |
Constructor. It initialices all the properties taking aware if they have been given with a real value or they are null.
Firebase.Auth.FirebaseUser | firebase user data |
List<Dictionary<string,string>> | (Optional) Information of the sites that the user has already visited |
Dictionary<string,string> | (Optional) Information of the geographical coords of the user's base. |
List<string> | (Optional) List of user ids of the current user's friends. |
List<string> | (Optional) List of user ids of the current user's new friendship invitations. |
List<string> | (Optional) List of user ids of the users that has accepted current user's friendships invitations. |
List<string> | (Optional) List of user ids of the users that has deleted current user's friendship. |
List<Dictionary<string,string>> | (Optional) List of the current user's challenges. |
string | (Optional) the user's current score |
string | (Optional) the user's score that has earned by the completion of challenges that the user has sended. |
List<Dictionary<string,string>> | (Optional) the user's story of range achievements.
|
void UserData.acceptFriend | ( | string | uid | ) |
This method add the given user id to the friend list and removes the friendship invitation and the friendship invitation data of the attributes of the current user.
string | that contains the user id of the user that the current user wants to add as a friend. |
void UserData.addFriendData | ( | FriendData | friendData | ) |
FriendData | to add to the friendDataList_ attribute. |
void UserData.addNewFriendData | ( | newFriendData | friendData | ) |
newFriendData | the data that you want to add to the newFriendDataList_ attribute. |
void UserData.addRangeElementOnRangeStory | ( | Dictionary< string, string > | toAdd | ) |
This method adds the given dictionary to the rangeStory_ property. The rangeStory_ expects dictionaries with at least range_ and date_ entries.
Dictionary<string,string> | that contains the information of the rangeStory that you want to add. |
bool UserData.anyUserHasToBeNotified | ( | ) |
This method returns true if the acceptedFriendsToNotify_ isnt empty, false in any other case.
bool UserData.baseEstablished | ( | ) |
Getter of the baseEstablished_ attribute, true if the base of the current user has been already established, false in other case.
int UserData.countOfAccumulatedVisits | ( | ) |
returns the accumulated sum of number of visit of all the places that the current user has visited.
int UserData.countOfFriendData | ( | ) |
int UserData.countOfFriends | ( | ) |
int UserData.countOffriendsInvitations | ( | ) |
It returns an int with how many new friendship invitations the current user has.
int UserData.countOfNewFriendData | ( | ) |
int UserData.countOfNewFriends | ( | ) |
int UserData.countOfVisitedPlaces | ( | ) |
int UserData.countOfVisitedPlacesOfZone | ( | string | zone | ) |
returns the quantity of places of the given type that the user has visited. Zones of the map are defined on mapRulesHandler class.
int UserData.countVisitedPlacesOfZone | ( | string | zone | ) |
it returns the sum of all visits to places that are on the given zone. Zones of the map are defined on mapRulesHandler class.
string | Zone that you want to know how many visit the current user has done. |
void UserData.deleteFriend | ( | string | uid | ) |
This method remove either the given user id of the friend list and the correspondent data from the properties of the current user.
string | that contains the user id of the user that the current user wants to delete friendship. |
void UserData.deleteInvitationByName | ( | string | name | ) |
this method removes the frienship invitation of the user that has the given user id.
@string user id to delete the friendship invitation.
void UserData.destroyChallengeByChallengerId | ( | string | uid | ) |
This method deletes the challenge that has been sended by the user that has the given user id.
string | that contains the challenger's user id of the challenge that will be removed. |
bool UserData.friendDataIsComplete | ( | ) |
double UserData.getBaseLatitude | ( | ) |
Getter of the baseLatitude_ attribute.
double UserData.getBaseLongitude | ( | ) |
Getter of the baseLongitude_ attribute.
challengeData UserData.getChallenge | ( | int | index | ) |
This method returns the challengeData object that is on the given index-th position.
int | the position of the challenge that will be returned |
string UserData.getDisplayName | ( | ) |
Getter of the displayName_ property.
string UserData.getFriend | ( | int | index | ) |
Returns the user id of the friend index-th of the current user's friend list. If the given index is bigger than the size of the current user's friend list or its negative it will raise an exception.
int | position of the user id that you want to get. |
FriendData UserData.getFriendData | ( | int | index | ) |
Returns the friendData of the friend that is on the index-th position. If the given index is bigger than the size of the friendDataList_ list or its negative it will raise an exception.
int | position of the friendData that you want to get. |
FriendData UserData.getFriendDataByUID | ( | string | uid | ) |
This method returns the FriendData object that contains the information of the current user's friend that has the given id.
string | user id that we want to get the information. |
string UserData.getFriendInvitation | ( | int | index | ) |
It returns the user id of the friendship invitation that is on the given position on the list of all friendship invitations. If the index is bigger than the list or the index is negative it will raise an exception.
int | the index for choose the friendship invitation. |
string UserData.getJSONof | ( | string | property | ) |
this method returns the json conversion of the property of this user that has the given name
string | with the name of the property that you want to obtain the json conversion of. |
string UserData.getNewFriend | ( | int | index | ) |
It returns the user id of the index-th invitation of the friendsInvitationsList_ attribute. If the index is bigger than the list's size or its negative it will raise an exception.
int | the position of the invitation that you want to get. |
newFriendData UserData.getNewFriendData | ( | int | index | ) |
It returns the user id of the index-th friendship invitation data of the friendDataList_ attribute. If the index is bigger than the list's size or its negative it will raise an exception.
int | the position of the friendship invitation data that you want to get. |
int UserData.getQuantityOfChallenges | ( | ) |
This method returns the cuantity of active challenges that the current user has.
Dictionary< string, string > UserData.getRangeStory | ( | int | index | ) |
Getter of the elements rangeStory_ property.
int | with the index of the element that you want to obtain |
int UserData.getRangeStoryCount | ( | ) |
Getter of the rangeStory_.Count property.
int UserData.getScore | ( | ) |
Getter of the score_ property.
VisitedPlace UserData.getStoryPlaceData | ( | int | index | ) |
This method returns the VisitedPlace that is stored on the given position. If the given position is bigger than the visitedPlaces_ size or the given index is negative it will raise an exception.
int | the position of the visited place that you want to get. |
long UserData.getTimestampByName | ( | string | name | ) |
It returns the timestamp of the last visit to the place that has the given name, if the user hadn't visited a place with that name it returns 0.
string | name of the visited place. |
string UserData.getUid | ( | ) |
getter of the user id.
void UserData.hasBeenNotified | ( | string | uid | ) |
This method removes the given user id of the acceptedFriendsToNotify_ list.
string | with the user id that was notified. |
bool UserData.hasToBeNotified | ( | string | uid | ) |
true if the user with the given user id is on the acceptedFriendsToNotify_ list, false in another case.
string | with the user id that will be check if it has to be notified. |
bool UserData.hasVisitPlace | ( | string | type, |
int | id | ||
) |
This method return true if the current user has visited the place that has the given type and the given id. It returns false in any other case.
string | type of the searched place. |
int | id of the searched place. |
bool UserData.isAFriendByDisplayName | ( | string | displayName | ) |
This method checks if on the current user's friend list exists any user with the given display name.
string | that contains the user's display name. |
bool UserData.IsAnonymous | ( | ) |
int UserData.lastChallengeScore | ( | ) |
getter of the lastChallengeScore_ property.
int UserData.lastVisitScore | ( | ) |
getter of the lastVisitScore_ property.
string UserData.mostVisitedPlace | ( | ) |
it returns a string that contains the name of the place that the current user has visited more times.
string UserData.mostVisitedType | ( | ) |
it returns a string that contains the most visited zone of the current user. Type of the sites are defined on mapRulesHandler class.
string UserData.mostVisitedZone | ( | ) |
it returns a string that contains the most visited zone of the current user. Zones of the map are defined on mapRulesHandler class.
bool UserData.newFriendDataIsComplete | ( | ) |
void UserData.newVisitAt | ( | string | type, |
int | id, | ||
long | visitTime | ||
) |
This method register a visit of the current user to the place that has the given type and id. It registers the visit at the given timestamp. If the user havent visit a place with the given type and id this method adds a new VisitedPlace object to the visitedPlaces_ array. It also adds to the user a bonus of score. The obtained score depends on: if its the first time that the user visit that place and the proportion of visits that place has compared to the most visited place. It is calculated using getScoreForVisitingAPlace method of gameRules class. It also checks if one of the challenges was visit that place, if that is the case it use the calculateChallengeScore method of gameRules class.
string | type of the site that the current user has visit. |
int | id of the site that the current user has visit. |
long | timestamp of the visit. |
string UserData.nextFriendToBeNotified | ( | ) |
void UserData.setBase | ( | double | latitude, |
double | longitude | ||
) |
this method should be called once per user. It stablished the user base on the given coords and set the baseEstablished_ attribute to true.
double | latitude of the base |
double | longitude of the base |
string UserData.ToJson | ( | ) |
This method converts all the properties of the current object in a string that follows the JSON format.
List<string> UserData.acceptedFriends_ |
List<string> that stores all the friends invitations that the other user has accepted.
|
private |
List<string> that stores the user ids that have to been notified that this user accepted the friendship invitation.
|
private |
bool true if the user has already stablished his base, false in other case.
|
private |
double that contains the latitude of the base of the current user.
|
private |
double that contains the longitude of the base of the current user.
|
private |
List that stores all the data of the challenges that this user has.
List<challengeData> UserData.deletedChallenges_ |
List<challengeData> that stores all the challenges that the user completes or removes in order to prevent the database incongruences.
List<string> UserData.deletedFriends_ |
List<string> that stores all the friends that the user deletes in order to prevent the database incongruences.
|
private |
String that contains the display name of the current user.
int UserData.earnedScoreBeforeAdding_ |
int that stores the score that this user had before adding the score that is on the database version. This has to be done on this way because other users can add score to this user so the database version could be different of the local score version
Firebase.Auth.FirebaseUser UserData.firebaseUserData_ |
Reference to the current user firebase data.
|
private |
list that contains all the data of the friends of the current user.
|
private |
list of strings that contains all the user ids of the friends of the current user.
List<string> UserData.friendsInvitationsDeletedList_ |
List<string> that stores all the friends invitations that the user accepts or denies in order to prevent the database incongruences.
|
private |
list that contains strings with the user ids of all the user that has sended a friendship invitation to the current user and the current user hasnt accepted or denied.
|
private |
int that stores the score obtained by the last challenge done.
|
private |
int that stores the score obtained by the last visit done.
|
private |
list that stores all the necessary information of the users those that the current user has a new friendship invitation.
|
private |
List<Dictionary<string,string>> that stores all the user range story. It has an element for each time the user has reached a new range. Each element stores the range that is reached and the date of the achievement. The rangeStory_ expects dictionaries with at least range_ and date_ entries.
|
static |
static List<string> that store the names of the properties that are considered safe to write on the database because they only can be modified by the user that own them
|
private |
Int that stores the score of the current user.
|
static |
static List<string> that store the names of the properties that are considered unsafe to write on the database because they could be modified by the user that own them and other users.
List<VisitedPlace> UserData.visitedPlaces_ |
List of the places that the current user has visited.