So today first up I decided I'd start working on turn system. Given that GameMode is only on the server, I concluded that the decision of which player gets first turn should be my first job. With that in mind I spent about 3 hours compiler bashing and googling trying to figure out how to a) get a list of players in game mode and b) print that data meaningfully. About two hours in after I finally managed to get this little snippet done.
auto players = this->GetGameState<AcppGameState>()->PlayerArray;
auto playercount = players.Num();
UE_LOG(LogTemp, Warning, TEXT("Player array contains %c players."), playercount);
Unfortunately the output from that in UE4 was less than useful.
I also battled pretty hard because I was getting an error about PlayerController being unable to spawn even though I hadn't made a change to PlayerController.
Turns out that one was caused by me failing to include cppPlayerController.h in cppGameMode.h. It wasn't an issue until I tried to do something involving playercontrollers I think. It's frustrating how meaningless the error messages can be. I was getting one about having to derefernce the players.Num reference using &, when in fact I'd forgotten I had to use players.Num(). You would think the compiler would be a bit more helpful in that case.
Once I had that fixed and realised how unhelpful my efforts on printing a count on the playercontroller array was, I decided to move in a different direction and see if I could print Names obtained from the player controllers instead. After much more googling, compiler bashing and swearing I finally got this code snippet.
When the game runs now it outputs
LogTemp: Warning: Game state has now been loaded
LogTemp: Warning: Player controller is now loaded
LogTemp: Warning: The game has started
LogTemp: Warning: Player found with name -2034984760.
So now I know I can get a list of players, I'll justchoose a player randomly and figure out how to pass that information along to the gamestate module (I could probably put it in playerstate, but at this point I don't think it matters) so that each client is aware of who is currently has control on the board. Since game state is being loaded before BeginPlay is called I'll have to put a variable in GameState that contains the player in control.
Ended up having a lot of trouble generating a random number and plugging it into the array (since there was only player in the array it was pretty much an exercise in futility anyway) so after about an hour of playing around I gave up on that and decided just to force the first player in the array as going first for now and I'll randomise it later. Added a string into GameState to contain the name of the player to make first move and BeginPlay now stores the chosen player there.
At this point I'm getting mentally exhausted. Turns out my c++ skills are actually nowhere near where they need to be. Maybe I should have done this in blueprints. Maybe I'll improve over the next few days. I need to take a break at this point for sure. Might swing back later and take a crack and doing a FinishTurn function in GameMode or a card basetype. I'll put another post up tomorrow detailing how I went.
--Pillboxing
Speaking of games ... you should have received your first HIVE rewards. You need to go to your wallet and press the claim rewards button.
Some of your rewards will be in the form of HBD. You probably want to exchange the HBD for HIVE. you do this by going to the internal market (click the link under the value of your HBD.)
The Internal Market Page shows a canyon shaped graph with orders to buy HIVE with HBD on the left and orders to buy HBD with HIVE on the right. You will want to fill out the form on the left with the HBD you have to sell (just click the link under the word "available") and place the order. Once you have traded your HBD for HIVE you can power up.
If you power up your HIVE you should have about 15 HP in your account. So, I will remove the delegation I gave to your account.
Game on.