-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAKAListEntry.cpp
72 lines (59 loc) · 1.41 KB
/
AKAListEntry.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
// wxWindows includes
#include <wx/string.h>
#include <wx/arrstr.h>
#include <wx/dynarray.h>
// Statsgen includes
#include "AKAListEntry.h"
#include "GlobalStatistics.h"
AKAListEntry::AKAListEntry()
{
}
AKAListEntry::~AKAListEntry()
{
}
wxString AKAListEntry::SQLTableName()
{
wxString tableName="akadata";
return (tableName);
}
wxString AKAListEntry::SQLCreateTable()
{
wxString SQL;
SQL.Printf("create table %s"
"("
"playerindex integer,"
"%s"
")",
SQLTableName().GetData(),
StatsgenDatabase::StringFieldDefinition("name","akaname",FIELD_WIDTH_PLAYER_NAME).GetData()
);
return SQL;
}
bool AKAListEntry::WriteToDatabase()
{
wxString SQL;
bool retVal=true;
int actualPlayerIndex;
Player player;
player=globalStatistics.playerList.Item(playerIndex);
actualPlayerIndex=player.actualPlayerIndex;
if (actualPlayerIndex<globalStatistics.statsgenDatabase.NextPlayerIndex())
{
SQL.Printf("delete from %s "
"where "
"playerindex='%d' and "
"name='%s'",
SQLTableName().GetData(),
actualPlayerIndex,
StatsgenDatabase::SafeForInsert(name).GetData());
globalStatistics.statsgenDatabase.SimpleExecute(SQL);
}
SQL.Printf("Insert into %s"
"(playerindex,name)"
"values('%d','%s')",
SQLTableName().GetData(),
actualPlayerIndex,
StatsgenDatabase::SafeForInsert(name).GetData());
globalStatistics.statsgenDatabase.SimpleExecute(SQL);
return retVal;
}