[Orxonox-commit 7559] r12162 - code/branches/wagnis_HS18/src/modules/wagnis
samuelbl at orxonox.net
samuelbl at orxonox.net
Wed Dec 5 21:08:38 CET 2018
Author: samuelbl
Date: 2018-12-05 21:08:38 +0100 (Wed, 05 Dec 2018)
New Revision: 12162
Modified:
code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.cc
code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc
Log:
Attack move fixed
Modified: code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.cc
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.cc 2018-12-05 19:08:42 UTC (rev 12161)
+++ code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.cc 2018-12-05 20:08:38 UTC (rev 12162)
@@ -15,7 +15,7 @@
this->gameBoard = nullptr;
this->gameStage = NOT_READY;
this->active_player = 1;
- this->initial_reinforcements_left = 5;
+ this->initial_reinforcements_left = 2; //changed here
this->empty_provinces_left = 0;
int n = 3;
Modified: code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc 2018-12-05 19:08:42 UTC (rev 12161)
+++ code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc 2018-12-05 20:08:38 UTC (rev 12162)
@@ -94,7 +94,6 @@
if (checkMove(ATTACK))
{
- orxout()<<"Attack move check returned valid"<<endl;
while ((this->origin_province->getTroops() > 1) && (this->target_province->getTroops() > 0)) //still troops available
{
while ((this->origin_province->getTroops() >= 4) && (this->target_province->getTroops() >= 2))
@@ -105,6 +104,7 @@
int att3 = dice();
int def1 = dice();
int def2 = dice();
+
int attBest = best3(att1, att2, att3);
int attSecond = second3(att1, att2, att3);
int defBest = best2(def1, def2);
@@ -127,6 +127,7 @@
int att2 = dice();
int def1 = dice();
int def2 = dice();
+
int attBest = best2(att1, att2);
int attSecond = second2(att1, att2);
int defBest = best2(def1, def2);
@@ -148,6 +149,7 @@
int attBest = dice();
int def1 = dice();
int def2 = dice();
+
int defBest = best2(def1, def2);
if(defBest >= attBest)
@@ -163,6 +165,7 @@
int att2 = dice();
int att3 = dice();
int defBest = dice();
+
int attBest = best3(att1, att2, att3);
if(defBest >= attBest)
@@ -177,6 +180,7 @@
int att1 = dice();
int att2 = dice();
int defBest = dice();
+
int attBest = best2(att1, att2);
if(defBest >= attBest)
@@ -204,8 +208,6 @@
this->target_province->setTroops(this->origin_province->getTroops() - 1);
this->origin_province->setTroops(1);
}
- }else{
- orxout()<<"Attack move check returned false"<<endl;
}
break;
@@ -214,7 +216,7 @@
if (checkMove(MOVE))
{
- this->target_province->setTroops(this->origin_province->getTroops()-1);
+ this->target_province->setTroops(this->target_province->getTroops() + this->origin_province->getTroops()-1);
this->origin_province->setTroops(1);
master->playerFinishedStageCallback(this);
}
@@ -305,8 +307,7 @@
int WagnisPlayer::dice() //returns random integer in range [1, 2, 3, 4, 5, 6]
{
- srand(time(NULL));
- return (rand()%6+1);
+ return (rand()%6+1);
}
int WagnisPlayer::best3(int a, int b, int c) //returns best of 3 integers for attack stage
More information about the Orxonox-commit
mailing list