-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameCommand.cpp
98 lines (85 loc) · 3.68 KB
/
GameCommand.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
#include "GameCommand.h"
#include <iostream>
void DoMoveToArenaCommand(Model& model, int pokemon_id, int arena_id)
{
if (model.GetPokemonPtr(pokemon_id) != 0 && model.GetPokemonGymPtr(arena_id) != 0) {
cout << "Moving " << model.GetPokemonPtr(pokemon_id)->GetName()
<< " to arena " << arena_id << endl;
model.GetPokemonPtr(pokemon_id)->StartMovingToArena(model.GetBattleArenaPtr(arena_id));
} else
cout << "ERROR: Please enter a valid command!" << endl;
}
void DoBattleCommand(Model& model, int pokemon_id, int rival_id) {
Pokemon* Pokemon = model.GetPokemonPtr(pokemon_id);
if (Pokemon != 0) {
cout << Pokemon->GetName()
<< " Getting ready for the battle " << endl;
Rival* rival=model.GetRivalPtr(rival_id);
Pokemon->ReadyBattle(rival);
if (Pokemon->GetState() == BATTLE)
Pokemon->StartBattle();
} else
cout << "ERROR: Please enter a valid command!" << endl;
}
void DoMoveCommand(Model& model, int pokemon_id, Point2D p1) {
if (model.GetPokemonPtr(pokemon_id) != 0) {
cout << "Moving " << model.GetPokemonPtr(pokemon_id)->GetName()
<< " to " << p1 << endl;
model.GetPokemonPtr(pokemon_id)->StartMoving(p1);
} else
cout << "ERROR: Please enter a valid command!" << endl;
}
void DoMoveToCenterCommand(Model& model, int pokemon_id, int center_id) {
if (model.GetPokemonPtr(pokemon_id) != 0 && model.GetPokemonCenterPtr(center_id) != 0) {
cout << "Moving " << model.GetPokemonPtr(pokemon_id)->GetName()
<< " to center " << center_id << endl;
model.GetPokemonPtr(pokemon_id)->StartMovingToCenter(model.GetPokemonCenterPtr(center_id));
} else
cout << "ERROR: Please enter a valid command!" << endl;
}
void DoMoveToGymCommand(Model& model, int pokemon_id, int gym_id) {
if (model.GetPokemonPtr(pokemon_id) != 0 && model.GetPokemonGymPtr(gym_id) != 0) {
cout << "Moving " << model.GetPokemonPtr(pokemon_id)->GetName()
<< " to gym " << gym_id << endl;
model.GetPokemonPtr(pokemon_id)->StartMovingToGym(model.GetPokemonGymPtr(gym_id));
} else
cout << "ERROR: Please enter a valid command!" << endl;
}
void DoStopCommand(Model& model, int pokemon_id) {
if (model.GetPokemonPtr(pokemon_id) != 0) {
cout << "Stopping " << model.GetPokemonPtr(pokemon_id)->GetName() << endl;
model.GetPokemonPtr(pokemon_id)->Stop();
} else
cout << "ERROR: Please enter a valid command!" << endl;
}
void DoTrainInGymCommand(Model& model, int pokemon_id, unsigned int training_units) {
if (model.GetPokemonPtr(pokemon_id) != 0) {
cout << "Training " << model.GetPokemonPtr(pokemon_id)->GetName() << endl;
model.GetPokemonPtr(pokemon_id)->StartTraining(training_units);
} else
cout << "ERROR: Please enter a valid command!" << endl;
}
void DoRecoverInCenterCommand(Model& model, int pokemon_id, unsigned int stamina_points) {
if (model.GetPokemonPtr(pokemon_id) != 0) {
cout << "Recovering " << model.GetPokemonPtr(pokemon_id)->GetName() << "'s stamina" << endl;
model.GetPokemonPtr(pokemon_id)->StartRecoveringStamina(stamina_points);
} else
cout << "ERROR: Please enter a valid command!" << endl;
}
void DoGoCommand(Model& model, View& view) {
cout << "Advancing one tick." << endl;
model.Update();
model.ShowStatus();
model.Display(view);
}
void DoRunCommand(Model& model, View& view) {
cout << "Advancing to next event." << endl;
int count = 0;
bool event = false;
while (count < 5 && !event) {
event = model.Update();
count++;
}
model.ShowStatus();
model.Display(view);
}