forked from CleverRaven/Cataclysm-DDA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iuse_software.cpp
79 lines (69 loc) · 2.25 KB
/
iuse_software.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "iuse_software.h"
#include <algorithm>
#include <map>
#include <string>
#include "iuse_software_kitten.h"
#include "iuse_software_lightson.h"
#include "iuse_software_minesweeper.h"
#include "iuse_software_snake.h"
#include "iuse_software_sokoban.h"
#include "string_formatter.h"
#include "translations.h"
bool play_videogame( const std::string &function_name,
std::map<std::string, std::string> &game_data,
int &score )
{
if( function_name.empty() ) {
score = 15;
return true; // generic game
}
if( function_name == "robot_finds_kitten" ) {
robot_finds_kitten findkitten;
bool foundkitten = findkitten.ret;
if( foundkitten ) {
game_data["end_message"] = _( "You found kitten!" );
game_data["moraletype"] = "MORALE_GAME_FOUND_KITTEN";
score = 30;
}
return foundkitten;
} else if( function_name == "snake_game" ) {
snake_game sg;
int iScore = sg.start_game();
if( iScore >= 10000 ) {
score = 30;
} else if( iScore >= 5000 ) {
score = 15;
} else {
score = 5;
}
return true;
} else if( function_name == "sokoban_game" ) {
sokoban_game sg;
int iScore = sg.start_game();
if( iScore >= 5000 ) {
score = 30;
} else if( iScore >= 1000 ) {
score = 15;
} else {
score = 5;
}
return true;
} else if( function_name == "minesweeper_game" ) {
minesweeper_game mg;
score = mg.start_game();
return true;
} else if( function_name == "lightson_game" ) {
lightson_game lg;
int iScore = lg.start_game();
score = std::min( 15, iScore * 3 );
return true;
} else {
score = -5;
/* morale/activity workaround >.> */
game_data["end_message"] = string_format(
_( "You struggle to get '%s' working, and finally give up to play minesweeper." ),
function_name );
// TODO: better messages in morale system // game_data["moraletype"]="MORALE_GAME_SOFTWARE_PROBLEM";
return false;
}
}