| 1 |
/* -*- Mode: vala; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
| 2 |
* |
| 3 |
* Copyright © 2014 Nikhar Agrawal |
| 4 |
* |
| 5 |
* This file is part of libgnome-games-support. |
| 6 |
* |
| 7 |
* libgnome-games-support is free software: you can redistribute it and/or modify |
| 8 |
* it under the terms of the GNU Lesser General Public License as published by |
| 9 |
* the Free Software Foundation, either version 3 of the License, or |
| 10 |
* (at your option) any later version. |
| 11 |
* |
| 12 |
* libgnome-games-support is distributed in the hope that it will be useful, |
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
* GNU Lesser General Public License for more details. |
| 16 |
* |
| 17 |
* You should have received a copy of the GNU Lesser General Public License |
| 18 |
* along with libgnome-games-support. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
*/ |
| 20 |
|
| 21 |
namespace Games { |
| 22 |
namespace Scores { |
| 23 |
|
| 24 |
public class Score : Object |
| 25 |
{ |
| 26 |
public long score { get; set; } |
| 27 |
|
| 28 |
/* Although the scores dialog does not currently display the time a |
| 29 |
* score was achieved, it did in the past and it might again in the future. |
| 30 |
*/ |
| 31 |
private int64 _time; |
| 32 |
public int64 time |
| 33 |
{ |
| 34 |
get { return _time; } |
| 35 |
set { _time = (value == 0 ? new DateTime.now_local ().to_unix () : value); } |
| 36 |
} |
| 37 |
|
| 38 |
private string _user; |
| 39 |
public string user |
| 40 |
{ |
| 41 |
get { return _user; } |
| 42 |
set { _user = (value == null ? Environment.get_real_name () : value); } |
| 43 |
} |
| 44 |
|
| 45 |
public Score (long score, int64 time = 0, string? user = null) |
| 46 |
{ |
| 47 |
Object (score: score, time: time, user: user); |
| 48 |
} |
| 49 |
|
| 50 |
public static bool equals (Score a, Score b) |
| 51 |
{ |
| 52 |
return a.score == b.score && a.time == b.time && a.user == b.user; |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
} /* namespace Scores */ |
| 57 |
} /* namespace Games */ |