See the full Java Board and Perang Classes by clicking the buttons below.Java Board Class Java Perang Class Java User Interface Class
In Unreal Engine, the Board Blueprint handles the game logic similar to how the Board, Perang, and User Interface Java classes handles the game logic. The Board Java class has methods for setting cards in the slot, the coin flip to determine who starts the game, printing the board to the screen, and modifying attack and defense values in the case of a tie.
The Perang Java class handles the initial setup, changing the player turns, and checking for game over events.
The User Interface Java class handles state machines and the entire battle phase including user print outs and determining valid input.
Event Begin Play
When the battle begins, these are the events that start up the board which ends with the 'Start Winner State Machine' event, which takes over during play.
Enabling and Disabling the mouse can be done with three nodes: Show Mouse Cursor, Enable Click Events, and Enable Mouse Over Events. I find it more convenient to create custom events for things like this with logical names.
Set Battle Cam Locations
I attached a camera, Battle Cam, to the blueprint to control the initial and end views. This function sets start and end variables for the Battle Cam then sets the current view. The end variables will get used at the end of battles.
Create Player Slots
This is a simple function that spawns the Player's Card Slots and uses the Spawn Player Card in Slot event from the Card Slot blueprint. The Create AI Slots does the exact same thing but uses the AI deck to spawn its cards.
Set All Cards Face Down and Card Slots to Not Empty
These two events are straight forward. Sets all the Cards face down and all the Card Slots to Not Empty.
The last part of the Event Begin Play initiates a State Machine. I'll go over those in the State Machine section.