[Orxonox-commit 7494] r12100 - code/branches/wagnis_HS18/src/modules/wagnis
samuelbl at orxonox.net
samuelbl at orxonox.net
Wed Nov 14 09:29:00 CET 2018
Author: samuelbl
Date: 2018-11-14 09:29:00 +0100 (Wed, 14 Nov 2018)
New Revision: 12100
Modified:
code/branches/wagnis_HS18/src/modules/wagnis/CMakeLists.txt
code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc
code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.h
Log:
Wagnis Player updated
Modified: code/branches/wagnis_HS18/src/modules/wagnis/CMakeLists.txt
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/CMakeLists.txt 2018-11-14 08:17:56 UTC (rev 12099)
+++ code/branches/wagnis_HS18/src/modules/wagnis/CMakeLists.txt 2018-11-14 08:29:00 UTC (rev 12100)
@@ -1,7 +1,6 @@
SET_SOURCE_FILES(WAGNIS_SRC_FILES
WagnisProvince.cc
WagnisGameboard.cc
- WagnisPlayer.cc
)
ORXONOX_ADD_LIBRARY(wagnis
Modified: code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc 2018-11-14 08:17:56 UTC (rev 12099)
+++ code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc 2018-11-14 08:29:00 UTC (rev 12100)
@@ -24,21 +24,71 @@
}
//Manages a Players turn
- void WagnisPlayer::playerTurn(WagnisGameboard* gameBoard){
+ void WagnisPlayer::playerTurn(){
}
- //checks if a move is valid
- bool WagnisPlayer::checkMove(WagnisGameboard*,WagnisProvince*,WagnisProvince*){
+ //checks if a move is valid, possible MoveTypes: ATTACK, MOVE, SET_TROOPS, SET_TROOPS_INITIAL
+ bool WagnisPlayer::checkMove(WagnisProvince*,WagnisProvince*,MoveType)
+ {
+ if (MoveType == ATTACK)
+ {
+ if (isNeighbour(this->origin, this->target))//TODO: provinces neighbours
+ {
+ if (this->origin->getOwner_ID() == this->Player_ID) //origin belongs to player
+ {
+ if (this->target->getOwner_ID() != this->Player_ID)//target belongs to enemy
+ return true;
+ }
+ }
+ }
+
+ if (MoveType == MOVE)
+ {
+ if (existPath(this->origin, this->target))//TODO: path exists, all belong to same player
+ {
+ if (this->origin->getOwner_ID() == this->Player_ID)//origin belongs to player
+ return true;
+ }
+
+ }
+
+ if (MoveType == SET_Troops)
+ {
+ if (this->target->getOwner_ID() == this->Player_ID)//target belongs to player
+ return true;
+ }
+
+ if (MoveType == SET_TROOPS_INITIAL)
+ {
+ if (this->target->getOwner_ID() == 0)//target belongs to nobody
+ return true;
+ }
+
return false;
}
+
+ //TODO
+ bool WagnisPlayer::isNeighbour(WagnisProvince*,WagnisProvince*)
+ {
+ for ()
+
+ return false;
+ }
+
+ //TODO
+ bool WagnisPlayer::existPath(WagnisProvince*,WagnisProvince*)
+ {
+ return false;
+ }
+
//
- void WagnisPlayer::setTroops(WagnisGameboard* gameBoard,WagnisProvince* prov,MoveType type){
+ void WagnisPlayer::setTroops(WagnisProvince*){
}
- void WagnisPlayer::attack(WagnisGameboard* gameBoard,WagnisProvince* own,WagnisProvince* target){
+ void WagnisPlayer::attack(WagnisProvince*,WagnisProvince*){
}
- void WagnisPlayer::moveTroops(WagnisGameboard* gameBoard,WagnisProvince* current,WagnisProvince* target){
+ void WagnisPlayer::moveTroops(WagnisProvince*,WagnisProvince*){
}
//Return a "Player x" String
Modified: code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.h
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.h 2018-11-14 08:17:56 UTC (rev 12099)
+++ code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.h 2018-11-14 08:29:00 UTC (rev 12100)
@@ -14,7 +14,7 @@
#include <vector>
#include <string>
-enum MoveType { ATTACK, MOVE, SET_TROOPS };
+enum MoveType { ATTACK, MOVE, SET_TROOPS, SET_TROOPS_INITIAL };
@@ -26,7 +26,7 @@
WagnisPlayer(Context*,WagnisGameboard*);
virtual ~WagnisPlayer();
- void playerTurn(WagnisGameboard*);
+ void playerTurn();
bool checkMove(WagnisProvince*,WagnisProvince*,MoveType);
void setTroops(WagnisProvince*);
void attack(WagnisProvince*,WagnisProvince*);
@@ -38,6 +38,8 @@
WagnisGameboard* gameBoard;
WagnisProvince* origin;
WagnisProvince* target;
+ bool isNeighbour(WagnisProvince*,WagnisProvince*);
+ bool existPath(WagnisProvince*,WagnisProvince*)
};
}
More information about the Orxonox-commit
mailing list