-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathBattleCoreOutput.cpp
166 lines (116 loc) · 3.48 KB
/
BattleCoreOutput.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
//#include "stdafx.h"
#include <fstream>
#include "Basic_Battle/Robot/RobotAITest.h"
#include "stdafx.h"
#include "BattleCoreOutput.h"
void LoadGameData()
{
//pDataLoader->LoadDataFromLuaScript("GameData.lua");
pDataLoader->LoadDataFromLuaScript(pBattlefield->battleMode.lua_path.c_str());
}
void InitNewBattle()
{
//播撒随机数种子
SetSeed();
//清扫之前的战场
pBattlefield->SweepBattlefield(true,true,true,true);
}
/*
void SetBattleMode(const BattleMode & battleMode)
{
pBattlefield->SetBattleMode(battleMode);
}
*/
void SetBattleModeWithConfigFile(const char * filename)
{
pBattlefield->SetBattleModeWithConfigFile(filename);
}
void SetBattleModeNew(const char * filename,const char * record_path,const char * statistics_path)
{
pBattlefield->SetBattleModeWithConfigFile(filename);
pBattlefield->SetBattleModeNew(record_path,statistics_path);
}
int AddRobotAI(RobotAI_Interface* pAI)
{
//向Battlefield添加AI
//为pAI指向的AI创建新的机器人加入到战场
//函数指针赋值
pAI->trace=trace_global; //调试输出函数指针
pAI->getWeaponName=getWeaponName;
//pAI->getWeaponDamage=getWeaponDamage;
pAI->getWeaponAmmo=getWeaponAmmo;
pAI->getWeaponCoolingTime=getWeaponCoolingTime;
pAI->getWeaponInaccuracy=getWeaponInaccuracy;
pAI->getWeaponRotationSpeed=getWeaponRotationSpeed;
pAI->getEngineName=getEngineName;
pAI->getEngineMaxSpeed=getEngineMaxSpeed;
pAI->getEngineMaxHp=getEngineMaxHp;
pAI->getEngineRotationSpeed=getEngineRotationSpeed;
pAI->getEngineAcceleration=getEngineAcceleration;
pAI->getBulletName=getBulletName;
pAI->getBulletSpeed=getBulletSpeed;
pAI->getBulletDamage=getBulletDamage;
pAI->getBulletFlyTime=getBulletFlyTime;
///////////////////
//TODO:这里的index原来是AIManager中的AI下标
//现在不需要了
//封装:BattleCore不管外面链进来的AI的信息
//只要返回当前加入AI在pRobot的下标
return (pBattlefield->AddRobotAI(pAI,0)); //先0冗余一下
}
/*
AchievementData_Battle& GetAchievementData(int robotID)
{
return (pBattlefield->GetAchievementData(robotID));
}
*/
/*
BattleStatistics& GetBattleStatistics()
{
return (pBattlefield->GetBattleStatistics());
}
*/
bool LaunchBattle()
{
pBattlefield->NewBattle();
//temp
return true;
}
#ifdef ROBOT_AI_TEST
void StartTestingBattleWithRandomEquipment()
{
BattleMode defaultBattleMode(true,4000,true,"zTestingBattle.txt");
RobotAI_Interface* ai0=new RobotAITest();
RobotAI_Interface* ai1=new RobotAITest();
InitNewBattle();
pBattlefield->SetBattleMode(defaultBattleMode);
int id0=AddRobotAI(ai0);
int id1=AddRobotAI(ai1);
LaunchBattle();
//TODO:打印一些战斗统计数据
BattleStatistics& battleStatistics=pBattlefield->GetBattleStatistics();
cout<<"winner id: "<<battleStatistics.winnerID<<'\n';
delete ai0;
delete ai1;
}
void StartTestingBattleWithAssignedEquipment(int weapon0,int engine0,int weapon1,int engine1)
{
BattleMode defaultBattleMode(true,4000,true,"zTestingBattle.txt");
RobotAI_Interface* ai0=new RobotAITest();
((RobotAITest*)ai0)->m_weapon=(weapontypename)weapon0;
((RobotAITest*)ai0)->m_engine=(enginetypename)engine0;
RobotAI_Interface* ai1=new RobotAITest();
((RobotAITest*)ai1)->m_weapon=(weapontypename)weapon1;
((RobotAITest*)ai1)->m_engine=(enginetypename)engine1;
InitNewBattle();
pBattlefield->SetBattleMode(defaultBattleMode);
int id0=AddRobotAI(ai0);
int id1=AddRobotAI(ai1);
LaunchBattle();
//TODO:打印一些战斗统计数据
BattleStatistics& battleStatistics=pBattlefield->GetBattleStatistics();
cout<<"winner id: "<<battleStatistics.winnerID<<'\n';
delete ai0;
delete ai1;
}
#endif