More implementation for attacking
This commit is contained in:
38
gamedata.cpp
38
gamedata.cpp
@ -32,7 +32,7 @@ void GameData::do_vertex(int x, int y, int r)
|
||||
{
|
||||
if (current != NULL &&
|
||||
(MathUtils::distance(current->x, current->y, x, y)
|
||||
> get_move_radius()))
|
||||
> get_range()))
|
||||
{
|
||||
select_vertex(x, y);
|
||||
return;
|
||||
@ -122,26 +122,20 @@ float GameData::calculate_strength(Vertex* node)
|
||||
float GameData::calculate_strength_r(Vertex* node, unsigned int depth, list<Vertex*>& visited)
|
||||
{
|
||||
// Find which vertices we need to visit from here
|
||||
list<Edge> es = get_vertex_edges(node);
|
||||
list<Vertex*> neighbors = get_neighbors(node);
|
||||
list<Vertex*> to_visit;
|
||||
|
||||
visited.push_back(node);
|
||||
|
||||
for (list<Edge>::iterator cursor = es.begin(); cursor != es.end();
|
||||
cursor++)
|
||||
for (list<Vertex*>::iterator cursor = neighbors.begin();
|
||||
cursor != neighbors.end(); cursor++)
|
||||
{
|
||||
Edge e = *cursor;
|
||||
Vertex* v = *cursor;
|
||||
// if this is true, we haven't visited the vertex on the other end of
|
||||
// this edge yet
|
||||
if (e.a == node &&
|
||||
find(visited.begin(), visited.end(), e.b) == visited.end())
|
||||
if (find(visited.begin(), visited.end(), v) == visited.end())
|
||||
{
|
||||
to_visit.push_back(e.b);
|
||||
}
|
||||
else if (e.b == node &&
|
||||
find(visited.begin(), visited.end(), e.a) == visited.end())
|
||||
{
|
||||
to_visit.push_back(e.a);
|
||||
to_visit.push_back(v);
|
||||
}
|
||||
}
|
||||
|
||||
@ -169,8 +163,20 @@ float GameData::calculate_strength_r(Vertex* node, unsigned int depth, list<Vert
|
||||
}
|
||||
|
||||
|
||||
int GameData::get_move_radius(Vertex* node)
|
||||
int GameData::get_range(Vertex* node)
|
||||
{
|
||||
if (current == NULL) return 0;
|
||||
else return 100;
|
||||
if (node == NULL) node = current;
|
||||
|
||||
if (node == NULL) return 0;
|
||||
else if (mode == MODE_MOVE) return 100;
|
||||
else if (mode == MODE_ATTACK)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GameData::attack_vertex(Vertex* target)
|
||||
{
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user