System jBoard - Advanced Multiboard System

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
jBoard
Combines the power of jQuery (webdesign) into vJASS multiboards.
The manual is quite clear, give it a look:

JASS:
//==============================================================================
//  jBoard -- ADVANCED MULTIBOARD SYSTEM BY MAGENTIX -- v1.2
//==============================================================================

//==============================================================================
//  Quick manual:
//==============================================================================
//
//    Implement by adding "requires jBoardLib" behind your library/scope names
//
//    ----------------------------------------------------------------------
//      What is jBoard?
//    ----------------------------------------------------------------------
//
//      jBoard is an enhanced multiboard management system, inspired by the
//      jQuery library that is available to webdesigners. That javascript library
//      allows for a cool functionality called "chaining".
//
//      Because WC3 multiboards often require a huge amount of function calls,
//      I came up with jBoard to allow you to make your multiboard code shorter,
//      smoother and overall more easy to use.
//
//
//    ----------------------------------------------------------------------
//      What is chaining and how to use it?
//    ----------------------------------------------------------------------
//
//      An example says a thousand words, assume this is your 10x5 multiboard setup
//      and you want to set all fields to "0" and the first field to "1":
//
//      -  local multiboard MB = CreateMultiboard()
//         local multiboarditem MBI
//         call MultiboardSetTitleText(MB,"My Multiboard")
//         call MultiboardDisplay(MB,true)
//         call MultiboardSetRowCount(MB,10)
//         call MultiboardSetColumnCount(MB,5)
//         call MultiboardSetItemsValue(MB,"0")
//         call MultiboardSetItemsStyle(MB,true,false)
//         set MBI = MultiboardGetItem(MB,0,0)
//         call MultiboardSetItemValue(MBI,"1")
//
//      Now take a look at jBoard:
//      -  //! runtextmacro jBoardCreate("MyBoard","10","5")
//         local MyBoard MB = MyBoard.create("My Multiboard").field(0,0).setValue("1")
//      That's all you need to type!
//
//      Remember: the textmacro also only has to be called ONCE to create a
//      multiboard with the wanted dimensions. So actually that line wouldn't be
//      there, but at the top of your script.
//
//      Did you also notice how every method call returned an object that you
//      could then call another method on? That is the beauty of chaining.
//
//   !! EVERY FUNCTION CALL RETURNS A jBoard OBJECT UNLESS STATED OTHERWISE !!
//
//
//    ----------------------------------------------------------------------
//      I noticed a textmacro there, what gives?
//    ----------------------------------------------------------------------
//      
//      Since you need to create structs that represent your multiboard, jBoard
//      needs to know the dimensions of your multiboard to ensure the structs
//      don't take up more space than they need to.
//
//      For every multiboard variation you plan to use, simply call this once at
//      the top of your script:
//      //! runtextmacro jBoardCreate("StructName","RowAmount","ColAmount")
//
//      Example for an 8 row, 4 col board:
//      //! runtextmacro jBoardCreate("My8x4Board","8","4")
//      Which you can then instanciate in your script as
//      My8x4Board.create("BoardTitle")
//
//
//    ----------------------------------------------------------------------
//      Defaults
//    ----------------------------------------------------------------------
//      
//      Somtimes we don't want our board cells to be empty by default, but show
//      0 for example. This is easy to achieve by setting a default. Take a look
//      at the jBoard struct further down this info block and edit the defaults
//      you like to see changed. Every jBoard that gets created after a change
//      will take those defaults into account.
//
//      Note that you can hardcode defaults below and still change them on the fly!
//      set jBoard.defaultItemValue = "1" -- Valid syntax!
//
//      Edit your defaults here:
//! textmacro jBoardDefaults
        static string  defaultItemValue = ""
        static string  defaultIconPath  = "UI\\Widgets\\EscMenu\\Human\\observer-icon.blp"
        static boolean defaultShowValue = true
        static boolean defaultShowIcon  = false
        static boolean defaultShowBoard = true
        static real    defaultItemWidth = 0.03
//! endtextmacro
//
//==============================================================================

//==============================================================================
//  Tip: Commenting out newlines
//==============================================================================
//
//  Sometimes when chaining methods, a command can get quite lengthy. jQuery
//  doesn't suffer from this visually, because javascript allows people to write
//  code over multiple lines until they end it with a semicolon (<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink    ;)" loading="lazy" data-shortname=";)" />
//
//  JASS, however, doesn&#039;t allow that directly. Fortunately you can call jBoard
//  commands just as easily on multiple lines. Remember: Until you call .reset(),
//  your selection will be saved to the next line!
//
//  Example:
//  local MyBoard MB = MyBoard.create(&quot;funkyboard&quot;).setplayerrow(0,2).setcolour(&quot;ff0000&quot;).reset().setplayerrow(1,3).setcolour(&quot;0000ff&quot;).reset().etc...
//
//  Could become:
//      local MyBoard MB = MyBoard.create(&quot;funkyboard&quot;)
//      call MB.setplayerrow(0,2).setcolour(&quot;ff0000&quot;).reset()
//      call MB.setplayerrow(1,3)
//      call MB.setcolour(&quot;0000ff&quot;).reset() &lt;-- Previous row selection was saved to this line
//
//  In the end it all boils down to which type of coding you prefer, of course.
//
//==============================================================================

//==============================================================================
//  Tip: -R Functions
//==============================================================================
//
//  When chaining several commands onto a set of fields, one could easily say:
//  &quot;There, now let me reset my selection and continue chaining methods&quot;
//
//  However, when chaining that way, a string of jBoard commands could easily
//  contain the call .reset() a dozen times.
//
//  To save coding space and safeguard readability, I introduced the -R functions:
//  Basically, any non-selector function that returns a jBoard object can be called
//  with a capital &quot;R&quot; behind the name and the jBoard system will automatically
//  call a .reset() for you.
//
//  The above example of commenting out newlines would then become:
//  local MyBoard MB = MyBoard.create(&quot;funkyboard&quot;).setPlayerRow(0,2).setColourR(&quot;ff0000&quot;).setPlayerRow(1,3).setColourR(&quot;0000ff&quot;).etc...
//
//  As you can see, this makes the chaining process yet again a little smoother
//  Once again: this functionality does not work on selectors/&quot;getters&quot;!
//
//==============================================================================

//==============================================================================
//  Function index:
//==============================================================================
//
//    ----------------------------------------------------------------------
//      Standard Functions - Creating, showing, etc...
//    ----------------------------------------------------------------------
//
//      Main functionality you&#039;d expect from any multiboard. May be used within
//      a local player block. Can be used on any jBoard object (boad, row, col,
//      field(s)) and returns the selection you called the function on.
//
//    .create(&quot;MultiboardName&quot;)
//    .show()
//    .hide()
//    .clear() -- SHOULD NEVER BE CALLED, just here for completion
//    .fold()
//    .unfold()
//    .setName()
//    .getName() -- Returns the multiboard name as a string, not a jBoard object
//    .setNameColour(&quot;rgb value&quot;)
//      Colour syntax: rrggbb (in hexadecimal)
//    .getNameColour()
//    .destroy()
//
//
//    ----------------------------------------------------------------------
//      Selection Functions - Adds rows, cols or fields to the selection
//    ----------------------------------------------------------------------
//
//      Selectors can be used on any jBoard object (boad, row, col, field(s))
//      They always return the collection of all the objects you selected from
//      the last .reset() up to that point.
//
//    VERY IMPORTANT!
//    .reset()
//      Resets the current selection to the board
//
//    MAIN SELECTORS
//    .row(integer start, integer end)
//    .col(integer start, integer end)
//      Selects a row, a columns or multiple of any
//      -  .row(0,0) returns the row object of row 0
//      -  .row(0,1) returns the combined fields of row 0 and row 1
//      -  ONLY WHEN HAVING -ONE- ROW/COL SELECTED will you be able
//         to use row/col only functionality
//         (it won&#039;t give errors or bugs if you try, though)
//
//    SINGLE SELECTOR
//    .field(integer row, integer col)
//      Adds one field to the selection or (if selection is empty)
//      returns one field to use field-level manipulations on
//    .getPlayerRowField(integer player, integer column)
//    .getPlayerColField(integer player, integer row)
//      The above two return just ONE field of a player&#039;s row.
//      Since the player selectors return an entire row and a deep
//      selector inside that row would clear the selection first,
//      it would otherwise be impossible to select multiple fields
//      from player rows or columns...
//      You should use this over .getPlayerRow(0).getField(3) unless
//      you want only that field of course.
//
//    DEEP SELECTOR
//    .getField(integer which)
//      Returns just ONE field, selected from your previous selection
//      
//      Quick list of what it does when used on a:
//      -  Board:  Returns the field in position X of the board,
//                 reading from top left to bottom right
//      -  Row:    Returns the field in column X of that row
//      -  Column: Returns the field in row X of that column
//      -  Fields: Returns the field in position X of the selection,
//                 reading from top left to bottom right
//      -  Field:  Does nothing (returns same field)
//
//
//    ----------------------------------------------------------------------
//      Player Selectors
//    ----------------------------------------------------------------------
//
//      Simple functions that allow you to save a row/col to a player.
//
//      Both the setters and the getters add the row/col you just set
//      to the current selection. Hence, this is both valid syntax:
//      -  MB.setPlayerRow(0,1).setcolour(&quot;ff0000&quot;)
//      -  MB.setPlayerRow(0,1)
//         MB.getPlayerRow(0,1).setcolour(&quot;ff0000&quot;)
// 
//      The player &quot;setters&quot; have -R functionality, but the &quot;getters&quot; don&#039;t!
//      
//    .setPlayerRow(integer player, integer row)
//    .setPlayerCol(integer player, integer col)
//    .getPlayerRow(integer player)
//    .getPlayerCol(integer player)
//
//
//    ----------------------------------------------------------------------
//      Manipulation Functions - Also referred to as &quot;setters&quot;
//    ----------------------------------------------------------------------
//
//      Setters can be used on any jBoard object (boad, row, col, field(s))
//      They always return the object that was just manipulated
//
//      ABOUT PREFIXES AND SUFFIXES:
//      Imagine you want a row with user experience values, by setting a suffix
//      &quot;XP&quot;, you could still use .add(value) to a field, because the content
//      can still be handled by S2I(). Example:
//      -  .field(1,2) has content &quot;2&quot; and suffix &quot; xp&quot;, the field shows &quot;2 xp&quot;
//         A user calls .field(1,2).add(4), the field now show &quot;6 xp&quot;, without
//         having to worry about the &quot; xp&quot; bit!
//
//    VALUE SETTERS
//    .setValue(&quot;value&quot;)
//    .setColour(&quot;rgb value&quot;)
//      Colour syntax: rrggbb (in hexadecimal)
//    .setPrefix(&quot;value&quot;)
//    .setSuffix(&quot;value&quot;)
//    .setIconPath(&quot;path&quot;)
//    .setWidth(real width)
//
//    VALUE MANIPULATORS
//    .add(integer value)
//      Only works if field contents are numerical strings, value can be negative
//
//
//    ----------------------------------------------------------------------
//      Retrieval Functions - Also referred to as &quot;getters&quot;
//    ----------------------------------------------------------------------
//
//      Getters can be used on any jBoard object (boad, row, col, field(s))
//                      !! EVERY GETTER RETURNS A STRING !!
//
//      HERE&#039;S WHY:
//      When using a getter on anything but a single field, a string is returned
//      with all values in it, separated by a pipe (|).
//      Future versions may support smart retrieval of a row&#039;s/col&#039;s properties
//      should they all have the same colour for example...
//
//      Naturally, the fact that these methods return a string instead of a
//      jBoard object means that calling any of these methods is in fact
//      &quot;The end of the line&quot; for that chaining process...
//
//    .getValue()
//    .getColour()
//    .getPrefix()
//    .getSuffix()
//    .getIconPath() -- CAREFUL USE on many fields! (might blow up in your face)
//    .getWidth()
//
//
//    ----------------------------------------------------------------------
//      Extra Functions - Various
//    ----------------------------------------------------------------------
//
//    .showIcon()
//    .hideIcon()
//    .showValue()
//    .hideValue()
//
//==============================================================================

//==============================================================================
//  Credits:
//==============================================================================
//
//  John Resig for coming up with jQuery and its chaining
//  Vexorian for vJass and JassHelper, making jBoard possible
//
//==============================================================================

//==============================================================================
//  Open letter to Vexorian:
//==============================================================================
//
//  Take a look at the setter/getter methods and the -R functions. If that isn&#039;t
//  a reason why textmacroes should be allowed to be nested, I don&#039;t know what
//  is :x (They&#039;re all the same bar the function name...)
//
//  Protip: Yes, this is a request to you to get nested textmacroes working <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":)" title="Smile    :)" loading="lazy" data-shortname=":)" />
//
//==============================================================================

//==============================================================================
//  Macro function core -- No touchy from here on out!
//==============================================================================

//! textmacro jBoardCreate takes NAME, ROWS, COLS
    globals
        private constant integer $NAME$SIZE = $ROWS$*$COLS$
        private constant integer $NAME$ROWS = $ROWS$
        private constant integer $NAME$COLS = $COLS$
    endglobals
    
    private struct $NAME$FIELD
        $NAME$ parent
        integer realRow
        integer realCol
        multiboarditem mbi
        
        real   width    = jBoard.defaultItemWidth
        string iconpath = jBoard.defaultIconPath
        string colour   = &quot;ffffff&quot;
        string prefix   = &quot;&quot;
        string content  = jBoard.defaultItemValue
        string suffix   = &quot;&quot;
        
        boolean showV   = jBoard.defaultShowValue
        boolean showI   = jBoard.defaultShowIcon
        
        static method create takes $NAME$ parent, integer row, integer col returns thistype
            local thistype f = thistype.allocate()
            set f.parent = parent
            set f.realRow = row
            set f.realCol = col
            set f.mbi = MultiboardGetItem(f.parent.MB,f.realRow,f.realCol)
            
            return f
        endmethod
        
        method onDestroy takes nothing returns nothing
            call MultiboardReleaseItem(.mbi)
        endmethod
        
        private method updateField takes nothing returns nothing
            call MultiboardSetItemValue(.mbi,&quot;|cff&quot;+.colour+.prefix+.content+.suffix+&quot;|r&quot;)
        endmethod
        
        method add takes integer i returns nothing
            set .content = I2S(S2I(.content) + i)
            call .updateField()
        endmethod
        
        method setValue takes string s returns nothing
            set .content = s
            call .updateField()
        endmethod
        
        method setPrefix takes string s returns nothing
            set .prefix = s
            call .updateField()
        endmethod
        
        method setSuffix takes string s returns nothing
            set .suffix = s
            call .updateField()
        endmethod
        
        method setColour takes string rgb returns nothing
            set .colour = rgb
            call .updateField()
        endmethod
        
        method setWidth takes real w returns nothing
            set .width = w
            call MultiboardSetItemWidth(.mbi,w)
        endmethod
        
        method showIcon takes nothing returns nothing
            set .showI = true
            call MultiboardSetItemStyle(.mbi,.showV,.showI)
        endmethod
        
        method hideIcon takes nothing returns nothing
            set .showI = false
            call MultiboardSetItemStyle(.mbi,.showV,.showI)
        endmethod
        
        method showValue takes nothing returns nothing
            set .showV = true
            call MultiboardSetItemStyle(.mbi,.showV,.showI)
        endmethod
        
        method hideValue takes nothing returns nothing
            set .showV = false
            call MultiboardSetItemStyle(.mbi,.showV,.showI)
        endmethod
        
        method setIconPath takes string s returns nothing
            set .iconpath = s
        endmethod
        
        method getValue takes nothing returns string
            return .content
        endmethod
        
        method getPrefix takes nothing returns string
            return .prefix
        endmethod
        
        method getSuffix takes nothing returns string
            return .suffix
        endmethod
        
        method getColour takes nothing returns string
            return .colour
        endmethod
        
        method getWidth takes nothing returns string
            return R2S(.width)
        endmethod
        
        method getIconPath takes nothing returns string
            return .iconpath
        endmethod
    endstruct
    
    private interface $NAME$FIELDCOLLECTION
        $NAME$ parent
        method getField takes integer i returns $NAME$FIELD
    endinterface
    
    private struct $NAME$UTILITY extends $NAME$FIELDCOLLECTION        
        stub method getField takes integer i returns $NAME$FIELD
            return 0
        endmethod
    endstruct

    private struct $NAME$ROW extends $NAME$UTILITY
        $NAME$FIELD array fields[$COLS$]
        integer realPos
        integer fromPlayer = -1
        
        static method create takes $NAME$ parent, integer pos returns thistype
            local thistype row = thistype.allocate()
            local integer i = 0
            set row.parent = parent
            set row.realPos = pos
            
            loop
            exitwhen i == $NAME$COLS
                set row.fields<i> = $NAME$FIELD.create(parent,pos,i)
                set i = i + 1
            endloop
            
            return row
        endmethod
        
        method getField takes integer i returns $NAME$FIELD
            return .fields<i>
        endmethod
    endstruct
    
    private struct $NAME$COL extends $NAME$UTILITY
        $NAME$FIELD array fields[$ROWS$]
        integer realPos
        integer fromPlayer = -1
        
        static method create takes $NAME$ parent, integer pos returns thistype
            local thistype col = thistype.allocate()
            local integer i = 0
            set col.parent = parent
            set col.realPos = pos
            
            loop
            exitwhen i == $NAME$ROWS
                set col.fields<i> = col.parent.rows<i>.fields[pos]
                set i = i + 1
            endloop
            
            return col
        endmethod
        
        method getField takes integer i returns $NAME$FIELD
            return .fields<i>
        endmethod
    endstruct
    
    private struct $NAME$FLD extends $NAME$UTILITY
        $NAME$FIELD array fields[$NAME$SIZE]
        
        static method create takes $NAME$ parent returns thistype
            local thistype fld = thistype.allocate()
            set fld.parent = parent
            return fld
        endmethod
        
        private method hasField takes $NAME$FIELD f returns boolean
            local integer i = 0
            
            loop
            exitwhen i == .parent.selectionAmount
                if (.fields<i> == f) then
                    return true
                endif
                set i = i + 1
            endloop
            
            return false
        endmethod
        
        method addFields takes $NAME$FIELDCOLLECTION f, integer amount returns nothing
            local integer i = 0
            
            loop
            exitwhen i == amount
                if not(.hasField(f.getField(i))) then
                    set .fields[.parent.selectionAmount] = f.getField(i)
                    set .parent.selectionAmount = .parent.selectionAmount + 1
                endif
                
                set i = i + 1
            endloop
        endmethod
        
        method getField takes integer i returns $NAME$FIELD
            return .fields<i>
        endmethod
    endstruct
    
    struct $NAME$ extends jBoard    
        $NAME$ROW array rows[$ROWS$]
        $NAME$COL array cols[$COLS$]
        $NAME$FLD selection
        
        static method create takes string boardName returns thistype
            local thistype board = thistype.allocate(boardName)
            local integer i = 0
            
            call MultiboardSetRowCount(board.MB,$NAME$ROWS)
            call MultiboardSetColumnCount(board.MB,$NAME$COLS)
            
            set board.selection = $NAME$FLD.create(board)
            loop
            exitwhen i == $NAME$ROWS
                set board.rows<i> = $NAME$ROW.create(board,i)
                set i = i + 1
            endloop
            set i = 0
            loop
            exitwhen i == $NAME$COLS
                set board.cols<i> = $NAME$COL.create(board,i)
                set i = i + 1
            endloop
            
            call board.initBoard()
            return board
        endmethod
        
        private method transfer takes $NAME$FIELDCOLLECTION f, integer ftype, integer amount returns nothing
            set .selectionLevel = IntegerTertiaryOp(.selectionLevel == jBoard_SELECTION_LVL_BOARD,ftype,jBoard_SELECTION_LVL_FIELDS)
            call .selection.addFields(f,amount)
        endmethod
        
        method reset takes nothing returns thistype
            set .selectionLevel = jBoard_SELECTION_LVL_BOARD
            set .selectionAmount = 0
            return this
        endmethod
        
        method field takes integer row, integer col returns thistype
            set .selection.fields[0] = .rows[row].fields[col]
            set .selectionLevel = jBoard_SELECTION_LVL_FLD
            return this
        endmethod
        
        method getField takes integer which returns thistype
            if .selectionLevel == jBoard_SELECTION_LVL_ROW then
                set .selection.fields[0] = .rows[.selectionSpecial].fields[which]
            elseif .selectionLevel == jBoard_SELECTION_LVL_COL then
                set .selection.fields[0] = .cols[.selectionSpecial].fields[which]
            elseif .selectionLevel == jBoard_SELECTION_LVL_FIELDS then
                set .selection.fields[0] = .selection.fields[which]
            elseif .selectionLevel == jBoard_SELECTION_LVL_BOARD then
                set .selection.fields[0] = .rows[which/$NAME$COLS].fields[ModuloInteger(which,$NAME$COLS)]
            endif
            
            set .selectionLevel = jBoard_SELECTION_LVL_FLD
            return this
        endmethod
        
        method row takes integer start, integer end returns thistype
            local integer i = IntegerTertiaryOp(start&lt;end,start,end)
            local integer j = IntegerTertiaryOp(start&lt;end,end,start)
            
            if start == end then
                set .selectionSpecial = start
                call .transfer(.rows[start],jBoard_SELECTION_LVL_ROW,$NAME$COLS)
            else
                loop
                exitwhen i &gt; j
                    call .transfer(.rows<i>,jBoard_SELECTION_LVL_ROW,$NAME$COLS)
                    set i = i + 1
                endloop
            endif
            
            return this
        endmethod
        
        method col takes integer start, integer end returns thistype
            local integer i = IntegerTertiaryOp(start&lt;end,start,end)
            local integer j = IntegerTertiaryOp(start&lt;end,end,start)
            
            if start == end then
                set .selectionSpecial = start
                call .transfer(.cols[start],jBoard_SELECTION_LVL_COL,$NAME$ROWS)
            else
                loop
                exitwhen i &gt; j
                    call .transfer(.cols<i>,jBoard_SELECTION_LVL_COL,$NAME$ROWS)
                    set i = i + 1
                endloop
            endif
            
            return this
        endmethod
        
        method setPlayerRow takes integer p, integer row returns thistype
            set .playerRow[p] = row
            set .rows[row].fromPlayer = p
            return .row(row,row)
        endmethod
        
        method getPlayerRow takes integer p returns thistype
            return .row(.playerRow[p],.playerRow[p])
        endmethod
        
        method getPlayerRowField takes integer p, integer i returns thistype
            return .field(.playerRow[p],i)
        endmethod
        
        method setPlayerCol takes integer p, integer col returns thistype
            set .playerCol[p] = col
            set .cols[col].fromPlayer = p
            return .col(col,col)
        endmethod
        
        method getPlayerCol takes integer p returns thistype
            return .col(.playerCol[p],.playerCol[p])
        endmethod
        
        method getPlayerColField takes integer p, integer i returns thistype
            return .field(i,.playerCol[p])
        endmethod

        method setColour takes string rgb returns thistype
            local integer i = 0
                      
            if (.selectionLevel == jBoard_SELECTION_LVL_BOARD) then            
                loop
                exitwhen i == $NAME$ROWS
                    call .reset().row(i,i).setColour(rgb)
                    set i = i + 1
                endloop
                set .selectionLevel = jBoard_SELECTION_LVL_BOARD
            elseif (.selectionLevel == jBoard_SELECTION_LVL_FIELDS) then
                loop
                exitwhen i == .selectionAmount
                    call .selection.fields<i>.setColour(rgb)
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_ROW) then
                loop
                exitwhen i == $NAME$COLS
                    call .rows[.selectionSpecial].fields<i>.setColour(rgb)
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_COL) then
                loop
                exitwhen i == $NAME$ROWS
                    call .cols[.selectionSpecial].fields<i>.setColour(rgb)
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_FLD) then
                call .selection.fields[0].setColour(rgb)
            endif
            
            return this
        endmethod
        
        method setWidth takes real w returns thistype
            local integer i = 0
                      
            if (.selectionLevel == jBoard_SELECTION_LVL_BOARD) then            
                loop
                exitwhen i == $NAME$ROWS
                    call .reset().row(i,i).setWidth(w)
                    set i = i + 1
                endloop
                set .selectionLevel = jBoard_SELECTION_LVL_BOARD
            elseif (.selectionLevel == jBoard_SELECTION_LVL_FIELDS) then
                loop
                exitwhen i == .selectionAmount
                    call .selection.fields<i>.setWidth(w)
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_ROW) then
                loop
                exitwhen i == $NAME$COLS
                    call .rows[.selectionSpecial].fields<i>.setWidth(w)
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_COL) then
                loop
                exitwhen i == $NAME$ROWS
                    call .cols[.selectionSpecial].fields<i>.setWidth(w)
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_FLD) then
                call .selection.fields[0].setWidth(w)
            endif
            
            return this
        endmethod
        
        method setPrefix takes string val returns thistype
            local integer i = 0
                      
            if (.selectionLevel == jBoard_SELECTION_LVL_BOARD) then            
                loop
                exitwhen i == $NAME$ROWS
                    call .reset().row(i,i).setPrefix(val)
                    set i = i + 1
                endloop
                set .selectionLevel = jBoard_SELECTION_LVL_BOARD
            elseif (.selectionLevel == jBoard_SELECTION_LVL_FIELDS) then
                loop
                exitwhen i == .selectionAmount
                    call .selection.fields<i>.setPrefix(val)
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_ROW) then
                loop
                exitwhen i == $NAME$COLS
                    call .rows[.selectionSpecial].fields<i>.setPrefix(val)
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_COL) then
                loop
                exitwhen i == $NAME$ROWS
                    call .cols[.selectionSpecial].fields<i>.setPrefix(val)
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_FLD) then
                call .selection.fields[0].setPrefix(val)
            endif
            
            return this
        endmethod
        
        method setSuffix takes string val returns thistype
            local integer i = 0
                      
            if (.selectionLevel == jBoard_SELECTION_LVL_BOARD) then            
                loop
                exitwhen i == $NAME$ROWS
                    call .reset().row(i,i).setSuffix(val)
                    set i = i + 1
                endloop
                set .selectionLevel = jBoard_SELECTION_LVL_BOARD
            elseif (.selectionLevel == jBoard_SELECTION_LVL_FIELDS) then
                loop
                exitwhen i == .selectionAmount
                    call .selection.fields<i>.setSuffix(val)
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_ROW) then
                loop
                exitwhen i == $NAME$COLS
                    call .rows[.selectionSpecial].fields<i>.setSuffix(val)
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_COL) then
                loop
                exitwhen i == $NAME$ROWS
                    call .cols[.selectionSpecial].fields<i>.setSuffix(val)
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_FLD) then
                call .selection.fields[0].setSuffix(val)
            endif
            
            return this
        endmethod
        
        method setIconPath takes string val returns thistype
            local integer i = 0
                      
            if (.selectionLevel == jBoard_SELECTION_LVL_BOARD) then            
                loop
                exitwhen i == $NAME$ROWS
                    call .reset().row(i,i).setIconPath(val)
                    set i = i + 1
                endloop
                set .selectionLevel = jBoard_SELECTION_LVL_BOARD
            elseif (.selectionLevel == jBoard_SELECTION_LVL_FIELDS) then
                loop
                exitwhen i == .selectionAmount
                    call .selection.fields<i>.setIconPath(val)
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_ROW) then
                loop
                exitwhen i == $NAME$COLS
                    call .rows[.selectionSpecial].fields<i>.setIconPath(val)
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_COL) then
                loop
                exitwhen i == $NAME$ROWS
                    call .cols[.selectionSpecial].fields<i>.setIconPath(val)
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_FLD) then
                call .selection.fields[0].setIconPath(val)
            endif
            
            return this
        endmethod
        
        method showIcon takes nothing returns thistype
            local integer i = 0
                      
            if (.selectionLevel == jBoard_SELECTION_LVL_BOARD) then            
                loop
                exitwhen i == $NAME$ROWS
                    call .reset().row(i,i).showIcon()
                    set i = i + 1
                endloop
                set .selectionLevel = jBoard_SELECTION_LVL_BOARD
            elseif (.selectionLevel == jBoard_SELECTION_LVL_FIELDS) then
                loop
                exitwhen i == .selectionAmount
                    call .selection.fields<i>.showIcon()
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_ROW) then
                loop
                exitwhen i == $NAME$COLS
                    call .rows[.selectionSpecial].fields<i>.showIcon()
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_COL) then
                loop
                exitwhen i == $NAME$ROWS
                    call .cols[.selectionSpecial].fields<i>.showIcon()
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_FLD) then
                call .selection.fields[0].showIcon()
            endif
            
            return this
        endmethod
        
        method hideIcon takes nothing returns thistype
            local integer i = 0
                      
            if (.selectionLevel == jBoard_SELECTION_LVL_BOARD) then            
                loop
                exitwhen i == $NAME$ROWS
                    call .reset().row(i,i).hideIcon()
                    set i = i + 1
                endloop
                set .selectionLevel = jBoard_SELECTION_LVL_BOARD
            elseif (.selectionLevel == jBoard_SELECTION_LVL_FIELDS) then
                loop
                exitwhen i == .selectionAmount
                    call .selection.fields<i>.hideIcon()
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_ROW) then
                loop
                exitwhen i == $NAME$COLS
                    call .rows[.selectionSpecial].fields<i>.hideIcon()
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_COL) then
                loop
                exitwhen i == $NAME$ROWS
                    call .cols[.selectionSpecial].fields<i>.hideIcon()
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_FLD) then
                call .selection.fields[0].hideIcon()
            endif
            
            return this
        endmethod
        
        method showValue takes nothing returns thistype
            local integer i = 0
                      
            if (.selectionLevel == jBoard_SELECTION_LVL_BOARD) then            
                loop
                exitwhen i == $NAME$ROWS
                    call .reset().row(i,i).showValue()
                    set i = i + 1
                endloop
                set .selectionLevel = jBoard_SELECTION_LVL_BOARD
            elseif (.selectionLevel == jBoard_SELECTION_LVL_FIELDS) then
                loop
                exitwhen i == .selectionAmount
                    call .selection.fields<i>.showValue()
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_ROW) then
                loop
                exitwhen i == $NAME$COLS
                    call .rows[.selectionSpecial].fields<i>.showValue()
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_COL) then
                loop
                exitwhen i == $NAME$ROWS
                    call .cols[.selectionSpecial].fields<i>.showValue()
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_FLD) then
                call .selection.fields[0].showValue()
            endif
            
            return this
        endmethod
        
        method hideValue takes nothing returns thistype
            local integer i = 0
                      
            if (.selectionLevel == jBoard_SELECTION_LVL_BOARD) then            
                loop
                exitwhen i == $NAME$ROWS
                    call .reset().row(i,i).hideValue()
                    set i = i + 1
                endloop
                set .selectionLevel = jBoard_SELECTION_LVL_BOARD
            elseif (.selectionLevel == jBoard_SELECTION_LVL_FIELDS) then
                loop
                exitwhen i == .selectionAmount
                    call .selection.fields<i>.hideValue()
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_ROW) then
                loop
                exitwhen i == $NAME$COLS
                    call .rows[.selectionSpecial].fields<i>.hideValue()
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_COL) then
                loop
                exitwhen i == $NAME$ROWS
                    call .cols[.selectionSpecial].fields<i>.hideValue()
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_FLD) then
                call .selection.fields[0].hideValue()
            endif
            
            return this
        endmethod
        
        method setValue takes string val returns thistype
            local integer i = 0
                      
            if (.selectionLevel == jBoard_SELECTION_LVL_BOARD) then            
                loop
                exitwhen i == $NAME$ROWS
                    call .reset().row(i,i).setValue(val)
                    set i = i + 1
                endloop
                set .selectionLevel = jBoard_SELECTION_LVL_BOARD
            elseif (.selectionLevel == jBoard_SELECTION_LVL_FIELDS) then
                loop
                exitwhen i == .selectionAmount
                    call .selection.fields<i>.setValue(val)
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_ROW) then
                loop
                exitwhen i == $NAME$COLS
                    call .rows[.selectionSpecial].fields<i>.setValue(val)
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_COL) then
                loop
                exitwhen i == $NAME$ROWS
                    call .cols[.selectionSpecial].fields<i>.setValue(val)
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_FLD) then
                call .selection.fields[0].setValue(val)
            endif
            
            return this
        endmethod
        
        method add takes integer val returns thistype
            local integer i = 0
                      
            if (.selectionLevel == jBoard_SELECTION_LVL_BOARD) then            
                loop
                exitwhen i == $NAME$ROWS
                    call .reset().row(i,i).add(val)
                    set i = i + 1
                endloop
                set .selectionLevel = jBoard_SELECTION_LVL_BOARD
            elseif (.selectionLevel == jBoard_SELECTION_LVL_FIELDS) then
                loop
                exitwhen i == .selectionAmount
                    call .selection.fields<i>.add(val)
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_ROW) then
                loop
                exitwhen i == $NAME$COLS
                    call .rows[.selectionSpecial].fields<i>.add(val)
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_COL) then
                loop
                exitwhen i == $NAME$ROWS
                    call .cols[.selectionSpecial].fields<i>.add(val)
                    set i = i + 1
                endloop
            elseif (.selectionLevel == jBoard_SELECTION_LVL_FLD) then
                call .selection.fields[0].add(val)
            endif
            
            return this
        endmethod
        
        method getValue takes nothing returns string
            local integer i = 0
            local string s = &quot;&quot;
            
            if (.selectionLevel == jBoard_SELECTION_LVL_FLD) then
                set s = .selection.fields[0].getValue()
            else
                loop
                exitwhen i == .selectionAmount
                    set s = s + .selection.fields<i>.getValue()
                    set i = i + 1
                exitwhen i == .selectionAmount
                    set s = s + &quot;|&quot;
                endloop
            endif
            
            call .reset()
            return s
        endmethod
        
        method getPrefix takes nothing returns string
            local integer i = 0
            local string s = &quot;&quot;
            
            if (.selectionLevel == jBoard_SELECTION_LVL_FLD) then
                set s = .selection.fields[0].getPrefix()
            else
                loop
                exitwhen i == .selectionAmount
                    set s = s + .selection.fields<i>.getPrefix()
                    set i = i + 1
                exitwhen i == .selectionAmount
                    set s = s + &quot;|&quot;
                endloop
            endif
            
            call .reset()
            return s
        endmethod
        
        method getSuffix takes nothing returns string
            local integer i = 0
            local string s = &quot;&quot;
            
            if (.selectionLevel == jBoard_SELECTION_LVL_FLD) then
                set s = .selection.fields[0].getSuffix()
            else
                loop
                exitwhen i == .selectionAmount
                    set s = s + .selection.fields<i>.getSuffix()
                    set i = i + 1
                exitwhen i == .selectionAmount
                    set s = s + &quot;|&quot;
                endloop
            endif
            
            call .reset()
            return s
        endmethod
        
        method getWidth takes nothing returns string
            local integer i = 0
            local string s = &quot;&quot;
            
            if (.selectionLevel == jBoard_SELECTION_LVL_FLD) then
                set s = .selection.fields[0].getWidth()
            else
                loop
                exitwhen i == .selectionAmount
                    set s = s + .selection.fields<i>.getWidth()
                    set i = i + 1
                exitwhen i == .selectionAmount
                    set s = s + &quot;|&quot;
                endloop
            endif
            
            call .reset()
            return s
        endmethod
        
        method getColour takes nothing returns string
            local integer i = 0
            local string s = &quot;&quot;
            
            if (.selectionLevel == jBoard_SELECTION_LVL_FLD) then
                set s = .selection.fields[0].getColour()
            else
                loop
                exitwhen i == .selectionAmount
                    set s = s + .selection.fields<i>.getColour()
                    set i = i + 1
                exitwhen i == .selectionAmount
                    set s = s + &quot;|&quot;
                endloop
            endif
            
            call .reset()
            return s
        endmethod
        
        method getIconPath takes nothing returns string
            local integer i = 0
            local string s = &quot;&quot;
            
            if (.selectionLevel == jBoard_SELECTION_LVL_FLD) then
                set s = .selection.fields[0].getIconPath()
            else
                loop
                exitwhen i == .selectionAmount
                    set s = s + .selection.fields<i>.getIconPath()
                    set i = i + 1
                exitwhen i == .selectionAmount
                    set s = s + &quot;|&quot;
                endloop
            endif
            
            call .reset()
            return s
        endmethod
        
        method setName takes string s returns thistype
            set .boardName = s
            call MultiboardSetTitleText(.MB,&quot;|cff&quot;+.boardNameColour+.boardName+&quot;|r&quot;)
            return this
        endmethod
        
        method getName takes nothing returns string
            call .reset()
            return .boardName
        endmethod
        
        method setNameColour takes string s returns thistype
            set .boardNameColour = s
            call MultiboardSetTitleText(.MB,&quot;|cff&quot;+.boardNameColour+.boardName+&quot;|r&quot;)
            return this
        endmethod
        
        method getNameColour takes nothing returns string
            call .reset()
            return .boardNameColour
        endmethod
        
        method show takes nothing returns thistype
            call MultiboardDisplay(.MB,true)
            return this
        endmethod
            
        method hide takes nothing returns thistype
            call MultiboardDisplay(.MB,false)
            return this
        endmethod
            
        method clear takes nothing returns thistype
            call MultiboardClear(.MB)
            return this
        endmethod

        method fold takes nothing returns thistype
            call MultiboardMinimize(.MB,true)
            return this
        endmethod
            
        method unfold takes nothing returns thistype
            call MultiboardMinimize(.MB,false)
            return this
        endmethod
        
        method setValueR takes string val returns thistype
            call .setValue(val)
            call .reset()
            return this
        endmethod
        
        method setColourR takes string rgb returns thistype
            call .setColour(rgb)
            call .reset()
            return this
        endmethod
        
        method setPrefixR takes string val returns thistype
            call .setPrefix(val)
            call .reset()
            return this
        endmethod
        
        method setSuffixR takes string val returns thistype
            call .setSuffix(val)
            call .reset()
            return this
        endmethod
        
        method setIconPathR takes string val returns thistype
            call .setIconPath(val)
            call .reset()
            return this
        endmethod
        
        method setWidthR takes real w returns thistype
            call .setWidth(w)
            call .reset()
            return this
        endmethod
        
        method addR takes integer val returns thistype
            call .add(val)
            call .reset()
            return this
        endmethod
        
        method setPlayerRowR takes integer p, integer col returns thistype
            call .setPlayerRow(p,row)
            call .reset()
            return this
        endmethod
        
        method setPlayerColR takes integer p, integer col returns thistype
            call .setPlayerCol(p,col)
            call .reset()
            return this
        endmethod
        
        method setNameR takes string s returns thistype
            call .setName(s)
            call .reset()
            return this
        endmethod
        
        method setNameColourR takes string s returns thistype
            call .setNameColour(s)
            call .reset()
            return this
        endmethod
        
        method showR takes nothing returns thistype
            call .show()
            call .reset()
            return this
        endmethod
        
        method showIconR takes nothing returns thistype
            call .showIcon()
            call .reset()
            return this
        endmethod
        
        method hideIconR takes nothing returns thistype
            call .hideIcon()
            call .reset()
            return this
        endmethod
        
        method showValueR takes nothing returns thistype
            call .showValue()
            call .reset()
            return this
        endmethod
        
        method hideValueR takes nothing returns thistype
            call .hideValue()
            call .reset()
            return this
        endmethod
        
        method hideR takes nothing returns thistype
            call .hide()
            call .reset()
            return this
        endmethod
        
        method clearR takes nothing returns thistype
            call .clear()
            call .reset()
            return this
        endmethod
        
        method foldR takes nothing returns thistype
            call .fold()
            call .reset()
            return this
        endmethod
        
        method unfoldR takes nothing returns thistype
            call .unfold()
            call .reset()
            return this
        endmethod
        
        method destroy takes nothing returns nothing
            local integer i = 0
            local integer j = 0
            
            loop
            exitwhen i == $NAME$ROWS
                loop
                exitwhen j == $NAME$COLS
                    call rows<i>.fields[j].destroy()
                    set j = j + 1
                endloop
                
                set i = i + 1
            endloop
            
            call DestroyMultiboard(.MB)
            call .deallocate()
        endmethod
    endstruct
//! endtextmacro


//==============================================================================
//  ACTUAL LIBRARY
//==============================================================================
library jBoardLib

    globals
        constant integer jBoard_SELECTION_LVL_BOARD = 0
        constant integer jBoard_SELECTION_LVL_ROW = 1
        constant integer jBoard_SELECTION_LVL_COL = 2
        constant integer jBoard_SELECTION_LVL_FLD = 3
        constant integer jBoard_SELECTION_LVL_FIELDS = 4
    endglobals

    struct jBoard
//! runtextmacro jBoardDefaults()
        
        multiboard MB
        string boardName
        string boardNameColour = &quot;ffffcc&quot;
        
        integer selectionLevel = 0
        integer selectionSpecial = 0
        integer selectionAmount = 0
        
        integer array playerRow[12]
        integer array playerCol[12]
        
        static method create takes string boardName returns jBoard
            local jBoard j = thistype.allocate()
            local integer i = 0
                
            set  j.MB = CreateMultiboard()
            set  j.boardName = boardName
            call MultiboardSetTitleText(j.MB,boardName)
            call MultiboardDisplay(j.MB,false)
                
            return j
        endmethod
        method initBoard takes nothing returns nothing
            call MultiboardSetItemsValue(.MB,.defaultItemValue)
            call MultiboardSetItemsIcon(.MB,.defaultIconPath)
            call MultiboardSetItemsStyle(.MB,.defaultShowValue,.defaultShowIcon)
            call MultiboardSetItemsWidth(.MB,.defaultItemWidth)
            call MultiboardDisplay(.MB,.defaultShowBoard)
        endmethod
    endstruct
endlibrary
//==============================================================================
//  END OF jBoard ADVANCED MULTIBOARD SYSTEM
//==============================================================================
</i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i>


You can copy this into a map to try it out:
JASS:
library test initializer Init requires jBoardLib
    //! runtextmacro jBoardCreate(&quot;MyBoard&quot;,&quot;4&quot;,&quot;4&quot;)
    
    private function Actions takes nothing returns nothing
        local MyBoard mb = MyBoard.create(&quot;Some jBoard&quot;)
        call mb.setPlayerRow(0,0).setValue(&quot;1&quot;).setColourR(&quot;ff0000&quot;)
        call mb.setPlayerRow(1,1).setValue(&quot;2&quot;).setColourR(&quot;00ff00&quot;)
        call mb.setPlayerRow(2,2).setValue(&quot;3&quot;).setColourR(&quot;ffff00&quot;)
        call mb.setPlayerRow(3,3).setValue(&quot;4&quot;).setColourR(&quot;ff00ff&quot;)
        call mb.getField(3).setValueR(&quot;Sup&quot;).getField(14).setValueR(&quot;Dawg?&quot;)
    endfunction
    
    private function Init takes nothing returns nothing
        local trigger T = CreateTrigger()
        call TriggerRegisterTimerEvent(T,1.,false)
        call TriggerAddAction(T,function Actions)
    endfunction
endlibrary


Changelog:
Code:
v1.2 - Fixed unwanted behaviour of "getters" not resetting your selection
       Deleted support for commenting out newlines, added multi-line call hint instead
       Added two new functions: getPlayerRowField and getPlayerColField
         Now you can get just one field belonging to a player and add it to
         your selection instead of being bound to adding the entire row
v1.1 - Followed method naming convention
       Added a defaultShowBoard value
 

Jesus4Lyf

Good Idea™
Reaction score
397
JASS:
//      Since you need to create structs that represent your multiboard, jBoard
//      needs to know the dimensions of your multiboard to ensure the structs
//      don&#039;t take up more space than they need to.

I don't believe this justifies having to duplicate all that code, and not allowing dynamic adding/removing of columns. I would suggest you remove the text macro interface, and replace it hashtable use, or something. Multiboards are definitely not efficiency critical...

I haven't worked heaps with multiboards, so I'm not aware of the actual JASS limitations, though.

Edit: Also, convention for method names is camelCase.
 

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
I don't believe this justifies having to duplicate all that code, and not allowing dynamic adding/removing of columns. I would suggest you remove the text macro interface, and replace it hashtable use, or something. Multiboards are definitely not efficiency critical...

The reason you don't get to dynamically define your multiboard's size is twofold:
  1. Speed. jBoard uses only array lookups and stores every multiboarditem once at start. Every manipulation you then execute on any item, row, col or the entire board will be way faster than hashtables or having to lookup the multiboarditem again.
  2. Most people don't change multiboard size during the game. If they want to, they can just create another jBoard
  3. It looks like "all that code" because you can't nest textmacroes. 75% of the code in there could be created with 7 lines of textmacroes...

Anachron said:
Yes, Board by Earth-Fury is a lot better.
  • jBoard allows for chaining, which is if I'm not mistaken the first vJASS library to ever do so.
  • jBoard is probably faster
  • jBoard has smart selecting calling .row(1,2).field(3,0) will let you then manipulate all fields in rows 1 and 2 AND the field in row 3, column 0 all at once. A simple -R or .reset() call and you're back to manipulating the parent jBoard

jBoard =/= Board, doesn't mean one's de facto better than the other.


Also, convention for method names is camelCase.
I'll fix that
 

Anachron

New Member
Reaction score
53
jBoard allows for chaining, which is if I'm not mistaken the first vJASS library to ever do so.
Nope, I did such things before, basically because in PHP 5 you are able to do it in bigger librarys.

jBoard is probably faster
No it isn't, the first benchmark of a DotA-like board did result that yours is slower.

jBoard has smart selecting calling .row(1,2).field(3,0) will let you then manipulate all fields in rows 1 and 2 AND the field in row 3, column 0 all at once. A simple -R or .reset() call and you're back to manipulating the parent jBoard
Board (by Earth-Fury) provides functions to get a group of objects, like a row or column in which you can edit all cells at once. So nothing new here.
 

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
  • Show me your benchmark please
  • A row/col isn't new indeed because blizzard.j already has functions for that. Can Board edit the contents of, for example: cell(0,0), cell(1,5), cell(7,3), in one call?

In a DotA-like board, you could update both the team score and a player score in one call (supposing kills are kept in column 4 and team kills in row 1):
[LJASS]dotaboard.getPlayerRow(1).getField(3).field(0,3).add(1)[/LJASS]
 

Anachron

New Member
Reaction score
53
Who cares? Linking rows to players isn't new and also not effective.
(The rows that are linked to a player can change, for example in an sorting multiboard)
 

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
Who cares? Linking rows to players isn't new and also not effective.
(The rows that are linked to a player can change, for example in an sorting multiboard)

People that don't sort multiboards (like DotA) care
People that want to easily update a player's score care
Need I go on?

Just because it doesn't suit YOUR needs or because you can't see a use for it, doesn't mean it can't suit someone else's needs


And if you really wanted sorting, it would only take me an hour or so to add it to the system...
P.S.: I asked for your benchmark
 

Anachron

New Member
Reaction score
53
Don't get rude.

People that don't sort multiboards (like DotA) care
Well DotA != good.

People that want to easily update a player's score care
Well, what if you have not only one Row for your player?
What if you have for example, like in DotAs End-Board, player columns?

Just because it doesn't suit YOUR needs or because you can't see a use for it, doesn't mean it can't suit someone else's needs
Well, it's okay I guess, but the player-row feature isn't that good.

And if you really wanted sorting, it would only take me an hour or so to add it to the system...
Then add it please.

P.S.: I asked for your benchmark
You only need to check the number of actions you execute.
 

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
You only need to check the number of actions you execute.

Oh my, you are so wrong here...
Board refetches the multiboarditem every time you want to manipulate it, that's a native doing something behind the scenes.
All jBoard does, is an array lookup.

Array lookups >>> natives
My guess is you didn't really benchmark it, now did you?

As for DotA endboard: I also have a player-column function.
I suppose I could add sorting (was going to in a future release anyhow)

But why do you criticise me for not having sorting functionality when Board doesn't seem to have it either?

By the way:
The player column/row system is to help people who don't need complicated jBoards. You don't have to use it, you just can.. Want more than one column per player? Store your own globals...
 

Anachron

New Member
Reaction score
53
Oh my, you are so wrong here...
Board refetches the multiboarditem every time you want to manipulate it, that's a native doing something behind the scenes.
All jBoard does, is an array lookup.

Array lookups >>> natives
My guess is you didn't really benchmark it, now did you?
Same goes for Board.

As for DotA endboard: I also have a player-column function.
I suppose I could add sorting (was going to in a future release anyhow)
Sounds neat.

But why do you criticise me for not having sorting functionality when Board doesn't seem to have it either?
Because Board doesn't have the player bounded functionality. So it doesn't have to provide the sort functionality that updates the player linked rows.

By the way:
The player column/row system is to help people who don't need complicated jBoards. You don't have to use it, you just can.. Want more than one column per player? Store your own globals...
Sounds fair enough. I guess I might give it a try. Anyway, good job on making it.
 

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
I'm working on a new version that doesn't require textmacroes by the way...
Expect to release it soon(tm)
 

Chaos_Knight

New Member
Reaction score
39
So amazing. So simple to use. This is awsome. Maybe add a function that enables the user to check Players Hero kills. (Very useful for Hero Arenas) :D
 

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
Check on unit death event, register the killer and dying unit's owner to the multiboard. (Using player rows for example)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top