Ok .. so working on a game "dragonchess" .. which cloned the old "chess" program, so it's chock full of some old/legacy "ajaxcall"s ... and I'm now getting warnings to replace it with bgaPerformAction ..
Ok .. not a problem .. except the documentation seems to imply the parameter for these guys are not a straight forward translation
First off, from the docs I see this:
Ok .. so my current ajaxcall looks like this:
This is when a user clicks on a piece .. it triggers the logic to check if it's your piece . if your moving/capturing .. etc, etc.
Ok .. and trying to build the new bgaPerformAction .. I'm struggling a bit .. hoping for some help.
So I see these parameters for the ajaxcall (and how I suspect they are mapping ):
url (=> action: string) = "selectCell.html" it seems from the examples, I no longer need the full path to it? is this correct?
parameters (=> args?: object) = "{ cell_x: cell_x, cell_y: cell_y, cell_z: cell_z, selected_piece: this.gamedatas.piece_selected, lock: true }"
this one appears to be same setup from what I can tell ... passing in the parameters into the code that it needs ...
obj_callback (=> ?? ) = this
does this map to any of the parameters for the bgaPerformAction ??
callback (=> ?? ) =function( result ) {}
again, how does this map to the new function?
callback_anycase? (??) Seems this code doesn't use this parameter for ajax call?
ajax_method?: string (??) again, not used ??
the following parameters for the new bgaPerformAction:
action: string (from url) = "selectCell.html"
args?: object (from parameters) = "{ cell_x: cell_x, cell_y: cell_y, cell_z: cell_z, selected_piece: this.gamedatas.piece_selected }"
options: object (??) = "{ lock: true }" ??
is this correct, we move the "lock:true" to this section away from the previous argument ??
:Promise<void> ?? not sure what I'm supposed to use here? is this something do to with that "function ( result )" part in my ajaxcall?
So trying my best .. I end up with this "guess" ??
?? is this along the right lines?
Ok .. not a problem .. except the documentation seems to imply the parameter for these guys are not a straight forward translation
First off, from the docs I see this:
Code: Select all
this.ajaxcall(url, parameters, obj_callback, callback, callback_anycase?, ajax_method?: string)
this.bgaPerformAction(action: string, args?: object, options: object = { lock: true, checkAction: true }): Promise<void>
Code: Select all
this.ajaxcall( "/dragonchess/dragonchess/selectCell.html", { cell_x: cell_x, cell_y: cell_y, cell_z: cell_z, selected_piece: this.gamedatas.piece_selected, lock: true }, this, function( result ) {} );Ok .. and trying to build the new bgaPerformAction .. I'm struggling a bit .. hoping for some help.
So I see these parameters for the ajaxcall (and how I suspect they are mapping ):
url (=> action: string) = "selectCell.html" it seems from the examples, I no longer need the full path to it? is this correct?
parameters (=> args?: object) = "{ cell_x: cell_x, cell_y: cell_y, cell_z: cell_z, selected_piece: this.gamedatas.piece_selected, lock: true }"
this one appears to be same setup from what I can tell ... passing in the parameters into the code that it needs ...
obj_callback (=> ?? ) = this
does this map to any of the parameters for the bgaPerformAction ??
callback (=> ?? ) =function( result ) {}
again, how does this map to the new function?
callback_anycase? (??) Seems this code doesn't use this parameter for ajax call?
ajax_method?: string (??) again, not used ??
the following parameters for the new bgaPerformAction:
action: string (from url) = "selectCell.html"
args?: object (from parameters) = "{ cell_x: cell_x, cell_y: cell_y, cell_z: cell_z, selected_piece: this.gamedatas.piece_selected }"
options: object (??) = "{ lock: true }" ??
is this correct, we move the "lock:true" to this section away from the previous argument ??
:Promise<void> ?? not sure what I'm supposed to use here? is this something do to with that "function ( result )" part in my ajaxcall?
So trying my best .. I end up with this "guess" ??
Code: Select all
this.bgaPerformAction( "selectCell.html", { cell_x: cell_x, cell_y: cell_y, cell_z: cell_z, selected_piece: this.gamedatas.piece_selected }, { lock: true }).then(()=>{ this.function( result ) });