My Question Thread!

Flare

Stops copies me!
Reaction score
662
JASS:
function AdjustPlayerStateSimpleBJ takes player whichPlayer, playerstate whichPlayerState, integer delta returns nothing
    call SetPlayerState(whichPlayer, whichPlayerState, GetPlayerState(whichPlayer, whichPlayerState) + delta)
endfunction

function AdjustPlayerStateBJ takes integer delta, player whichPlayer, playerstate whichPlayerState returns nothing
    // If the change was positive, apply the difference to the player's
    // gathered resources property as well.
    if (delta > 0) then
        if (whichPlayerState == PLAYER_STATE_RESOURCE_GOLD) then
            call AdjustPlayerStateSimpleBJ(whichPlayer, PLAYER_STATE_GOLD_GATHERED, delta)
        elseif (whichPlayerState == PLAYER_STATE_RESOURCE_LUMBER) then
            call AdjustPlayerStateSimpleBJ(whichPlayer, PLAYER_STATE_LUMBER_GATHERED, delta)
        endif
    endif

    call AdjustPlayerStateSimpleBJ(whichPlayer, whichPlayerState, delta)
endfunction


BJ's have their uses ^_^ Not really sure what it does in relation to other player states like PLAYER_STATE_OBSERVER and that :(
Kinda weird that the If-Then-Else with PLAYER_STATE_GOLD/LUMBER is even there, couldn't they have just called AdjustPlayerStateSimpleBJ and be done with it?

Whats the IntegerTertiaryOp thing all about?
Seems to be the equivalent of IMax/MinBJ, all rolled into a single function, using the boolean to determine whether you're looking for max or min :p
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
Kinda weird that the If-Then-Else with PLAYER_STATE_GOLD/LUMBER is even there, couldn't they have just called AdjustPlayerStateSimpleBJ and be done with it?
Then it wouldn't update the total gathered amount, which is kinda the point of that function.

Seems to be the equivalent of IMax/MinBJ, all rolled into a single function, using the boolean to determine whether you're looking for max or min :p
No, it has nothing to do with min or max values of two integers. It lets you shrink code like this:
JASS:
if myboolean then
    call MyFunction(2)
else
    call MyFunction(3)
endif

to this:
JASS:
call MyFunction(IntegerTertiaryOp(myboolean, 2, 3))

Useful if it wasn't for the slowness of jass that made most jassers more inclined to create pages of (slightly faster) code instead of a few lines of compact code.
 

AdamGriffith

You can change this now in User CP.
Reaction score
69
But if I wanted to remove that TertiaryBj thing what number what I have to put into the original native? 1 or 0?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top