Skip to content
Snippets Groups Projects
Commit ab4cb664 authored by Luboš Horáček's avatar Luboš Horáček
Browse files

Game stats for result screen

parent aea38a21
Branches
Tags
No related merge requests found
Showing
with 34 additions and 27 deletions
......@@ -10,7 +10,7 @@ game_kidnapping_loadingtext_2=Pak si\u00A0poslechni zvuky okolních ulic a urči
game_kidnapping_loadingtext_3=Se\u00A0sluchátky zvuky lépe uslyšíš.
game_kidnapping_instructions_silence=Pššššt!
game_kidnapping_instructions_pay_attention=Poslouchej pozorně
game_kidnapping_stats=Počet chyb: <b>%1$s</b>
game_kidnapping_stats=Počet chyb: [BLACK]{1}[]
game_kidnapping_rule_easy=Najdi ulici se\u00A0stejně znějícím zvukem nebo slovem.
game_kidnapping_rule_medium=Najdi ulici se\u00A0stejně znějícím zvukem nebo slovem, jehož hláskovaná varianta odpovídá té\u00A0čtené.
game_kidnapping_rule_hardcore=Najdi ulici se\u00A0stejně znějícím zvukem nebo slovem, kterému chybí předposlední písmeno.
......@@ -10,7 +10,7 @@ game_kidnapping_loadingtext_2=Dann hör dir die\u00A0Geräusche der umliegenden
game_kidnapping_loadingtext_3=Mit\u00A0Kopfhörern hörst du die Geräusche besser.
game_kidnapping_instructions_silence=Psssst!
game_kidnapping_instructions_pay_attention=Hör aufmerksam zu
game_kidnapping_stats=Fehlerzahl: <b>%1$s</b>
game_kidnapping_stats=Fehlerzahl: [BLACK]{1}[]
game_kidnapping_rule_easy=Finde die Straße mit\u00A0dem gleich klingenden Geräusch oder Wort.
game_kidnapping_rule_medium=Finde die Straße mit\u00A0dem gleich klingenden Geräusch oder Wort, dessen buchstabierte Variante der\u00A0gelesenen entspricht.
game_kidnapping_rule_hardcore=Finde die Straße mit\u00A0dem gleich klingenden Geräusch oder Wort, dem der vorletzte Buchstabe fehlt.
......@@ -10,7 +10,7 @@ game_kidnapping_loadingtext_2=Potom si vypočuj zvuky okolitých ulic a urči, k
game_kidnapping_loadingtext_3=So slúchatkami budeš zvuky počuť lepšie.
game_kidnapping_instructions_silence=Pššššt!
game_kidnapping_instructions_pay_attention=Počúvaj pozorne
game_kidnapping_stats=Počet chýb: <b>%1$s</b>
game_kidnapping_stats=Počet chýb: [BLACK]{1}[]
game_kidnapping_rule_easy=Nájdi ulicu s rovnako znejúcim zvukom alebo slovom.
game_kidnapping_rule_medium=Nájdi ulicu s rovnako znejúcim zvukom alebo slovom, ktorému chýba predposledné písmeno.
game_kidnapping_rule_hardcore=Nájdi ulicu s rovnako znejúcim zvukom alebo slovom, ktorého hláskovaná varianta odpovedá tej čítanej
......
......@@ -8,3 +8,4 @@ game_shootingrange_loadingtext_1=Pozorně sleduj kytku v\u00A0pravém horním ro
game_shootingrange_loadingtext_2=Kliknutí na bednu s\u00A0hvězdičkou ti\u00A0strefování kytek ulehčí, kliknutí na\u00A0bednu s\u00A0lebkou naopak ztíží.
game_shootingrange_plus=+5
game_shootingrange_minus=-5
game_shootingrange_stats=Tvoje skóre: [BLACK]{1}[]
......@@ -8,3 +8,4 @@ game_shootingrange_loadingtext_1=Verfolge aufmerksam die Blume im\u00A0oberen re
game_shootingrange_loadingtext_2=Mit einem Klick auf die Kiste mit\u00A0Stern lassen sich die\u00A0Blumen leichter treffen, mit einem Klick auf\u00A0 die Kiste mit\u00A0Schädel schwieriger.
game_shootingrange_plus=+5
game_shootingrange_minus=-5
game_shootingrange_stats=Deine Punktzahl: [BLACK]{1}[]
\ No newline at end of file
......@@ -8,5 +8,5 @@ game_shootingrange_loadingtext_1=Pozorne sleduj kvet v pravom hornom rohu. Na st
game_shootingrange_loadingtext_2=Kliknutie na bedňu s hviezdičkou ti triafanie kvetov uľahčí, kliknutie na bedňu s lebkou naopak sťaží.
game_shootingrange_plus=+5
game_shootingrange_minus=-5
game_shootingrange_stats=Tvoje skóre: [BLACK]{1}[]
......@@ -52,7 +52,7 @@ public class KidnappingGame extends AbstractTablexiaGame<GameState> {
@Override
protected GameState prepareGameData(java.util.Map<String, String> gameState) {
GameState gs = GameState.GameStateFactory.createInstance(getRandom(), getGameDifficulty(), Properties.MAP_WIDTH, Properties.MAP_HEIGHT, Properties.GAME_STOPS, Properties.MAP_WIDTH / 2, Properties.MAP_HEIGHT / 2);
GameState gs = GameState.GameStateFactory.createInstance(getGame(),getRandom(), getGameDifficulty(), Properties.MAP_WIDTH, Properties.MAP_HEIGHT, Properties.GAME_STOPS, Properties.MAP_WIDTH / 2, Properties.MAP_HEIGHT / 2);
Log.info(getClass(), "Game State: " + gs.toString());
return gs;
}
......@@ -174,7 +174,7 @@ public class KidnappingGame extends AbstractTablexiaGame<GameState> {
@Override
protected List<SummaryMessage> getSummaryMessageForGameResult(Game game) {
return null;
return Arrays.asList(new SummaryMessage(SummaryImage.STATS, getFormattedText(Properties.RESULT_TEXT_SUMMARY, game.getGameScore(GameState.GAME_MISSES, "0"))));
}
@Override
......
......@@ -4,8 +4,6 @@ package cz.nic.tablexia.game.games.kidnapping;
* Created by lhoracek on 5/15/15.
*/
public class Properties {
public static final String SCORE_ERRORS = "score_errors";
public static final String SCORE_REPLAYS = "score_replays";
public static final int TILE_BASE_WIDTH = 528;
public static final int TILE_BASE_HEIGHT = 264;
......@@ -27,4 +25,5 @@ public class Properties {
static final String[] RESULT_SOUNDS = new String[]{"mfx/result/result_0.mp3", "mfx/result/result_1.mp3", "mfx/result/result_2.mp3", "mfx/result/result_3.mp3"};
static final String[] RESULT_TEXT = new String[]{"game_kidnapping_result_0", "game_kidnapping_result_1", "game_kidnapping_result_2", "game_kidnapping_result_3"};
static final String RESULT_TEXT_SUMMARY = "game_kidnapping_stats";
}
......@@ -13,25 +13,30 @@ import cz.nic.tablexia.game.games.kidnapping.generator.TileMapGenerator;
import cz.nic.tablexia.game.games.kidnapping.media.DirectionSounds;
import cz.nic.tablexia.game.games.kidnapping.media.assets.TileType;
import cz.nic.tablexia.game.games.kidnapping.util.DirectionsHelper;
import cz.nic.tablexia.model.game.Game;
/**
* Created by lhoracek on 5/15/15.
*/
public class GameState {
public static final String GAME_MISSES = "GAME_MISSES";
public static final String GAME_REPLAYS = "GAME_REPLAYS";
public static final String GAME_STEP = "GAME_STEP";
private final Map<Position, TileType> map;
private final List<Position> path;
private final List<DirectionSounds.SoundPack> sounds;
private final Direction startDirection, endDirection;
private int step = 0;
private int misses = 0;
private int replays = 0;
private Game game;
private GameState(Map<Position, TileType> map, List<Position> path, List<DirectionSounds.SoundPack> sounds, Direction endDirection, Direction startDirection) {
private GameState(Game game, Map<Position, TileType> map, List<Position> path, List<DirectionSounds.SoundPack> sounds, Direction endDirection, Direction startDirection) {
this.map = map;
this.path = path;
this.sounds = sounds;
this.startDirection = startDirection;
this.endDirection = endDirection;
this.game = game;
}
public Map<Position, TileType> getMap() {
......@@ -43,35 +48,35 @@ public class GameState {
}
public int getStep() {
return step;
return Integer.parseInt(game.getGameScore(GAME_STEP, "0"));
}
public void setStep(int step) {
this.step = step;
game.setGameScore(GAME_STEP, String.valueOf(step));
}
public Position getCurrentPosition() {
return path.get(step);
return path.get(getStep());
}
public Position getLastPosition() {
return path.get(step - 1);
return path.get(getStep() - 1);
}
public void addReplay() {
replays++;
game.setGameScore(GAME_REPLAYS, String.valueOf(getReplays() + 1));
}
public void addMiss() {
misses++;
game.setGameScore(GAME_MISSES, String.valueOf(getMisses() + 1));
}
public int getMisses() {
return misses;
return Integer.parseInt(game.getGameScore(GAME_MISSES, "0"));
}
public int getReplays() {
return replays;
return Integer.parseInt(game.getGameScore(GAME_REPLAYS, "0"));
}
public List<DirectionSounds.SoundPack> getSounds() {
......@@ -86,21 +91,21 @@ public class GameState {
nextDirs.add(DirectionsHelper.getNextDirection(path, i));
lastDirs.add(DirectionsHelper.getLastDirection(path, i));
}
return "Kidnapping[" + map.size() + " tiles][" + path.size() + " steps][" + sounds.size() + " soundPacks][step: " + step + "]\n[path: " + Arrays.toString(path.toArray()) + "]\n" +
"[dirsNext: " + Arrays.toString(nextDirs.toArray()) + "]" + "[dirsLast: " + Arrays.toString(lastDirs.toArray()) + "][startDir:" + startDirection.name() + " endDir:" + endDirection.name() + "]" ;
return "Kidnapping[" + map.size() + " tiles][" + path.size() + " steps][" + sounds.size() + " soundPacks][step: " + getStep() + "]\n[path: " + Arrays.toString(path.toArray()) + "]\n" +
"[dirsNext: " + Arrays.toString(nextDirs.toArray()) + "]" + "[dirsLast: " + Arrays.toString(lastDirs.toArray()) + "][startDir:" + startDirection.name() + " endDir:" + endDirection.name() + "]";
}
public Direction getNextDirection() {
return (step == getPath().size() - 1) ? endDirection : DirectionsHelper.getNextDirection(path, step);
return (getStep() == getPath().size() - 1) ? endDirection : DirectionsHelper.getNextDirection(path, getStep());
}
public Direction getLastDirection() {
return step == 0 ? startDirection : DirectionsHelper.getLastDirection(path, step);
return getStep() == 0 ? startDirection : DirectionsHelper.getLastDirection(path, getStep());
}
public static class GameStateFactory {
public static GameState createInstance(Random random, GameDifficulty gameDifficulty, int width, int height, int stops, int startX, int startY) {
public static GameState createInstance(Game game, Random random, GameDifficulty gameDifficulty, int width, int height, int stops, int startX, int startY) {
TileMapGenerator mapGenerator = new TileMapGenerator(random);
PathGenerator pathGenerator = new PathGenerator(random);
SoundPathGenerator soundPathGenerator = new SoundPathGenerator(random, gameDifficulty);
......@@ -109,7 +114,7 @@ public class GameState {
List<DirectionSounds.SoundPack> sounds = soundPathGenerator.generatePath(path);
Direction startDirection = pathGenerator.getRandomDirection(DirectionsHelper.getNextDirection(path, 0));
Direction endDirection = pathGenerator.getRandomDirection(DirectionsHelper.getNextDirection(path, path.size() - 2));
return new GameState(map, path, sounds, startDirection, endDirection);
return new GameState(game, map, path, sounds, startDirection, endDirection);
}
}
}
......@@ -3,6 +3,7 @@ package cz.nic.tablexia.game.games.kidnapping.util;
import cz.nic.tablexia.game.AbstractTablexiaGame;
import cz.nic.tablexia.game.GameDefinition;
import cz.nic.tablexia.game.games.kidnapping.Properties;
import cz.nic.tablexia.game.games.kidnapping.model.GameState;
import cz.nic.tablexia.model.game.Game;
/**
......@@ -12,7 +13,7 @@ public class KidnappingResultResolver implements GameDefinition.GameResultResolv
@Override
public AbstractTablexiaGame.GameResult getGameResult(Game game) {
int[] levels = Properties.GAMERULE_CUPS[game.getDifficulty().getDifficultyNumber()-1];
int misses = Integer.valueOf(game.getGameScore(Properties.SCORE_ERRORS));
int misses = Integer.valueOf(game.getGameScore(GameState.GAME_MISSES));
if (misses <= levels[0]) {
return AbstractTablexiaGame.GameResult.THREE_STAR;
} else if (misses <= levels[1]) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment