Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cpp-project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Maul
cpp-project
Commits
a048952d
Commit
a048952d
authored
5 months ago
by
Frederik
Browse files
Options
Downloads
Patches
Plain Diff
Fix Bug with start and end turn and start the first turn immeadiatly after loading
parent
03e2d6bd
No related branches found
No related tags found
2 merge requests
!29
Merge main into box2d to implement physics
,
!27
Implement Player Class
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/game/Level.cpp
+5
-3
5 additions, 3 deletions
src/game/Level.cpp
src/game/Player.cpp
+6
-3
6 additions, 3 deletions
src/game/Player.cpp
src/game/Player.hpp
+2
-2
2 additions, 2 deletions
src/game/Player.hpp
with
13 additions
and
8 deletions
src/game/Level.cpp
+
5
−
3
View file @
a048952d
...
...
@@ -123,9 +123,11 @@ std::shared_ptr<Level> Level::loadLevel(std::string path, Engine& engine)
}
}
return
std
::
make_shared
<
Level
>
(
name
,
width
,
height
,
tiles
,
buildings
,
units
,
std
::
vector
<
Effect
>
{},
turnQ
);
};
Level
level
(
name
,
width
,
height
,
tiles
,
buildings
,
units
,
std
::
vector
<
Effect
>
{},
turnQ
);
level
.
m_turnQ
.
front
().
startTurn
(
level
.
m_units
,
level
.
m_buildings
);
return
std
::
make_shared
<
Level
>
(
level
);
}
std
::
pair
<
int
,
int
>
Level
::
calcTilePos
(
int
mouseX
,
int
mouseY
)
{
...
...
This diff is collapsed.
Click to expand it.
src/game/Player.cpp
+
6
−
3
View file @
a048952d
...
...
@@ -4,12 +4,15 @@
namespace
advanced_wars
{
Player
::
Player
(
int
money
,
PlayerFaction
faction
)
:
m_money
(
money
),
m_faction
(
faction
)
{}
Player
::
Player
(
int
money
,
PlayerFaction
faction
)
:
m_money
(
money
),
m_alive
(
true
),
m_activeTurn
(
false
),
m_faction
(
faction
)
{
}
Player
::~
Player
()
{}
void
Player
::
startTurn
(
std
::
unordered_map
<
int
,
Unit
>
lvUnits
,
std
::
unordered_map
<
int
,
Building
>
lvBuildings
)
std
::
unordered_map
<
int
,
Unit
>
&
lvUnits
,
std
::
unordered_map
<
int
,
Building
>
&
lvBuildings
)
{
for
(
auto
&
[
id
,
unit
]
:
lvUnits
)
{
...
...
@@ -98,7 +101,7 @@ void Player::startTurn(
m_activeTurn
=
true
;
}
void
Player
::
endTurn
(
std
::
unordered_map
<
int
,
Unit
>
lvUnits
)
void
Player
::
endTurn
(
std
::
unordered_map
<
int
,
Unit
>
&
lvUnits
)
{
for
(
auto
&
[
id
,
unit
]
:
lvUnits
)
{
...
...
This diff is collapsed.
Click to expand it.
src/game/Player.hpp
+
2
−
2
View file @
a048952d
...
...
@@ -36,7 +36,7 @@ class Player
* @param lvBuildings All buildings of a level
*/
void
startTurn
(
std
::
unordered_map
<
int
,
Unit
>
lvUnits
,
std
::
unordered_map
<
int
,
Building
>
lvBuildings
);
std
::
unordered_map
<
int
,
Unit
>
&
lvUnits
,
std
::
unordered_map
<
int
,
Building
>
&
lvBuildings
);
/**
* Sets all units of the players faction to unavailable and sets them as no longer being the
...
...
@@ -44,7 +44,7 @@ class Player
*
* @param lvUnits All current units of a level
*/
void
endTurn
(
std
::
unordered_map
<
int
,
Unit
>
lvUnits
);
void
endTurn
(
std
::
unordered_map
<
int
,
Unit
>
&
lvUnits
);
};
}
// namespace advanced_wars
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment