Hi,
So our game has two modes , a player vs player and a player vs bot.
Both are server authoritative, even for the bot that must handle by the server.
At the moment, I wrote all the logic with custom rpc functions but it’s not working as intended.
The problem is that the values of the variables I’m using are not entirely changing, it can be changed in a function but as soon as another function needs access to that variable or the client needs access to it in order to decide what to do next, they only get the default value of that variable.
By digging here, I’ve read that we need to use match state in order to modify variables.
So I tried this in order to have variables that can be modified :
interface State
{
testBoolean:boolean
// Match label
label: MatchLabel
// Ticks where no actions have occurred.
emptyTicks: number
// Currently connected users, or reserved spaces.
presences: {[userId: string]: nkruntime.Presence}
// Number of users currently in the process of connecting to the match.
joinsInProgress: number
// True if there's a game currently in progress.
playing: boolean
// Current state of the board.
board: Board
// Mark assignments to player user IDs.
marks: {[userId: string]: Mark | null}
// Whose turn it currently is.
mark: Mark
// Ticks until they must submit their move.
deadlineRemainingTicks: number
// The winner of the current game.
winner: Mark | null
// The winner positions.
winnerPositions: BoardPosition[] | null
// Ticks until the next game starts, if applicable.
nextGameRemainingTicks: number
}
var state:State;
But the compiler is giving me an error message :
error TS2741: Property ‘testBoolean’ is missing in type ‘{ label: MatchLabel; emptyTicks: number; presences: {}; joinsInProgress: number; playing: false; board: never; marks: {}; mark: Mark.UNDEFINED; deadlineRemainingTicks: number; winner: null; winnerPositions: null; nextGameRemainingTicks: number; }’ but required in type ‘State’.
If I remove my testBoolean variable, compile works.
But how exactly am I suppose to create variables that client can ask the server to change ?