| Start/ | End/ | |||
| True | False | - | Line | Source |
| 1 | /* | |||
| 2 | * [[ Frozen-Bubble ]] | |||
| 3 | * | |||
| 4 | * Copyright (c) 2000-2003 Guillaume Cottenceau. | |||
| 5 | * Java sourcecode - Copyright (c) 2003 Glenn Sanson. | |||
| 6 | * | |||
| 7 | * This code is distributed under the GNU General Public License | |||
| 8 | * | |||
| 9 | * This program is free software; you can redistribute it and/or | |||
| 10 | * modify it under the terms of the GNU General Public License | |||
| 11 | * version 2, as published by the Free Software Foundation. | |||
| 12 | * | |||
| 13 | * This program is distributed in the hope that it will be useful, but | |||
| 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |||
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
| 16 | * General Public License for more details. | |||
| 17 | * | |||
| 18 | * You should have received a copy of the GNU General Public License along | |||
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., | |||
| 20 | * 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| 21 | * | |||
| 22 | * | |||
| 23 | * Artwork: | |||
| 24 | * Alexis Younes <73lab at free.fr> | |||
| 25 | * (everything but the bubbles) | |||
| 26 | * Amaury Amblard-Ladurantie <amaury at linuxfr.org> | |||
| 27 | * (the bubbles) | |||
| 28 | * | |||
| 29 | * Soundtrack: | |||
| 30 | * Matthias Le Bidan <matthias.le_bidan at caramail.com> | |||
| 31 | * (the three musics and all the sound effects) | |||
| 32 | * | |||
| 33 | * Design & Programming: | |||
| 34 | * Guillaume Cottenceau <guillaume.cottenceau at free.fr> | |||
| 35 | * (design and manage the project, whole Perl sourcecode) | |||
| 36 | * | |||
| 37 | * Java version: | |||
| 38 | * Glenn Sanson <glenn.sanson at free.fr> | |||
| 39 | * (whole Java sourcecode, including JIGA classes | |||
| 40 | * http://glenn.sanson.free.fr/jiga/) | |||
| 41 | * | |||
| 42 | * [[ http://glenn.sanson.free.fr/fb/ ]] | |||
| 43 | * [[ http://www.frozen-bubble.org/ ]] | |||
| 44 | */ | |||
| 45 | ||||
| 46 | ||||
| 47 | public class HighscoreManager | |||
| 48 | { | |||
| 49 | private int levelCompleted; | |||
| 50 | private long startTime; | |||
| 51 | ||||
| 52 | private long totalTime; | |||
| 53 | private int totalBubbles; | |||
| 54 | ||||
| 95 | 0 | 55 | public HighscoreManager() { | |
| 56 | reset(); | |||
| 57 | } | |||
| 58 | ||||
| 198 | 0 | 59 | public void reset() { | |
| 60 | levelCompleted = 0; | |||
| 61 | totalTime = 0; | |||
| 62 | totalBubbles = 0; | |||
| 63 | } | |||
| 64 | ||||
| 360 | 0 | 65 | public void startLevel() { | |
| 66 | startTime = System.currentTimeMillis(); | |||
| 67 | } | |||
| 68 | ||||
| 281 | 0 | 69 | public void endLevel(int nbBubbles) { | |
| 70 | totalTime += System.currentTimeMillis() - startTime; | |||
| 71 | totalBubbles += nbBubbles; | |||
| 72 | levelCompleted++; | |||
| 73 | } | |||
| 74 | ||||
| 0 | 0 | - | 75 | public String getParameters(String player) { |
| 76 | return "item=fb&name=" + convertToHTML(player) | |||
| 77 | + "&score=" + String.valueOf(levelCompleted) | |||
| 0 | - | 78 | + "&subscore=" + String.valueOf(86400000 - totalTime); | |
| 79 | } | |||
| 80 | ||||
| 0 | 0 | - | 81 | private String convertToHTML(String input) { |
| 82 | String output = new String(); | |||
| 83 | ||||
| 84 | int begin = 0; | |||
| 85 | int end = input.indexOf(" "); | |||
| 86 | ||||
| 0 | 0 | - | 87 | while (end != -1) { |
| 88 | output += input.substring(begin, end); | |||
| 89 | output += "%20"; | |||
| 90 | ||||
| 91 | begin = end + 1; | |||
| 92 | end = input.indexOf(" ", begin); | |||
| 93 | } | |||
| 94 | ||||
| 95 | output += input.substring(begin); | |||
| 96 | ||||
| 0 | - | 97 | return output; | |
| 98 | } | |||
| 99 | } | |||
| ***TER 40% (4/10) of SOURCE FILE HighscoreManager.java | ||||